diff --git a/source/core/gamestruct.h b/source/core/gamestruct.h index 0d41ddd6a..0d53ad5e4 100644 --- a/source/core/gamestruct.h +++ b/source/core/gamestruct.h @@ -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) {} diff --git a/source/core/rendering/scene/hw_drawinfo.cpp b/source/core/rendering/scene/hw_drawinfo.cpp index 7df71ce99..85a883a13 100644 --- a/source/core/rendering/scene/hw_drawinfo.cpp +++ b/source/core/rendering/scene/hw_drawinfo.cpp @@ -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(); diff --git a/source/games/blood/src/animatesprite.cpp b/source/games/blood/src/animatesprite.cpp index c2035ffbe..36eb0e347 100644 --- a/source/games/blood/src/animatesprite.cpp +++ b/source/games/blood/src/animatesprite.cpp @@ -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; diff --git a/source/games/blood/src/blood.h b/source/games/blood/src/blood.h index 28afe57c9..e53e09448 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -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; diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 1e61b36b6..4fe4b95ce 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -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; diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index 97d9f15da..9846c0439 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -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); } diff --git a/source/games/exhumed/src/exhumed.h b/source/games/exhumed/src/exhumed.h index a2878f994..abaa146e5 100644 --- a/source/games/exhumed/src/exhumed.h +++ b/source/games/exhumed/src/exhumed.h @@ -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 GetCoordinates() override; diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 1c9a2e97b..afa9647bd 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -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); } diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index d4f324611..bef3fc4a7 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -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); } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 202c1f2f0..695cf4780 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -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);