- Exhumed: Add sprite interpolation to `analyzesprites()`.

This commit is contained in:
Mitchell Richters 2020-11-26 19:15:49 +11:00
parent 00ce61959c
commit 1504e19cf8
3 changed files with 41 additions and 3 deletions

View File

@ -174,6 +174,8 @@ int nTimeLimit;
int bVanilla = 0; int bVanilla = 0;
Loc oldLocs[MAXSPRITES];
void DebugOut(const char *fmt, ...) void DebugOut(const char *fmt, ...)
{ {
#ifdef _DEBUG #ifdef _DEBUG
@ -260,10 +262,25 @@ double calc_smoothratio()
return I_GetTimeFrac() * MaxSmoothRatio; return I_GetTimeFrac() * MaxSmoothRatio;
} }
static void recordoldspritepos()
{
for (int i = 0; i < MAXSPRITES; i++)
{
auto* spr = &sprite[i];
Loc* oldLoc = &oldLocs[i];
oldLoc->x = spr->x;
oldLoc->y = spr->y;
oldLoc->z = spr->z;
oldLoc->ang = spr->ang;
}
}
void GameMove(void) void GameMove(void)
{ {
FixPalette(); FixPalette();
recordoldspritepos();
if (currentLevel->levelNumber == kMap20) if (currentLevel->levelNumber == kMap20)
{ {
if (lCountDown <= 0) if (lCountDown <= 0)

View File

@ -121,8 +121,24 @@ void viewRestoreInterpolations(void) //Stick at end of drawscreen
} }
// NOTE - not to be confused with Ken's analyzesprites() // NOTE - not to be confused with Ken's analyzesprites()
static void analyzesprites() static void analyzesprites(double const smoothratio)
{ {
tspritetype *pTSprite;
for (int i = 0; i < spritesortcnt; i++) {
pTSprite = &tsprite[i];
if (pTSprite->owner != -1)
{
// interpolate sprite position
Loc* oldLoc = &oldLocs[pTSprite->owner];
pTSprite->x = oldLoc->x + MulScale(pTSprite->x - oldLoc->x, smoothratio, 16);
pTSprite->y = oldLoc->y + MulScale(pTSprite->y - oldLoc->y, smoothratio, 16);
pTSprite->z = oldLoc->z + MulScale(pTSprite->z - oldLoc->z, smoothratio, 16);
pTSprite->ang = oldLoc->ang + MulScale(((pTSprite->ang - oldLoc->ang + 1024) & 0x7FF) - 1024, smoothratio, 16);
}
}
short nPlayerSprite = PlayerList[nLocalPlayer].nSprite; short nPlayerSprite = PlayerList[nLocalPlayer].nSprite;
int var_38 = 20; int var_38 = 20;
@ -142,7 +158,6 @@ static void analyzesprites()
int nAngle = (2048 - pPlayerSprite->ang) & kAngleMask; int nAngle = (2048 - pPlayerSprite->ang) & kAngleMask;
int nTSprite; int nTSprite;
tspritetype *pTSprite;
// int var_20 = var_24; // int var_20 = var_24;
@ -398,7 +413,7 @@ void DrawView(double smoothRatio, bool sceneonly)
} }
renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), nSector); renderDrawRoomsQ16(nCamerax, nCameray, viewz, nCameraa.asq16(), nCamerapan.asq16(), nSector);
analyzesprites(); analyzesprites(smoothRatio);
renderDrawMasks(); renderDrawMasks();
if (HavePLURemap()) if (HavePLURemap())

View File

@ -46,6 +46,12 @@ extern short bTouchFloor;
extern short nChunkTotal; extern short nChunkTotal;
extern int gFov; extern int gFov;
struct Loc
{
int x, y, z, ang;
};
extern Loc oldLocs[MAXSPRITES];
static inline int angle_interpolate16(int a, int b, int smooth) static inline int angle_interpolate16(int a, int b, int smooth)
{ {
return a + mulscale16(((b+1024-a)&2047)-1024, smooth); return a + mulscale16(((b+1024-a)&2047)-1024, smooth);