From c25493762b774a4ca4fe1426b48e175571bb9f8c Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sat, 27 Aug 2022 23:33:03 +1000 Subject: [PATCH] - Eliminate `bvectangbam()`. --- source/core/binaryangle.h | 7 +------ source/core/gamecontrol.cpp | 2 +- source/core/rendering/scene/hw_portal.cpp | 14 +++++++------- source/games/exhumed/src/gun.cpp | 2 +- wadsrc/static/zscript/games/sw/swgame.zs | 2 +- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index 54da31135..e5abfb44c 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -372,14 +372,9 @@ inline FSerializer &Serialize(FSerializer &arc, const char *key, fixedhoriz &obj // //--------------------------------------------------------------------------- -inline binangle bvectangbam(double x, double y) -{ - return radang(atan2(y, x)); -} - inline int getangle(double xvect, double yvect) { - return bvectangbam(xvect, yvect).asbuild(); + return DVector2(xvect, yvect).Angle().Buildang(); } inline int getangle(const DVector2& vec) diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 5c1ed04c7..bf87d8b3d 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1537,7 +1537,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, bcos, bcos) int raze_getangle(double x, double y) { - return bvectangbam(x, y).asbuild(); + return VecToAngle(x, y).Buildang(); } DEFINE_ACTION_FUNCTION_NATIVE(_Raze, getangle, raze_getangle) diff --git a/source/core/rendering/scene/hw_portal.cpp b/source/core/rendering/scene/hw_portal.cpp index 90b0f1ac8..10e4878a0 100644 --- a/source/core/rendering/scene/hw_portal.cpp +++ b/source/core/rendering/scene/hw_portal.cpp @@ -540,16 +540,16 @@ bool HWMirrorPortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *clippe double newx = x * 2 + dx * i / j - view.X; double newy = y * 2 + dy * i / j - view.Y; - auto myan = bvectangbam(dx, dy); - auto newan = myan + myan - bamang(vp.RotAngle); + auto myan = RAD2BAM(atan2(dy, dx)); + auto newan = myan + myan - vp.RotAngle; - vp.RotAngle = newan.asbam(); + vp.RotAngle = newan; vp.SectNums = nullptr; vp.SectCount = line->sector; vp.Pos.X = newx; vp.Pos.Y = -newy; - vp.HWAngles.Yaw = FAngle::fromDeg( - 90.f + newan.asdeg()); + vp.HWAngles.Yaw = FAngle::fromBam(-ANGLE_90 + newan); double FocalTangent = tan(vp.FieldOfView.Radians() / 2); DAngle an = DAngle::fromDeg(270. - vp.HWAngles.Yaw.Degrees()); @@ -613,10 +613,10 @@ bool HWLineToLinePortal::Setup(HWDrawInfo *di, FRenderState &rstate, Clipper *cl int dx2 = line->point2Wall()->x - line->x; int dy2 = line->point2Wall()->y - line->y; - auto srcang = bvectangbam(dx, dy); - auto destang = bvectangbam(-dx, -dy); + auto srcang = RAD2BAM(atan2(dy, dx)); + auto destang = RAD2BAM(atan2(-dy, -dx)); - vp.RotAngle += (destang - srcang).asbam(); + vp.RotAngle += destang - srcang; #endif // Nothing in the entire setup mandates that both lines have the same length. diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index 643d62ef5..1a3e1d23b 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -808,7 +808,7 @@ loc_flag: DExhumedActor* t = sPlayerInput[nPlayer].pTarget; // only autoaim if target is in front of the player. assert(t->sector()); - int angletotarget = bvectangbam(t->int_pos().X - pPlayerActor->int_pos().X, t->int_pos().Y - pPlayerActor->int_pos().Y).asbuild(); + int angletotarget = VecToAngle(t->int_pos().X - pPlayerActor->int_pos().X, t->int_pos().Y - pPlayerActor->int_pos().Y).Buildang(); int anglediff = (pPlayerActor->int_ang() - angletotarget) & 2047; if (anglediff < 512 || anglediff > 1536) { diff --git a/wadsrc/static/zscript/games/sw/swgame.zs b/wadsrc/static/zscript/games/sw/swgame.zs index ec0cd6572..990983b21 100644 --- a/wadsrc/static/zscript/games/sw/swgame.zs +++ b/wadsrc/static/zscript/games/sw/swgame.zs @@ -167,7 +167,7 @@ struct SWPlayer native SPRITEp last_camera_sp; PlayerHorizon horizon; PlayerAngle angle; - binangle RevolveAng; + double RevolveAng; // under vars are for wading and swimming //int16 PlayerSprite, PlayerUnderSprite; SPRITEp SpriteP, UnderSpriteP;