From 2306d4b59bcfef58c21f1a5f3e9e88caec644d5f Mon Sep 17 00:00:00 2001 From: Alug Date: Sun, 23 Mar 2025 15:28:59 +0100 Subject: [PATCH] Revert "test: revert all the view interp stuff" This reverts commit 1a836031a7d7036926bbf5e587b02ecf4f531809. --- src/g_game.c | 1 - src/p_setup.c | 1 - src/p_spec.c | 1 - src/p_telept.c | 2 -- src/p_tick.c | 8 +++++++- src/p_user.c | 1 - src/r_fps.c | 11 +++++++++-- src/r_main.c | 1 - 8 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ee995c334..ddfc2e174 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -900,7 +900,6 @@ static void G_BuildLocalTiccmd(ticcmd_t *cmd, UINT8 ssplayer, boolean freecam) displayplayers[0] = consoleplayer; R_ResetViewInterpolation(0); - R_ResetViewInterpolation(0); camera[0].reset_aiming = true; } } diff --git a/src/p_setup.c b/src/p_setup.c index aa0611888..6d5c53bed 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3185,7 +3185,6 @@ boolean P_SetupLevel(boolean fromnetsave, boolean reloadinggamestate) if (rendermode != render_none && !reloadinggamestate) { - R_ResetViewInterpolation(0); R_ResetViewInterpolation(0); R_UpdateMobjInterpolators(); } diff --git a/src/p_spec.c b/src/p_spec.c index a28f34aea..3f71e934e 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2455,7 +2455,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) if (displayplayers[i] == (mo->player - players)) { R_ResetViewInterpolation(i + 1); - R_ResetViewInterpolation(i + 1); } } } diff --git a/src/p_telept.c b/src/p_telept.c index 36a77a18f..ceed7dc93 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -89,7 +89,6 @@ void P_MixUp(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, P_ResetCamera(thing->player, &camera[i]); R_ResetViewInterpolation(i + 1); - R_ResetViewInterpolation(i + 1); } // don't run in place after a teleport @@ -166,7 +165,6 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle if (camera[i].chase) P_ResetCamera(thing->player, &camera[i]); - R_ResetViewInterpolation(i + 1); R_ResetViewInterpolation(i + 1); break; } diff --git a/src/p_tick.c b/src/p_tick.c index 8531e27ef..2cc451d36 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -541,6 +541,13 @@ void P_Ticker(boolean run) } } + if (run) + { + // Update old view state BEFORE ticking so resetting + // the old interpolation state from game logic works. + R_UpdateViewInterpolation(); + } + if (objectplacing) { if (OP_FreezeObjectplace()) @@ -772,7 +779,6 @@ void P_Ticker(boolean run) if (run) { R_UpdateLevelInterpolators(); - R_UpdateViewInterpolation(); // Hack: ensure newview is assigned every tic. // Ensures view interpolation is T-1 to T in poor network conditions diff --git a/src/p_user.c b/src/p_user.c index 48dcc5cf5..0f1dfb016 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4068,7 +4068,6 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall { P_MoveChaseCamera(player, thiscam, false); R_ResetViewInterpolation(num + 1); - R_ResetViewInterpolation(num + 1); } return (x == thiscam->x && y == thiscam->y && z == thiscam->z && angle == thiscam->aiming); diff --git a/src/r_fps.c b/src/r_fps.c index b3129724f..e3e598bc3 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -80,6 +80,7 @@ static viewvars_t skyview_old[MAXSPLITSCREENPLAYERS]; static viewvars_t skyview_new[MAXSPLITSCREENPLAYERS]; static viewvars_t *oldview = &pview_old[0]; +static tic_t last_view_update; static int oldview_invalid[MAXSPLITSCREENPLAYERS] = {0, 0, 0, 0}; viewvars_t *newview = &pview_new[0]; @@ -213,21 +214,27 @@ void R_UpdateViewInterpolation(void) if (oldview_invalid[i]) oldview_invalid[i]--; } + + last_view_update = I_GetTime(); } void R_ResetViewInterpolation(UINT8 p) { + // Wait an extra tic if the interpolation state hasn't + // updated yet. + int t = ((last_view_update == I_GetTime()) ? 1 : 2); + if (p == 0) { UINT8 i; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { - oldview_invalid[i]++; + oldview_invalid[i] = t; } } else { - oldview_invalid[p - 1]++; + oldview_invalid[p - 1] = t; } } diff --git a/src/r_main.c b/src/r_main.c index 1051ab478..aa28078ae 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1215,7 +1215,6 @@ void R_SetupFrame(int s, boolean skybox) R_SetViewContext(VIEWCONTEXT_PLAYER1 + s); if (thiscam->reset) { - R_ResetViewInterpolation(s); R_ResetViewInterpolation(s); thiscam->reset = false; }