Skip to content

Commit

Permalink
Blood: Fix interpolated sprite pos for ror transitions
Browse files Browse the repository at this point in the history
  • Loading branch information
tmyqlfpir authored and Hendricks266 committed Dec 18, 2024
1 parent 15af7d8 commit 4b6b076
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions source/blood/src/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
12 changes: 10 additions & 2 deletions source/blood/src/warp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
Expand All @@ -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;
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 4b6b076

Please sign in to comment.