Pārlūkot izejas kodu

Removed _USE_MATH_DEFINES.

Branimir Karadzic 11 gadi atpakaļ
vecāks
revīzija
b1cee49176
3 mainītis faili ar 9 papildinājumiem un 10 dzēšanām
  1. 6 4
      include/bx/fpumath.h
  2. 3 5
      include/bx/rng.h
  3. 0 1
      scripts/toolchain.lua

+ 6 - 4
include/bx/fpumath.h

@@ -8,20 +8,22 @@
 #ifndef BX_FPU_MATH_H_HEADER_GUARD
 #define BX_FPU_MATH_H_HEADER_GUARD
 
-#define _USE_MATH_DEFINES
 #include <math.h>
 #include <string.h>
 
 namespace bx
 {
+	const float pi     = 3.14159265358979323846f;
+	const float piHalf = 1.57079632679489661923f;
+
 	inline float toRad(float _deg)
 	{
-		return _deg * float(M_PI / 180.0);
+		return _deg * pi / 180.0f;;
 	}
 
 	inline float toDeg(float _rad)
 	{
-		return _rad * float(180.0 / M_PI);
+		return _rad * 180.0f / pi;
 	}
 
 	inline float fmin(float _a, float _b)
@@ -231,7 +233,7 @@ namespace bx
 
 	inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false)
 	{
-		const float height = 1.0f/tanf(_fovy*( (float)M_PI/180.0f)*0.5f);
+		const float height = 1.0f/tanf(toRad(_fovy)*0.5f);
 		const float width = height * 1.0f/_aspect;
 		const float diff = _far-_near;
 		const float aa = _oglNdc ?       (_far+_near)/diff : _far/diff;

+ 3 - 5
include/bx/rng.h

@@ -7,9 +7,7 @@
 #define BX_RNG_H_HEADER_GUARD
 
 #include "bx.h"
-
-#define _USE_MATH_DEFINES
-#include <math.h>
+#include "fpumath.h"
 
 namespace bx
 {
@@ -115,7 +113,7 @@ namespace bx
 	static inline void randUnitSphere(float _result[3], Ty* _rng)
 	{
 		float rand0 = frnd(_rng) * 2.0f - 1.0f;
-		float rand1 = frnd(_rng) * float(M_PI) * 2.0f;
+		float rand1 = frnd(_rng) * pi * 2.0f;
 
 		float sqrtf1 = sqrtf(1.0f - rand0*rand0);
 		_result[0] = sqrtf1 * cosf(rand1);
@@ -167,7 +165,7 @@ namespace bx
 			tt = 2.0f * tt - 1.0f;
 
 			const float phi = (ii + 0.5f) / _num;
-			const float phirad =  phi * 2.0f * float(M_PI);
+			const float phirad =  phi * 2.0f * pi;
 			const float st = sqrtf(1.0f-tt*tt) * _scale;
 
 			float* xyz = (float*)data;

+ 0 - 1
scripts/toolchain.lua

@@ -357,7 +357,6 @@ function toolchain(_buildDir, _libDir)
 		includedirs { bxDir .. "include/compat/mingw" }
 		buildoptions {
 			"-std=c++11",
-			"-U__STRICT_ANSI__",
 			"-Wunused-value",
 			"-fdata-sections",
 			"-ffunction-sections",