diff --git a/src/r_fps.c b/src/r_fps.c index c678c2519..2d2b4f61e 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -35,6 +35,16 @@ viewvars_t *newview = &pview_new[0]; enum viewcontext_e viewcontext = VIEWCONTEXT_PLAYER1; +static fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac) +{ + return FixedMul(frac, to - from); +} + +static angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac) +{ + return FixedMul(frac, to - from); +} + // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). // 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out) @@ -78,6 +88,8 @@ void R_InterpolateView(fixed_t frac) if (FIXED_TO_FLOAT(frac) < 0) frac = 0; + if (frac > FRACUNIT) + frac = FRACUNIT; viewx = oldview->x + R_LerpFixed(oldview->x, newview->x, frac); viewy = oldview->y + R_LerpFixed(oldview->y, newview->y, frac); @@ -91,16 +103,8 @@ void R_InterpolateView(fixed_t frac) // this is gonna create some interesting visual errors for long distance teleports... // might want to recalculate the view sector every frame instead... - if (frac >= FRACUNIT) - { - viewplayer = newview->player; - viewsector = newview->sector; - } - else - { - viewplayer = oldview->player; - viewsector = oldview->sector; - } + viewplayer = newview->player; + viewsector = R_PointInSubsector(viewx, viewy)->sector; // well, this ain't pretty for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) @@ -157,18 +161,3 @@ void R_SetViewContext(enum viewcontext_e _viewcontext) break; } } - -fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac) -{ - return FixedMul(frac, to - from); -} - -INT32 R_LerpInt32(INT32 from, INT32 to, fixed_t frac) -{ - return FixedInt(FixedMul(frac, (to*FRACUNIT) - (from*FRACUNIT))); -} - -angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac) -{ - return FixedMul(frac, to - from); -} diff --git a/src/r_fps.h b/src/r_fps.h index 24b79c922..2d4dbe874 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -55,9 +55,4 @@ void R_UpdateViewInterpolation(void); // Set the current view context (the viewvars pointed to by newview) void R_SetViewContext(enum viewcontext_e _viewcontext); -fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac); -INT32 R_LerpInt32(INT32 from, INT32 to, fixed_t frac); -UINT32 R_LerpUInt32(UINT32 from, UINT32 to, fixed_t frac); -angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac); - #endif