From 2757140ad1cfc3168e2614667e6a2e98200310f5 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 28 Aug 2022 14:41:05 +1000 Subject: [PATCH] - Convert all remaining angle internals of `PlayerAngle` into `DAngle` units. * With the old setup, we needed to use primitives to get the desired outcome, but since DAngle stores a proper angle in true degrees, we can use it all the way. --- source/core/gamefuncs.h | 1 + source/core/gameinput.h | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index aededa76a..4ff021209 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -169,6 +169,7 @@ enum constexpr double BAngRadian = pi::pi() * (1. / 1024.); constexpr double BAngToDegree = 360. / 2048.; +constexpr DAngle DAngleBuildToDeg = DAngle::fromDeg(BAngToDegree); extern int sintable[2048]; diff --git a/source/core/gameinput.h b/source/core/gameinput.h index bbf7d4598..0b3496a6c 100644 --- a/source/core/gameinput.h +++ b/source/core/gameinput.h @@ -145,8 +145,8 @@ struct PlayerAngle DAngle interpolatedrotscrn(double const smoothratio) { return interpolatedangle(orotscrnang, rotscrnang, smoothratio); } // Ticrate playsim adjustment helpers. - void resetadjustment() { adjustment = 0; } - bool targetset() { return target.BAMs(); } + void resetadjustment() { adjustment = nullAngle; } + bool targetset() { return target.Sgn(); } // Input locking helpers. void lockinput() { inputdisabled = true; } @@ -162,7 +162,7 @@ struct PlayerAngle { if (!SyncInput()) { - adjustment += value.Normalized180().Degrees(); + adjustment += value.Normalized180(); } else { @@ -174,7 +174,7 @@ struct PlayerAngle { if (!SyncInput() && !backup) { - target = value.BAMs() ? value : DAngle::fromBam(1); + target = value.Sgn() ? value : DAngle::fromBam(1); } else { @@ -187,11 +187,11 @@ struct PlayerAngle { if (targetset()) { - auto delta = deltaangle(ang, target).Degrees(); + auto delta = deltaangle(ang, target); - if (abs(delta) > BAngToDegree) + if (abs(delta) > DAngleBuildToDeg) { - ang += DAngle::fromDeg(scaleAdjust * delta); + ang += delta * scaleAdjust; } else { @@ -199,15 +199,14 @@ struct PlayerAngle target = nullAngle; } } - else if (adjustment) + else if (adjustment.Sgn()) { - ang += DAngle::fromDeg(scaleAdjust * adjustment); + ang += adjustment * scaleAdjust; } } private: - DAngle target; - double adjustment; + DAngle target, adjustment; bool inputdisabled; };