diff --git a/source/common/utility/basics.h b/source/common/utility/basics.h index 8661372e9..4ebc2cc88 100644 --- a/source/common/utility/basics.h +++ b/source/common/utility/basics.h @@ -91,16 +91,27 @@ inline double DEG2RAD(double deg) return deg * (M_PI / 180.0); } -inline float RAD2DEG(float deg) +inline float RAD2DEG(float rad) { - return deg * float(180. / M_PI); + return rad * float(180. / M_PI); } -inline double RAD2DEG(double deg) +inline double RAD2DEG(double rad) { - return deg * (180. / M_PI); + return rad * (180. / M_PI); } +inline angle_t RAD2BAM(float rad) +{ + return angle_t(rad * float(0x80000000u / M_PI)); +} + +inline angle_t RAD2BAM(double rad) +{ + return angle_t(rad * (0x80000000u / M_PI)); +} + + // This is needed in common code, despite being Doom specific. enum EStateUseFlags { diff --git a/source/core/maptypes.h b/source/core/maptypes.h index 05fbab985..3a3e39949 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -406,7 +406,7 @@ struct walltype uint8_t yrepeat; // extensions not from the binary map format. - binangle clipangle; + angle_t clipangle; int length; // cached value to avoid calling sqrt repeatedly. uint16_t portalnum; diff --git a/source/core/rendering/scene/hw_bunchdrawer.cpp b/source/core/rendering/scene/hw_bunchdrawer.cpp index 626f53e6d..259f40cfc 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.cpp +++ b/source/core/rendering/scene/hw_bunchdrawer.cpp @@ -73,7 +73,7 @@ void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, vec2_t& view, binangle a1, b { // Precalculate the clip angles to avoid doing this repeatedly during level traversal. auto vv = w.wall_int_pos() - view; - w.clipangle = bvectangbam(vv.X, vv.Y); + w.clipangle = RAD2BAM(atan2(vv.Y, vv.X)); } memset(sectionstartang.Data(), -1, sectionstartang.Size() * sizeof(sectionstartang[0])); memset(sectionendang.Data(), -1, sectionendang.Size() * sizeof(sectionendang[0])); diff --git a/source/core/rendering/scene/hw_bunchdrawer.h b/source/core/rendering/scene/hw_bunchdrawer.h index 23f180e5e..6996adf98 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.h +++ b/source/core/rendering/scene/hw_bunchdrawer.h @@ -45,7 +45,7 @@ private: CL_Pass = 2, }; - binangle ClipAngle(int wal) { return wall[wal].clipangle - ang1; } + binangle ClipAngle(int wal) { return bamang(wall[wal].clipangle) - ang1; } void StartScene(); bool StartBunch(int sectnum, int linenum, binangle startan, binangle endan, bool portal); bool AddLineToBunch(int line, binangle newan);