From c953d919e69fd512312a0683346a635997fae79e Mon Sep 17 00:00:00 2001 From: Roman Fomin Date: Wed, 18 May 2022 14:15:11 +0700 Subject: [PATCH] interpolation for weapon bobbing from PrBoom+ (#554) --- Source/r_things.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Source/r_things.c b/Source/r_things.c index c45d06c7..d1f0ee1a 100644 --- a/Source/r_things.c +++ b/Source/r_things.c @@ -750,6 +750,39 @@ void R_DrawPSprite (pspdef_t *psp) else vis->colormap = spritelights[MAXLIGHTSCALE-1]; // local light + // interpolation for weapon bobbing + if (uncapped) + { + static int oldx1, x1_saved; + static fixed_t oldtexturemid, texturemid_saved; + static int oldlump = -1; + static int oldgametic = -1; + + if (oldgametic < gametic) + { + oldx1 = x1_saved; + oldtexturemid = texturemid_saved; + oldgametic = gametic; + } + + x1_saved = vis->x1; + texturemid_saved = vis->texturemid; + + if (lump == oldlump) + { + int deltax = vis->x2 - vis->x1; + vis->x1 = oldx1 + FixedMul(vis->x1 - oldx1, fractionaltic); + vis->x2 = vis->x1 + deltax; + vis->texturemid = oldtexturemid + FixedMul(vis->texturemid - oldtexturemid, fractionaltic); + } + else + { + oldx1 = vis->x1; + oldtexturemid = vis->texturemid; + oldlump = lump; + } + } + R_DrawVisSprite(vis, vis->x1, vis->x2); }