diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e507a05e..e99c5f311 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ ## Bug Fixes +- **Further corrected view pitch as FOV changes** - **Disabled teleport-to-Automap-pointer during non-Casual Play** - **Excess speed when airborne with noclip enabled** [thanks @kitchen-ace] - **Teleporter Zoom and BFG "explosion" shake affecting all players in multiplayer** diff --git a/src/r_data.h b/src/r_data.h index 0815046c8..f5e7404be 100644 --- a/src/r_data.h +++ b/src/r_data.h @@ -30,10 +30,10 @@ #define MAXFOV 160 #define LOOKDIRMAX 100 -#define LOOKDIRMAX2 (LOOKDIRMAX+24) // [Nugget] +#define PITCHMAX (LOOKDIRMAX+24) // [Nugget] Accommodate pitch effects (e.g. recoil) // [crispy] lookdir range: -100..100 // [Nugget] Increased to accommodate variable FOV -#define LOOKDIRS ((2*LOOKDIRMAX2+1)*ORIGFOV/MINFOV) +#define LOOKDIRS ((2*PITCHMAX+1) * ORIGFOV / (MINFOV-2)) #define MLOOKUNIT 8 // Retrieve column data for span blitting. diff --git a/src/r_main.c b/src/r_main.c index 5e75c5147..babc8cfe3 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -113,15 +113,16 @@ lighttable_t **colormaps; int extralight; // bumped light from gun blasts int extra_level_brightness; // level brightness feature -// [Nugget] FOV from Doom Retro /------ +// [Nugget] FOV from Doom Retro /--------------------------------------------- boolean fovchange = true; static int bfov; // Base FOV static int rfov; // Rendered (currently applied) FOV, with effects added to it float fovdiff; // Used for some corrections +#define FOVDIFF2 (fovdiff + ((fovdiff - 1.0) * ((fovdiff < 1.0) ? 0.5 : 0.22))) static fixed_t fovscale; -static int lookdirmax; +static int pitchmax; static fovfx_t fovfx[NUMFOVFX]; // FOV effects (recoil, teleport) static int zoomed = 0; // Current zoom state @@ -175,9 +176,9 @@ void R_SetZoom(const int state) { zoomed = ZOOM_OFF; } } -// [Nugget] --------------------------/ +// [Nugget] -----------------------------------------------------------------/ -// [Nugget] Explosion shake effect /--------------------------------- +// [Nugget] Explosion shake effect /------------------------------------------ static fixed_t shake; #define MAXSHAKE 50 @@ -219,7 +220,7 @@ void R_ExplosionShake(fixed_t bombx, fixed_t bomby, int force, int range) #undef SHAKERANGEMULT } -// [Nugget] --------------------------------------------------------/ +// [Nugget] -----------------------------------------------------------------/ void (*colfunc)(void) = R_DrawColumn; // current column draw function @@ -603,7 +604,8 @@ void R_ExecuteSetViewSize (void) viewblocks = MIN(setblocks, 10) << hires; // [Nugget] FOV changes - if (fovchange) { + if (fovchange) + { static int oldtic = -1; int fx = 0; int zoomtarget; @@ -629,26 +631,31 @@ void R_ExecuteSetViewSize (void) else for (i = 0; i < NUMFOVFX; i++) if (fovfx[i].target || fovfx[i].current) { fovchange = true; } } - - if (fovchange) { + + if (fovchange) + { if (oldtic != gametic) { fovchange = false; - + fovfx[FOVFX_ZOOM].old = fovfx[FOVFX_ZOOM].current = fovfx[FOVFX_ZOOM].target; - if (zoomtarget || fovfx[FOVFX_ZOOM].target) { // Special handling for zoom + if (zoomtarget || fovfx[FOVFX_ZOOM].target) + { + // Special handling for zoom int step = zoomtarget - fovfx[FOVFX_ZOOM].target; const int sign = ((step > 0) ? 1 : -1); step = BETWEEN(2, 16, abs(step) / 4); + fovfx[FOVFX_ZOOM].target += step*sign; - if ( (sign > 0 && fovfx[FOVFX_ZOOM].target > zoomtarget) - ||(sign < 0 && fovfx[FOVFX_ZOOM].target < zoomtarget)) + + if ( (sign > 0 && fovfx[FOVFX_ZOOM].target > zoomtarget) + || (sign < 0 && fovfx[FOVFX_ZOOM].target < zoomtarget)) { fovfx[FOVFX_ZOOM].target = zoomtarget; } - + if (fovfx[FOVFX_ZOOM].current != fovfx[FOVFX_ZOOM].target) { fovchange = true; } } - + fovfx[FOVFX_TELEPORT].old = fovfx[FOVFX_TELEPORT].current = fovfx[FOVFX_TELEPORT].target; if (fovfx[FOVFX_TELEPORT].target) { @@ -662,24 +669,23 @@ void R_ExecuteSetViewSize (void) for (i = 0; i < NUMFOVFX; i++) { fovfx[i].current = fovfx[i].old + ((fovfx[i].target - fovfx[i].old) * ((float) fractionaltic/FRACUNIT)); } } - + oldtic = gametic; for (i = 0; i < NUMFOVFX; i++) { fx += fovfx[i].current; } - + rfov = bfov + fx; fovdiff = (float) ORIGFOV / rfov; - lookdirmax = LOOKDIRMAX2 * fovdiff; + pitchmax = PITCHMAX * FOVDIFF2; // Mitigate `PLAYER_SLOPE()` and `lookdir` misalignment } - + // [Nugget] FOV from Doom Retro if (widescreen) { // fov * 0.82 is vertical FOV for 4:3 aspect ratio WIDEFOVDELTA = (atan(SCREENWIDTH / ((SCREENHEIGHT * 1.2) / tan(rfov * 0.82 * M_PI / 360.0))) * 360.0 / M_PI) - rfov; } - else - { WIDEFOVDELTA = 0; } + else { WIDEFOVDELTA = 0; } centery = viewheight/2; centerx = viewwidth/2; @@ -710,12 +716,11 @@ void R_ExecuteSetViewSize (void) for (j = 0; j < LOOKDIRS; j++) { // [crispy] re-generate lookup-table for yslope[] whenever "viewheight" or "hires" change - // [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment - fixed_t dy = abs(((i-viewheight/2-(j-lookdirmax)*viewblocks/10)<recoilpitch + player->impactpitch; // [Nugget] } - // [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment - pitch *= fovdiff; + // [Nugget] Mitigate `PLAYER_SLOPE()` and `lookdir` misalignment + pitch *= FOVDIFF2; // [Nugget] Explosion shake effect chasecamheight = chasecam_height * FRACUNIT; @@ -882,7 +887,7 @@ void R_SetupFrame (player_t *player) if (!(menuactive || paused)) { static int oldtime = -1; - + #define CALCSHAKE (((Woof_Random() - 128) % 3) * FRACUNIT) * shake / MAXSHAKE xofs = CALCSHAKE; yofs = CALCSHAKE; @@ -932,7 +937,7 @@ void R_SetupFrame (player_t *player) oldtic = gametic; } - P_PositionChasecam(z, dist, slope = ((-(lookdir * FRACUNIT) / PLAYER_SLOPE_DENOM) / fovdiff)); + P_PositionChasecam(z, dist, slope = (-(lookdir * FRACUNIT) / PLAYER_SLOPE_DENOM)); if (chasecam.hit) { viewx = chasecam.x; @@ -964,8 +969,7 @@ void R_SetupFrame (player_t *player) chaseyofs = viewy - oldviewy; chaseaofs = viewangle - oldviewangle; } - else - { chasexofs = chaseyofs = chaseaofs = 0; } + else { chasexofs = chaseyofs = chaseaofs = 0; } // [Nugget]: [crispy] A11Y if (!NOTSTRICTMODE(a11y_weapon_flash)) @@ -975,11 +979,10 @@ void R_SetupFrame (player_t *player) extralight += STRICTMODE(LIGHTBRIGHT * extra_level_brightness); // level brightness feature - // [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment - if (pitch > lookdirmax) - pitch = lookdirmax; - else if (pitch < -lookdirmax) - pitch = -lookdirmax; + if (pitch > pitchmax) + pitch = pitchmax; + else if (pitch < -pitchmax) + pitch = -pitchmax; // apply new yslope[] whenever "lookdir", "viewheight" or "hires" change tempCentery = viewheight/2 + pitch * viewblocks / 10; @@ -987,7 +990,7 @@ void R_SetupFrame (player_t *player) { centery = tempCentery; centeryfrac = centery << FRACBITS; - yslope = yslopes[lookdirmax + pitch]; // [Nugget] Mitigate PLAYER_SLOPE() and 'lookdir' misalignment + yslope = yslopes[pitchmax + pitch]; } viewsin = finesine[viewangle>>ANGLETOFINESHIFT];