diff --git a/include/bx/inline/easing.inl b/include/bx/inline/easing.inl index 5267f5c..d105d0b 100644 --- a/include/bx/inline/easing.inl +++ b/include/bx/inline/easing.inl @@ -36,12 +36,12 @@ namespace bx inline float easeSmoothStep(float _t) { - return fsq(_t)*(3.0f - 2.0f*_t); + return square(_t)*(3.0f - 2.0f*_t); } inline float easeInQuad(float _t) { - return fsq(_t); + return square(_t); } inline float easeOutQuad(float _t) @@ -121,7 +121,7 @@ namespace bx inline float easeInSine(float _t) { - return 1.0f - fcos(_t*kPiHalf); + return 1.0f - cos(_t*kPiHalf); } inline float easeOutSine(float _t) @@ -141,7 +141,7 @@ namespace bx inline float easeInExpo(float _t) { - return fpow(2.0f, 10.0f * (_t - 1.0f) ) - 0.001f; + return pow(2.0f, 10.0f * (_t - 1.0f) ) - 0.001f; } inline float easeOutExpo(float _t) @@ -161,7 +161,7 @@ namespace bx inline float easeInCirc(float _t) { - return -(fsqrt(1.0f - _t*_t) - 1.0f); + return -(sqrt(1.0f - _t*_t) - 1.0f); } inline float easeOutCirc(float _t) @@ -181,7 +181,7 @@ namespace bx inline float easeOutElastic(float _t) { - return fpow(2.0f, -10.0f*_t)*fsin( (_t-0.3f/4.0f)*(2.0f*kPi)/0.3f) + 1.0f; + return pow(2.0f, -10.0f*_t)*sin( (_t-0.3f/4.0f)*(2.0f*kPi)/0.3f) + 1.0f; } inline float easeInElastic(float _t) @@ -201,7 +201,7 @@ namespace bx inline float easeInBack(float _t) { - return easeInCubic(_t) - _t*fsin(_t*kPi); + return easeInCubic(_t) - _t*sin(_t*kPi); } inline float easeOutBack(float _t) diff --git a/include/bx/inline/math.inl b/include/bx/inline/math.inl index 5b26d67..0793cf6 100644 --- a/include/bx/inline/math.inl +++ b/include/bx/inline/math.inl @@ -92,125 +92,125 @@ namespace bx return tmp == UINT64_C(0x7ff0000000000000); } - inline float fround(float _f) + inline float round(float _f) { - return ffloor(_f + 0.5f); + return floor(_f + 0.5f); } - inline float fceil(float _a) + inline float ceil(float _a) { - return -ffloor(-_a); + return -floor(-_a); } - inline float flerp(float _a, float _b, float _t) + inline float lerp(float _a, float _b, float _t) { return _a + (_b - _a) * _t; } - inline float fabs(float _a) + inline float abs(float _a) { return _a < 0.0f ? -_a : _a; } - inline float fsign(float _a) + inline float sign(float _a) { return _a < 0.0f ? -1.0f : 1.0f; } - inline float fsq(float _a) + inline float square(float _a) { return _a * _a; } - inline float fexp2(float _a) + inline float exp2(float _a) { - return fpow(2.0f, _a); + return pow(2.0f, _a); } - inline float flog2(float _a) + inline float log2(float _a) { - return flog(_a) * kInvLogNat2; + return log(_a) * kInvLogNat2; } - inline float frsqrt(float _a) + inline float rsqrt(float _a) { - return 1.0f/fsqrt(_a); + return 1.0f/sqrt(_a); } - inline float ftrunc(float _a) + inline float trunc(float _a) { return float(int(_a) ); } - inline float ffract(float _a) + inline float fract(float _a) { - return _a - ftrunc(_a); + return _a - trunc(_a); } - inline float fmod(float _a, float _b) + inline float mod(float _a, float _b) { - return _a - _b * ffloor(_a / _b); + return _a - _b * floor(_a / _b); } - inline bool fequal(float _a, float _b, float _epsilon) + inline bool equal(float _a, float _b, float _epsilon) { // http://realtimecollisiondetection.net/blog/?p=89 - const float lhs = fabs(_a - _b); - const float rhs = _epsilon * max(1.0f, fabs(_a), fabs(_b) ); + const float lhs = abs(_a - _b); + const float rhs = _epsilon * max(1.0f, abs(_a), abs(_b) ); return lhs <= rhs; } - inline bool fequal(const float* _a, const float* _b, uint32_t _num, float _epsilon) + inline bool equal(const float* _a, const float* _b, uint32_t _num, float _epsilon) { - bool equal = fequal(_a[0], _b[0], _epsilon); - for (uint32_t ii = 1; equal && ii < _num; ++ii) + bool result = equal(_a[0], _b[0], _epsilon); + for (uint32_t ii = 1; result && ii < _num; ++ii) { - equal = fequal(_a[ii], _b[ii], _epsilon); + result = equal(_a[ii], _b[ii], _epsilon); } - return equal; - } - - inline float fwrap(float _a, float _wrap) - { - const float mod = fmod(_a, _wrap); - const float result = mod < 0.0f ? _wrap + mod : mod; return result; } - inline float fstep(float _edge, float _a) + inline float wrap(float _a, float _wrap) + { + const float tmp0 = mod(_a, _wrap); + const float result = tmp0 < 0.0f ? _wrap + tmp0 : tmp0; + return result; + } + + inline float step(float _edge, float _a) { return _a < _edge ? 0.0f : 1.0f; } - inline float fpulse(float _a, float _start, float _end) + inline float pulse(float _a, float _start, float _end) { - return fstep(_a, _start) - fstep(_a, _end); + return step(_a, _start) - step(_a, _end); } - inline float fsmoothstep(float _a) + inline float smoothStep(float _a) { - return fsq(_a)*(3.0f - 2.0f*_a); + return square(_a)*(3.0f - 2.0f*_a); } - inline float fbias(float _time, float _bias) + inline float bias(float _time, float _bias) { return _time / ( ( (1.0f/_bias - 2.0f)*(1.0f - _time) ) + 1.0f); } - inline float fgain(float _time, float _gain) + inline float gain(float _time, float _gain) { if (_time < 0.5f) { - return fbias(_time * 2.0f, _gain) * 0.5f; + return bias(_time * 2.0f, _gain) * 0.5f; } - return fbias(_time * 2.0f - 1.0f, 1.0f - _gain) * 0.5f + 0.5f; + return bias(_time * 2.0f - 1.0f, 1.0f - _gain) * 0.5f + 0.5f; } inline float angleDiff(float _a, float _b) { - const float dist = fwrap(_b - _a, kPi2); - return fwrap(dist*2.0f, kPi2) - dist; + const float dist = wrap(_b - _a, kPi2); + return wrap(dist*2.0f, kPi2) - dist; } inline float angleLerp(float _a, float _b, float _t) @@ -227,9 +227,9 @@ namespace bx inline void vec3Abs(float* _result, const float* _a) { - _result[0] = fabs(_a[0]); - _result[1] = fabs(_a[1]); - _result[2] = fabs(_a[2]); + _result[0] = abs(_a[0]); + _result[1] = abs(_a[1]); + _result[2] = abs(_a[2]); } inline void vec3Neg(float* _result, const float* _a) @@ -295,21 +295,21 @@ namespace bx inline float vec3Length(const float* _a) { - return fsqrt(vec3Dot(_a, _a) ); + return sqrt(vec3Dot(_a, _a) ); } inline void vec3Lerp(float* _result, const float* _a, const float* _b, float _t) { - _result[0] = flerp(_a[0], _b[0], _t); - _result[1] = flerp(_a[1], _b[1], _t); - _result[2] = flerp(_a[2], _b[2], _t); + _result[0] = lerp(_a[0], _b[0], _t); + _result[1] = lerp(_a[1], _b[1], _t); + _result[2] = lerp(_a[2], _b[2], _t); } inline void vec3Lerp(float* _result, const float* _a, const float* _b, const float* _c) { - _result[0] = flerp(_a[0], _b[0], _c[0]); - _result[1] = flerp(_a[1], _b[1], _c[1]); - _result[2] = flerp(_a[2], _b[2], _c[2]); + _result[0] = lerp(_a[0], _b[0], _c[0]); + _result[1] = lerp(_a[1], _b[1], _c[1]); + _result[2] = lerp(_a[2], _b[2], _c[2]); } inline float vec3Norm(float* _result, const float* _a) @@ -349,60 +349,60 @@ namespace bx const float ny = _n[1]; const float nz = _n[2]; - if (bx::fabs(nx) > bx::fabs(nz) ) + if (abs(nx) > abs(nz) ) { - float invLen = 1.0f / bx::fsqrt(nx*nx + nz*nz); + float invLen = 1.0f / sqrt(nx*nx + nz*nz); _t[0] = -nz * invLen; _t[1] = 0.0f; _t[2] = nx * invLen; } else { - float invLen = 1.0f / bx::fsqrt(ny*ny + nz*nz); + float invLen = 1.0f / sqrt(ny*ny + nz*nz); _t[0] = 0.0f; _t[1] = nz * invLen; _t[2] = -ny * invLen; } - bx::vec3Cross(_b, _n, _t); + vec3Cross(_b, _n, _t); } inline void vec3TangentFrame(const float* _n, float* _t, float* _b, float _angle) { vec3TangentFrame(_n, _t, _b); - const float sa = fsin(_angle); - const float ca = fcos(_angle); + const float sa = sin(_angle); + const float ca = cos(_angle); _t[0] = -sa * _b[0] + ca * _t[0]; _t[1] = -sa * _b[1] + ca * _t[1]; _t[2] = -sa * _b[2] + ca * _t[2]; - bx::vec3Cross(_b, _n, _t); + vec3Cross(_b, _n, _t); } inline void vec3FromLatLong(float* _vec, float _u, float _v) { - const float phi = _u * bx::kPi2; - const float theta = _v * bx::kPi; + const float phi = _u * kPi2; + const float theta = _v * kPi; - const float st = bx::fsin(theta); - const float sp = bx::fsin(phi); - const float ct = bx::fcos(theta); - const float cp = bx::fcos(phi); + const float st = sin(theta); + const float sp = sin(phi); + const float ct = cos(theta); + const float cp = cos(phi); _vec[0] = -st*sp; - _vec[1] = ct; + _vec[1] = ct; _vec[2] = -st*cp; } inline void vec3ToLatLong(float* _u, float* _v, const float* _vec) { - const float phi = bx::fatan2(_vec[0], _vec[2]); - const float theta = bx::facos(_vec[1]); + const float phi = atan2(_vec[0], _vec[2]); + const float theta = acos(_vec[1]); - *_u = (bx::kPi + phi)*bx::kInvPi*0.5f; - *_v = theta*bx::kInvPi; + *_u = (kPi + phi)*kInvPi*0.5f; + *_v = theta*kInvPi; } inline void quatIdentity(float* _result) @@ -478,7 +478,7 @@ namespace bx const float norm = quatDot(_quat, _quat); if (0.0f < norm) { - const float invNorm = 1.0f / fsqrt(norm); + const float invNorm = 1.0f / sqrt(norm); _result[0] = _quat[0] * invNorm; _result[1] = _quat[1] * invNorm; _result[2] = _quat[2] * invNorm; @@ -501,16 +501,16 @@ namespace bx const float zz = z * z; const float xx = x * x; - _result[0] = fatan2(2.0f * (x * w - y * z), 1.0f - 2.0f * (xx + zz) ); - _result[1] = fatan2(2.0f * (y * w + x * z), 1.0f - 2.0f * (yy + zz) ); - _result[2] = fasin (2.0f * (x * y + z * w) ); + _result[0] = atan2(2.0f * (x * w - y * z), 1.0f - 2.0f * (xx + zz) ); + _result[1] = atan2(2.0f * (y * w + x * z), 1.0f - 2.0f * (yy + zz) ); + _result[2] = asin (2.0f * (x * y + z * w) ); } inline void quatRotateAxis(float* _result, const float* _axis, float _angle) { const float ha = _angle * 0.5f; - const float ca = fcos(ha); - const float sa = fsin(ha); + const float ca = cos(ha); + const float sa = sin(ha); _result[0] = _axis[0] * sa; _result[1] = _axis[1] * sa; _result[2] = _axis[2] * sa; @@ -520,8 +520,8 @@ namespace bx inline void quatRotateX(float* _result, float _ax) { const float hx = _ax * 0.5f; - const float cx = fcos(hx); - const float sx = fsin(hx); + const float cx = cos(hx); + const float sx = sin(hx); _result[0] = sx; _result[1] = 0.0f; _result[2] = 0.0f; @@ -531,8 +531,8 @@ namespace bx inline void quatRotateY(float* _result, float _ay) { const float hy = _ay * 0.5f; - const float cy = fcos(hy); - const float sy = fsin(hy); + const float cy = cos(hy); + const float sy = sin(hy); _result[0] = 0.0f; _result[1] = sy; _result[2] = 0.0f; @@ -542,8 +542,8 @@ namespace bx inline void quatRotateZ(float* _result, float _az) { const float hz = _az * 0.5f; - const float cz = fcos(hz); - const float sz = fsin(hz); + const float cz = cos(hz); + const float sz = sin(hz); _result[0] = 0.0f; _result[1] = 0.0f; _result[2] = sz; @@ -712,7 +712,7 @@ namespace bx float yy = _vec[0] * _mat[ 1] + _vec[1] * _mat[5] + _vec[2] * _mat[ 9] + _mat[13]; float zz = _vec[0] * _mat[ 2] + _vec[1] * _mat[6] + _vec[2] * _mat[10] + _mat[14]; float ww = _vec[0] * _mat[ 3] + _vec[1] * _mat[7] + _vec[2] * _mat[11] + _mat[15]; - float invW = fsign(ww)/ww; + float invW = sign(ww)/ww; _result[0] = xx*invW; _result[1] = yy*invW; _result[2] = zz*invW; diff --git a/include/bx/inline/pixelformat.inl b/include/bx/inline/pixelformat.inl index 6b53805..9bc6109 100644 --- a/include/bx/inline/pixelformat.inl +++ b/include/bx/inline/pixelformat.inl @@ -11,7 +11,7 @@ namespace bx { inline uint32_t toUnorm(float _value, float _scale) { - return uint32_t(fround(clamp(_value, 0.0f, 1.0f) * _scale) ); + return uint32_t(round(clamp(_value, 0.0f, 1.0f) * _scale) ); } inline float fromUnorm(uint32_t _value, float _scale) @@ -21,7 +21,7 @@ namespace bx inline int32_t toSnorm(float _value, float _scale) { - return int32_t(fround( + return int32_t(round( clamp(_value, -1.0f, 1.0f) * _scale) ); } @@ -719,18 +719,18 @@ namespace bx const float mm = max(rr, gg, bb); union { float ff; uint32_t ui; } cast = { mm }; int32_t expShared = int32_t(uint32_imax(uint32_t(-expBias-1), ( ( (cast.ui>>23) & 0xff) - 127) ) ) + 1 + expBias; - float denom = fpow(2.0f, float(expShared - expBias - MantissaBits) ); + float denom = pow(2.0f, float(expShared - expBias - MantissaBits) ); - if ( (1< @@ -74,10 +74,10 @@ namespace bx { const float rand0 = frnd(_rng) * 2.0f - 1.0f; const float rand1 = frnd(_rng) * kPi2; - const float sqrtf1 = fsqrt(1.0f - rand0*rand0); + const float sqrtf1 = sqrt(1.0f - rand0*rand0); - _result[0] = sqrtf1 * fcos(rand1); - _result[1] = sqrtf1 * fsin(rand1); + _result[0] = sqrtf1 * cos(rand1); + _result[1] = sqrtf1 * sin(rand1); _result[2] = rand0; } @@ -122,13 +122,13 @@ namespace bx const float phi = (ii + 0.5f) / _num; const float phirad = phi * kPi2; - const float st = fsqrt(1.0f-tt*tt) * _scale; + const float st = sqrt(1.0f-tt*tt) * _scale; float* xyz = (float*)data; data += _stride; - xyz[0] = st * fcos(phirad); - xyz[1] = st * fsin(phirad); + xyz[0] = st * cos(phirad); + xyz[1] = st * sin(phirad); xyz[2] = tt * _scale; } } diff --git a/include/bx/inline/simd128_ref.inl b/include/bx/inline/simd128_ref.inl index f9aff98..0fa28d4 100644 --- a/include/bx/inline/simd128_ref.inl +++ b/include/bx/inline/simd128_ref.inl @@ -364,10 +364,10 @@ BX_SIMD128_IMPLEMENT_TEST(xyzw , 0xf); BX_SIMD_FORCE_INLINE simd128_ref_t simd_sqrt(simd128_ref_t _a) { simd128_ref_t result; - result.fxyzw[0] = fsqrt(_a.fxyzw[0]); - result.fxyzw[1] = fsqrt(_a.fxyzw[1]); - result.fxyzw[2] = fsqrt(_a.fxyzw[2]); - result.fxyzw[3] = fsqrt(_a.fxyzw[3]); + result.fxyzw[0] = sqrt(_a.fxyzw[0]); + result.fxyzw[1] = sqrt(_a.fxyzw[1]); + result.fxyzw[2] = sqrt(_a.fxyzw[2]); + result.fxyzw[3] = sqrt(_a.fxyzw[3]); return result; } @@ -375,10 +375,10 @@ BX_SIMD128_IMPLEMENT_TEST(xyzw , 0xf); BX_SIMD_FORCE_INLINE simd128_ref_t simd_rsqrt_est(simd128_ref_t _a) { simd128_ref_t result; - result.fxyzw[0] = 1.0f / fsqrt(_a.fxyzw[0]); - result.fxyzw[1] = 1.0f / fsqrt(_a.fxyzw[1]); - result.fxyzw[2] = 1.0f / fsqrt(_a.fxyzw[2]); - result.fxyzw[3] = 1.0f / fsqrt(_a.fxyzw[3]); + result.fxyzw[0] = rsqrt(_a.fxyzw[0]); + result.fxyzw[1] = rsqrt(_a.fxyzw[1]); + result.fxyzw[2] = rsqrt(_a.fxyzw[2]); + result.fxyzw[3] = rsqrt(_a.fxyzw[3]); return result; } diff --git a/include/bx/math.h b/include/bx/math.h index 1883f38..718abd0 100644 --- a/include/bx/math.h +++ b/include/bx/math.h @@ -84,98 +84,98 @@ namespace bx bool isInfinite(double _f); /// - float ffloor(float _f); + float floor(float _f); /// - float fceil(float _f); + float ceil(float _f); /// - float fround(float _f); + float round(float _f); /// - float flerp(float _a, float _b, float _t); + float lerp(float _a, float _b, float _t); /// - float fsign(float _a); + float sign(float _a); /// - float fabs(float _a); + float abs(float _a); /// - float fsq(float _a); + float square(float _a); /// - float fsin(float _a); + float sin(float _a); /// - float fasin(float _a); + float asin(float _a); /// - float fcos(float _a); + float cos(float _a); /// - float ftan(float _a); + float tan(float _a); /// - float facos(float _a); + float acos(float _a); /// - float fatan2(float _y, float _x); + float atan2(float _y, float _x); /// - float fpow(float _a, float _b); + float pow(float _a, float _b); /// - float fexp2(float _a); + float exp2(float _a); /// - float flog(float _a); + float log(float _a); /// - float flog2(float _a); + float log2(float _a); /// - float fsqrt(float _a); + float sqrt(float _a); /// - float frsqrt(float _a); + float rsqrt(float _a); /// - float ftrunc(float _a); + float trunc(float _a); /// - float ffract(float _a); + float fract(float _a); /// - float fmod(float _a, float _b); + float mod(float _a, float _b); /// - bool fequal(float _a, float _b, float _epsilon); + bool equal(float _a, float _b, float _epsilon); /// - bool fequal(const float* _a, const float* _b, uint32_t _num, float _epsilon); + bool equal(const float* _a, const float* _b, uint32_t _num, float _epsilon); /// - float fwrap(float _a, float _wrap); + float wrap(float _a, float _wrap); /// - float fstep(float _edge, float _a); + float step(float _edge, float _a); /// - float fpulse(float _a, float _start, float _end); + float pulse(float _a, float _start, float _end); /// - float fsmoothstep(float _a); + float smoothStep(float _a); // References: // - Bias And Gain Are Your Friend // http://blog.demofox.org/2012/09/24/bias-and-gain-are-your-friend/ // - http://demofox.org/biasgain.html /// - float fbias(float _time, float _bias); + float bias(float _time, float _bias); /// - float fgain(float _time, float _gain); + float gain(float _time, float _gain); /// float angleDiff(float _a, float _b); diff --git a/src/math.cpp b/src/math.cpp index 2c402ec..7cfc47e 100644 --- a/src/math.cpp +++ b/src/math.cpp @@ -22,56 +22,56 @@ namespace bx const float kHuge = HUGE_VALF; #endif // BX_COMPILER_MSVC - float fsin(float _a) + float sin(float _a) { return ::sinf(_a); } - float fasin(float _a) + float asin(float _a) { return ::asinf(_a); } - float fcos(float _a) + float cos(float _a) { return ::cosf(_a); } - float ftan(float _a) + float tan(float _a) { return ::tanf(_a); } - float facos(float _a) + float acos(float _a) { return ::acosf(_a); } - float fatan2(float _y, float _x) + float atan2(float _y, float _x) { return ::atan2f(_y, _x); } - float fpow(float _a, float _b) + float pow(float _a, float _b) { return ::powf(_a, _b); } - float flog(float _a) + float log(float _a) { return ::logf(_a); } - float fsqrt(float _a) + float sqrt(float _a) { return ::sqrtf(_a); } - float ffloor(float _a) + float floor(float _a) { if (_a < 0.0f) { - const float fr = ffract(-_a); + const float fr = fract(-_a); float result = -_a - fr; return -(0.0f != fr @@ -80,7 +80,7 @@ namespace bx ; } - return _a - ffract(_a); + return _a - fract(_a); } void mtxLookAtImpl(float* _result, const float* _eye, const float* _view, const float* _up) @@ -185,7 +185,7 @@ namespace bx template void mtxProjImpl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc) { - const float height = 1.0f/ftan(toRad(_fovy)*0.5f); + const float height = 1.0f/tan(toRad(_fovy)*0.5f); const float width = height * 1.0f/_aspect; mtxProjXYWH(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc); } @@ -282,7 +282,7 @@ namespace bx template void mtxProjInfImpl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc) { - const float height = 1.0f/ftan(toRad(_fovy)*0.5f); + const float height = 1.0f/tan(toRad(_fovy)*0.5f); const float width = height * 1.0f/_aspect; mtxProjInfXYWH(_result, 0.0f, 0.0f, width, height, _near, _oglNdc); } @@ -402,8 +402,8 @@ namespace bx void mtxRotateX(float* _result, float _ax) { - const float sx = fsin(_ax); - const float cx = fcos(_ax); + const float sx = sin(_ax); + const float cx = cos(_ax); memSet(_result, 0, sizeof(float)*16); _result[ 0] = 1.0f; @@ -416,8 +416,8 @@ namespace bx void mtxRotateY(float* _result, float _ay) { - const float sy = fsin(_ay); - const float cy = fcos(_ay); + const float sy = sin(_ay); + const float cy = cos(_ay); memSet(_result, 0, sizeof(float)*16); _result[ 0] = cy; @@ -430,8 +430,8 @@ namespace bx void mtxRotateZ(float* _result, float _az) { - const float sz = fsin(_az); - const float cz = fcos(_az); + const float sz = sin(_az); + const float cz = cos(_az); memSet(_result, 0, sizeof(float)*16); _result[ 0] = cz; @@ -444,10 +444,10 @@ namespace bx void mtxRotateXY(float* _result, float _ax, float _ay) { - const float sx = fsin(_ax); - const float cx = fcos(_ax); - const float sy = fsin(_ay); - const float cy = fcos(_ay); + const float sx = sin(_ax); + const float cx = cos(_ax); + const float sy = sin(_ay); + const float cy = cos(_ay); memSet(_result, 0, sizeof(float)*16); _result[ 0] = cy; @@ -463,12 +463,12 @@ namespace bx void mtxRotateXYZ(float* _result, float _ax, float _ay, float _az) { - const float sx = fsin(_ax); - const float cx = fcos(_ax); - const float sy = fsin(_ay); - const float cy = fcos(_ay); - const float sz = fsin(_az); - const float cz = fcos(_az); + const float sx = sin(_ax); + const float cx = cos(_ax); + const float sy = sin(_ay); + const float cy = cos(_ay); + const float sz = sin(_az); + const float cz = cos(_az); memSet(_result, 0, sizeof(float)*16); _result[ 0] = cy*cz; @@ -485,12 +485,12 @@ namespace bx void mtxRotateZYX(float* _result, float _ax, float _ay, float _az) { - const float sx = fsin(_ax); - const float cx = fcos(_ax); - const float sy = fsin(_ay); - const float cy = fcos(_ay); - const float sz = fsin(_az); - const float cz = fcos(_az); + const float sx = sin(_ax); + const float cx = cos(_ax); + const float sy = sin(_ay); + const float cy = cos(_ay); + const float sz = sin(_az); + const float cz = cos(_az); memSet(_result, 0, sizeof(float)*16); _result[ 0] = cy*cz; @@ -507,12 +507,12 @@ namespace bx void mtxSRT(float* _result, float _sx, float _sy, float _sz, float _ax, float _ay, float _az, float _tx, float _ty, float _tz) { - const float sx = fsin(_ax); - const float cx = fcos(_ax); - const float sy = fsin(_ay); - const float cy = fcos(_ay); - const float sz = fsin(_az); - const float cz = fcos(_az); + const float sx = sin(_ax); + const float cx = cos(_ax); + const float sy = sin(_ay); + const float cy = cos(_ay); + const float sz = sin(_az); + const float cz = cos(_az); const float sxsz = sx*sz; const float cycz = cy*cz; @@ -700,24 +700,24 @@ namespace bx const float gg = _rgb[1]; const float bb = _rgb[2]; - const float s0 = fstep(bb, gg); + const float s0 = step(bb, gg); - const float px = flerp(bb, gg, s0); - const float py = flerp(gg, bb, s0); - const float pz = flerp(-1.0f, 0.0f, s0); - const float pw = flerp(2.0f/3.0f, -1.0f/3.0f, s0); + const float px = lerp(bb, gg, s0); + const float py = lerp(gg, bb, s0); + const float pz = lerp(-1.0f, 0.0f, s0); + const float pw = lerp(2.0f/3.0f, -1.0f/3.0f, s0); - const float s1 = fstep(px, rr); + const float s1 = step(px, rr); - const float qx = flerp(px, rr, s1); + const float qx = lerp(px, rr, s1); const float qy = py; - const float qz = flerp(pw, pz, s1); - const float qw = flerp(rr, px, s1); + const float qz = lerp(pw, pz, s1); + const float qw = lerp(rr, px, s1); const float dd = qx - min(qw, qy); const float ee = 1.0e-10f; - _hsv[0] = fabs(qz + (qw - qy) / (6.0f * dd + ee) ); + _hsv[0] = abs(qz + (qw - qy) / (6.0f * dd + ee) ); _hsv[1] = dd / (qx + ee); _hsv[2] = qx; } @@ -728,13 +728,13 @@ namespace bx const float ss = _hsv[1]; const float vv = _hsv[2]; - const float px = fabs(ffract(hh + 1.0f ) * 6.0f - 3.0f); - const float py = fabs(ffract(hh + 2.0f/3.0f) * 6.0f - 3.0f); - const float pz = fabs(ffract(hh + 1.0f/3.0f) * 6.0f - 3.0f); + const float px = abs(fract(hh + 1.0f ) * 6.0f - 3.0f); + const float py = abs(fract(hh + 2.0f/3.0f) * 6.0f - 3.0f); + const float pz = abs(fract(hh + 1.0f/3.0f) * 6.0f - 3.0f); - _rgb[0] = vv * flerp(1.0f, clamp(px - 1.0f, 0.0f, 1.0f), ss); - _rgb[1] = vv * flerp(1.0f, clamp(py - 1.0f, 0.0f, 1.0f), ss); - _rgb[2] = vv * flerp(1.0f, clamp(pz - 1.0f, 0.0f, 1.0f), ss); + _rgb[0] = vv * lerp(1.0f, clamp(px - 1.0f, 0.0f, 1.0f), ss); + _rgb[1] = vv * lerp(1.0f, clamp(py - 1.0f, 0.0f, 1.0f), ss); + _rgb[2] = vv * lerp(1.0f, clamp(pz - 1.0f, 0.0f, 1.0f), ss); } } // namespace bx diff --git a/tests/math_test.cpp b/tests/math_test.cpp index 7fa7bc5..8596425 100644 --- a/tests/math_test.cpp +++ b/tests/math_test.cpp @@ -23,7 +23,7 @@ TEST_CASE("isFinite, isInfinite, isNan", "") bool flog2_test(float _a) { - return bx::flog2(_a) == bx::flog(_a) * (1.0f / bx::flog(2.0f) ); + return bx::log2(_a) == bx::log(_a) * (1.0f / bx::log(2.0f) ); } TEST_CASE("flog2", "") @@ -35,23 +35,23 @@ TEST_CASE("flog2", "") TEST_CASE("libm", "") { - REQUIRE(1389.0f == bx::fabs(-1389.0f) ); - REQUIRE(1389.0f == bx::fabs( 1389.0f) ); - REQUIRE( 0.0f == bx::fabs(-0.0f) ); - REQUIRE( 0.0f == bx::fabs( 0.0f) ); + REQUIRE(1389.0f == bx::abs(-1389.0f) ); + REQUIRE(1389.0f == bx::abs( 1389.0f) ); + REQUIRE( 0.0f == bx::abs(-0.0f) ); + REQUIRE( 0.0f == bx::abs( 0.0f) ); - REQUIRE(389.0f == bx::fmod(1389.0f, 1000.0f) ); - REQUIRE(bx::isNan(bx::fmod(0.0f, 0.0f) ) ); + REQUIRE(389.0f == bx::mod(1389.0f, 1000.0f) ); + REQUIRE(bx::isNan(bx::mod(0.0f, 0.0f) ) ); - REQUIRE( 13.0f == bx::ffloor( 13.89f) ); - REQUIRE(-14.0f == bx::ffloor(-13.89f) ); - REQUIRE( 14.0f == bx::fceil( 13.89f) ); - REQUIRE(-13.0f == bx::fceil( -13.89f) ); + REQUIRE( 13.0f == bx::floor( 13.89f) ); + REQUIRE(-14.0f == bx::floor(-13.89f) ); + REQUIRE( 14.0f == bx::ceil( 13.89f) ); + REQUIRE(-13.0f == bx::ceil( -13.89f) ); - REQUIRE( 13.0f == bx::ftrunc( 13.89f) ); - REQUIRE(-13.0f == bx::ftrunc(-13.89f) ); - REQUIRE(bx::fequal( 0.89f, bx::ffract( 13.89f), 0.000001f) ); - REQUIRE(bx::fequal(-0.89f, bx::ffract(-13.89f), 0.000001f) ); + REQUIRE( 13.0f == bx::trunc( 13.89f) ); + REQUIRE(-13.0f == bx::trunc(-13.89f) ); + REQUIRE(bx::equal( 0.89f, bx::fract( 13.89f), 0.000001f) ); + REQUIRE(bx::equal(-0.89f, bx::fract(-13.89f), 0.000001f) ); } TEST_CASE("ToBits", "") @@ -62,7 +62,7 @@ TEST_CASE("ToBits", "") void mtxCheck(const float* _a, const float* _b) { - if (!bx::fequal(_a, _b, 16, 0.01f) ) + if (!bx::equal(_a, _b, 16, 0.01f) ) { DBG("\n" "A:\n" @@ -110,7 +110,7 @@ TEST_CASE("quaternion", "") float euler[3]; bx::quatToEuler(euler, quat); - CHECK(bx::fequal(euler[0], ax, 0.001f) ); + CHECK(bx::equal(euler[0], ax, 0.001f) ); bx::quatRotateY(quat, ay); bx::mtxQuat(mtxQ, quat); @@ -118,7 +118,7 @@ TEST_CASE("quaternion", "") mtxCheck(mtxQ, mtx); bx::quatToEuler(euler, quat); - CHECK(bx::fequal(euler[1], ay, 0.001f) ); + CHECK(bx::equal(euler[1], ay, 0.001f) ); bx::quatRotateZ(quat, az); bx::mtxQuat(mtxQ, quat); @@ -126,5 +126,5 @@ TEST_CASE("quaternion", "") mtxCheck(mtxQ, mtx); bx::quatToEuler(euler, quat); - CHECK(bx::fequal(euler[2], az, 0.001f) ); + CHECK(bx::equal(euler[2], az, 0.001f) ); } diff --git a/tests/simd_bench.cpp b/tests/simd_bench.cpp index ab71871..38ba407 100644 --- a/tests/simd_bench.cpp +++ b/tests/simd_bench.cpp @@ -121,10 +121,10 @@ void simd_bench() for (uint32_t ii = 0; ii < numVertices; ++ii) { float* ptr = (float*)&src[ii]; - ptr[0] = bx::fabs(ptr[0]); - ptr[1] = bx::fabs(ptr[1]); - ptr[2] = bx::fabs(ptr[2]); - ptr[3] = bx::fabs(ptr[3]); + ptr[0] = bx::abs(ptr[0]); + ptr[1] = bx::abs(ptr[1]); + ptr[2] = bx::abs(ptr[2]); + ptr[3] = bx::abs(ptr[3]); } simd_bench_pass(dst, src, numVertices); diff --git a/tests/simd_test.cpp b/tests/simd_test.cpp index 1684f3e..3a211ca 100644 --- a/tests/simd_test.cpp +++ b/tests/simd_test.cpp @@ -162,10 +162,10 @@ void simd_check_float( , _0, _1, _2, _3 ); - CHECK(bx::fequal(c.f[0], _0, 0.0001f) ); - CHECK(bx::fequal(c.f[1], _1, 0.0001f) ); - CHECK(bx::fequal(c.f[2], _2, 0.0001f) ); - CHECK(bx::fequal(c.f[3], _3, 0.0001f) ); + CHECK(bx::equal(c.f[0], _0, 0.0001f) ); + CHECK(bx::equal(c.f[1], _1, 0.0001f) ); + CHECK(bx::equal(c.f[2], _2, 0.0001f) ); + CHECK(bx::equal(c.f[3], _3, 0.0001f) ); } void simd_check_float( @@ -189,14 +189,14 @@ void simd_check_float( , _0, _1, _2, _3, _4, _5, _6, _7 ); - CHECK(bx::fequal(c.f[0], _0, 0.0001f) ); - CHECK(bx::fequal(c.f[1], _1, 0.0001f) ); - CHECK(bx::fequal(c.f[2], _2, 0.0001f) ); - CHECK(bx::fequal(c.f[3], _3, 0.0001f) ); - CHECK(bx::fequal(c.f[4], _4, 0.0001f) ); - CHECK(bx::fequal(c.f[5], _5, 0.0001f) ); - CHECK(bx::fequal(c.f[6], _6, 0.0001f) ); - CHECK(bx::fequal(c.f[7], _7, 0.0001f) ); + CHECK(bx::equal(c.f[0], _0, 0.0001f) ); + CHECK(bx::equal(c.f[1], _1, 0.0001f) ); + CHECK(bx::equal(c.f[2], _2, 0.0001f) ); + CHECK(bx::equal(c.f[3], _3, 0.0001f) ); + CHECK(bx::equal(c.f[4], _4, 0.0001f) ); + CHECK(bx::equal(c.f[5], _5, 0.0001f) ); + CHECK(bx::equal(c.f[6], _6, 0.0001f) ); + CHECK(bx::equal(c.f[7], _7, 0.0001f) ); } void simd_check_string(const char* _str, bx::simd128_t _a)