diff --git a/source/core/coreplayer.cpp b/source/core/coreplayer.cpp index 3d44ec299..047d5bb75 100644 --- a/source/core/coreplayer.cpp +++ b/source/core/coreplayer.cpp @@ -227,12 +227,13 @@ void DCorePlayer::doViewYaw() // //--------------------------------------------------------------------------- -void DCorePlayer::doRollInput(const DVector2& nVelVect, const double nMaxVel, const bool bUnderwater) +void DCorePlayer::doRollInput(const bool bUnderwater) { // Allow viewtilting if we're not in a VR mode. if (!vr_mode) { // Scale/attenuate tilting based on player actions. + const auto nMaxVel = GetMaxInputVel(); const auto rollAmp = cl_viewtiltscale / (1 + bUnderwater); const auto runScale = 1. / (1 + !(cmd.ucmd.actions & SB_RUN)); const auto strafeScale = 1 + !!cmd.ucmd.vel.Y; @@ -255,7 +256,7 @@ void DCorePlayer::doRollInput(const DVector2& nVelVect, const double nMaxVel, co else if (cl_viewtilting == 3) { // Movement rolling from player's velocity. Adjustment == (90/48) for running keyboard strafe. - const auto rollAdj = nVelVect.Rotated(-actor->spr.Angles.Yaw).Y * strafeScale * rollAmp; + const auto rollAdj = GetInputVelocity().Rotated(-actor->spr.Angles.Yaw).Y * strafeScale * rollAmp; const auto rollMax = nMaxVel * runScale * cl_viewtiltscale; actor->spr.Angles.Roll = DAngle::fromDeg(clamp(rollAdj, -rollMax, rollMax) * (1.875 / nMaxVel)); } diff --git a/source/core/coreplayer.h b/source/core/coreplayer.h index 87e30d129..0dea605a5 100644 --- a/source/core/coreplayer.h +++ b/source/core/coreplayer.h @@ -36,13 +36,15 @@ public: // All overridable methods. virtual DCoreActor* GetActor() = 0; + virtual const DVector2& GetInputVelocity() const { return actor->vel.XY(); } + virtual const double GetMaxInputVel() const = 0; // Angle prototypes. void doPitchInput(); void doYawInput(); void doViewPitch(const bool canslopetilt, const bool climbing = false); void doViewYaw(); - void doRollInput(const DVector2& nVelVect, const double nMaxVel, const bool bUnderwater); + void doRollInput(const bool bUnderwater); // Angle methods. void InitAngles(const DAngle viewyaw = nullAngle) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index 315d22143..75d752f6e 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -6054,8 +6054,7 @@ static void actCheckDudes() if (actor->xspr.height > 0) nDrag -= Scale(nDrag, (double)actor->xspr.height, 256.); - constexpr auto maxVel = (36211. / 3000.); - pPlayer->doRollInput(actor->vel.XY(), maxVel, false); + pPlayer->doRollInput(false); pPlayer->StrafeVel -= pPlayer->StrafeVel * nDrag; } diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index 6531f746f..6194118a7 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -271,6 +271,11 @@ public: { return static_cast(actor); } + + const double GetMaxInputVel() const override + { + return (36211. / 3000.); + } }; inline DBloodPlayer* getPlayer(int index) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index b806ac033..0e8bcf22c 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1537,7 +1537,6 @@ void processinput_d(DDukePlayer* const p) // Get strafe value before it's rotated by the angle. const auto strafeVel = p->cmd.ucmd.vel.Y; - constexpr auto maxVel = (117351124. / 10884538.); rotateInputVel(p); @@ -1812,7 +1811,7 @@ void processinput_d(DDukePlayer* const p) } } - p->doRollInput(p->vel.XY(), maxVel, (psectlotag == 1) || (psectlotag == 2)); + p->doRollInput((psectlotag == 1) || (psectlotag == 2)); HORIZONLY: diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index b2fc479a1..d3b7e5d47 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2277,7 +2277,6 @@ void processinput_r(DDukePlayer* const p) // Get strafe value before it's rotated by the angle. const auto strafeVel = p->cmd.ucmd.vel.Y; - constexpr auto maxVel = (117351124. / 10884538.); auto psectp = p->cursector; if (p->OnMotorcycle && pact->spr.extra > 0) @@ -2703,7 +2702,7 @@ void processinput_r(DDukePlayer* const p) if (!p->OnMotorcycle && !p->OnBoat) { - p->doRollInput(p->vel.XY(), maxVel, (psectlotag == 1) || (psectlotag == 2)); + p->doRollInput((psectlotag == 1) || (psectlotag == 2)); } HORIZONLY: diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 5dc825c50..2aa801536 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -361,6 +361,16 @@ public: void checkhardlanding(); void playerweaponsway(double xvel); + const double GetMaxInputVel() const override + { + return (117351124. / 10884538.); + } + + const DVector2& GetInputVelocity() const override + { + return vel.XY(); + } + inline void setCursector(sectortype* sect) { cursector = sect; diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index c1a487662..f66789922 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -1549,13 +1549,12 @@ static void doPlayerCameraEffects(DExhumedPlayer* const pPlayer, const double nD { const auto pPlayerActor = pPlayer->GetActor(); const auto nUnderwater = !!(pPlayerActor->sector()->Flag & kSectUnderwater); - constexpr auto maxVel = 15.25; // Pitch tilting when player's Z changes (stairs, jumping, etc). doPlayerVertPanning(pPlayer, nDestVertPan * cl_slopetilting); // Roll tilting effect, either console or Quake-style. - pPlayer->doRollInput(pPlayerActor->vel.XY(), maxVel, nUnderwater); + pPlayer->doRollInput(nUnderwater); // Update Z bobbing. if (cl_viewbob) @@ -1566,7 +1565,7 @@ static void doPlayerCameraEffects(DExhumedPlayer* const pPlayer, const double nD pPlayer->nIdxBobZ *= !pPlayerActor->vel.Z; // Increment bob value with index's sine, amplified by player velocity, bob type and bob height CVAR. - const auto nBobVel = (pPlayerActor->vel.XY().Length() < 0.09375 && nUnderwater) ? (maxVel / 3.) : pPlayer->totalvel; + const auto nBobVel = (pPlayerActor->vel.XY().Length() < 0.09375 && nUnderwater) ? (pPlayer->GetMaxInputVel() * (1. / 3.)) : pPlayer->totalvel; const auto nBobAmp = nBobVel * 0.05 * cl_viewbob * cl_exviewbobheight; const auto newBobZ = BobVal(pPlayer->nIdxBobZ) * nBobAmp; pPlayer->nBobZ = (cl_viewbob == 2) ? (abs(newBobZ) - nBobAmp * 0.5 * !nUnderwater) : (newBobZ); diff --git a/source/games/exhumed/src/player.h b/source/games/exhumed/src/player.h index 9e7a87d87..6b331ce2f 100644 --- a/source/games/exhumed/src/player.h +++ b/source/games/exhumed/src/player.h @@ -118,6 +118,11 @@ public: { return static_cast(actor); } + + const double GetMaxInputVel() const override + { + return 15.25; + } }; extern int PlayerCount; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index f49bfaf6c..52f6e8328 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1846,6 +1846,16 @@ public: uint8_t WpnReloadState; + const double GetMaxInputVel() const override + { + return (380401538. / 36022361.); + } + + const DVector2& GetInputVelocity() const override + { + return vect; + } + inline DSWActor* GetActor() override { return static_cast(actor); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 3be8567a2..5ff62ef04 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1899,8 +1899,7 @@ void DoPlayerMove(DSWPlayer* pp) actor->vel.X = pp->vect.Length(); - constexpr auto maxVel = (380401538. / 36022361.); - pp->doRollInput(pp->vect, maxVel, pp->Flags & (PF_SWIMMING|PF_DIVING)); + pp->doRollInput(pp->Flags & (PF_SWIMMING|PF_DIVING)); if (pp->Flags & (PF_CLIP_CHEAT)) {