From 257316ab01d597ccc5cf39901d171605e1e87489 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 5 Dec 2018 18:19:14 -0800 Subject: [PATCH] Cleanup. --- include/bx/inline/math.inl | 22 +++++++++++++++++++--- include/bx/math.h | 8 +++----- src/math.cpp | 16 ---------------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/include/bx/inline/math.inl b/include/bx/inline/math.inl index 3e3814f..c3f6d1e 100644 --- a/include/bx/inline/math.inl +++ b/include/bx/inline/math.inl @@ -95,16 +95,32 @@ namespace bx return tmp == UINT64_C(0x7ff0000000000000); } - inline BX_CONST_FUNC float round(float _f) + inline BX_CONSTEXPR_FUNC float floor(float _a) { - return floor(_f + 0.5f); + if (_a < 0.0f) + { + const float fr = fract(-_a); + const float result = -_a - fr; + + return -(0.0f != fr + ? result + 1.0f + : result) + ; + } + + return _a - fract(_a); } - inline BX_CONST_FUNC float ceil(float _a) + inline BX_CONSTEXPR_FUNC float ceil(float _a) { return -floor(-_a); } + inline BX_CONSTEXPR_FUNC float round(float _f) + { + return floor(_f + 0.5f); + } + inline BX_CONSTEXPR_FUNC float lerp(float _a, float _b, float _t) { return _a + (_b - _a) * _t; diff --git a/include/bx/math.h b/include/bx/math.h index 075cb5f..f373f97 100644 --- a/include/bx/math.h +++ b/include/bx/math.h @@ -3,8 +3,6 @@ * License: https://github.com/bkaradzic/bx#license-bsd-2-clause */ -// FPU math lib - #ifndef BX_MATH_H_HEADER_GUARD #define BX_MATH_H_HEADER_GUARD @@ -112,15 +110,15 @@ namespace bx /// Returns the largest integer value not greater than _f. /// - BX_CONST_FUNC float floor(float _f); + BX_CONSTEXPR_FUNC float floor(float _f); /// Returns the smallest integer value not less than _f. /// - BX_CONST_FUNC float ceil(float _f); + BX_CONSTEXPR_FUNC float ceil(float _f); /// Returns the nearest integer value to _f, rounding halfway cases away from zero, /// - BX_CONST_FUNC float round(float _f); + BX_CONSTEXPR_FUNC float round(float _f); /// Returns linear interpolation between two values _a and _b. /// diff --git a/src/math.cpp b/src/math.cpp index ba0676e..5a31633 100644 --- a/src/math.cpp +++ b/src/math.cpp @@ -239,22 +239,6 @@ namespace bx return result; } - BX_CONST_FUNC float floor(float _a) - { - if (_a < 0.0f) - { - const float fr = fract(-_a); - const float result = -_a - fr; - - return -(0.0f != fr - ? result + 1.0f - : result) - ; - } - - return _a - fract(_a); - } - static void mtxLookAtImpl(float* _result, const Vec3& _eye, const Vec3& _view, const Vec3& _up) { const Vec3 uxv = cross(_up, _view);