From 4ebbb4e1247f33ae7a1763bd2f2864956a130a69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Mon, 12 Jun 2017 22:43:23 -0700 Subject: [PATCH] Cleanup. --- include/bx/fpumath.h | 54 ++++++++--------- include/bx/inline/fpumath.inl | 109 +++++++++++++++++----------------- 2 files changed, 83 insertions(+), 80 deletions(-) diff --git a/include/bx/fpumath.h b/include/bx/fpumath.h index 3f5c57f..cac7105 100644 --- a/include/bx/fpumath.h +++ b/include/bx/fpumath.h @@ -332,85 +332,85 @@ namespace bx void mtxLookAt(float* _result, const float* _eye, const float* _at, const float* _up = NULL); /// - void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false); + void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc); /// - void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false); + void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc); /// - void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false); + void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc); /// - void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false); + void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc); /// - void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false); + void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc); /// - void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false); + void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc); /// - void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc = false); + void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc); /// - void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc = false); + void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc); /// - void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc = false); + void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc); /// - void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc = false); + void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc); /// - void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false); + void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc); /// - void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false); + void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc); /// - void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false); + void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc); /// - void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false); + void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc); /// - void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false); + void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc); /// - void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false); + void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc); /// - void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false); + void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc); /// - void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false); + void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc); /// - void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false); + void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc); /// - void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc = false); + void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc); /// - void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false); + void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc); /// - void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc = false); + void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc); /// - void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc = false); + void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc); /// - void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc = false); + void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc); /// - void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false); + void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc); /// - void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false); + void mtxOrthoLh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc); /// - void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset = 0.0f, bool _oglNdc = false); + void mtxOrthoRh(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc); /// void mtxRotateX(float* _result, float _ax); diff --git a/include/bx/inline/fpumath.inl b/include/bx/inline/fpumath.inl index 6dc8a62..98f5c0a 100644 --- a/include/bx/inline/fpumath.inl +++ b/include/bx/inline/fpumath.inl @@ -667,7 +667,7 @@ namespace bx mtxQuatTranslation(_result, quat, _translation); } - inline void mtxLookAt_Impl(float* _result, const float* _eye, const float* _view, const float* _up) + inline void mtxLookAtImpl(float* _result, const float* _eye, const float* _view, const float* _up) { float up[3] = { 0.0f, 1.0f, 0.0f }; if (NULL != _up) @@ -712,7 +712,7 @@ namespace bx float view[4]; vec3Norm(view, tmp); - mtxLookAt_Impl(_result, _eye, view, _up); + mtxLookAtImpl(_result, _eye, view, _up); } inline void mtxLookAtRh(float* _result, const float* _eye, const float* _at, const float* _up) @@ -723,7 +723,7 @@ namespace bx float view[4]; vec3Norm(view, tmp); - mtxLookAt_Impl(_result, _eye, view, _up); + mtxLookAtImpl(_result, _eye, view, _up); } inline void mtxLookAt(float* _result, const float* _eye, const float* _at, const float* _up) @@ -731,12 +731,12 @@ namespace bx mtxLookAtLh(_result, _eye, _at, _up); } - template + template inline void mtxProjXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, float _far, bool _oglNdc) { const float diff = _far-_near; - const float aa = _oglNdc ? (_far+_near)/diff : _far/diff; - const float bb = _oglNdc ? (2.0f*_far*_near)/diff : _near*aa; + const float aa = _oglNdc ? ( _far+_near)/diff : _far/diff; + const float bb = _oglNdc ? (2.0f*_far*_near)/diff : _near*aa; memSet(_result, 0, sizeof(float)*16); _result[ 0] = _width; @@ -748,8 +748,8 @@ namespace bx _result[14] = -bb; } - template - inline void mtxProj_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc) + template + inline void mtxProjImpl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc) { const float invDiffRl = 1.0f/(_rt - _lt); const float invDiffUd = 1.0f/(_ut - _dt); @@ -760,14 +760,14 @@ namespace bx mtxProjXYWH(_result, xx, yy, width, height, _near, _far, _oglNdc); } - template - inline void mtxProj_impl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc) + template + inline void mtxProjImpl(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc) { - mtxProj_impl(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _far, _oglNdc); + mtxProjImpl(_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) + template + inline 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 width = height * 1.0f/_aspect; @@ -776,50 +776,50 @@ namespace bx inline void mtxProj(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc) { - mtxProj_impl(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc); + mtxProjImpl(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc); } inline void mtxProj(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc) { - mtxProj_impl(_result, _fov, _near, _far, _oglNdc); + mtxProjImpl(_result, _fov, _near, _far, _oglNdc); } inline void mtxProj(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc) { - mtxProj_impl(_result, _fovy, _aspect, _near, _far, _oglNdc); + mtxProjImpl(_result, _fovy, _aspect, _near, _far, _oglNdc); } inline void mtxProjLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc) { - mtxProj_impl(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc); + mtxProjImpl(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc); } inline void mtxProjLh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc) { - mtxProj_impl(_result, _fov, _near, _far, _oglNdc); + mtxProjImpl(_result, _fov, _near, _far, _oglNdc); } inline void mtxProjLh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc) { - mtxProj_impl(_result, _fovy, _aspect, _near, _far, _oglNdc); + mtxProjImpl(_result, _fovy, _aspect, _near, _far, _oglNdc); } inline void mtxProjRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, float _far, bool _oglNdc) { - mtxProj_impl(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc); + mtxProjImpl(_result, _ut, _dt, _lt, _rt, _near, _far, _oglNdc); } inline void mtxProjRh(float* _result, const float _fov[4], float _near, float _far, bool _oglNdc) { - mtxProj_impl(_result, _fov, _near, _far, _oglNdc); + mtxProjImpl(_result, _fov, _near, _far, _oglNdc); } inline void mtxProjRh(float* _result, float _fovy, float _aspect, float _near, float _far, bool _oglNdc) { - mtxProj_impl(_result, _fovy, _aspect, _near, _far, _oglNdc); + mtxProjImpl(_result, _fovy, _aspect, _near, _far, _oglNdc); } - template + template inline void mtxProjInfXYWH(float* _result, float _x, float _y, float _width, float _height, float _near, bool _oglNdc) { float aa; @@ -845,8 +845,8 @@ namespace bx _result[14] = -bb; } - template - inline void mtxProjInf_impl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc) + template + inline void mtxProjInfImpl(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc) { const float invDiffRl = 1.0f/(_rt - _lt); const float invDiffUd = 1.0f/(_ut - _dt); @@ -857,14 +857,14 @@ namespace bx mtxProjInfXYWH(_result, xx, yy, width, height, _near, _oglNdc); } - template - inline void mtxProjInf_impl(float* _result, const float _fov[4], float _near, bool _oglNdc) + template + inline void mtxProjInfImpl(float* _result, const float _fov[4], float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc); + mtxProjInfImpl(_result, _fov[0], _fov[1], _fov[2], _fov[3], _near, _oglNdc); } - template - inline void mtxProjInf_impl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc) + template + inline void mtxProjInfImpl(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc) { const float height = 1.0f/ftan(toRad(_fovy)*0.5f); const float width = height * 1.0f/_aspect; @@ -873,88 +873,91 @@ namespace bx inline void mtxProjInf(float* _result, const float _fov[4], float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fov, _near, _oglNdc); + mtxProjInfImpl(_result, _fov, _near, _oglNdc); } inline void mtxProjInf(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _ut, _dt, _lt, _rt, _near, _oglNdc); + mtxProjInfImpl(_result, _ut, _dt, _lt, _rt, _near, _oglNdc); } inline void mtxProjInf(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fovy, _aspect, _near, _oglNdc); + mtxProjInfImpl(_result, _fovy, _aspect, _near, _oglNdc); } inline void mtxProjInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _ut, _dt, _lt, _rt, _near, _oglNdc); + mtxProjInfImpl(_result, _ut, _dt, _lt, _rt, _near, _oglNdc); } inline void mtxProjInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fov, _near, _oglNdc); + mtxProjInfImpl(_result, _fov, _near, _oglNdc); } inline void mtxProjInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fovy, _aspect, _near, _oglNdc); + mtxProjInfImpl(_result, _fovy, _aspect, _near, _oglNdc); } inline void mtxProjInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _ut, _dt, _lt, _rt, _near, _oglNdc); + mtxProjInfImpl(_result, _ut, _dt, _lt, _rt, _near, _oglNdc); } inline void mtxProjInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fov, _near, _oglNdc); + mtxProjInfImpl(_result, _fov, _near, _oglNdc); } inline void mtxProjInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fovy, _aspect, _near, _oglNdc); + mtxProjInfImpl(_result, _fovy, _aspect, _near, _oglNdc); } inline void mtxProjRevInfLh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _ut, _dt, _lt, _rt, _near, _oglNdc); + mtxProjInfImpl(_result, _ut, _dt, _lt, _rt, _near, _oglNdc); } inline void mtxProjRevInfLh(float* _result, const float _fov[4], float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fov, _near, _oglNdc); + mtxProjInfImpl(_result, _fov, _near, _oglNdc); } inline void mtxProjRevInfLh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fovy, _aspect, _near, _oglNdc); + mtxProjInfImpl(_result, _fovy, _aspect, _near, _oglNdc); } inline void mtxProjRevInfRh(float* _result, float _ut, float _dt, float _lt, float _rt, float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _ut, _dt, _lt, _rt, _near, _oglNdc); + mtxProjInfImpl(_result, _ut, _dt, _lt, _rt, _near, _oglNdc); } inline void mtxProjRevInfRh(float* _result, const float _fov[4], float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fov, _near, _oglNdc); + mtxProjInfImpl(_result, _fov, _near, _oglNdc); } inline void mtxProjRevInfRh(float* _result, float _fovy, float _aspect, float _near, bool _oglNdc) { - mtxProjInf_impl(_result, _fovy, _aspect, _near, _oglNdc); + mtxProjInfImpl(_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, bool _oglNdc) + template + inline void mtxOrthoImpl(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc) { const float aa = 2.0f/(_right - _left); const float bb = 2.0f/(_top - _bottom); const float cc = (_oglNdc ? 2.0f : 1.0f) / (_far - _near); - const float dd = (_left + _right)/(_left - _right); - const float ee = (_top + _bottom)/(_bottom - _top); - const float ff = _oglNdc ? (_near + _far)/(_near - _far) : _near/(_near - _far); + const float dd = (_left + _right )/(_left - _right); + const float ee = (_top + _bottom)/(_bottom - _top ); + const float ff = _oglNdc + ? (_near + _far)/(_near - _far) + : _near /(_near - _far) + ; memSet(_result, 0, sizeof(float)*16); _result[ 0] = aa; @@ -968,17 +971,17 @@ namespace bx inline void mtxOrtho(float* _result, float _left, float _right, float _bottom, float _top, float _near, float _far, float _offset, bool _oglNdc) { - mtxOrtho_impl(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc); + mtxOrthoImpl(_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, bool _oglNdc) { - mtxOrtho_impl(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc); + mtxOrthoImpl(_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, bool _oglNdc) { - mtxOrtho_impl(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc); + mtxOrthoImpl(_result, _left, _right, _bottom, _top, _near, _far, _offset, _oglNdc); } inline void mtxRotateX(float* _result, float _ax)