diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index d124ea6f6..1ce8fa6f2 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -210,8 +210,6 @@ enum }; constexpr double BAngRadian = pi::pi() * (1. / 1024.); -constexpr double BAngToDegree = 360. / 2048.; -constexpr DAngle DAngleBuildToDeg = DAngle::fromDeg(BAngToDegree); //--------------------------------------------------------------------------- // diff --git a/source/games/blood/src/animatesprite.cpp b/source/games/blood/src/animatesprite.cpp index 11c8c45ba..a9ecbda54 100644 --- a/source/games/blood/src/animatesprite.cpp +++ b/source/games/blood/src/animatesprite.cpp @@ -529,7 +529,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA, PLAYER* pPlayer = &gPlayer[gViewIndex]; int nViewSprites = tsprites.Size(); // shift before interpolating to increase precision. - DAngle myclock = DAngle::fromDeg(((PlayClock << 3) + (4 << 3) * interpfrac) * BAngToDegree); + DAngle myclock = DAngle::fromBuild((PlayClock << 3) + (4 << 3) * interpfrac); gCameraAng = cA; for (int nTSprite = int(tsprites.Size()) - 1; nTSprite >= 0; nTSprite--) { diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index 62ddec42e..8635c4fdb 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -87,15 +87,15 @@ void displaymasks_r(int snum, int p, double interpfrac) // //--------------------------------------------------------------------------- -inline static void ShowMotorcycle(double x, double y, int tilenum, int shade, int orientation, int p, double a) +inline static void ShowMotorcycle(double x, double y, int tilenum, int shade, int orientation, int p, DAngle a) { - hud_drawsprite(x, y, 34816, a * -BAngToDegree, tilenum, shade, p, 2 | orientation); + hud_drawsprite(x, y, 34816, a.Degrees(), tilenum, shade, p, 2 | orientation); } -inline static void ShowBoat(double x, double y, int tilenum, int shade, int orientation, int p, double a) +inline static void ShowBoat(double x, double y, int tilenum, int shade, int orientation, int p, DAngle a) { - hud_drawsprite(x, y, 66048, a * -BAngToDegree, tilenum, shade, p, 2 | orientation); + hud_drawsprite(x, y, 66048, a.Degrees(), tilenum, shade, p, 2 | orientation); } @@ -150,6 +150,7 @@ void displayweapon_r(int snum, double interpfrac) if (p->OnMotorcycle) { + angle = DAngle::fromBuild(-TiltStatus); int temp_kb; if (numplayers == 1) { @@ -198,11 +199,12 @@ void displayweapon_r(int snum, double interpfrac) temp_kb = RTILE_MOTOHIT; } - ShowMotorcycle(160 + offsets.X, 174, temp_kb, shade, 0, pal, TiltStatus*5); + ShowMotorcycle(160 + offsets.X, 174, temp_kb, shade, 0, pal, angle * 5); return; } if (p->OnBoat) { + angle = DAngle::fromBuild(-TiltStatus); int temp2, temp_kb, temp3; temp2 = 0; if (TiltStatus > 0) @@ -265,7 +267,7 @@ void displayweapon_r(int snum, double interpfrac) if (temp2) shade = -96; - ShowBoat(160 + offsets.X, temp3, temp_kb, shade, 0, pal, TiltStatus); + ShowBoat(160 + offsets.X, temp3, temp_kb, shade, 0, pal, angle); return; } diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 44539e2ab..2bc3963dc 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -555,7 +555,7 @@ static void processInputBits(player_struct *p, ControlInfo* const hidInput) // //--------------------------------------------------------------------------- -static double motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool const kbdLeft, bool const kbdRight, double const factor) +static FAngle motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool const kbdLeft, bool const kbdRight, double const factor) { double turnvel = 0; p->oTiltStatus = p->TiltStatus; @@ -636,7 +636,7 @@ static double motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool if (fabs(p->TiltStatus) < factor) p->TiltStatus = 0; - return turnvel * factor; + return FAngle::fromBuild(turnvel * factor); } //--------------------------------------------------------------------------- @@ -645,7 +645,7 @@ static double motoApplyTurn(player_struct* p, ControlInfo* const hidInput, bool // //--------------------------------------------------------------------------- -static double boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool const kbdLeft, bool const kbdRight, double const factor) +static FAngle boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool const kbdLeft, bool const kbdRight, double const factor) { double turnvel = 0; p->oTiltStatus = p->TiltStatus; @@ -722,7 +722,7 @@ static double boatApplyTurn(player_struct *p, ControlInfo* const hidInput, bool if (fabs(p->TiltStatus) < factor) p->TiltStatus = 0; - return turnvel * factor; + return FAngle::fromBuild(turnvel * factor); } //--------------------------------------------------------------------------- @@ -751,16 +751,15 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I if (p->OnMotorcycle) { - input.avel = (float)motoApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust); + input.avel = motoApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust).Degrees(); if (p->moto_underwater) p->MotoSpeed = 0; } else { - input.avel = (float)boatApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust); + input.avel = boatApplyTurn(p, hidInput, kbdLeft, kbdRight, scaleAdjust).Degrees(); } loc.fvel = clamp((float)p->MotoSpeed, -(MAXVELMOTO >> 3), MAXVELMOTO) * (1.f / 40.f); - input.avel *= BAngToDegree; loc.avel += input.avel; } diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index c3ce1419d..c18fda691 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -730,17 +730,19 @@ void player_struct::apply_seasick() { if (SeaSick < 250) { + static constexpr DAngle adjustment = DAngle::fromDeg(4.21875); + if (SeaSick >= 180) - Angles.ViewAngles.Roll -= DAngle::fromDeg(24 * BAngToDegree); + Angles.ViewAngles.Roll -= adjustment; else if (SeaSick >= 130) - Angles.ViewAngles.Roll += DAngle::fromDeg(24 * BAngToDegree); + Angles.ViewAngles.Roll += adjustment; else if (SeaSick >= 70) - Angles.ViewAngles.Roll -= DAngle::fromDeg(24 * BAngToDegree); + Angles.ViewAngles.Roll -= adjustment; else if (SeaSick >= 20) - Angles.ViewAngles.Roll += DAngle::fromDeg(24 * BAngToDegree); + Angles.ViewAngles.Roll += adjustment; } if (SeaSick < 250) - Angles.ViewAngles.Yaw = DAngle::fromDeg(((krand() & 255) - 128) * BAngToDegree); + Angles.ViewAngles.Yaw = DAngle::fromDeg(krandf(45) - 22.5); } } diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index 2d5c7c981..66c24dcc3 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -967,7 +967,7 @@ void DrawWeapons(double interpfrac) if (cl_hudinterpolation) { - nBobAngle = interpolatedvalue(obobangle, bobangle, interpfrac) * BAngToDegree; + nBobAngle = interpolatedvalue(obobangle, bobangle, interpfrac); nVal = interpolatedvalue(PlayerList[nLocalPlayer].ototalvel, PlayerList[nLocalPlayer].totalvel, interpfrac); } else @@ -976,11 +976,11 @@ void DrawWeapons(double interpfrac) nVal = PlayerList[nLocalPlayer].totalvel; } - yOffset = nVal * fabs(g_sindeg(nBobAngle)) * (1. / 16.); + yOffset = nVal * fabs(BobVal(nBobAngle)) * (1. / 16.); if (var_34 == 1) { - xOffset = nVal * g_cosdeg(nBobAngle) * (1. / 8.); + xOffset = nVal * BobVal(nBobAngle + 512) * (1. / 8.); } } else