From f378c481b3375770131c64a22cf256836662bb91 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Tue, 6 Sep 2022 23:16:13 +1000 Subject: [PATCH] - Exhumed: Flatten smoothratio back to float and rename to `interpfrac`. --- source/games/exhumed/src/engine.h | 2 +- source/games/exhumed/src/exhumed.cpp | 7 ++----- source/games/exhumed/src/gameloop.cpp | 8 ++++---- source/games/exhumed/src/map.cpp | 6 +++--- source/games/exhumed/src/view.cpp | 26 +++++++++++++------------- source/games/exhumed/src/view.h | 2 +- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/source/games/exhumed/src/engine.h b/source/games/exhumed/src/engine.h index 75f32723f..538380ce1 100644 --- a/source/games/exhumed/src/engine.h +++ b/source/games/exhumed/src/engine.h @@ -103,7 +103,7 @@ extern bool bShowTowers; void GrabMap(); void UpdateMap(); -void DrawMap(double const smoothratio); +void DrawMap(double const interpfrac); // random diff --git a/source/games/exhumed/src/exhumed.cpp b/source/games/exhumed/src/exhumed.cpp index 16610e304..89a7f9c17 100644 --- a/source/games/exhumed/src/exhumed.cpp +++ b/source/games/exhumed/src/exhumed.cpp @@ -245,12 +245,9 @@ void DrawClock() DoEnergyTile(); } -double calc_smoothratio() +double calc_interpfrac() { - if (bRecord || bPlayback || nFreeze != 0 || paused || cl_capfps || !cl_interpolate || EndLevel) - return MaxSmoothRatio; - - return I_GetTimeFrac() * MaxSmoothRatio; + return bRecord || bPlayback || nFreeze != 0 || paused || cl_capfps || !cl_interpolate || EndLevel ? 1. : I_GetTimeFrac(); } void DoGameOverScene(bool finallevel) diff --git a/source/games/exhumed/src/gameloop.cpp b/source/games/exhumed/src/gameloop.cpp index b17013879..21ec92da9 100644 --- a/source/games/exhumed/src/gameloop.cpp +++ b/source/games/exhumed/src/gameloop.cpp @@ -57,7 +57,7 @@ int nBestLevel; void RunCinemaScene(int num); void GameMove(void); void DrawClock(); -double calc_smoothratio(); +double calc_interpfrac(); void DoTitle(CompletionFunc completion); @@ -73,15 +73,15 @@ void GameInterface::Render() DrawClock(); } - double const smoothratio = calc_smoothratio(); + double const interpfrac = calc_interpfrac(); - DrawView(smoothratio); + DrawView(interpfrac); if (nFreeze != 2) // Hide when Ramses is talking. { DrawStatusBar(); - DrawCrosshair(kCrosshairTile, PlayerList[nLocalPlayer].nHealth >> 3, -PlayerList[nLocalPlayer].angle.look_anghalf(smoothratio), 0, 1); + DrawCrosshair(kCrosshairTile, PlayerList[nLocalPlayer].nHealth >> 3, -PlayerList[nLocalPlayer].angle.look_anghalf(interpfrac), 0, 1); if (paused && !M_Active()) { diff --git a/source/games/exhumed/src/map.cpp b/source/games/exhumed/src/map.cpp index 1f893611f..fb037c06a 100644 --- a/source/games/exhumed/src/map.cpp +++ b/source/games/exhumed/src/map.cpp @@ -44,13 +44,13 @@ void UpdateMap() } } -void DrawMap(double const smoothratio) +void DrawMap(double const interpfrac) { if (!nFreeze && automapMode != am_off) { auto pPlayerActor = PlayerList[nLocalPlayer].pActor; - auto ang = !SyncInput() ? PlayerList[nLocalPlayer].angle.sum() : PlayerList[nLocalPlayer].angle.interpolatedsum(smoothratio * (1. / MaxSmoothRatio)); - DrawOverheadMap(pPlayerActor->interpolatedvec3(smoothratio * (1. / MaxSmoothRatio)).XY(), ang, smoothratio); + auto ang = !SyncInput() ? PlayerList[nLocalPlayer].angle.sum() : PlayerList[nLocalPlayer].angle.interpolatedsum(interpfrac); + DrawOverheadMap(pPlayerActor->interpolatedvec3(interpfrac).XY(), ang, interpfrac * MaxSmoothRatio); } } diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index a29603b77..d7f8ad5d7 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -174,15 +174,15 @@ void ResetView() static TextOverlay subtitleOverlay; -void DrawView(double smoothRatio, bool sceneonly) +void DrawView(double interpfrac, bool sceneonly) { DExhumedActor* pEnemy = nullptr; int nEnemyPal = -1; sectortype* pSector = nullptr; DAngle nCameraa, rotscrnang; - fixedhoriz nCamerapan; + fixedhoriz nCamerapan = q16horiz(0); - DoInterpolations(smoothRatio * (1. / MaxSmoothRatio)); + DoInterpolations(interpfrac); auto pPlayerActor = PlayerList[nLocalPlayer].pActor; auto nPlayerOldCstat = pPlayerActor->spr.cstat; @@ -214,7 +214,7 @@ void DrawView(double smoothRatio, bool sceneonly) } else { - nCamera = pPlayerActor->interpolatedvec3(smoothRatio * (1. / MaxSmoothRatio)).plusZ(interpolatedvaluef(PlayerList[nLocalPlayer].oeyelevel, PlayerList[nLocalPlayer].eyelevel, smoothRatio) * zinttoworld); + nCamera = pPlayerActor->interpolatedvec3(interpfrac).plusZ(interpolatedvaluef(PlayerList[nLocalPlayer].oeyelevel, PlayerList[nLocalPlayer].eyelevel, interpfrac * MaxSmoothRatio) * zinttoworld); pSector = PlayerList[nLocalPlayer].pPlayerViewSect; updatesector(nCamera, &pSector); @@ -228,9 +228,9 @@ void DrawView(double smoothRatio, bool sceneonly) } else { - nCamerapan = PlayerList[nLocalPlayer].horizon.interpolatedsum(smoothRatio); - nCameraa = PlayerList[nLocalPlayer].angle.interpolatedsum(smoothRatio * (1. / MaxSmoothRatio)); - rotscrnang = PlayerList[nLocalPlayer].angle.interpolatedrotscrn(smoothRatio * (1. / MaxSmoothRatio)); + nCamerapan = PlayerList[nLocalPlayer].horizon.interpolatedsum(interpfrac * MaxSmoothRatio); + nCameraa = PlayerList[nLocalPlayer].angle.interpolatedsum(interpfrac); + rotscrnang = PlayerList[nLocalPlayer].angle.interpolatedrotscrn(interpfrac); } if (!bCamera) @@ -258,10 +258,10 @@ void DrawView(double smoothRatio, bool sceneonly) if (bCamera) { nCamera.Z -= 10; - if (!calcChaseCamPos(nCamera, pPlayerActor, &pSector, nCameraa, nCamerapan, smoothRatio)) + if (!calcChaseCamPos(nCamera, pPlayerActor, &pSector, nCameraa, nCamerapan, interpfrac * MaxSmoothRatio)) { nCamera.Z += 10; - calcChaseCamPos(nCamera, pPlayerActor, &pSector, nCameraa, nCamerapan, smoothRatio); + calcChaseCamPos(nCamera, pPlayerActor, &pSector, nCameraa, nCamerapan, interpfrac * MaxSmoothRatio); } } } @@ -303,8 +303,8 @@ void DrawView(double smoothRatio, bool sceneonly) } if (!nFreeze && !sceneonly) - DrawWeapons(smoothRatio); - render_drawrooms(nullptr, nCamera, sectnum(pSector), nCameraa, nCamerapan, rotscrnang, smoothRatio); + DrawWeapons(interpfrac * MaxSmoothRatio); + render_drawrooms(nullptr, nCamera, sectnum(pSector), nCameraa, nCamerapan, rotscrnang, interpfrac * MaxSmoothRatio); if (HavePLURemap()) { @@ -369,7 +369,7 @@ void DrawView(double smoothRatio, bool sceneonly) { if (nSnakeCam < 0) { - DrawMap(smoothRatio); + DrawMap(interpfrac); } else { @@ -378,7 +378,7 @@ void DrawView(double smoothRatio, bool sceneonly) pEnemy->spr.pal = (uint8_t)nEnemyPal; } - DrawMap(smoothRatio); + DrawMap(interpfrac); } } } diff --git a/source/games/exhumed/src/view.h b/source/games/exhumed/src/view.h index 77c92ca0e..c79967d7a 100644 --- a/source/games/exhumed/src/view.h +++ b/source/games/exhumed/src/view.h @@ -26,7 +26,7 @@ extern TObjPtr bestTarget; extern bool bCamera; void DrawStatusBar(); -void DrawView(double smoothRatio, bool sceneonly = false); +void DrawView(double interpfrac, bool sceneonly = false); void ResetView(); void NoClip(); void Clip();