diff --git a/source/core/gameinput.h b/source/core/gameinput.h index ac85fbc9c..5eee8cbd2 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -89,7 +89,6 @@ struct PlayerAngles } // Pitch methods. - void addPitch(const DAngle value) { updateAngle(PITCH, ClampViewPitch(pActor->spr.Angles.Pitch + value)); } void setPitch(const DAngle value, const bool backup = false) { updateAngle(PITCH, ClampViewPitch(value), backup); } // Yaw methods. diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 08c0ad948..ab1701102 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1546,7 +1546,7 @@ void ProcessInput(PLAYER* pPlayer) } pPlayer->deathTime += 4; if (!bSeqStat) - pPlayer->Angles.addPitch(deltaangle(pPlayer->actor->spr.Angles.Pitch, gi->playerPitchMax() * (1. - BobVal(min((pPlayer->deathTime << 3) + 512, 1536))) * 0.5)); + pPlayer->actor->spr.Angles.Pitch += deltaangle(pPlayer->actor->spr.Angles.Pitch, gi->playerPitchMax() * (1. - BobVal(min((pPlayer->deathTime << 3) + 512, 1536))) * 0.5); if (pPlayer->curWeapon) pInput->setNewWeapon(pPlayer->curWeapon); if (pInput->actions & SB_OPEN) diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 864bec217..c3ce1419d 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -118,7 +118,7 @@ void forceplayerangle(int snum) player_struct* p = &ps[snum]; const auto ang = (DAngle22_5 - randomAngle(45)) / 2.; - p->Angles.addPitch(DAngle::fromDeg(-26.566)); + p->GetActor()->spr.Angles.Pitch -= DAngle::fromDeg(26.566); p->sync.actions |= SB_CENTERVIEW; p->Angles.ViewAngles.Yaw = ang; p->Angles.ViewAngles.Roll = -ang; @@ -797,7 +797,7 @@ void player_struct::checkhardlanding() { if (hard_landing > 0) { - Angles.addPitch(maphoriz(hard_landing << 4)); + GetActor()->spr.Angles.Pitch += maphoriz(hard_landing << 4); hard_landing--; } } diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index f9eeadc63..87d6cf956 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1660,7 +1660,7 @@ static void onMotorcycle(int snum, ESyncBits &actions) } if (horiz != FRACUNIT) { - p->Angles.addPitch(deltaangle(p->GetActor()->spr.Angles.Pitch, maphoriz(-horiz))); + p->GetActor()->spr.Angles.Pitch += deltaangle(p->GetActor()->spr.Angles.Pitch, maphoriz(-horiz)); } const DAngle adjust = mapangle(-510); @@ -1928,7 +1928,7 @@ static void onBoat(int snum, ESyncBits &actions) } if (horiz != FRACUNIT) { - p->Angles.addPitch(deltaangle(p->GetActor()->spr.Angles.Pitch, maphoriz(-horiz))); + p->GetActor()->spr.Angles.Pitch += deltaangle(p->GetActor()->spr.Angles.Pitch, maphoriz(-horiz)); } if (p->MotoSpeed > 0 && p->on_ground == 1 && (p->vehTurnLeft || p->vehTurnRight)) @@ -2836,7 +2836,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) case RIFLEGUN_WEAPON: p->kickback_pic++; - p->Angles.addPitch(DAngle::fromDeg(-0.4476)); + p->GetActor()->spr.Angles.Pitch -= DAngle::fromDeg(0.4476); p->recoil++; if (p->kickback_pic <= 12) @@ -3008,7 +3008,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) else if (p->kickback_pic == 12) { p->vel.XY() -= p->GetActor()->spr.Angles.Yaw.ToVector(); - p->Angles.addPitch(DAngle::fromDeg(-8.88)); + p->GetActor()->spr.Angles.Pitch -= DAngle::fromDeg(8.88); p->recoil += 20; } if (p->kickback_pic > 20) @@ -3817,7 +3817,7 @@ HORIZONLY: if (!d) d = 1; p->recoil -= d; - p->Angles.addPitch(maphoriz(d)); + p->GetActor()->spr.Angles.Pitch += maphoriz(d); } if (SyncInput()) diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index fad5df4cb..045f8b8bd 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -1041,7 +1041,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, angle, dukeplayer_angle) void dukeplayer_addpitch(player_struct* self, double a) { - self->Angles.addPitch(DAngle::fromDeg(a)); + self->GetActor()->spr.Angles.Pitch += DAngle::fromDeg(a); } DEFINE_ACTION_FUNCTION_NATIVE(_DukePlayer, addpitch, dukeplayer_addpitch) diff --git a/source/games/exhumed/src/player.cpp b/source/games/exhumed/src/player.cpp index 1f1b9d06f..4a4ca2e5f 100644 --- a/source/games/exhumed/src/player.cpp +++ b/source/games/exhumed/src/player.cpp @@ -2496,7 +2496,7 @@ sectdone: { if (double nVertPan = deltaangle(pPlayer->pActor->spr.Angles.Pitch, pPlayer->nDestVertPan).Tan() * 32.) { - pPlayer->Angles.addPitch(maphoriz(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.)); + pPlayer->pActor->spr.Angles.Pitch += maphoriz(abs(nVertPan) >= 4 ? clamp(nVertPan, -4., 4.) : nVertPan * 2.); } } } @@ -2621,7 +2621,7 @@ sectdone: } else { - PlayerList[nPlayer].Angles.addPitch(maphoriz(-dVertPan[nPlayer])); + PlayerList[nPlayer].pActor->spr.Angles.Pitch -= maphoriz(dVertPan[nPlayer]); if (PlayerList[nPlayer].pActor->spr.Angles.Pitch.Degrees() <= 38) { diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 90c953aba..658361a9d 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -5883,11 +5883,17 @@ void DoPlayerBeginDie(PLAYER* pp) static inline void DoPlayerDeathHoriz(PLAYER* pp, const DAngle target, const double speed) { - auto targetdelta = deltaangle(pp->actor->spr.Angles.Pitch, target); + auto& pitch = pp->actor->spr.Angles.Pitch; + auto pspeed = DAngle::fromDeg(speed); - if (abs(targetdelta.Degrees()) > 1) + if (pitch < target) { - pp->Angles.addPitch(DAngle::fromDeg(speed * targetdelta.Sgn())); + pitch = min(pitch + pspeed, target); + } + + if (pitch > target) + { + pitch = max(pitch - pspeed, target); } }