Add functions to handle interpolation

Much less code duplication
This commit is contained in:
Sally Coolatta 2021-12-24 11:30:19 -05:00 committed by Eidolon
parent ca8698d13e
commit 8fb939df79
2 changed files with 24 additions and 0 deletions

View file

@ -177,6 +177,26 @@ void R_SetViewContext(enum viewcontext_e _viewcontext)
}
}
fixed_t R_InterpolateFixed(fixed_t from, fixed_t to)
{
if (cv_frameinterpolation.value == 0)
{
return to;
}
return (R_LerpFixed(from, to, rendertimefrac));
}
angle_t R_InterpolateAngle(angle_t from, angle_t to)
{
if (cv_frameinterpolation.value == 0)
{
return to;
}
return (R_LerpAngle(from, to, rendertimefrac));
}
void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
{
out->x = R_LerpFixed(mobj->old_x, mobj->x, frac);

View file

@ -99,6 +99,10 @@ void R_UpdateViewInterpolation(void);
void R_ResetViewInterpolation(void);
// Set the current view context (the viewvars pointed to by newview)
void R_SetViewContext(enum viewcontext_e _viewcontext);
fixed_t R_InterpolateFixed(fixed_t from, fixed_t to);
angle_t R_InterpolateAngle(angle_t from, angle_t to);
// Evaluate the interpolated mobj state for the given mobj
void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out);
// Evaluate the interpolated mobj state for the given precipmobj