Remove unneeded standard math functions

This commit is contained in:
Jack Andersen
2018-06-02 20:10:58 -10:00
parent b1b4903cb1
commit 17a501f339
6 changed files with 7 additions and 148 deletions

View File

@@ -90,7 +90,7 @@ public:
return dist;
}
float distanceFromPoint(const CVector3f& other) const { return sqrtF(distanceFromPointSquared(other)); }
float distanceFromPoint(const CVector3f& other) const { return std::sqrt(distanceFromPointSquared(other)); }
inline bool intersects(const CAABox& other) const
{

View File

@@ -374,7 +374,7 @@ public:
void toHSL(float& h, float& s, float& l);
CColor toGrayscale() { return {sqrtF((r * r + g * g + b * b) / 3), a}; }
CColor toGrayscale() { return {std::sqrt((r * r + g * g + b * b) / 3), a}; }
/**
* @brief Clamps to GPU-safe RGBA values [0,1]

View File

@@ -337,7 +337,7 @@ public:
return x * x + y * y;
#endif
}
inline float magnitude() const { return sqrtF(magSquared()); }
inline float magnitude() const { return std::sqrt(magSquared()); }
inline void zeroOut()
{

View File

@@ -306,7 +306,7 @@ public:
#endif
}
inline float magnitude() const { return sqrtF(magSquared()); }
inline float magnitude() const { return std::sqrt(magSquared()); }
inline bool isNotInf() const
{

View File

@@ -107,26 +107,13 @@ CVector3f getCatmullRomSplinePoint(const CVector3f& a, const CVector3f& b, const
CVector3f getRoundCatmullRomSplinePoint(const CVector3f& a, const CVector3f& b, const CVector3f& c, const CVector3f& d,
float t);
inline float powF(float a, float b) { return std::pow(a, b); }
inline float floorF(float val) { return std::floor(val); }
inline float ceilingF(float val)
{
float tmp = std::floor(val);
return (tmp == val ? tmp : tmp + 1.0);
}
// Since round(double) doesn't exist in some <cmath> implementations
// we'll define our own
inline double round(double val) { return (val < 0.0 ? ceilingF(val - 0.5) : floorF(val + 0.5)); }
inline double round(double val) { return (val < 0.0 ? std::ceil(val - 0.5) : std::ceil(val + 0.5)); }
inline double powD(float a, float b) { return std::exp(b * std::log(a)); }
double sqrtD(double val);
inline double invSqrtD(double val) { return 1.0 / sqrtD(val); }
inline float invSqrtF(float val) { return float(1.0 / sqrtD(val)); }
inline float sqrtF(float val) { return float(sqrtD(val)); }
float fastArcCosF(float val);
float fastCosF(float val);
float fastSinF(float val);
inline double invSqrtD(double val) { return 1.0 / std::sqrt(val); }
inline float invSqrtF(float val) { return float(1.0 / std::sqrt(val)); }
int floorPowerOfTwo(int x);
int ceilingPowerOfTwo(int x);