From 7c00cea1fc01cff3c1284f5912e6ffddcd607a80 Mon Sep 17 00:00:00 2001 From: Eidolon <furyhunter600@gmail.com> Date: Thu, 5 May 2022 20:11:37 -0500 Subject: [PATCH] Add per-split player view resets --- src/p_tick.c | 2 +- src/r_fps.c | 33 ++++++++++++++++++++++++++++----- src/r_fps.h | 2 +- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/p_tick.c b/src/p_tick.c index 10270107f2..217af37142 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -835,7 +835,7 @@ void P_PreTicker(INT32 frames) R_UpdateLevelInterpolators(); R_UpdateViewInterpolation(); - R_ResetViewInterpolation(); + R_ResetViewInterpolation(0); P_MapEnd(); } diff --git a/src/r_fps.c b/src/r_fps.c index 10e3cc10b7..f3675ab97e 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -83,7 +83,7 @@ static viewvars_t sky2view_old; static viewvars_t sky2view_new; static viewvars_t *oldview = &p1view_old; -static int oldview_invalid = 0; +static int oldview_invalid[MAXSPLITSCREENPLAYERS] = {0, 0}; viewvars_t *newview = &p1view_new; @@ -160,12 +160,23 @@ void R_InterpolateView(fixed_t frac) { viewvars_t* prevview = oldview; boolean skybox = 0; + UINT8 i; + if (FIXED_TO_FLOAT(frac) < 0) frac = 0; if (frac > FRACUNIT) frac = FRACUNIT; - if (oldview_invalid != 0) + if (viewcontext == VIEWCONTEXT_SKY1 || viewcontext == VIEWCONTEXT_PLAYER1) + { + i = 0; + } + else + { + i = 1; + } + + if (oldview_invalid[i] != 0) { // interpolate from newview to newview prevview = newview; @@ -201,12 +212,24 @@ void R_UpdateViewInterpolation(void) p2view_old = p2view_new; sky1view_old = sky1view_new; sky2view_old = sky2view_new; - if (oldview_invalid) oldview_invalid--; + if (oldview_invalid[0] > 0) oldview_invalid[0]--; + if (oldview_invalid[1] > 0) oldview_invalid[1]--; } -void R_ResetViewInterpolation(void) +void R_ResetViewInterpolation(UINT8 p) { - oldview_invalid++; + if (p == 0) + { + UINT8 i; + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + oldview_invalid[i]++; + } + } + else + { + oldview_invalid[p - 1]++; + } } void R_SetViewContext(enum viewcontext_e _viewcontext) diff --git a/src/r_fps.h b/src/r_fps.h index 97d6022b7d..85c87a2f49 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -118,7 +118,7 @@ void R_InterpolateView(fixed_t frac); // Buffer the current new views into the old views. Call once after each real tic. void R_UpdateViewInterpolation(void); // Reset the view states (e.g. after level load) so R_InterpolateView doesn't interpolate invalid data -void R_ResetViewInterpolation(void); +void R_ResetViewInterpolation(UINT8 p); // Set the current view context (the viewvars pointed to by newview) void R_SetViewContext(enum viewcontext_e _viewcontext); -- GitLab