2019-10-06 22:40:52 +00:00
|
|
|
// SONIC ROBO BLAST 2
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 1993-1996 by id Software, Inc.
|
|
|
|
// Copyright (C) 1998-2000 by DooM Legacy Team.
|
|
|
|
// Copyright (C) 1999-2000 by Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze, Andrey Budko (prboom)
|
|
|
|
// Copyright (C) 1999-2019 by Sonic Team Junior.
|
|
|
|
//
|
|
|
|
// This program is free software distributed under the
|
|
|
|
// terms of the GNU General Public License, version 2.
|
|
|
|
// See the 'LICENSE' file for more details.
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
/// \file r_fps.h
|
|
|
|
/// \brief Uncapped framerate stuff.
|
|
|
|
|
|
|
|
#include "r_fps.h"
|
|
|
|
|
|
|
|
#include "r_main.h"
|
|
|
|
#include "g_game.h"
|
|
|
|
#include "i_video.h"
|
|
|
|
#include "r_plane.h"
|
|
|
|
#include "p_spec.h"
|
2024-01-30 01:08:22 +00:00
|
|
|
#include "p_slopes.h"
|
2019-10-06 22:40:52 +00:00
|
|
|
#include "r_state.h"
|
2022-04-13 01:45:49 +00:00
|
|
|
#include "z_zone.h"
|
2022-04-27 22:59:54 +00:00
|
|
|
#include "m_perfstats.h" // ps_metric_t
|
2019-10-06 22:40:52 +00:00
|
|
|
#ifdef HWRENDER
|
|
|
|
#include "hardware/hw_main.h" // for cv_glshearing
|
|
|
|
#endif
|
|
|
|
|
2022-03-27 03:48:08 +00:00
|
|
|
static CV_PossibleValue_t fpscap_cons_t[] = {
|
|
|
|
#ifdef DEVELOP
|
|
|
|
// Lower values are actually pretty useful for debugging interp problems!
|
2022-04-16 16:36:40 +00:00
|
|
|
{1, "MIN"},
|
|
|
|
#else
|
|
|
|
{TICRATE, "MIN"},
|
2022-03-27 03:48:08 +00:00
|
|
|
#endif
|
2022-04-16 16:36:40 +00:00
|
|
|
{300, "MAX"},
|
|
|
|
{-1, "Unlimited"},
|
|
|
|
{0, "Match refresh rate"},
|
2022-03-27 03:48:08 +00:00
|
|
|
{0, NULL}
|
|
|
|
};
|
|
|
|
consvar_t cv_fpscap = CVAR_INIT ("fpscap", "Match refresh rate", CV_SAVE, fpscap_cons_t, NULL);
|
|
|
|
|
2022-04-27 22:59:54 +00:00
|
|
|
ps_metric_t ps_interp_frac = {0};
|
|
|
|
ps_metric_t ps_interp_lag = {0};
|
2022-03-30 00:51:58 +00:00
|
|
|
|
2022-03-27 03:48:08 +00:00
|
|
|
UINT32 R_GetFramerateCap(void)
|
|
|
|
{
|
2022-04-27 21:31:52 +00:00
|
|
|
if (rendermode == render_none)
|
|
|
|
{
|
|
|
|
// If we're not rendering (dedicated server),
|
|
|
|
// we shouldn't be using any interpolation.
|
|
|
|
return TICRATE;
|
|
|
|
}
|
|
|
|
|
2022-04-16 16:36:40 +00:00
|
|
|
if (cv_fpscap.value == 0)
|
2022-03-27 03:48:08 +00:00
|
|
|
{
|
2022-04-16 16:36:40 +00:00
|
|
|
// 0: Match refresh rate
|
2022-03-27 03:48:08 +00:00
|
|
|
return I_GetRefreshRate();
|
|
|
|
}
|
|
|
|
|
2022-04-16 16:36:40 +00:00
|
|
|
if (cv_fpscap.value < 0)
|
|
|
|
{
|
|
|
|
// -1: Unlimited
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-03-27 03:48:08 +00:00
|
|
|
return cv_fpscap.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean R_UsingFrameInterpolation(void)
|
|
|
|
{
|
2022-04-27 23:27:32 +00:00
|
|
|
return (R_GetFramerateCap() != TICRATE || cv_timescale.value < FRACUNIT);
|
2022-03-27 03:48:08 +00:00
|
|
|
}
|
|
|
|
|
2019-10-06 22:40:52 +00:00
|
|
|
static viewvars_t p1view_old;
|
|
|
|
static viewvars_t p1view_new;
|
|
|
|
static viewvars_t p2view_old;
|
|
|
|
static viewvars_t p2view_new;
|
|
|
|
static viewvars_t sky1view_old;
|
|
|
|
static viewvars_t sky1view_new;
|
|
|
|
static viewvars_t sky2view_old;
|
|
|
|
static viewvars_t sky2view_new;
|
|
|
|
|
|
|
|
static viewvars_t *oldview = &p1view_old;
|
2022-05-06 01:11:37 +00:00
|
|
|
static int oldview_invalid[MAXSPLITSCREENPLAYERS] = {0, 0};
|
2019-10-06 22:40:52 +00:00
|
|
|
viewvars_t *newview = &p1view_new;
|
|
|
|
|
|
|
|
|
|
|
|
enum viewcontext_e viewcontext = VIEWCONTEXT_PLAYER1;
|
|
|
|
|
2022-04-13 01:45:49 +00:00
|
|
|
static levelinterpolator_t **levelinterpolators;
|
|
|
|
static size_t levelinterpolators_len;
|
|
|
|
static size_t levelinterpolators_size;
|
|
|
|
|
|
|
|
|
2019-12-22 07:16:57 +00:00
|
|
|
static fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac)
|
|
|
|
{
|
2022-04-12 23:39:11 +00:00
|
|
|
return from + FixedMul(frac, to - from);
|
2019-12-22 07:16:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac)
|
|
|
|
{
|
2022-04-12 23:39:11 +00:00
|
|
|
return from + FixedMul(frac, to - from);
|
2019-12-22 07:16:57 +00:00
|
|
|
}
|
|
|
|
|
2022-04-25 09:27:57 +00:00
|
|
|
static vector2_t *R_LerpVector2(const vector2_t *from, const vector2_t *to, fixed_t frac, vector2_t *out)
|
|
|
|
{
|
|
|
|
FV2_SubEx(to, from, out);
|
|
|
|
FV2_MulEx(out, frac, out);
|
|
|
|
FV2_AddEx(from, out, out);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
|
|
|
static vector3_t *R_LerpVector3(const vector3_t *from, const vector3_t *to, fixed_t frac, vector3_t *out)
|
|
|
|
{
|
|
|
|
FV3_SubEx(to, from, out);
|
|
|
|
FV3_MulEx(out, frac, out);
|
|
|
|
FV3_AddEx(from, out, out);
|
|
|
|
return out;
|
|
|
|
}
|
|
|
|
|
2019-10-06 22:40:52 +00:00
|
|
|
// 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)
|
|
|
|
static void R_SetupFreelook(player_t *player, boolean skybox)
|
|
|
|
{
|
|
|
|
#ifndef HWRENDER
|
|
|
|
(void)player;
|
|
|
|
(void)skybox;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// clip it in the case we are looking a hardware 90 degrees full aiming
|
|
|
|
// (lmps, network and use F12...)
|
|
|
|
if (rendermode == render_soft
|
|
|
|
#ifdef HWRENDER
|
|
|
|
|| (rendermode == render_opengl
|
|
|
|
&& (cv_glshearing.value == 1
|
|
|
|
|| (cv_glshearing.value == 2 && R_IsViewpointThirdPerson(player, skybox))))
|
|
|
|
#endif
|
|
|
|
)
|
|
|
|
{
|
|
|
|
G_SoftwareClipAimingPitch((INT32 *)&aimingangle);
|
|
|
|
}
|
|
|
|
|
|
|
|
centeryfrac = (viewheight/2)<<FRACBITS;
|
|
|
|
|
|
|
|
if (rendermode == render_soft)
|
|
|
|
centeryfrac += FixedMul(AIMINGTODY(aimingangle), FixedDiv(viewwidth<<FRACBITS, BASEVIDWIDTH<<FRACBITS));
|
|
|
|
|
|
|
|
centery = FixedInt(FixedRound(centeryfrac));
|
|
|
|
|
|
|
|
if (rendermode == render_soft)
|
|
|
|
yslope = &yslopetab[viewheight*8 - centery];
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef AIMINGTODY
|
|
|
|
|
|
|
|
void R_InterpolateView(fixed_t frac)
|
|
|
|
{
|
2022-04-11 16:22:54 +00:00
|
|
|
viewvars_t* prevview = oldview;
|
2019-10-06 22:40:52 +00:00
|
|
|
boolean skybox = 0;
|
2022-05-06 01:11:37 +00:00
|
|
|
UINT8 i;
|
|
|
|
|
2019-10-06 22:40:52 +00:00
|
|
|
if (FIXED_TO_FLOAT(frac) < 0)
|
|
|
|
frac = 0;
|
2019-12-22 07:16:57 +00:00
|
|
|
if (frac > FRACUNIT)
|
|
|
|
frac = FRACUNIT;
|
2019-10-06 22:40:52 +00:00
|
|
|
|
2022-05-06 01:11:37 +00:00
|
|
|
if (viewcontext == VIEWCONTEXT_SKY1 || viewcontext == VIEWCONTEXT_PLAYER1)
|
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
i = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldview_invalid[i] != 0)
|
2022-04-11 16:22:54 +00:00
|
|
|
{
|
|
|
|
// interpolate from newview to newview
|
|
|
|
prevview = newview;
|
|
|
|
}
|
|
|
|
|
2022-04-12 23:39:11 +00:00
|
|
|
viewx = R_LerpFixed(prevview->x, newview->x, frac);
|
|
|
|
viewy = R_LerpFixed(prevview->y, newview->y, frac);
|
|
|
|
viewz = R_LerpFixed(prevview->z, newview->z, frac);
|
2019-10-06 22:40:52 +00:00
|
|
|
|
2022-04-12 23:39:11 +00:00
|
|
|
viewangle = R_LerpAngle(prevview->angle, newview->angle, frac);
|
|
|
|
aimingangle = R_LerpAngle(prevview->aim, newview->aim, frac);
|
2019-10-06 22:40:52 +00:00
|
|
|
|
|
|
|
viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT);
|
|
|
|
viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT);
|
|
|
|
|
|
|
|
// this is gonna create some interesting visual errors for long distance teleports...
|
|
|
|
// might want to recalculate the view sector every frame instead...
|
2019-12-22 07:16:57 +00:00
|
|
|
viewplayer = newview->player;
|
|
|
|
viewsector = R_PointInSubsector(viewx, viewy)->sector;
|
2019-10-06 22:40:52 +00:00
|
|
|
|
|
|
|
// well, this ain't pretty
|
|
|
|
if (newview == &sky1view_new || newview == &sky2view_new)
|
|
|
|
{
|
|
|
|
skybox = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
R_SetupFreelook(newview->player, skybox);
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_UpdateViewInterpolation(void)
|
|
|
|
{
|
|
|
|
p1view_old = p1view_new;
|
|
|
|
p2view_old = p2view_new;
|
|
|
|
sky1view_old = sky1view_new;
|
|
|
|
sky2view_old = sky2view_new;
|
2022-05-06 01:11:37 +00:00
|
|
|
if (oldview_invalid[0] > 0) oldview_invalid[0]--;
|
|
|
|
if (oldview_invalid[1] > 0) oldview_invalid[1]--;
|
2022-04-11 16:22:54 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 01:11:37 +00:00
|
|
|
void R_ResetViewInterpolation(UINT8 p)
|
2022-04-11 16:22:54 +00:00
|
|
|
{
|
2022-05-06 01:11:37 +00:00
|
|
|
if (p == 0)
|
|
|
|
{
|
|
|
|
UINT8 i;
|
|
|
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
|
|
|
{
|
|
|
|
oldview_invalid[i]++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
oldview_invalid[p - 1]++;
|
|
|
|
}
|
2019-10-06 22:40:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void R_SetViewContext(enum viewcontext_e _viewcontext)
|
|
|
|
{
|
|
|
|
I_Assert(_viewcontext == VIEWCONTEXT_PLAYER1
|
|
|
|
|| _viewcontext == VIEWCONTEXT_PLAYER2
|
|
|
|
|| _viewcontext == VIEWCONTEXT_SKY1
|
|
|
|
|| _viewcontext == VIEWCONTEXT_SKY2);
|
|
|
|
viewcontext = _viewcontext;
|
|
|
|
|
|
|
|
switch (viewcontext)
|
|
|
|
{
|
|
|
|
case VIEWCONTEXT_PLAYER1:
|
|
|
|
oldview = &p1view_old;
|
|
|
|
newview = &p1view_new;
|
|
|
|
break;
|
|
|
|
case VIEWCONTEXT_PLAYER2:
|
|
|
|
oldview = &p2view_old;
|
|
|
|
newview = &p2view_new;
|
|
|
|
break;
|
|
|
|
case VIEWCONTEXT_SKY1:
|
|
|
|
oldview = &sky1view_old;
|
|
|
|
newview = &sky1view_new;
|
|
|
|
break;
|
|
|
|
case VIEWCONTEXT_SKY2:
|
|
|
|
oldview = &sky2view_old;
|
|
|
|
newview = &sky2view_new;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
I_Error("viewcontext value is invalid: we should never get here without an assert!!");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-04-12 23:39:11 +00:00
|
|
|
|
2021-12-24 16:30:19 +00:00
|
|
|
fixed_t R_InterpolateFixed(fixed_t from, fixed_t to)
|
|
|
|
{
|
2022-03-27 03:48:08 +00:00
|
|
|
if (!R_UsingFrameInterpolation())
|
2021-12-24 16:30:19 +00:00
|
|
|
{
|
|
|
|
return to;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (R_LerpFixed(from, to, rendertimefrac));
|
|
|
|
}
|
|
|
|
|
|
|
|
angle_t R_InterpolateAngle(angle_t from, angle_t to)
|
|
|
|
{
|
2022-03-27 03:48:08 +00:00
|
|
|
if (!R_UsingFrameInterpolation())
|
2021-12-24 16:30:19 +00:00
|
|
|
{
|
|
|
|
return to;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (R_LerpAngle(from, to, rendertimefrac));
|
|
|
|
}
|
|
|
|
|
2022-04-12 23:39:11 +00:00
|
|
|
void R_InterpolateMobjState(mobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
|
|
|
|
{
|
2022-04-29 02:07:06 +00:00
|
|
|
if (frac == FRACUNIT)
|
|
|
|
{
|
|
|
|
out->x = mobj->x;
|
|
|
|
out->y = mobj->y;
|
|
|
|
out->z = mobj->z;
|
|
|
|
out->scale = mobj->scale;
|
2023-08-25 08:42:12 +00:00
|
|
|
out->radius = mobj->radius;
|
|
|
|
out->height = mobj->height;
|
2022-04-29 02:07:06 +00:00
|
|
|
out->subsector = mobj->subsector;
|
|
|
|
out->angle = mobj->player ? mobj->player->drawangle : mobj->angle;
|
2020-10-30 06:15:49 +00:00
|
|
|
out->pitch = mobj->pitch;
|
|
|
|
out->roll = mobj->roll;
|
|
|
|
out->spriteroll = mobj->spriteroll;
|
2022-04-29 19:21:30 +00:00
|
|
|
out->spritexscale = mobj->spritexscale;
|
|
|
|
out->spriteyscale = mobj->spriteyscale;
|
|
|
|
out->spritexoffset = mobj->spritexoffset;
|
|
|
|
out->spriteyoffset = mobj->spriteyoffset;
|
2022-04-29 02:07:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-04-12 23:39:11 +00:00
|
|
|
out->x = R_LerpFixed(mobj->old_x, mobj->x, frac);
|
|
|
|
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
|
|
|
|
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
|
2022-04-29 19:21:30 +00:00
|
|
|
out->spritexscale = mobj->resetinterp ? mobj->spritexscale : R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac);
|
|
|
|
out->spriteyscale = mobj->resetinterp ? mobj->spriteyscale : R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac);
|
2022-05-01 02:56:42 +00:00
|
|
|
|
2023-08-25 08:42:12 +00:00
|
|
|
if (mobj->scale == mobj->old_scale) // Tiny optimisation - scale is usually unchanging, so let's skip a lerp, two FixedMuls, and two FixedDivs
|
|
|
|
{
|
|
|
|
out->scale = mobj->scale;
|
|
|
|
out->radius = mobj->radius;
|
|
|
|
out->height = mobj->height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
out->scale = R_LerpFixed(mobj->old_scale, mobj->scale, frac);
|
|
|
|
out->radius = FixedMul(mobj->radius, FixedDiv(out->scale, mobj->scale));
|
|
|
|
out->height = FixedMul(mobj->height, FixedDiv(out->scale, mobj->scale));
|
|
|
|
}
|
|
|
|
|
2022-05-01 02:56:42 +00:00
|
|
|
// Sprite offsets are not interpolated until we have a way to interpolate them explicitly in Lua.
|
|
|
|
// It seems existing mods visually break more often than not if it is interpolated.
|
|
|
|
out->spritexoffset = mobj->spritexoffset;
|
|
|
|
out->spriteyoffset = mobj->spriteyoffset;
|
2022-04-12 23:39:11 +00:00
|
|
|
|
2022-04-26 00:14:53 +00:00
|
|
|
out->subsector = R_PointInSubsector(out->x, out->y);
|
|
|
|
|
2022-04-12 23:39:11 +00:00
|
|
|
if (mobj->player)
|
|
|
|
{
|
2022-04-28 23:46:02 +00:00
|
|
|
out->angle = mobj->resetinterp ? mobj->player->drawangle : R_LerpAngle(mobj->player->old_drawangle, mobj->player->drawangle, frac);
|
2022-04-12 23:39:11 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-04-28 23:46:02 +00:00
|
|
|
out->angle = mobj->resetinterp ? mobj->angle : R_LerpAngle(mobj->old_angle, mobj->angle, frac);
|
2022-04-12 23:39:11 +00:00
|
|
|
}
|
2020-10-30 06:15:49 +00:00
|
|
|
|
|
|
|
out->pitch = mobj->resetinterp ? mobj->pitch : R_LerpAngle(mobj->old_pitch, mobj->pitch, frac);
|
|
|
|
out->roll = mobj->resetinterp ? mobj->roll : R_LerpAngle(mobj->old_roll, mobj->roll, frac);
|
|
|
|
out->spriteroll = mobj->resetinterp ? mobj->spriteroll : R_LerpAngle(mobj->old_spriteroll, mobj->spriteroll, frac);
|
2022-04-12 23:39:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void R_InterpolatePrecipMobjState(precipmobj_t *mobj, fixed_t frac, interpmobjstate_t *out)
|
|
|
|
{
|
2022-04-29 02:07:06 +00:00
|
|
|
if (frac == FRACUNIT)
|
|
|
|
{
|
|
|
|
out->x = mobj->x;
|
|
|
|
out->y = mobj->y;
|
|
|
|
out->z = mobj->z;
|
2022-04-29 19:21:30 +00:00
|
|
|
out->scale = FRACUNIT;
|
2023-08-25 08:42:12 +00:00
|
|
|
out->radius = mobj->radius;
|
|
|
|
out->height = mobj->height;
|
2022-04-29 02:07:06 +00:00
|
|
|
out->subsector = mobj->subsector;
|
|
|
|
out->angle = mobj->angle;
|
2020-10-30 06:15:49 +00:00
|
|
|
out->pitch = mobj->angle;
|
|
|
|
out->roll = mobj->roll;
|
|
|
|
out->spriteroll = mobj->spriteroll;
|
2022-04-29 19:21:30 +00:00
|
|
|
out->spritexscale = mobj->spritexscale;
|
|
|
|
out->spriteyscale = mobj->spriteyscale;
|
|
|
|
out->spritexoffset = mobj->spritexoffset;
|
|
|
|
out->spriteyoffset = mobj->spriteyoffset;
|
2022-04-29 02:07:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-04-12 23:39:11 +00:00
|
|
|
out->x = R_LerpFixed(mobj->old_x, mobj->x, frac);
|
|
|
|
out->y = R_LerpFixed(mobj->old_y, mobj->y, frac);
|
|
|
|
out->z = R_LerpFixed(mobj->old_z, mobj->z, frac);
|
2022-04-29 19:21:30 +00:00
|
|
|
out->scale = FRACUNIT;
|
2023-08-25 08:42:12 +00:00
|
|
|
out->radius = mobj->radius;
|
|
|
|
out->height = mobj->height;
|
2022-04-29 19:21:30 +00:00
|
|
|
out->spritexscale = R_LerpFixed(mobj->old_spritexscale, mobj->spritexscale, frac);
|
|
|
|
out->spriteyscale = R_LerpFixed(mobj->old_spriteyscale, mobj->spriteyscale, frac);
|
|
|
|
out->spritexoffset = R_LerpFixed(mobj->old_spritexoffset, mobj->spritexoffset, frac);
|
|
|
|
out->spriteyoffset = R_LerpFixed(mobj->old_spriteyoffset, mobj->spriteyoffset, frac);
|
2022-04-26 00:14:53 +00:00
|
|
|
|
|
|
|
out->subsector = R_PointInSubsector(out->x, out->y);
|
|
|
|
|
2022-04-13 03:54:56 +00:00
|
|
|
out->angle = R_LerpAngle(mobj->old_angle, mobj->angle, frac);
|
2020-10-30 06:15:49 +00:00
|
|
|
out->pitch = R_LerpAngle(mobj->old_pitch, mobj->pitch, frac);
|
|
|
|
out->roll = R_LerpAngle(mobj->old_roll, mobj->roll, frac);
|
|
|
|
out->spriteroll = R_LerpAngle(mobj->old_spriteroll, mobj->spriteroll, frac);
|
2022-04-12 23:39:11 +00:00
|
|
|
}
|
2022-04-13 01:45:49 +00:00
|
|
|
|
|
|
|
static void AddInterpolator(levelinterpolator_t* interpolator)
|
|
|
|
{
|
|
|
|
if (levelinterpolators_len >= levelinterpolators_size)
|
|
|
|
{
|
|
|
|
if (levelinterpolators_size == 0)
|
|
|
|
{
|
|
|
|
levelinterpolators_size = 128;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
levelinterpolators_size *= 2;
|
|
|
|
}
|
2022-11-12 01:31:04 +00:00
|
|
|
|
2023-07-14 11:25:09 +00:00
|
|
|
levelinterpolators = Z_Realloc(
|
2022-04-13 01:45:49 +00:00
|
|
|
(void*) levelinterpolators,
|
|
|
|
sizeof(levelinterpolator_t*) * levelinterpolators_size,
|
|
|
|
PU_LEVEL,
|
2023-07-14 11:25:09 +00:00
|
|
|
NULL
|
2022-04-13 01:45:49 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
levelinterpolators[levelinterpolators_len] = interpolator;
|
|
|
|
levelinterpolators_len += 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static levelinterpolator_t *CreateInterpolator(levelinterpolator_type_e type, thinker_t *thinker)
|
|
|
|
{
|
2023-07-14 11:25:09 +00:00
|
|
|
levelinterpolator_t *ret = (levelinterpolator_t*) Z_Calloc(
|
|
|
|
sizeof(levelinterpolator_t), PU_LEVEL, NULL
|
2022-04-13 01:45:49 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
ret->type = type;
|
|
|
|
ret->thinker = thinker;
|
|
|
|
|
|
|
|
AddInterpolator(ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_CreateInterpolator_SectorPlane(thinker_t *thinker, sector_t *sector, boolean ceiling)
|
|
|
|
{
|
|
|
|
levelinterpolator_t *interp = CreateInterpolator(LVLINTERP_SectorPlane, thinker);
|
|
|
|
interp->sectorplane.sector = sector;
|
|
|
|
interp->sectorplane.ceiling = ceiling;
|
|
|
|
if (ceiling)
|
|
|
|
{
|
|
|
|
interp->sectorplane.oldheight = interp->sectorplane.bakheight = sector->ceilingheight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
interp->sectorplane.oldheight = interp->sectorplane.bakheight = sector->floorheight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-13 02:22:39 +00:00
|
|
|
void R_CreateInterpolator_SectorScroll(thinker_t *thinker, sector_t *sector, boolean ceiling)
|
|
|
|
{
|
|
|
|
levelinterpolator_t *interp = CreateInterpolator(LVLINTERP_SectorScroll, thinker);
|
|
|
|
interp->sectorscroll.sector = sector;
|
|
|
|
interp->sectorscroll.ceiling = ceiling;
|
|
|
|
if (ceiling)
|
|
|
|
{
|
2022-11-25 23:06:07 +00:00
|
|
|
interp->sectorscroll.oldxoffs = interp->sectorscroll.bakxoffs = sector->ceilingxoffset;
|
|
|
|
interp->sectorscroll.oldyoffs = interp->sectorscroll.bakyoffs = sector->ceilingyoffset;
|
2022-04-13 02:22:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-11-25 23:01:27 +00:00
|
|
|
interp->sectorscroll.oldxoffs = interp->sectorscroll.bakxoffs = sector->floorxoffset;
|
|
|
|
interp->sectorscroll.oldyoffs = interp->sectorscroll.bakyoffs = sector->flooryoffset;
|
2022-04-13 02:22:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-13 02:35:52 +00:00
|
|
|
void R_CreateInterpolator_SideScroll(thinker_t *thinker, side_t *side)
|
|
|
|
{
|
|
|
|
levelinterpolator_t *interp = CreateInterpolator(LVLINTERP_SideScroll, thinker);
|
|
|
|
interp->sidescroll.side = side;
|
|
|
|
interp->sidescroll.oldtextureoffset = interp->sidescroll.baktextureoffset = side->textureoffset;
|
|
|
|
interp->sidescroll.oldrowoffset = interp->sidescroll.bakrowoffset = side->rowoffset;
|
|
|
|
}
|
|
|
|
|
2022-04-13 03:22:16 +00:00
|
|
|
void R_CreateInterpolator_Polyobj(thinker_t *thinker, polyobj_t *polyobj)
|
|
|
|
{
|
|
|
|
levelinterpolator_t *interp = CreateInterpolator(LVLINTERP_Polyobj, thinker);
|
|
|
|
interp->polyobj.polyobj = polyobj;
|
|
|
|
interp->polyobj.vertices_size = polyobj->numVertices;
|
|
|
|
|
|
|
|
interp->polyobj.oldvertices = Z_CallocAlign(sizeof(fixed_t) * 2 * polyobj->numVertices, PU_LEVEL, NULL, 32);
|
|
|
|
interp->polyobj.bakvertices = Z_CallocAlign(sizeof(fixed_t) * 2 * polyobj->numVertices, PU_LEVEL, NULL, 32);
|
|
|
|
for (size_t i = 0; i < polyobj->numVertices; i++)
|
|
|
|
{
|
|
|
|
interp->polyobj.oldvertices[i * 2 ] = interp->polyobj.bakvertices[i * 2 ] = polyobj->vertices[i]->x;
|
|
|
|
interp->polyobj.oldvertices[i * 2 + 1] = interp->polyobj.bakvertices[i * 2 + 1] = polyobj->vertices[i]->y;
|
|
|
|
}
|
|
|
|
|
|
|
|
interp->polyobj.oldcx = interp->polyobj.bakcx = polyobj->centerPt.x;
|
|
|
|
interp->polyobj.oldcy = interp->polyobj.bakcy = polyobj->centerPt.y;
|
|
|
|
}
|
|
|
|
|
2022-04-25 09:27:57 +00:00
|
|
|
void R_CreateInterpolator_DynSlope(thinker_t *thinker, pslope_t *slope)
|
|
|
|
{
|
|
|
|
levelinterpolator_t *interp = CreateInterpolator(LVLINTERP_DynSlope, thinker);
|
|
|
|
interp->dynslope.slope = slope;
|
|
|
|
|
|
|
|
FV3_Copy(&interp->dynslope.oldo, &slope->o);
|
|
|
|
FV3_Copy(&interp->dynslope.bako, &slope->o);
|
|
|
|
|
|
|
|
FV2_Copy(&interp->dynslope.oldd, &slope->d);
|
|
|
|
FV2_Copy(&interp->dynslope.bakd, &slope->d);
|
|
|
|
|
|
|
|
interp->dynslope.oldzdelta = interp->dynslope.bakzdelta = slope->zdelta;
|
|
|
|
}
|
|
|
|
|
2022-04-13 01:45:49 +00:00
|
|
|
void R_InitializeLevelInterpolators(void)
|
|
|
|
{
|
|
|
|
levelinterpolators_len = 0;
|
|
|
|
levelinterpolators_size = 0;
|
|
|
|
levelinterpolators = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void UpdateLevelInterpolatorState(levelinterpolator_t *interp)
|
|
|
|
{
|
2022-04-13 03:22:16 +00:00
|
|
|
size_t i;
|
|
|
|
|
2022-04-13 01:45:49 +00:00
|
|
|
switch (interp->type)
|
|
|
|
{
|
|
|
|
case LVLINTERP_SectorPlane:
|
|
|
|
interp->sectorplane.oldheight = interp->sectorplane.bakheight;
|
|
|
|
interp->sectorplane.bakheight = interp->sectorplane.ceiling ? interp->sectorplane.sector->ceilingheight : interp->sectorplane.sector->floorheight;
|
|
|
|
break;
|
2022-04-13 02:22:39 +00:00
|
|
|
case LVLINTERP_SectorScroll:
|
|
|
|
interp->sectorscroll.oldxoffs = interp->sectorscroll.bakxoffs;
|
2022-11-25 23:06:07 +00:00
|
|
|
interp->sectorscroll.bakxoffs = interp->sectorscroll.ceiling ? interp->sectorscroll.sector->ceilingxoffset : interp->sectorscroll.sector->floorxoffset;
|
2022-04-13 02:22:39 +00:00
|
|
|
interp->sectorscroll.oldyoffs = interp->sectorscroll.bakyoffs;
|
2022-11-25 23:06:07 +00:00
|
|
|
interp->sectorscroll.bakyoffs = interp->sectorscroll.ceiling ? interp->sectorscroll.sector->ceilingyoffset : interp->sectorscroll.sector->flooryoffset;
|
2022-04-13 02:22:39 +00:00
|
|
|
break;
|
2022-04-13 02:35:52 +00:00
|
|
|
case LVLINTERP_SideScroll:
|
|
|
|
interp->sidescroll.oldtextureoffset = interp->sidescroll.baktextureoffset;
|
|
|
|
interp->sidescroll.baktextureoffset = interp->sidescroll.side->textureoffset;
|
|
|
|
interp->sidescroll.oldrowoffset = interp->sidescroll.bakrowoffset;
|
|
|
|
interp->sidescroll.bakrowoffset = interp->sidescroll.side->rowoffset;
|
|
|
|
break;
|
2022-04-13 03:22:16 +00:00
|
|
|
case LVLINTERP_Polyobj:
|
|
|
|
for (i = 0; i < interp->polyobj.vertices_size; i++)
|
|
|
|
{
|
|
|
|
interp->polyobj.oldvertices[i * 2 ] = interp->polyobj.bakvertices[i * 2 ];
|
|
|
|
interp->polyobj.oldvertices[i * 2 + 1] = interp->polyobj.bakvertices[i * 2 + 1];
|
|
|
|
interp->polyobj.bakvertices[i * 2 ] = interp->polyobj.polyobj->vertices[i]->x;
|
|
|
|
interp->polyobj.bakvertices[i * 2 + 1] = interp->polyobj.polyobj->vertices[i]->y;
|
|
|
|
}
|
|
|
|
interp->polyobj.oldcx = interp->polyobj.bakcx;
|
|
|
|
interp->polyobj.oldcy = interp->polyobj.bakcy;
|
|
|
|
interp->polyobj.bakcx = interp->polyobj.polyobj->centerPt.x;
|
|
|
|
interp->polyobj.bakcy = interp->polyobj.polyobj->centerPt.y;
|
|
|
|
break;
|
2022-04-25 09:27:57 +00:00
|
|
|
case LVLINTERP_DynSlope:
|
|
|
|
FV3_Copy(&interp->dynslope.oldo, &interp->dynslope.bako);
|
|
|
|
FV2_Copy(&interp->dynslope.oldd, &interp->dynslope.bakd);
|
|
|
|
interp->dynslope.oldzdelta = interp->dynslope.bakzdelta;
|
|
|
|
|
|
|
|
FV3_Copy(&interp->dynslope.bako, &interp->dynslope.slope->o);
|
|
|
|
FV2_Copy(&interp->dynslope.bakd, &interp->dynslope.slope->d);
|
|
|
|
interp->dynslope.bakzdelta = interp->dynslope.slope->zdelta;
|
|
|
|
break;
|
2022-04-13 01:45:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_UpdateLevelInterpolators(void)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < levelinterpolators_len; i++)
|
|
|
|
{
|
|
|
|
levelinterpolator_t *interp = levelinterpolators[i];
|
2022-04-25 18:16:41 +00:00
|
|
|
|
2022-04-13 01:45:49 +00:00
|
|
|
UpdateLevelInterpolatorState(interp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_ClearLevelInterpolatorState(thinker_t *thinker)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < levelinterpolators_len; i++)
|
|
|
|
{
|
|
|
|
levelinterpolator_t *interp = levelinterpolators[i];
|
2022-04-25 18:16:41 +00:00
|
|
|
|
2022-04-13 01:45:49 +00:00
|
|
|
if (interp->thinker == thinker)
|
|
|
|
{
|
|
|
|
// Do it twice to make the old state match the new
|
|
|
|
UpdateLevelInterpolatorState(interp);
|
|
|
|
UpdateLevelInterpolatorState(interp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_ApplyLevelInterpolators(fixed_t frac)
|
|
|
|
{
|
2022-04-13 03:22:16 +00:00
|
|
|
size_t i, ii;
|
2022-04-13 01:45:49 +00:00
|
|
|
|
|
|
|
for (i = 0; i < levelinterpolators_len; i++)
|
|
|
|
{
|
|
|
|
levelinterpolator_t *interp = levelinterpolators[i];
|
|
|
|
|
|
|
|
switch (interp->type)
|
|
|
|
{
|
|
|
|
case LVLINTERP_SectorPlane:
|
|
|
|
if (interp->sectorplane.ceiling)
|
|
|
|
{
|
|
|
|
interp->sectorplane.sector->ceilingheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
interp->sectorplane.sector->floorheight = R_LerpFixed(interp->sectorplane.oldheight, interp->sectorplane.bakheight, frac);
|
|
|
|
}
|
2022-04-25 18:16:41 +00:00
|
|
|
interp->sectorplane.sector->moved = true;
|
2022-04-13 02:22:39 +00:00
|
|
|
break;
|
|
|
|
case LVLINTERP_SectorScroll:
|
|
|
|
if (interp->sectorscroll.ceiling)
|
|
|
|
{
|
2022-11-25 23:06:07 +00:00
|
|
|
interp->sectorscroll.sector->ceilingxoffset = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac);
|
|
|
|
interp->sectorscroll.sector->ceilingyoffset = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac);
|
2022-04-13 02:22:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-11-25 23:01:27 +00:00
|
|
|
interp->sectorscroll.sector->floorxoffset = R_LerpFixed(interp->sectorscroll.oldxoffs, interp->sectorscroll.bakxoffs, frac);
|
|
|
|
interp->sectorscroll.sector->flooryoffset = R_LerpFixed(interp->sectorscroll.oldyoffs, interp->sectorscroll.bakyoffs, frac);
|
2022-04-13 02:22:39 +00:00
|
|
|
}
|
|
|
|
break;
|
2022-04-13 02:35:52 +00:00
|
|
|
case LVLINTERP_SideScroll:
|
|
|
|
interp->sidescroll.side->textureoffset = R_LerpFixed(interp->sidescroll.oldtextureoffset, interp->sidescroll.baktextureoffset, frac);
|
|
|
|
interp->sidescroll.side->rowoffset = R_LerpFixed(interp->sidescroll.oldrowoffset, interp->sidescroll.bakrowoffset, frac);
|
|
|
|
break;
|
2022-04-13 03:22:16 +00:00
|
|
|
case LVLINTERP_Polyobj:
|
|
|
|
for (ii = 0; ii < interp->polyobj.vertices_size; ii++)
|
|
|
|
{
|
|
|
|
interp->polyobj.polyobj->vertices[ii]->x = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 ], interp->polyobj.bakvertices[ii * 2 ], frac);
|
|
|
|
interp->polyobj.polyobj->vertices[ii]->y = R_LerpFixed(interp->polyobj.oldvertices[ii * 2 + 1], interp->polyobj.bakvertices[ii * 2 + 1], frac);
|
|
|
|
}
|
|
|
|
interp->polyobj.polyobj->centerPt.x = R_LerpFixed(interp->polyobj.oldcx, interp->polyobj.bakcx, frac);
|
|
|
|
interp->polyobj.polyobj->centerPt.y = R_LerpFixed(interp->polyobj.oldcy, interp->polyobj.bakcy, frac);
|
|
|
|
break;
|
2022-04-25 09:27:57 +00:00
|
|
|
case LVLINTERP_DynSlope:
|
|
|
|
R_LerpVector3(&interp->dynslope.oldo, &interp->dynslope.bako, frac, &interp->dynslope.slope->o);
|
|
|
|
R_LerpVector2(&interp->dynslope.oldd, &interp->dynslope.bakd, frac, &interp->dynslope.slope->d);
|
|
|
|
interp->dynslope.slope->zdelta = R_LerpFixed(interp->dynslope.oldzdelta, interp->dynslope.bakzdelta, frac);
|
2024-01-30 01:08:22 +00:00
|
|
|
P_RecalculateSlopeVectors(interp->dynslope.slope);
|
2022-04-25 09:27:57 +00:00
|
|
|
break;
|
2022-04-13 01:45:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_RestoreLevelInterpolators(void)
|
|
|
|
{
|
2022-04-13 03:22:16 +00:00
|
|
|
size_t i, ii;
|
2022-04-13 01:45:49 +00:00
|
|
|
|
|
|
|
for (i = 0; i < levelinterpolators_len; i++)
|
|
|
|
{
|
|
|
|
levelinterpolator_t *interp = levelinterpolators[i];
|
2022-11-12 01:31:04 +00:00
|
|
|
|
2022-04-13 01:45:49 +00:00
|
|
|
switch (interp->type)
|
|
|
|
{
|
|
|
|
case LVLINTERP_SectorPlane:
|
|
|
|
if (interp->sectorplane.ceiling)
|
|
|
|
{
|
|
|
|
interp->sectorplane.sector->ceilingheight = interp->sectorplane.bakheight;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
interp->sectorplane.sector->floorheight = interp->sectorplane.bakheight;
|
|
|
|
}
|
2022-04-25 18:16:41 +00:00
|
|
|
interp->sectorplane.sector->moved = true;
|
2022-04-13 02:22:39 +00:00
|
|
|
break;
|
|
|
|
case LVLINTERP_SectorScroll:
|
|
|
|
if (interp->sectorscroll.ceiling)
|
|
|
|
{
|
2022-11-25 23:06:07 +00:00
|
|
|
interp->sectorscroll.sector->ceilingxoffset = interp->sectorscroll.bakxoffs;
|
|
|
|
interp->sectorscroll.sector->ceilingyoffset = interp->sectorscroll.bakyoffs;
|
2022-04-13 02:22:39 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-11-25 23:01:27 +00:00
|
|
|
interp->sectorscroll.sector->floorxoffset = interp->sectorscroll.bakxoffs;
|
|
|
|
interp->sectorscroll.sector->flooryoffset = interp->sectorscroll.bakyoffs;
|
2022-04-13 02:22:39 +00:00
|
|
|
}
|
|
|
|
break;
|
2022-04-13 02:35:52 +00:00
|
|
|
case LVLINTERP_SideScroll:
|
|
|
|
interp->sidescroll.side->textureoffset = interp->sidescroll.baktextureoffset;
|
|
|
|
interp->sidescroll.side->rowoffset = interp->sidescroll.bakrowoffset;
|
|
|
|
break;
|
2022-04-13 03:22:16 +00:00
|
|
|
case LVLINTERP_Polyobj:
|
|
|
|
for (ii = 0; ii < interp->polyobj.vertices_size; ii++)
|
|
|
|
{
|
|
|
|
interp->polyobj.polyobj->vertices[ii]->x = interp->polyobj.bakvertices[ii * 2 ];
|
|
|
|
interp->polyobj.polyobj->vertices[ii]->y = interp->polyobj.bakvertices[ii * 2 + 1];
|
|
|
|
}
|
|
|
|
interp->polyobj.polyobj->centerPt.x = interp->polyobj.bakcx;
|
|
|
|
interp->polyobj.polyobj->centerPt.y = interp->polyobj.bakcy;
|
|
|
|
break;
|
2022-04-25 09:27:57 +00:00
|
|
|
case LVLINTERP_DynSlope:
|
|
|
|
FV3_Copy(&interp->dynslope.slope->o, &interp->dynslope.bako);
|
|
|
|
FV2_Copy(&interp->dynslope.slope->d, &interp->dynslope.bakd);
|
|
|
|
interp->dynslope.slope->zdelta = interp->dynslope.bakzdelta;
|
|
|
|
break;
|
2022-04-13 01:45:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-13 03:39:40 +00:00
|
|
|
|
|
|
|
void R_DestroyLevelInterpolators(thinker_t *thinker)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < levelinterpolators_len; i++)
|
|
|
|
{
|
|
|
|
levelinterpolator_t *interp = levelinterpolators[i];
|
2022-11-12 01:31:04 +00:00
|
|
|
|
2022-04-13 03:39:40 +00:00
|
|
|
if (interp->thinker == thinker)
|
|
|
|
{
|
|
|
|
// Swap the tail of the level interpolators to this spot
|
|
|
|
levelinterpolators[i] = levelinterpolators[levelinterpolators_len - 1];
|
|
|
|
levelinterpolators_len -= 1;
|
|
|
|
|
|
|
|
Z_Free(interp);
|
|
|
|
i -= 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-23 18:13:58 +00:00
|
|
|
|
|
|
|
static mobj_t **interpolated_mobjs = NULL;
|
|
|
|
static size_t interpolated_mobjs_len = 0;
|
|
|
|
static size_t interpolated_mobjs_capacity = 0;
|
|
|
|
|
|
|
|
// NOTE: This will NOT check that the mobj has already been added, for perf
|
|
|
|
// reasons.
|
|
|
|
void R_AddMobjInterpolator(mobj_t *mobj)
|
|
|
|
{
|
|
|
|
if (interpolated_mobjs_len >= interpolated_mobjs_capacity)
|
|
|
|
{
|
|
|
|
if (interpolated_mobjs_capacity == 0)
|
|
|
|
{
|
|
|
|
interpolated_mobjs_capacity = 256;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
interpolated_mobjs_capacity *= 2;
|
|
|
|
}
|
|
|
|
|
2023-07-14 11:25:09 +00:00
|
|
|
interpolated_mobjs = Z_Realloc(
|
2022-04-23 18:13:58 +00:00
|
|
|
interpolated_mobjs,
|
|
|
|
sizeof(mobj_t *) * interpolated_mobjs_capacity,
|
|
|
|
PU_LEVEL,
|
2023-07-14 11:25:09 +00:00
|
|
|
NULL
|
2022-04-23 18:13:58 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
interpolated_mobjs[interpolated_mobjs_len] = mobj;
|
|
|
|
interpolated_mobjs_len += 1;
|
|
|
|
|
|
|
|
R_ResetMobjInterpolationState(mobj);
|
2022-04-29 19:21:30 +00:00
|
|
|
mobj->resetinterp = true;
|
2022-04-23 18:13:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void R_RemoveMobjInterpolator(mobj_t *mobj)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (interpolated_mobjs_len == 0) return;
|
|
|
|
|
2022-09-03 02:58:47 +00:00
|
|
|
for (i = 0; i < interpolated_mobjs_len; i++)
|
2022-04-23 18:13:58 +00:00
|
|
|
{
|
|
|
|
if (interpolated_mobjs[i] == mobj)
|
|
|
|
{
|
|
|
|
interpolated_mobjs[i] = interpolated_mobjs[
|
|
|
|
interpolated_mobjs_len - 1
|
|
|
|
];
|
|
|
|
interpolated_mobjs_len -= 1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_InitMobjInterpolators(void)
|
|
|
|
{
|
|
|
|
// apparently it's not acceptable to free something already unallocated
|
|
|
|
// Z_Free(interpolated_mobjs);
|
|
|
|
interpolated_mobjs = NULL;
|
|
|
|
interpolated_mobjs_len = 0;
|
|
|
|
interpolated_mobjs_capacity = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void R_UpdateMobjInterpolators(void)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < interpolated_mobjs_len; i++)
|
|
|
|
{
|
|
|
|
mobj_t *mobj = interpolated_mobjs[i];
|
|
|
|
if (!P_MobjWasRemoved(mobj))
|
|
|
|
R_ResetMobjInterpolationState(mobj);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// P_ResetMobjInterpolationState
|
|
|
|
//
|
|
|
|
// Reset the rendering interpolation state of the mobj.
|
|
|
|
//
|
|
|
|
void R_ResetMobjInterpolationState(mobj_t *mobj)
|
|
|
|
{
|
2022-04-26 20:40:13 +00:00
|
|
|
mobj->old_x2 = mobj->old_x;
|
|
|
|
mobj->old_y2 = mobj->old_y;
|
|
|
|
mobj->old_z2 = mobj->old_z;
|
|
|
|
mobj->old_angle2 = mobj->old_angle;
|
|
|
|
mobj->old_pitch2 = mobj->old_pitch;
|
|
|
|
mobj->old_roll2 = mobj->old_roll;
|
2020-10-30 06:15:49 +00:00
|
|
|
mobj->old_spriteroll2 = mobj->old_spriteroll;
|
2022-04-28 02:39:47 +00:00
|
|
|
mobj->old_scale2 = mobj->old_scale;
|
2022-04-23 18:13:58 +00:00
|
|
|
mobj->old_x = mobj->x;
|
|
|
|
mobj->old_y = mobj->y;
|
|
|
|
mobj->old_z = mobj->z;
|
|
|
|
mobj->old_angle = mobj->angle;
|
|
|
|
mobj->old_pitch = mobj->pitch;
|
|
|
|
mobj->old_roll = mobj->roll;
|
2020-10-30 06:15:49 +00:00
|
|
|
mobj->old_spriteroll = mobj->spriteroll;
|
2022-04-28 02:39:47 +00:00
|
|
|
mobj->old_scale = mobj->scale;
|
2022-04-29 19:21:30 +00:00
|
|
|
mobj->old_spritexscale = mobj->spritexscale;
|
|
|
|
mobj->old_spriteyscale = mobj->spriteyscale;
|
|
|
|
mobj->old_spritexoffset = mobj->spritexoffset;
|
|
|
|
mobj->old_spriteyoffset = mobj->spriteyoffset;
|
2022-04-23 18:13:58 +00:00
|
|
|
|
|
|
|
if (mobj->player)
|
|
|
|
{
|
2022-04-26 20:40:13 +00:00
|
|
|
mobj->player->old_drawangle2 = mobj->player->old_drawangle;
|
2022-04-23 18:13:58 +00:00
|
|
|
mobj->player->old_drawangle = mobj->player->drawangle;
|
|
|
|
}
|
2022-04-28 23:46:02 +00:00
|
|
|
|
|
|
|
mobj->resetinterp = false;
|
2022-04-23 18:13:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// P_ResetPrecipitationMobjInterpolationState
|
|
|
|
//
|
|
|
|
// Reset the rendering interpolation state of the precipmobj.
|
|
|
|
//
|
|
|
|
void R_ResetPrecipitationMobjInterpolationState(precipmobj_t *mobj)
|
|
|
|
{
|
2022-04-26 20:40:13 +00:00
|
|
|
mobj->old_x2 = mobj->old_x;
|
|
|
|
mobj->old_y2 = mobj->old_y;
|
|
|
|
mobj->old_z2 = mobj->old_z;
|
|
|
|
mobj->old_angle2 = mobj->old_angle;
|
|
|
|
mobj->old_pitch2 = mobj->old_pitch;
|
|
|
|
mobj->old_roll2 = mobj->old_roll;
|
2020-10-30 06:15:49 +00:00
|
|
|
mobj->old_spriteroll2 = mobj->old_spriteroll;
|
2022-04-23 18:13:58 +00:00
|
|
|
mobj->old_x = mobj->x;
|
|
|
|
mobj->old_y = mobj->y;
|
|
|
|
mobj->old_z = mobj->z;
|
|
|
|
mobj->old_angle = mobj->angle;
|
2020-10-30 06:15:49 +00:00
|
|
|
mobj->old_pitch = mobj->pitch;
|
|
|
|
mobj->old_roll = mobj->roll;
|
|
|
|
mobj->old_spriteroll = mobj->spriteroll;
|
2022-04-29 19:21:30 +00:00
|
|
|
mobj->old_spritexscale = mobj->spritexscale;
|
|
|
|
mobj->old_spriteyscale = mobj->spriteyscale;
|
|
|
|
mobj->old_spritexoffset = mobj->spritexoffset;
|
|
|
|
mobj->old_spriteyoffset = mobj->spriteyoffset;
|
2022-04-23 18:13:58 +00:00
|
|
|
}
|