From 4557c820a6157fb8c9cd07bb6ee99912145354b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 26 Mar 2016 19:19:15 -0700 Subject: [PATCH] Cleanup. --- include/bx/fpumath.h | 82 ++++++++++++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/include/bx/fpumath.h b/include/bx/fpumath.h index e88ad6a..7371f69 100644 --- a/include/bx/fpumath.h +++ b/include/bx/fpumath.h @@ -635,12 +635,12 @@ namespace bx { enum Enum { - RightHanded = false, - LeftHanded = true, + RightHanded, + LeftHanded, }; }; - template + template inline void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc = false) { const float diff = _far-_near; @@ -657,7 +657,7 @@ namespace bx _result[14] = -bb; } - template + template inline void mtxProj_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false) { const float invDiffRl = 1.0f/(_rt - _lt); @@ -669,20 +669,12 @@ namespace bx mtxProjXYWH(_result, xx, yy, width, height, _near, _far, _oglNdc); } - template + template inline void mtxProj_impl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false) { mtxProj_impl(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc); } - template - inline void mtxProj_impl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false) - { - const float height = 1.0f/tanf(toRad(_fovy)*0.5f); - const float width = height * 1.0f/_aspect; - mtxProjXYWH(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc); - } - inline void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false) { mtxProj_impl(_result, _fov, _near, _far, _oglNdc); @@ -698,6 +690,14 @@ namespace bx mtxProj_impl(_result, _fov, _near, _far, _oglNdc); } + template + inline void mtxProj_impl(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false) + { + const float height = 1.0f/tanf(toRad(_fovy)*0.5f); + const float width = height * 1.0f/_aspect; + mtxProjXYWH(_result, 0.0f, 0.0f, width, height, _near, _far, _oglNdc); + } + inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false) { mtxProj_impl(_result, _fovy, _aspect, _near, _far, _oglNdc); @@ -722,7 +722,7 @@ namespace bx }; }; - template + template inline void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _oglNdc = false) { float aa; @@ -748,7 +748,7 @@ namespace bx _result[14] = -bb; } - template + template inline void mtxProjInf_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false) { const float invDiffRl = 1.0f/(_rt - _lt); @@ -760,13 +760,28 @@ namespace bx mtxProjInfXYWH(_result, xx, yy, width, height, _near, _oglNdc); } - template + template inline void mtxProjInf_impl(float* _result, const float _fov[4], float _near, bool _oglNdc = false) { mtxProjInf_impl(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc); } - template + inline void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc = false) + { + mtxProjInf_impl(_result, _fov, _near, _oglNdc); + } + + inline void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false) + { + mtxProjInf_impl(_result, _fov, _near, _oglNdc); + } + + inline void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false) + { + mtxProjInf_impl(_result, _fov, _near, _oglNdc); + } + + template inline void mtxProjInf_impl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false) { const float height = 1.0f/tanf(toRad(_fovy)*0.5f); @@ -774,13 +789,17 @@ namespace bx mtxProjInfXYWH(_result, 0.0f, 0.0f, width, height, _near, _oglNdc); } - #define mtxProjInf mtxProjInf_impl - #define mtxProjInfLh mtxProjInf_impl - #define mtxProjInfRh mtxProjInf_impl - #define mtxProjRevInfLh mtxProjInf_impl - #define mtxProjRevInfRh mtxProjInf_impl + inline void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false) + { + mtxProjInf_impl(_result, _fovy, _aspect, _near, _oglNdc); + } - template + inline void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false) + { + mtxProjInf_impl(_result, _fovy, _aspect, _near, _oglNdc); + } + + template inline void mtxOrtho_impl(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false) { const float aa = 2.0f/(_right - _left); @@ -800,9 +819,20 @@ namespace bx _result[15] = 1.0f; } - #define mtxOrtho mtxOrtho_impl - #define mtxOrthoLh mtxOrtho_impl - #define mtxOrthoRh mtxOrtho_impl + inline void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false) + { + mtxOrtho_impl(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc); + } + + inline void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false) + { + mtxOrtho_impl(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc); + } + + inline void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false) + { + mtxOrtho_impl(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc); + } inline void mtxRotateX(float* _result, float _ax) {