From 31b09521a6eebd39d78c810b975eaaf43dd236e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 9 Jun 2017 20:08:38 -0700 Subject: [PATCH] Renamed constants to new style. --- include/bx/debug.h | 2 +- include/bx/fpumath.h | 13 +++++++------ include/bx/inline/easing.inl | 6 +++--- include/bx/inline/fpumath.inl | 10 +++++----- include/bx/inline/rng.inl | 6 +++--- src/fpumath.cpp | 15 ++++++++------- tests/fpumath_test.cpp | 6 +++--- 7 files changed, 30 insertions(+), 28 deletions(-) diff --git a/include/bx/debug.h b/include/bx/debug.h index e8266cd..58940ac 100644 --- a/include/bx/debug.h +++ b/include/bx/debug.h @@ -26,7 +26,7 @@ namespace bx void debugPrintfData(const void* _data, uint32_t _size, const char* _format, ...); /// - class WriterI* getDebugOut(); + struct WriterI* getDebugOut(); } // namespace bx diff --git a/include/bx/fpumath.h b/include/bx/fpumath.h index 02973da..3f5c57f 100644 --- a/include/bx/fpumath.h +++ b/include/bx/fpumath.h @@ -12,12 +12,13 @@ namespace bx { - extern const float pi; - extern const float invPi; - extern const float piHalf; - extern const float sqrt2; - extern const float invLogNat2; - extern const float huge; + extern const float kPi; + extern const float kPi2; + extern const float kInvPi; + extern const float kPiHalf; + extern const float kSqrt2; + extern const float kInvLogNat2; + extern const float kHuge; /// typedef float (*LerpFn)(float _a, float _b, float _t); diff --git a/include/bx/inline/easing.inl b/include/bx/inline/easing.inl index b23edb1..a422d73 100644 --- a/include/bx/inline/easing.inl +++ b/include/bx/inline/easing.inl @@ -111,7 +111,7 @@ namespace bx inline float easeInSine(float _t) { - return 1.0f - fcos(_t*piHalf); + return 1.0f - fcos(_t*kPiHalf); } inline float easeOutSine(float _t) @@ -171,7 +171,7 @@ namespace bx inline float easeOutElastic(float _t) { - return fpow(2.0f, -10.0f*_t)*fsin( (_t-0.3f/4.0f)*(2.0f*pi)/0.3f) + 1.0f; + return fpow(2.0f, -10.0f*_t)*fsin( (_t-0.3f/4.0f)*(2.0f*kPi)/0.3f) + 1.0f; } inline float easeInElastic(float _t) @@ -191,7 +191,7 @@ namespace bx inline float easeInBack(float _t) { - return easeInCubic(_t) - _t*fsin(_t*pi); + return easeInCubic(_t) - _t*fsin(_t*kPi); } inline float easeOutBack(float _t) diff --git a/include/bx/inline/fpumath.inl b/include/bx/inline/fpumath.inl index 4b79c09..6dc8a62 100644 --- a/include/bx/inline/fpumath.inl +++ b/include/bx/inline/fpumath.inl @@ -13,12 +13,12 @@ namespace bx { inline float toRad(float _deg) { - return _deg * pi / 180.0f; + return _deg * kPi / 180.0f; } inline float toDeg(float _rad) { - return _rad * 180.0f / pi; + return _rad * 180.0f / kPi; } inline uint32_t floatToBits(float _a) @@ -138,7 +138,7 @@ namespace bx inline float flog2(float _a) { - return flog(_a) * invLogNat2; + return flog(_a) * kInvLogNat2; } inline float frsqrt(float _a) @@ -208,8 +208,8 @@ namespace bx inline float angleDiff(float _a, float _b) { - const float dist = fwrap(_b - _a, pi*2.0f); - return fwrap(dist*2.0f, pi*2.0f) - dist; + const float dist = fwrap(_b - _a, kPi*2.0f); + return fwrap(dist*2.0f, kPi*2.0f) - dist; } inline float angleLerp(float _a, float _b, float _t) diff --git a/include/bx/inline/rng.inl b/include/bx/inline/rng.inl index 11b466d..1cda221 100644 --- a/include/bx/inline/rng.inl +++ b/include/bx/inline/rng.inl @@ -81,7 +81,7 @@ namespace bx template inline void randUnitCircle(float _result[3], Rng* _rng) { - const float angle = frnd(_rng) * pi * 2.0f; + const float angle = frnd(_rng) * kPi2; _result[0] = fcos(angle); _result[1] = 0.0f; @@ -92,7 +92,7 @@ namespace bx inline void randUnitSphere(float _result[3], Rng* _rng) { const float rand0 = frnd(_rng) * 2.0f - 1.0f; - const float rand1 = frnd(_rng) * pi * 2.0f; + const float rand1 = frnd(_rng) * kPi2; const float sqrtf1 = fsqrt(1.0f - rand0*rand0); _result[0] = sqrtf1 * fcos(rand1); @@ -140,7 +140,7 @@ namespace bx tt = 2.0f * tt - 1.0f; const float phi = (ii + 0.5f) / _num; - const float phirad = phi * 2.0f * pi; + const float phirad = phi * kPi2; const float st = fsqrt(1.0f-tt*tt) * _scale; float* xyz = (float*)data; diff --git a/src/fpumath.cpp b/src/fpumath.cpp index 24c1682..2f52669 100644 --- a/src/fpumath.cpp +++ b/src/fpumath.cpp @@ -8,15 +8,16 @@ namespace bx { - const float pi = 3.1415926535897932384626433832795f; - const float invPi = 1.0f/pi; - const float piHalf = 1.5707963267948966192313216916398f; - const float sqrt2 = 1.4142135623730950488016887242097f; - const float invLogNat2 = 1.4426950408889634073599246810019f; + const float kPi = 3.1415926535897932384626433832795f; + const float kPi2 = 6.2831853071795864769252867665590f; + const float kInvPi = 1.0f/kPi; + const float kPiHalf = 1.5707963267948966192313216916398f; + const float kSqrt2 = 1.4142135623730950488016887242097f; + const float kInvLogNat2 = 1.4426950408889634073599246810019f; #if BX_COMPILER_MSVC - const float huge = float(HUGE_VAL); + const float kHuge = float(HUGE_VAL); #else - const float huge = HUGE_VALF; + const float kHuge = HUGE_VALF; #endif // BX_COMPILER_MSVC float fabsolute(float _a) diff --git a/tests/fpumath_test.cpp b/tests/fpumath_test.cpp index 088d1a0..b2084d2 100644 --- a/tests/fpumath_test.cpp +++ b/tests/fpumath_test.cpp @@ -77,9 +77,9 @@ TEST_CASE("quaternion", "") bx::mtxIdentity(mtx); mtxCheck(mtxQ, mtx); - float ax = bx::pi/27.0f; - float ay = bx::pi/13.0f; - float az = bx::pi/7.0f; + float ax = bx::kPi/27.0f; + float ay = bx::kPi/13.0f; + float az = bx::kPi/7.0f; bx::quatRotateX(quat, ax); bx::mtxQuat(mtxQ, quat);