mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-27 17:30:51 +00:00
- cleanup on binaryangle.h
* why the reference parameters? These should be passed by value. * removed the < and > operators from binangle class because angles should not be ordered. * instead of calling the CRT trig functions, use the ones from cmath.h which are more reliable
This commit is contained in:
parent
5ba2e7863d
commit
b89cd6d14c
1 changed files with 19 additions and 37 deletions
|
@ -41,6 +41,7 @@
|
||||||
#include "xs_Float.h" // needed for reliably overflowing float->int conversions.
|
#include "xs_Float.h" // needed for reliably overflowing float->int conversions.
|
||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
#include "build.h"
|
#include "build.h"
|
||||||
|
#include "math/cmath.h"
|
||||||
|
|
||||||
class FSerializer;
|
class FSerializer;
|
||||||
|
|
||||||
|
@ -67,13 +68,13 @@ constexpr double BRadAngScale = 1. / BAngRadian;
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
inline int32_t bsin(const int16_t& ang, const int8_t& shift = 0)
|
inline int32_t bsin(const int ang, const int8_t shift = 0)
|
||||||
{
|
{
|
||||||
return shift < 0 ? sintable[ang & 2047] >> abs(shift) : sintable[ang & 2047] << shift;
|
return shift < 0 ? sintable[ang & 2047] >> abs(shift) : sintable[ang & 2047] << shift;
|
||||||
}
|
}
|
||||||
inline double bsinf(const double& ang, const int8_t& shift = 0)
|
inline double bsinf(const double ang, const int8_t shift = 0)
|
||||||
{
|
{
|
||||||
return sin(ang * BAngRadian) * (shift >= -SINSHIFT ? uint64_t(1) << (SINSHIFT + shift) : 1. / (uint64_t(1) << abs(SINSHIFT + shift)));
|
return g_sin(ang * BAngRadian) * (shift >= -SINSHIFT ? uint64_t(1) << (SINSHIFT + shift) : 1. / (uint64_t(1) << abs(SINSHIFT + shift)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -83,13 +84,13 @@ inline double bsinf(const double& ang, const int8_t& shift = 0)
|
||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
inline int32_t bcos(const int16_t& ang, const int8_t& shift = 0)
|
inline int32_t bcos(const int ang, const int8_t shift = 0)
|
||||||
{
|
{
|
||||||
return shift < 0 ? sintable[(ang + 512) & 2047] >> abs(shift) : sintable[(ang + 512) & 2047] << shift;
|
return shift < 0 ? sintable[(ang + 512) & 2047] >> abs(shift) : sintable[(ang + 512) & 2047] << shift;
|
||||||
}
|
}
|
||||||
inline double bcosf(const double& ang, const int8_t& shift = 0)
|
inline double bcosf(const double ang, const int8_t shift = 0)
|
||||||
{
|
{
|
||||||
return cos(ang * BAngRadian) * (shift >= -SINSHIFT ? uint64_t(1) << (SINSHIFT + shift) : 1. / (uint64_t(1) << abs(SINSHIFT + shift)));
|
return g_cos(ang * BAngRadian) * (shift >= -SINSHIFT ? uint64_t(1) << (SINSHIFT + shift) : 1. / (uint64_t(1) << abs(SINSHIFT + shift)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,24 +196,24 @@ public:
|
||||||
return lookangle(value - other.value);
|
return lookangle(value - other.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr lookangle &operator<<= (const uint8_t& shift)
|
constexpr lookangle &operator<<= (const uint8_t shift)
|
||||||
{
|
{
|
||||||
value <<= shift;
|
value <<= shift;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr lookangle &operator>>= (const uint8_t& shift)
|
constexpr lookangle &operator>>= (const uint8_t shift)
|
||||||
{
|
{
|
||||||
value >>= shift;
|
value >>= shift;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr lookangle operator<< (const uint8_t& shift) const
|
constexpr lookangle operator<< (const uint8_t shift) const
|
||||||
{
|
{
|
||||||
return lookangle(value << shift);
|
return lookangle(value << shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr lookangle operator>> (const uint8_t& shift) const
|
constexpr lookangle operator>> (const uint8_t shift) const
|
||||||
{
|
{
|
||||||
return lookangle(value >> shift);
|
return lookangle(value >> shift);
|
||||||
}
|
}
|
||||||
|
@ -268,25 +269,6 @@ public:
|
||||||
int bsin(const int8_t& shift = 0) const { return ::bsin(asbuild(), shift); }
|
int bsin(const int8_t& shift = 0) const { return ::bsin(asbuild(), shift); }
|
||||||
int bcos(const int8_t& shift = 0) const { return ::bcos(asbuild(), shift); }
|
int bcos(const int8_t& shift = 0) const { return ::bcos(asbuild(), shift); }
|
||||||
|
|
||||||
bool operator< (binangle other) const
|
|
||||||
{
|
|
||||||
return value < other.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator> (binangle other) const
|
|
||||||
{
|
|
||||||
return value > other.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator<= (binangle other) const
|
|
||||||
{
|
|
||||||
return value <= other.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator>= (binangle other) const
|
|
||||||
{
|
|
||||||
return value >= other.value;
|
|
||||||
}
|
|
||||||
constexpr bool operator== (binangle other) const
|
constexpr bool operator== (binangle other) const
|
||||||
{
|
{
|
||||||
return value == other.value;
|
return value == other.value;
|
||||||
|
@ -341,24 +323,24 @@ public:
|
||||||
return binangle(value - other.value);
|
return binangle(value - other.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr binangle &operator<<= (const uint8_t& shift)
|
constexpr binangle &operator<<= (const uint8_t shift)
|
||||||
{
|
{
|
||||||
value <<= shift;
|
value <<= shift;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr binangle &operator>>= (const uint8_t& shift)
|
constexpr binangle &operator>>= (const uint8_t shift)
|
||||||
{
|
{
|
||||||
value >>= shift;
|
value >>= shift;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr binangle operator<< (const uint8_t& shift) const
|
constexpr binangle operator<< (const uint8_t shift) const
|
||||||
{
|
{
|
||||||
return binangle(value << shift);
|
return binangle(value << shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr binangle operator>> (const uint8_t& shift) const
|
constexpr binangle operator>> (const uint8_t shift) const
|
||||||
{
|
{
|
||||||
return binangle(value >> shift);
|
return binangle(value >> shift);
|
||||||
}
|
}
|
||||||
|
@ -486,24 +468,24 @@ public:
|
||||||
return fixedhoriz(value - other.value);
|
return fixedhoriz(value - other.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr fixedhoriz &operator<<= (const uint8_t& shift)
|
constexpr fixedhoriz &operator<<= (const uint8_t shift)
|
||||||
{
|
{
|
||||||
value <<= shift;
|
value <<= shift;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr fixedhoriz &operator>>= (const uint8_t& shift)
|
constexpr fixedhoriz &operator>>= (const uint8_t shift)
|
||||||
{
|
{
|
||||||
value >>= shift;
|
value >>= shift;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr fixedhoriz operator<< (const uint8_t& shift) const
|
constexpr fixedhoriz operator<< (const uint8_t shift) const
|
||||||
{
|
{
|
||||||
return fixedhoriz(value << shift);
|
return fixedhoriz(value << shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr fixedhoriz operator>> (const uint8_t& shift) const
|
constexpr fixedhoriz operator>> (const uint8_t shift) const
|
||||||
{
|
{
|
||||||
return fixedhoriz(value >> shift);
|
return fixedhoriz(value >> shift);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue