From b1cee49176dc5e15090e3276824f439ce153f3de Mon Sep 17 00:00:00 2001 From: Branimir Karadzic Date: Thu, 23 Oct 2014 21:10:24 -0700 Subject: [PATCH] Removed _USE_MATH_DEFINES. --- include/bx/fpumath.h | 10 ++++++---- include/bx/rng.h | 8 +++----- scripts/toolchain.lua | 1 - 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/bx/fpumath.h b/include/bx/fpumath.h index 5f640f4..63cd503 100644 --- a/include/bx/fpumath.h +++ b/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 #include 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; diff --git a/include/bx/rng.h b/include/bx/rng.h index c8052dd..686b6d4 100644 --- a/include/bx/rng.h +++ b/include/bx/rng.h @@ -7,9 +7,7 @@ #define BX_RNG_H_HEADER_GUARD #include "bx.h" - -#define _USE_MATH_DEFINES -#include +#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; diff --git a/scripts/toolchain.lua b/scripts/toolchain.lua index 796b701..d942095 100755 --- a/scripts/toolchain.lua +++ b/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",