Add per-split player view resets

This commit is contained in:
Eidolon 2022-05-05 20:11:37 -05:00
parent d511857675
commit 7c00cea1fc
3 changed files with 30 additions and 7 deletions

View file

@ -835,7 +835,7 @@ void P_PreTicker(INT32 frames)
R_UpdateLevelInterpolators(); R_UpdateLevelInterpolators();
R_UpdateViewInterpolation(); R_UpdateViewInterpolation();
R_ResetViewInterpolation(); R_ResetViewInterpolation(0);
P_MapEnd(); P_MapEnd();
} }

View file

@ -83,7 +83,7 @@ static viewvars_t sky2view_old;
static viewvars_t sky2view_new; static viewvars_t sky2view_new;
static viewvars_t *oldview = &p1view_old; static viewvars_t *oldview = &p1view_old;
static int oldview_invalid = 0; static int oldview_invalid[MAXSPLITSCREENPLAYERS] = {0, 0};
viewvars_t *newview = &p1view_new; viewvars_t *newview = &p1view_new;
@ -160,12 +160,23 @@ void R_InterpolateView(fixed_t frac)
{ {
viewvars_t* prevview = oldview; viewvars_t* prevview = oldview;
boolean skybox = 0; boolean skybox = 0;
UINT8 i;
if (FIXED_TO_FLOAT(frac) < 0) if (FIXED_TO_FLOAT(frac) < 0)
frac = 0; frac = 0;
if (frac > FRACUNIT) if (frac > FRACUNIT)
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 // interpolate from newview to newview
prevview = newview; prevview = newview;
@ -201,12 +212,24 @@ void R_UpdateViewInterpolation(void)
p2view_old = p2view_new; p2view_old = p2view_new;
sky1view_old = sky1view_new; sky1view_old = sky1view_new;
sky2view_old = sky2view_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) void R_SetViewContext(enum viewcontext_e _viewcontext)

View file

@ -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. // Buffer the current new views into the old views. Call once after each real tic.
void R_UpdateViewInterpolation(void); void R_UpdateViewInterpolation(void);
// Reset the view states (e.g. after level load) so R_InterpolateView doesn't interpolate invalid data // 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) // Set the current view context (the viewvars pointed to by newview)
void R_SetViewContext(enum viewcontext_e _viewcontext); void R_SetViewContext(enum viewcontext_e _viewcontext);