Browse Source

Renamed constants to new style.

Branimir Karadžić 8 years ago
parent
commit
31b09521a6

+ 1 - 1
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
 

+ 7 - 6
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);

+ 3 - 3
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)

+ 5 - 5
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)

+ 3 - 3
include/bx/inline/rng.inl

@@ -81,7 +81,7 @@ namespace bx
 	template <typename Rng>
 	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;

+ 8 - 7
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)

+ 3 - 3
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);