From bf9a63b0900cb31d62c9188a5e952defdd6efa91 Mon Sep 17 00:00:00 2001 From: Roman Fomin Date: Wed, 25 May 2022 17:42:59 +0700 Subject: [PATCH] fix weapon bobbing interpolation at the start of the level --- Source/r_things.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Source/r_things.c b/Source/r_things.c index f4724ed6..3e0ea2fa 100644 --- a/Source/r_things.c +++ b/Source/r_things.c @@ -777,18 +777,23 @@ void R_DrawPSprite (pspdef_t *psp) x1_saved = vis->x1; texturemid_saved = vis->texturemid; - if (lump == oldlump) + // Do not interpolate on the first tic of the level, + // otherwise oldx1 and oldtexturemid are not reset + if (leveltime > 1) { - 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; + 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; + } } }