From 4bf2f70d7b46e1e571cba84a1ed539f1b0c8fc64 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Mon, 27 Mar 2023 08:14:42 +1100 Subject: [PATCH] - Exhumed: Remove `Player::nDestVertPan` entirely. * We can just pass the needed value into `doPlayerPitch()`. * For Ramses, no need to set `nDestVertPan` to the map value, just use the map value. * Avoids an excess `atan2()` call by way of `maphoriz()`. --- source/games/exhumed/src/player.cpp | 12 ++++-------- source/games/exhumed/src/player.h | 1 - source/games/exhumed/src/ramses.cpp | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 5a90c6156..c2467da23 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -300,7 +300,6 @@ void RestartPlayer(int nPlayer) pPlayer->dVertPan = 0; pPlayer->vel.Zero(); pPlayer->nThrust.Zero(); - pPlayer->nDestVertPan = nullAngle; pPlayer->nBreathTimer = 90; pPlayer->nTauntTimer = RandomSize(3) + 3; pPlayer->ototalvel = pPlayer->totalvel = 0; @@ -1426,7 +1425,6 @@ static void doPlayerRamses(Player* const pPlayer) if (nFreeze < 1) { nFreeze = 1; - pPlayer->nDestVertPan = currentLevel->ex_ramses_horiz; StopAllSounds(); StopLocalSound(); InitSpiritHead(); @@ -1460,11 +1458,10 @@ static void doPlayerGravity(DExhumedActor* const pPlayerActor) // //--------------------------------------------------------------------------- -static void doPlayerPitch(Player* const pPlayer) +static void doPlayerPitch(Player* const pPlayer, const double nDestVertPan) { const auto pInput = &pPlayer->input; - const auto nDestVertPan = cl_slopetilting ? pPlayer->nDestVertPan : nullAngle; - const auto nVertPan = deltaangle(pPlayer->Angles.ViewAngles.Pitch, nDestVertPan).Tan() * 32.; + const auto nVertPan = (nDestVertPan * cl_slopetilting - pPlayer->Angles.ViewAngles.Pitch.Tan() * 128) * 0.25; if (SyncInput()) { @@ -1752,12 +1749,11 @@ static bool doPlayerMovement(Player* const pPlayer) doPlayerMovingBlocks(pPlayer, nMove, spr_pos, spr_vel, spr_sect); } - // This should amplified 8x, not 2x, but it feels very heavy. Add a CVAR? - pPlayer->nDestVertPan = maphoriz((pPlayerActor->spr.pos.Z - spr_pos.Z) * 2.); pPlayer->ototalvel = pPlayer->totalvel; pPlayer->totalvel = int((spr_pos.XY() - pPlayerActor->spr.pos.XY()).Length() * worldtoint); - doPlayerPitch(pPlayer); + // This should amplified 8x, not 2x, but it feels very heavy. Add a CVAR? + doPlayerPitch(pPlayer, (pPlayerActor->spr.pos.Z - spr_pos.Z) * 2.); updatePlayerViewSector(pPlayer, nMove, spr_pos, spr_vel, bUnderwater); pPlayer->nPlayerD = (pPlayerActor->spr.pos - spr_pos); diff --git a/source/games/exhumed/src/player.h b/source/games/exhumed/src/player.h index 069a35654..1f6904e95 100644 --- a/source/games/exhumed/src/player.h +++ b/source/games/exhumed/src/player.h @@ -76,7 +76,6 @@ struct Player int16_t nState; int16_t nLastWeapon; int16_t nRun; - DAngle nDestVertPan; InputPacket input; PlayerAngles Angles; diff --git a/source/games/exhumed/src/ramses.cpp b/source/games/exhumed/src/ramses.cpp index fd30d6407..1208e5f01 100644 --- a/source/games/exhumed/src/ramses.cpp +++ b/source/games/exhumed/src/ramses.cpp @@ -199,7 +199,7 @@ void DoSpiritHead() const auto pPlayerActor = pPlayer->pActor; const auto nSpiritAngle = (pSpiritSprite->spr.pos.XY() - pPlayerActor->spr.pos.XY()).Angle(); pPlayerActor->spr.Angles.Yaw += deltaangle(pPlayerActor->spr.Angles.Yaw, nSpiritAngle) * 0.25; - pPlayerActor->spr.Angles.Pitch += deltaangle(pPlayerActor->spr.Angles.Pitch, pPlayer->nDestVertPan) * 0.25; + pPlayerActor->spr.Angles.Pitch += deltaangle(pPlayerActor->spr.Angles.Pitch, currentLevel->ex_ramses_horiz) * 0.25; switch (nHeadStage) {