diff --git a/source/core/gameinput.cpp b/source/core/gameinput.cpp index 8701187e6..2e0888ff5 100644 --- a/source/core/gameinput.cpp +++ b/source/core/gameinput.cpp @@ -267,7 +267,7 @@ void PlayerAngles::applyYaw(float const avel, ESyncBits* actions, double const s // //--------------------------------------------------------------------------- -void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust, bool const climbing) +void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, bool const climbing) { if (cl_slopetilting && cursectnum != nullptr) { @@ -292,7 +292,7 @@ void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const // accordingly if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslopeptr(tempsect, rotpt) - k) <= 4)) { - ViewAngles.Pitch -= maphoriz(scaleAdjust * ((j - k) * (!isBlood() ? 0.625 : 5.5))); + ViewAngles.Pitch -= maphoriz((j - k) * (!isBlood() ? 0.625 : 5.5)); } } } @@ -300,12 +300,12 @@ void PlayerAngles::doViewPitch(const DVector2& pos, DAngle const ang, bool const if (climbing) { // tilt when climbing but you can't even really tell it. - if (ViewAngles.Pitch > PITCH_HORIZOFFCLIMB) ViewAngles.Pitch += getscaledangle(PITCH_HORIZOFFSPEED, deltaangle(ViewAngles.Pitch, PITCH_HORIZOFFCLIMB), PITCH_HORIZOFFPUSH, scaleAdjust); + if (ViewAngles.Pitch > PITCH_HORIZOFFCLIMB) ViewAngles.Pitch += getscaledangle(PITCH_HORIZOFFSPEED, deltaangle(ViewAngles.Pitch, PITCH_HORIZOFFCLIMB), PITCH_HORIZOFFPUSH); } else { // Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope. - scaletozero(ViewAngles.Pitch, PITCH_HORIZOFFSPEED, scaleAdjust, PITCH_HORIZOFFPUSH); + scaletozero(ViewAngles.Pitch, PITCH_HORIZOFFSPEED, 1, PITCH_HORIZOFFPUSH); } // Clamp off against the maximum allowed pitch. diff --git a/source/core/gameinput.h b/source/core/gameinput.h index deb02b581..8ec51d95f 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -27,7 +27,7 @@ struct PlayerAngles void applyYaw(float const avel, ESyncBits* actions, double const scaleAdjust = 1); // Prototypes for applying view. - void doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, double const scaleAdjust = 1, bool const climbing = false); + void doViewPitch(const DVector2& pos, DAngle const ang, bool const aimmode, bool const canslopetilt, sectortype* const cursectnum, bool const climbing = false); void doViewYaw(const ESyncBits actions); // General methods. @@ -101,9 +101,8 @@ struct PlayerAngles // Legacy, to be removed. - DAngle horizOLDSUM() { return ZzOLDHORIZON() + PrevViewAngles.Pitch; } - DAngle horizSUM() { return ZzHORIZON() + ViewAngles.Pitch; } - DAngle horizLERPSUM(double const interpfrac) { return interpolatedvalue(horizOLDSUM(), horizSUM(), interpfrac); } + DAngle horizSUM(const double interpfrac = 1) { return ZzHORIZON() + interpolatedvalue(PrevViewAngles.Pitch, ViewAngles.Pitch, interpfrac); } + DAngle horizLERPSUM(double const interpfrac) { return interpolatedvalue(ZzOLDHORIZON() + PrevViewAngles.Pitch, ZzHORIZON() + ViewAngles.Pitch, interpfrac); } DAngle angSUM(const double interpfrac) { return ZzANGLE() + angLERPLOOKANG(interpfrac); } DAngle angLERPSUM(double const interpfrac) { return interpolatedvalue(ZzOLDANGLE() + PrevViewAngles.Yaw, ZzANGLE() + ViewAngles.Yaw, interpfrac); } DAngle angLERPANG(double const interpfrac) { return interpolatedvalue(ZzOLDANGLE(), ZzANGLE(), interpfrac); } diff --git a/source/games/blood/src/controls.cpp b/source/games/blood/src/controls.cpp index b2ec66c20..1b404fd80 100644 --- a/source/games/blood/src/controls.cpp +++ b/source/games/blood/src/controls.cpp @@ -34,8 +34,6 @@ BEGIN_BLD_NS static InputPacket gInput; -void doslopetilting(PLAYER* pPlayer, double const scaleAdjust); - //--------------------------------------------------------------------------- // // @@ -63,7 +61,6 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju { pPlayer->Angles.applyYaw(input.avel, &pPlayer->input.actions, scaleAdjust); pPlayer->Angles.applyPitch(input.horz, &pPlayer->input.actions, scaleAdjust); - doslopetilting(pPlayer, scaleAdjust); } pPlayer->Angles.applyScaledAdjustments(scaleAdjust); diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 41f7e8c63..06c4e8f85 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1498,12 +1498,12 @@ int ActionScan(PLAYER* pPlayer, HitInfo* out) // //--------------------------------------------------------------------------- -void doslopetilting(PLAYER* pPlayer, double const scaleAdjust = 1) +void doslopetilting(PLAYER* pPlayer) { auto plActor = pPlayer->actor; int const florhit = pPlayer->actor->hit.florhit.type; bool const va = plActor->xspr.height < 16 && (florhit == kHitSector || florhit == 0) ? 1 : 0; - pPlayer->Angles.doViewPitch(plActor->spr.pos.XY(), plActor->spr.Angles.Yaw, va, plActor->sector()->floorstat & CSTAT_SECTOR_SLOPE, plActor->sector(), scaleAdjust); + pPlayer->Angles.doViewPitch(plActor->spr.pos.XY(), plActor->spr.Angles.Yaw, va, plActor->sector()->floorstat & CSTAT_SECTOR_SLOPE, plActor->sector()); } //--------------------------------------------------------------------------- @@ -1715,9 +1715,10 @@ void ProcessInput(PLAYER* pPlayer) if (SyncInput()) { pPlayer->Angles.applyPitch(pInput->horz, &pInput->actions); - doslopetilting(pPlayer); } + doslopetilting(pPlayer); + pPlayer->Angles.unlockYaw(); pPlayer->Angles.unlockPitch(); diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 4a3a914f2..968a5440d 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -502,7 +502,7 @@ static void SetupView(PLAYER* pPlayer, DVector3& cPos, DAngle& cA, DAngle& cH, s if (!SyncInput()) { cA = pPlayer->Angles.angSUM(interpfrac); - cH = pPlayer->Angles.horizSUM(); + cH = pPlayer->Angles.horizSUM(interpfrac); } else { diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 0bc7ae1c7..1088f5fcd 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -229,7 +229,7 @@ void displayweapon_d(int snum, double interpfrac) gun_pos -= fabs(p->GetActor()->spr.scale.X < 0.5 ? BobVal(weapon_sway * 4.) * 32 : BobVal(weapon_sway * 0.5) * 16) + hard_landing; auto offsets = p->Angles.angWEAPONOFFSETS(interpfrac); - auto horiz = !SyncInput() ? p->Angles.horizSUM() : p->Angles.horizLERPSUM(interpfrac); + auto horiz = !SyncInput() ? p->Angles.horizSUM(interpfrac) : p->Angles.horizLERPSUM(interpfrac); auto pitchoffset = interpolatedvalue(0., 16., horiz / DAngle90); auto yawinput = getavel(snum) * (1. / 16.); auto angle = -p->Angles.angLERPROTSCRN(interpfrac); diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index 11af3ad00..dfb7aeef6 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -208,10 +208,10 @@ inline bool playrunning() return (paused == 0 || (paused == 1 && (ud.recstat == 2 || ud.multimode > 1))); } -inline void doslopetilting(player_struct* p, double const scaleAdjust = 1) +inline void doslopetilting(player_struct* p) { bool const canslopetilt = p->on_ground && p->insector() && p->cursector->lotag != ST_2_UNDERWATER && (p->cursector->floorstat & CSTAT_SECTOR_SLOPE); - p->Angles.doViewPitch(p->GetActor()->spr.pos.XY(), p->Angles.ZzANGLE(), p->aim_mode == 0, canslopetilt, p->cursector, scaleAdjust); + p->Angles.doViewPitch(p->GetActor()->spr.pos.XY(), p->Angles.ZzANGLE(), p->aim_mode == 0, canslopetilt, p->cursector); } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 7b69002f3..18167bff5 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -835,7 +835,6 @@ void GameInterface::GetInput(ControlInfo* const hidInput, double const scaleAdju if (p->GetActor()->spr.extra > 0) { // Do these in the same order as the old code. - doslopetilting(p, scaleAdjust); p->Angles.applyYaw(p->adjustavel(input.avel), &p->sync.actions, scaleAdjust); p->Angles.applyPitch(input.horz, &p->sync.actions, scaleAdjust); } diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 73ef5402a..c9d679d90 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -2761,10 +2761,7 @@ void processinput_d(int snum) pact->floorz = floorz; pact->ceilingz = ceilingz; - if (SyncInput()) - { - doslopetilting(p); - } + doslopetilting(p); if (chz.type == kHitSprite) { diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index a0f4c3557..db1c25bca 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -3347,10 +3347,7 @@ void processinput_r(int snum) pact->floorz = floorz; pact->ceilingz = ceilingz; - if (SyncInput()) - { - doslopetilting(p); - } + doslopetilting(p); if (chz.type == kHitSprite) { diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index c37576170..ec7b0bf08 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -305,7 +305,7 @@ void displayrooms(int snum, double interpfrac, bool sceneonly) { // This is for real time updating of the view direction. cang = p->Angles.angSUM(interpfrac); - choriz = p->Angles.horizSUM(); + choriz = p->Angles.horizSUM(interpfrac); } } diff --git a/source/games/exhumed/src/view.cpp b/source/games/exhumed/src/view.cpp index 7d50615f1..29d98cb0d 100644 --- a/source/games/exhumed/src/view.cpp +++ b/source/games/exhumed/src/view.cpp @@ -234,7 +234,7 @@ void DrawView(double interpfrac, bool sceneonly) if (!SyncInput()) { - nCamerapan = PlayerList[nLocalPlayer].Angles.horizSUM(); + nCamerapan = PlayerList[nLocalPlayer].Angles.horizSUM(interpfrac); nCameraang = PlayerList[nLocalPlayer].Angles.angSUM(interpfrac); } else diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index e8aa0d376..7ef5260f1 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -1250,7 +1250,7 @@ void drawscreen(PLAYER* pp, double interpfrac, bool sceneonly) else { tang = pp->Angles.angSUM(interpfrac); - thoriz = pp->Angles.horizSUM(); + thoriz = pp->Angles.horizSUM(interpfrac); } trotscrnang = camerapp->Angles.angLERPROTSCRN(interpfrac); tsect = camerapp->cursector; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 7313beff1..1b6e8cede 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1667,10 +1667,20 @@ void SlipSlope(PLAYER* pp) // //--------------------------------------------------------------------------- -void DoPlayerHorizon(PLAYER* pp, float const horz, double const scaleAdjust) +void DoPlayerSlopeTilting(PLAYER* pp) { bool const canslopetilt = !(pp->Flags & (PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING)) && pp->cursector && (pp->cursector->floorstat & CSTAT_SECTOR_SLOPE); - pp->Angles.doViewPitch(pp->actor->spr.pos.XY(), pp->Angles.ZzANGLE(), pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector, scaleAdjust, (pp->Flags & PF_CLIMBING)); + pp->Angles.doViewPitch(pp->actor->spr.pos.XY(), pp->Angles.ZzANGLE(), pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector, (pp->Flags & PF_CLIMBING)); +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void DoPlayerHorizon(PLAYER* pp, float const horz, double const scaleAdjust) +{ pp->Angles.applyPitch(horz, &pp->input.actions, scaleAdjust); } @@ -2202,6 +2212,8 @@ void DoPlayerMove(PLAYER* pp) DoPlayerHorizon(pp, pp->input.horz, 1); } + DoPlayerSlopeTilting(pp); + if (pp->insector() && (pp->cursector->extra & SECTFX_DYNAMIC_AREA)) { if (pp->Flags & (PF_FLYING|PF_JUMPING|PF_FALLING)) @@ -2776,6 +2788,8 @@ void DoPlayerMoveVehicle(PLAYER* pp) DoPlayerHorizon(pp, pp->input.horz, 1); } + DoPlayerSlopeTilting(pp); + DoTankTreads(pp); } @@ -2817,6 +2831,8 @@ void DoPlayerMoveTurret(PLAYER* pp) { DoPlayerHorizon(pp, pp->input.horz, 1); } + + DoPlayerSlopeTilting(pp); } //--------------------------------------------------------------------------- @@ -3380,6 +3396,8 @@ void DoPlayerClimb(PLAYER* pp) DoPlayerHorizon(pp, pp->input.horz, 1); } + DoPlayerSlopeTilting(pp); + if (FAF_ConnectArea(pp->cursector)) { updatesectorz(pp->actor->getPosWithOffsetZ(), &pp->cursector);