From 951734beae0da2240fe03574f5905fca50d31034 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sat, 27 Aug 2022 23:56:17 +1000 Subject: [PATCH] - Eliminate last remaining uses of `binangle` and the class itself. * https://www.youtube.com/watch?v=RgKAFK5djSk --- source/core/binaryangle.h | 120 ------------------ .../core/rendering/scene/hw_bunchdrawer.cpp | 4 +- source/core/rendering/scene/hw_clipper.cpp | 2 +- source/core/rendering/scene/hw_sprites.cpp | 2 +- 4 files changed, 4 insertions(+), 124 deletions(-) diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index d383258a4..75db25949 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -110,126 +110,6 @@ inline double bcosf(const double ang, const int shift = 0) return g_cosbam(ang * BAMUNIT) * sinscale(shift); } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -class binangle -{ - uint32_t value; - - constexpr binangle(uint32_t v) : value(v) {} - - friend constexpr binangle bamang(uint32_t v); - friend constexpr binangle q16ang(uint32_t v); - friend constexpr binangle buildang(uint32_t v); - friend binangle buildfang(double v); - friend binangle radang(double v); - friend binangle degang(double v); - - friend FSerializer &Serialize(FSerializer &arc, const char *key, binangle &obj, binangle *defval); - - constexpr int32_t tosigned() const { return int32_t(value); } - -public: - binangle() = default; - binangle(const binangle &other) = default; - binangle& operator=(const binangle& other) = default; - // This class intentionally makes no allowances for implicit type conversions because those would render it ineffective. - constexpr short asbuild() const { return value >> BAMBITS; } - constexpr double asbuildf() const { return value * (1. / +BAMUNIT); } - constexpr fixed_t asq16() const { return value >> 5; } - constexpr uint32_t asbam() const { return value; } - constexpr double asrad() const { return value * (pi::pi() / 0x80000000u); } - constexpr double asdeg() const { return DAngle::fromBam(value).Degrees(); } - constexpr short signedbuild() const { return tosigned() >> BAMBITS; } - constexpr double signedbuildf() const { return tosigned() * (1. / +BAMUNIT); } - constexpr fixed_t signedq16() const { return tosigned() >> 5; } - constexpr int32_t signedbam() const { return tosigned(); } - constexpr double signedrad() const { return tosigned() * (pi::pi() / 0x80000000u); } - constexpr double signeddeg() const { return DAngle::fromBam(tosigned()).Degrees(); } - - double fsin() const { return g_sinbam(asbam()); } - double fcos() const { return g_cosbam(asbam()); } - double ftan() const { return g_tan(asrad()); } - int bsin(const int8_t& shift = 0) const { return ::bsin(asbuild(), shift); } - int bcos(const int8_t& shift = 0) const { return ::bcos(asbuild(), shift); } - - constexpr bool operator== (binangle other) const - { - return value == other.value; - } - - constexpr bool operator!= (binangle other) const - { - return value != other.value; - } - - constexpr binangle &operator+= (binangle other) - { - value += other.value; - return *this; - } - - constexpr binangle &operator-= (binangle other) - { - value -= other.value; - return *this; - } - - constexpr binangle operator+ (binangle other) const - { - return binangle(value + other.value); - } - - constexpr binangle operator- (binangle other) const - { - return binangle(value - other.value); - } - - constexpr binangle operator- () const - { - return binangle(0 - value); - } - - constexpr binangle &operator<<= (const uint8_t shift) - { - value = tosigned() << shift; - return *this; - } - - constexpr binangle &operator>>= (const uint8_t shift) - { - value = tosigned() >> shift; - return *this; - } - - constexpr binangle operator<< (const uint8_t shift) const - { - return binangle(tosigned() << shift); - } - - constexpr binangle operator>> (const uint8_t shift) const - { - return binangle(tosigned() >> shift); - } -}; - -inline constexpr binangle bamang(uint32_t v) { return binangle(v); } -inline constexpr binangle q16ang(uint32_t v) { return binangle(v << 5); } -inline constexpr binangle buildang(uint32_t v) { return binangle(v << BAMBITS); } -inline binangle buildfang(double v) { return binangle(xs_ToFixed(BAMBITS, v)); } -inline binangle radang(double v) { return binangle(xs_CRoundToUInt(v * (0x80000000u / pi::pi()))); } -inline binangle degang(double v) { return binangle(FloatToAngle(v)); } - -inline FSerializer &Serialize(FSerializer &arc, const char *key, binangle &obj, binangle *defval) -{ - return Serialize(arc, key, obj.value, defval ? &defval->value : nullptr); -} - - //--------------------------------------------------------------------------- // // Functions for use with fixedhoriz and friendly functions. diff --git a/source/core/rendering/scene/hw_bunchdrawer.cpp b/source/core/rendering/scene/hw_bunchdrawer.cpp index f058ba44b..f503cd4d1 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.cpp +++ b/source/core/rendering/scene/hw_bunchdrawer.cpp @@ -66,8 +66,8 @@ void BunchDrawer::Init(HWDrawInfo *_di, Clipper* c, vec2_t& view, angle_t a1, an iview = view; StartScene(); - gcosang = bamang(di->Viewpoint.RotAngle).fcos(); - gsinang = bamang(di->Viewpoint.RotAngle).fsin(); + gcosang = g_cosbam(di->Viewpoint.RotAngle); + gsinang = g_sinbam(di->Viewpoint.RotAngle); for (auto& w : wall) { diff --git a/source/core/rendering/scene/hw_clipper.cpp b/source/core/rendering/scene/hw_clipper.cpp index 736c13297..58c81f966 100644 --- a/source/core/rendering/scene/hw_clipper.cpp +++ b/source/core/rendering/scene/hw_clipper.cpp @@ -654,6 +654,6 @@ void Clipper::DumpClipper() { for (auto node = cliphead; node; node = node->next) { - Printf("Range from %2.3f to %2.3f (top = %2.3f, bottom = %2.3f)\n", bamang(node->start).asdeg(), bamang(node->end).asdeg(), node->topclip, node->bottomclip); + Printf("Range from %2.3f to %2.3f (top = %2.3f, bottom = %2.3f)\n", DAngle::fromBam(node->start).Degrees(), DAngle::fromBam(node->end).Degrees(), node->topclip, node->bottomclip); } } diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index 33104de0a..1fee61385 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -524,7 +524,7 @@ bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, tspritetype* spr, s rotmat.loadIdentity(); rotmat.translate(x + translatevec.X, z - translatevec.Z, y - translatevec.Y); - rotmat.rotate(buildang(ang).asdeg() - 90.f, 0, 1, 0); + rotmat.rotate(DAngle::fromBuild(ang).Degrees() - 90.f, 0, 1, 0); rotmat.scale(scalevec.X, scalevec.Z, scalevec.Y); // Apply pivot last rotmat.translate(-voxel->piv.X, zoff, voxel->piv.Y);