From 4b6b0764c11b0a7e4d91ab2a52900f000fff5947 Mon Sep 17 00:00:00 2001 From: tmyqlfpir <80724828+tmyqlfpir@users.noreply.github.com> Date: Wed, 18 Dec 2024 00:07:37 +1000 Subject: [PATCH] Blood: Fix interpolated sprite pos for ror transitions --- source/blood/src/view.h | 16 ++++++++++++++++ source/blood/src/warp.cpp | 12 ++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/source/blood/src/view.h b/source/blood/src/view.h index ac2ea068ea..681422ef47 100644 --- a/source/blood/src/view.h +++ b/source/blood/src/view.h @@ -202,3 +202,19 @@ inline void viewBackupSpriteLoc(int nSprite, spritetype *pSprite) SetBitString(gInterpolateSprite, nSprite); } } + +inline void viewCorrectSpriteInterpolateOffsets(int nSprite, spritetype *pSprite, vec3_t const *oldpos) +{ + if (TestBitString(gInterpolateSprite, nSprite)) + { + if (!gViewInterpolate) // view interpolation is off, clear interpolation flag + { + ClearBitString(gInterpolateSprite, nSprite); + return; + } + LOCATION *pPrevLoc = &gPrevSpriteLoc[nSprite]; + pPrevLoc->x = pSprite->x+(pPrevLoc->x-oldpos->x); + pPrevLoc->y = pSprite->y+(pPrevLoc->y-oldpos->y); + pPrevLoc->z = pSprite->z+(pPrevLoc->z-oldpos->z); + } +} diff --git a/source/blood/src/warp.cpp b/source/blood/src/warp.cpp index b5d4c492f8..2ed17a7d19 100644 --- a/source/blood/src/warp.cpp +++ b/source/blood/src/warp.cpp @@ -200,6 +200,7 @@ int CheckLink(spritetype *pSprite) spritetype *pLower = &sprite[nLower]; dassert(pLower->sectnum >= 0 && pLower->sectnum < kMaxSectors); ChangeSpriteSect(pSprite->index, pLower->sectnum); + vec3_t const oldpos = pSprite->xyz; pSprite->x += pLower->x-pUpper->x; pSprite->y += pLower->y-pUpper->y; int z2; @@ -208,7 +209,10 @@ int CheckLink(spritetype *pSprite) else z2 = getceilzofslope(pSprite->sectnum, pSprite->x, pSprite->y); pSprite->z += z2-z; - ClearBitString(gInterpolateSprite, pSprite->index); + if (!VanillaMode()) // if sprite is set to be interpolated, update previous position + viewCorrectSpriteInterpolateOffsets(pSprite->index, pSprite, &oldpos); + else + ClearBitString(gInterpolateSprite, pSprite->index); return pUpper->type; } } @@ -227,6 +231,7 @@ int CheckLink(spritetype *pSprite) spritetype *pUpper = &sprite[nUpper]; dassert(pUpper->sectnum >= 0 && pUpper->sectnum < kMaxSectors); ChangeSpriteSect(pSprite->index, pUpper->sectnum); + vec3_t const oldpos = pSprite->xyz; pSprite->x += pUpper->x-pLower->x; pSprite->y += pUpper->y-pLower->y; int z2; @@ -235,7 +240,10 @@ int CheckLink(spritetype *pSprite) else z2 = getflorzofslope(pSprite->sectnum, pSprite->x, pSprite->y); pSprite->z += z2-z; - ClearBitString(gInterpolateSprite, pSprite->index); + if (!VanillaMode()) // if sprite is set to be interpolated, update previous position + viewCorrectSpriteInterpolateOffsets(pSprite->index, pSprite, &oldpos); + else + ClearBitString(gInterpolateSprite, pSprite->index); return pLower->type; } }