From ab8006cc402f527170e21f2803d755806da733ea Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 23 Jul 2020 16:40:59 +0200 Subject: [PATCH] - make binaryangle.h compile. --- source/core/binaryangle.h | 22 +++++++++++----------- source/games/duke/src/duke3d.h | 1 + 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/source/core/binaryangle.h b/source/core/binaryangle.h index 20d476a04..92a4a2555 100644 --- a/source/core/binaryangle.h +++ b/source/core/binaryangle.h @@ -9,13 +9,13 @@ class binangle { unsigned int value; - inline constexpr double pi() { return 3.14159265358979323846; } + inline static constexpr double pi() { return 3.14159265358979323846; } constexpr binangle(unsigned int v) : value(v) {} - friend binangle bamang(unsigned int v); - friend binangle q16ang(unsigned int v); - friend binangle buildang(unsigned int v); + friend constexpr binangle bamang(unsigned int v); + friend constexpr binangle q16ang(unsigned int v); + friend constexpr binangle buildang(unsigned int v); friend binangle radang(double v); friend binangle degang(double v); @@ -30,8 +30,8 @@ public: double fsin() const { return sin(asrad()); } double fcos() const { return cos(asrad()); } double ftan() const { return tan(asrad()); } - int bsin() const { return sintable(asbuild()); } - int bcos() const { return sintable((asbuild() + 512) & 2047); } + int bsin() const { return sintable[asbuild()]; } + int bcos() const { return sintable[(asbuild() + 512) & 2047]; } #if 0 // This makes no sense bool operator< (binangle other) const @@ -64,15 +64,15 @@ public: return value != other.value; } - constexpr binangle &operator+= (binangle other) const + constexpr binangle &operator+= (binangle other) { value += other.value; return *this; } - constexpr binangle &operator-= (binangle other) const + constexpr binangle &operator-= (binangle other) { - value -+= other.value; + value -= other.value; return *this; } @@ -98,6 +98,6 @@ public: inline constexpr binangle bamang(unsigned int v) { return binangle(v); } inline constexpr binangle q16ang(unsigned int v) { return binangle(v << 5); } inline constexpr binangle buildang(unsigned int v) { return binangle(v << 21); } -inline binangle radang(double v) { return binangle(xs_CRoundToUInt(v * (0x80000000u / pi())); } -inline binangle degang(double v) { return binangle(xs_CRoundToUInt(v * (0x40000000 / 90.)); } +inline binangle radang(double v) { return binangle(xs_CRoundToUInt(v * (0x80000000u / binangle::pi()))); } +inline binangle degang(double v) { return binangle(xs_CRoundToUInt(v * (0x40000000 / 90.))); } diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 1e705c496..4416342f6 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -22,6 +22,7 @@ #include "sounds.h" #include "soundefs.h" #include "stats.h" +#include "binaryangle.h" extern glcycle_t drawtime, actortime, thinktime, gameupdatetime;