- Floatify smoothratio for GameInterface::processSprites().

* Exhumed is now completely free of any Q16.16 interpolation scaling.
This commit is contained in:
Mitchell Richters 2022-09-07 19:25:55 +10:00 committed by Christoph Oelckers
parent 8f2d6f0779
commit 3019f9effc
10 changed files with 25 additions and 28 deletions

View file

@ -117,7 +117,7 @@ struct GameInterface
virtual void SwitchCoopView() { Printf("Unsupported command\n"); }
virtual void ToggleShowWeapon() { Printf("Unsupported command\n"); }
virtual DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(0,0,0); }
virtual void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio) = 0;
virtual void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double interpfrac) = 0;
virtual void UpdateCameras(double smoothratio) {}
virtual void EnterPortal(DCoreActor* viewer, int type) {}
virtual void LeavePortal(DCoreActor* viewer, int type) {}

View file

@ -392,7 +392,7 @@ void HWDrawInfo::CreateScene(bool portal)
mDrawer.RenderScene(&vp.SectCount, 1, portal);
SetupSprite.Clock();
gi->processSprites(tsprites, view.X, view.Y, vp.Pos.Z * -256, DAngle::fromBam(vp.RotAngle), vp.TicFrac * 65536);
gi->processSprites(tsprites, view.X, view.Y, vp.Pos.Z * -256, DAngle::fromBam(vp.RotAngle), vp.TicFrac);
DispatchSprites();
SetupSprite.Unclock();

View file

@ -522,11 +522,11 @@ static int GetOctant(int x, int y)
return OctantTable[7 - (x < 0) - (y < 0) * 2 - (vc < 0) * 4];
}
void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t cZ, DAngle cA, int32_t smoothratio)
void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t cZ, DAngle cA, double interpfrac)
{
int nViewSprites = tsprites.Size();
// shift before interpolating to increase precision.
int myclock = (PlayClock << 3) + MulScale(4 << 3, smoothratio, 16);
DAngle myclock = DAngle::fromDeg(((PlayClock << 3) + (4 << 3) * interpfrac) * BAngToDegree);
gCameraAng = cA;
for (int nTSprite = int(tsprites.Size()) - 1; nTSprite >= 0; nTSprite--)
{
@ -554,8 +554,8 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
if (cl_interpolate && owneractor->interpolated && !(pTSprite->flags & 512))
{
pTSprite->pos = owneractor->interpolatedpos(gInterpolate * (1. / MaxSmoothRatio));
pTSprite->angle = owneractor->interpolatedangle(gInterpolate * (1. / MaxSmoothRatio));
pTSprite->pos = owneractor->interpolatedpos(interpfrac);
pTSprite->angle = owneractor->interpolatedangle(interpfrac);
}
int nAnim = 0;
switch (picanm[nTile].extra & 7) {
@ -645,7 +645,7 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
pTSprite->picnum = voxelIndex[pTSprite->picnum];
if ((picanm[nTile].extra & 7) == 7)
{
pTSprite->set_int_ang( myclock & 2047);
pTSprite->angle = myclock.Normalized360();
}
}
}
@ -993,9 +993,9 @@ void viewProcessSprites(tspriteArray& tsprites, int32_t cX, int32_t cY, int32_t
//
//---------------------------------------------------------------------------
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio)
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double interpfrac)
{
viewProcessSprites(tsprites, viewx, viewy, viewz, viewang, int(smoothRatio));
viewProcessSprites(tsprites, viewx, viewy, viewz, viewang, interpfrac);
}
int display_mirror;

View file

@ -143,7 +143,7 @@ struct GameInterface : public ::GameInterface
void SwitchCoopView() override;
void ToggleShowWeapon() override;
DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 80., horiz.asbuildf() * 0.625 - 16); }
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio) override;
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double interpfrac) override;
void EnterPortal(DCoreActor* viewer, int type) override;
void LeavePortal(DCoreActor* viewer, int type) override;
void LoadGameTextures() override;

View file

@ -57,7 +57,7 @@ struct GameInterface : public ::GameInterface
void SwitchCoopView() override;
void ToggleShowWeapon() override;
DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 64., horiz.asbuildf() * 0.5); }
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio) override;
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double interpfrac) override;
void UpdateCameras(double smoothratio) override;
void EnterPortal(DCoreActor* viewer, int type) override;
void LeavePortal(DCoreActor* viewer, int type) override;

View file

@ -405,9 +405,9 @@ bool GameInterface::GenerateSavePic()
return true;
}
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio)
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double interpfrac)
{
fi.animatesprites(tsprites, viewx, viewy, viewang.Buildang(), smoothRatio * (1. / MaxSmoothRatio));
fi.animatesprites(tsprites, viewx, viewy, viewang.Buildang(), interpfrac);
}

View file

@ -237,7 +237,7 @@ struct GameInterface : public ::GameInterface
void WarpToCoords(double x, double y, double z, DAngle ang, int horz) override;
void ToggleThirdPerson() override;
DVector3 chaseCamPos(DAngle ang, fixedhoriz horiz) { return DVector3(-ang.ToVector() * 96., horiz.asbuildf() * 0.75); }
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio) override;
void processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double interpfrac) override;
int GetCurrentSkill() override;
std::pair<DVector3, DAngle> GetCoordinates() override;

View file

@ -400,9 +400,9 @@ bool GameInterface::GenerateSavePic()
return true;
}
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio)
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double interpfrac)
{
analyzesprites(tsprites, viewx, viewy, viewz, smoothRatio * (1. / MaxSmoothRatio));
analyzesprites(tsprites, viewx, viewy, viewz, interpfrac);
}

View file

@ -568,10 +568,9 @@ DSWActor* ConnectCopySprite(spritetypebase const* tsp)
}
void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int camang)
static void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int camang, double interpfrac)
{
int tSpriteNum;
double smr4, smr2;
static int ang = 0;
PLAYER* pp = Player + screenpeek;
int newshade=0;
@ -581,8 +580,8 @@ void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int
ang = NORM_ANGLE(ang + 12);
smr4 = smoothratio + IntToFixed(MoveSkip4);
smr2 = smoothratio + IntToFixed(MoveSkip2);
double smr4 = interpfrac + MoveSkip4;
double smr2 = interpfrac + MoveSkip2;
for (tSpriteNum = (int)tsprites.Size() - 1; tSpriteNum >= 0; tSpriteNum--)
{
@ -619,7 +618,7 @@ void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int
{
if (tsp->statnum <= STAT_SKIP4_INTERP_END)
{
tsp->pos = tActor->interpolatedpos(smr4 * (0.25 / MaxSmoothRatio));
tsp->pos = tActor->interpolatedpos(smr4 * 0.25);
}
}
@ -627,7 +626,7 @@ void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int
{
if (tsp->statnum <= STAT_SKIP2_INTERP_END)
{
tsp->pos = tActor->interpolatedpos(smr2 * (0.5 / MaxSmoothRatio));
tsp->pos = tActor->interpolatedpos(smr2 * 0.5);
}
}
}
@ -782,9 +781,8 @@ void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int
else // Otherwise just interpolate the player sprite
{
pp = tActor->user.PlayerP;
double sr = 1. - smoothratio * (1. / MaxSmoothRatio);
tsp->pos -= (pp->pos - pp->opos) * sr;
tsp->angle = pp->angle.interpolatedang(sr * (1. / MaxSmoothRatio));
tsp->pos = interpolatedvalue(pp->opos, pp->pos, interpfrac);
tsp->angle = pp->angle.interpolatedang(interpfrac);
}
}
@ -1650,9 +1648,9 @@ bool GameInterface::DrawAutomapPlayer(const DVector2& mxy, const DVector2& cpos,
return true;
}
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double smoothRatio)
void GameInterface::processSprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, DAngle viewang, double interpfrac)
{
analyzesprites(tsprites, viewx, viewy, viewz, viewang.Buildang());
analyzesprites(tsprites, viewx, viewy, viewz, viewang.Buildang(), interpfrac);
post_analyzesprites(tsprites);
}

View file

@ -1741,7 +1741,6 @@ void SetOwner(int a, int b); // we still need this...
void ClearOwner(DSWActor* ownr);
DSWActor* GetOwner(DSWActor* child);
void SetAttach(DSWActor*, DSWActor*);
void analyzesprites(tspriteArray& tsprites, int viewx, int viewy, int viewz, int camang);
void CollectPortals();
int SpawnBlood(DSWActor* actor, DSWActor* weapActor, DAngle hit_angle = nullAngle, const DVector3* hitpos = nullptr);