From 5aee869c86512c9b9a18ce33a827b9f6b57da165 Mon Sep 17 00:00:00 2001 From: Alaux <73968015+MrAlaux@users.noreply.github.com> Date: Wed, 29 Nov 2023 05:08:10 -0300 Subject: [PATCH] Chasecam speed effect interpolation, and more Also added a `break` to a loop in the FOV changing code, and fixed the explosion shake effect being stopped by the menu even if the game isn't actually paused (i.e. during demo playback or net play). Additionally, some reformatting. --- CHANGELOG.md | 2 ++ src/r_main.c | 31 ++++++++++++++++++++++--------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 035911633..197d9fc8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ - Disabled Armor icon by default. - **Speed of non-Melt wipes is now independent of resolution** - **Implemented Teleporter Zoom for multiplayer respawning** +- **Applied interpolation for Chasecam speed effect** - **MDK Fist attacks now prioritize enemies over friends** - **Current resolution is now reported by some video-related menu items** - **Disabled `input_spy` and `input_menu_reloadlevel` when typing in Chat** @@ -42,5 +43,6 @@ - **Excess speed when airborne with noclip enabled** [thanks @kitchen-ace] - **Blazing door sound fix not applying to Boom doors** - **Teleporter Zoom and BFG "explosion" shake affecting all players in multiplayer** +- **Explosion shake being stopped by the menu during demo playback and netgames** - **Fixed a demo desync** caused by a failed weapon autoswitch when picking up ammo - **Tweaked dark menu background and Automap overlay algorithm** (fixes very low values) diff --git a/src/r_main.c b/src/r_main.c index 6e3f86b07..73b855bb0 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -629,7 +629,11 @@ void R_ExecuteSetViewSize (void) if (fovfx[FOVFX_ZOOM].target != zoomtarget) { fovchange = true; } else for (i = 0; i < NUMFOVFX; i++) - if (fovfx[i].target || fovfx[i].current) { fovchange = true; } + if (fovfx[i].target || fovfx[i].current) + { + fovchange = true; + break; + } } if (fovchange) @@ -639,6 +643,7 @@ void R_ExecuteSetViewSize (void) fovchange = false; fovfx[FOVFX_ZOOM].old = fovfx[FOVFX_ZOOM].current = fovfx[FOVFX_ZOOM].target; + if (zoomtarget || fovfx[FOVFX_ZOOM].target) { // Special handling for zoom @@ -650,13 +655,16 @@ void R_ExecuteSetViewSize (void) if ( (sign > 0 && fovfx[FOVFX_ZOOM].target > zoomtarget) || (sign < 0 && fovfx[FOVFX_ZOOM].target < zoomtarget)) - { 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) { if ((fovfx[FOVFX_TELEPORT].target -= 5) < 0) @@ -884,7 +892,7 @@ void R_SetupFrame (player_t *player) { static fixed_t xofs=0, yofs=0, zofs=0; - if (!(menuactive || paused)) + if (!((menuactive && !demoplayback && !netgame) || paused)) { static int oldtime = -1; @@ -909,7 +917,7 @@ void R_SetupFrame (player_t *player) chasecam_on = STRICTMODE(chasecam_mode || (death_camera && player->mo->health <= 0 && player->playerstate == PST_DEAD)); if (chasecam_on) { - static fixed_t extradist = 0; + static fixed_t oldextradist = 0, extradist = 0; const fixed_t z = MIN(playerz + ((player->mo->health <= 0 && player->playerstate == PST_DEAD) ? 6*FRACUNIT : chasecamheight), player->mo->ceilingz - (2*FRACUNIT)); fixed_t slope; @@ -924,19 +932,24 @@ void R_SetupFrame (player_t *player) pitch = -pitch; } - dist += extradist; - - { // `extradist` is applied on the next tic + { static int oldtic = -1; - if (gametic != oldtic) { + if (oldtic != gametic) { + oldextradist = extradist; extradist = FixedMul(player->mo->momx, finecosine[viewangle >> ANGLETOFINESHIFT]) + FixedMul(player->mo->momy, finesine[viewangle >> ANGLETOFINESHIFT]); } - + oldtic = gametic; } + if (uncapped && leveltime > 1 && player->mo->interp == true && leveltime > oldleveltime) + { + dist += oldextradist + FixedMul(extradist - oldextradist, fractionaltic); + } + else { dist += extradist; } + P_PositionChasecam(z, dist, slope = (-(lookdir * FRACUNIT) / PLAYER_SLOPE_DENOM)); if (chasecam.hit) {