From bd6b0eaac563cab26d041a4095126f2e0186aa09 Mon Sep 17 00:00:00 2001 From: Mitchell Richters Date: Sun, 28 Aug 2022 09:40:14 +1000 Subject: [PATCH] - Fix some constexpr issues with the latest DAngle works. * We can't make `BAMs()` constexpr as we can't update to a C++20 compatible version of xs_Float where we use legal std::bit_cast instead of a union. --- source/common/utility/vectors.h | 2 +- source/core/binaryangle.h | 8 ++++---- source/core/coreactor.h | 2 +- source/core/maptypes.h | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/common/utility/vectors.h b/source/common/utility/vectors.h index 39fc85535..a16090aaa 100644 --- a/source/common/utility/vectors.h +++ b/source/common/utility/vectors.h @@ -1375,7 +1375,7 @@ public: return clamp(Tan(), -max, max); } - constexpr int Sgn() const + int Sgn() const { const auto normalized = (signed int)BAMs(); return (normalized > 0) - (normalized < 0); diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index 75db25949..5bfd561a8 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -299,14 +299,14 @@ inline constexpr int32_t interpolatedangle(int32_t oang, int32_t ang, int const return oang + MulScale(((ang + 1024 - oang) & 2047) - 1024, smoothratio, scale); } -inline constexpr DAngle interpolatedangle(DAngle oang, DAngle ang, double const smoothratio, int const scale = 16) +inline DAngle interpolatedangle(DAngle oang, DAngle ang, double const smoothratio, int const scale = 16) { - return DAngle::fromBam(oang.BAMs() + MulScale(((ang.BAMs() + 0x80000000 - oang.BAMs()) & 0xFFFFFFFF) - 0x80000000, int(smoothratio), scale)); + return oang + (deltaangle(oang, ang) * smoothratio * (1. / (1 << scale))); } -inline constexpr DAngle interpolatedangle(DAngle oang, DAngle ang, int const smoothratio, int const scale = 16) +inline DAngle interpolatedangle(DAngle oang, DAngle ang, int const smoothratio, int const scale = 16) { - return DAngle::fromBam(oang.BAMs() + MulScale(((ang.BAMs() + 0x80000000 - oang.BAMs()) & 0xFFFFFFFF) - 0x80000000, smoothratio, scale)); + return oang + (deltaangle(oang, ang) * smoothratio * (1. / (1 << scale))); } inline constexpr fixedhoriz interpolatedhorizon(fixedhoriz oval, fixedhoriz val, double const smoothratio, int const scale = 16) diff --git a/source/core/coreactor.h b/source/core/coreactor.h index b7ae2ab7d..990dbc007 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -107,7 +107,7 @@ public: spr.pos.Y = y * inttoworld; } - const int16_t int_ang() const + constexpr int16_t int_ang() const { return spr.__int_angle; } diff --git a/source/core/maptypes.h b/source/core/maptypes.h index 3a3e39949..f6b2f300a 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -493,7 +493,7 @@ struct spritetypebase return { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) }; } - const int16_t int_ang() const + constexpr int16_t int_ang() const { return __int_angle; }