From c1bc5bc5a2189f814bc85dccedf78fc36ffb9629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 21 Dec 2018 20:39:14 -0800 Subject: [PATCH] Cleanup. --- include/bx/inline/math.inl | 52 +++++++++++++++++--------------------- include/bx/math.h | 10 ++++---- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/include/bx/inline/math.inl b/include/bx/inline/math.inl index 4c8ac31..4be1e21 100644 --- a/include/bx/inline/math.inl +++ b/include/bx/inline/math.inl @@ -796,43 +796,41 @@ namespace bx mtxScale(_result, _scale, _scale, _scale); } - inline void mtxFromNormal(float* _result, const float* _normal, float _scale, const float* _pos) + inline void mtxFromNormal(float* _result, const Vec3& _normal, float _scale, const Vec3& _pos) { - const Vec3 normal = load(_normal); Vec3 tangent; Vec3 bitangent; - calcTangentFrame(tangent, bitangent, normal); + calcTangentFrame(tangent, bitangent, _normal); store(&_result[ 0], mul(bitangent, _scale) ); - store(&_result[ 4], mul(normal, _scale) ); + store(&_result[ 4], mul(_normal, _scale) ); store(&_result[ 8], mul(tangent, _scale) ); _result[ 3] = 0.0f; _result[ 7] = 0.0f; _result[11] = 0.0f; - _result[12] = _pos[0]; - _result[13] = _pos[1]; - _result[14] = _pos[2]; + _result[12] = _pos.x; + _result[13] = _pos.y; + _result[14] = _pos.z; _result[15] = 1.0f; } - inline void mtxFromNormal(float* _result, const float* _normal, float _scale, const float* _pos, float _angle) + inline void mtxFromNormal(float* _result, const Vec3& _normal, float _scale, const Vec3& _pos, float _angle) { - const Vec3 normal = load(_normal); Vec3 tangent; Vec3 bitangent; - calcTangentFrame(tangent, bitangent, normal, _angle); + calcTangentFrame(tangent, bitangent, _normal, _angle); store(&_result[0], mul(bitangent, _scale) ); - store(&_result[4], mul(normal, _scale) ); + store(&_result[4], mul(_normal, _scale) ); store(&_result[8], mul(tangent, _scale) ); _result[ 3] = 0.0f; _result[ 7] = 0.0f; _result[11] = 0.0f; - _result[12] = _pos[0]; - _result[13] = _pos[1]; - _result[14] = _pos[2]; + _result[12] = _pos.x; + _result[13] = _pos.y; + _result[14] = _pos.z; _result[15] = 1.0f; } @@ -1028,31 +1026,27 @@ namespace bx _dst[15] = _src[15]; } - inline void calcNormal(float _result[3], const float _va[3], const float _vb[3], const float _vc[3]) + inline bx::Vec3 calcNormal(const bx::Vec3& _va, const bx::Vec3& _vb, const bx::Vec3& _vc) { - const bx::Vec3 va = load(_va); - const bx::Vec3 vb = load(_vb); - const bx::Vec3 vc = load(_vc); - const bx::Vec3 ba = sub(vb, va); - const bx::Vec3 ca = sub(vc, va); + const bx::Vec3 ba = sub(_vb, _va); + const bx::Vec3 ca = sub(_vc, _va); const bx::Vec3 baxca = cross(ba, ca); - store(_result, bx::normalize(baxca) ); + return bx::normalize(baxca); } - inline void calcPlane(float _result[4], const float _va[3], const float _vb[3], const float _vc[3]) + inline void calcPlane(float _result[4], const bx::Vec3& _va, const bx::Vec3& _vb, const bx::Vec3& _vc) { - float normal[3]; - calcNormal(normal, _va, _vb, _vc); + bx::Vec3 normal = calcNormal(_va, _vb, _vc); calcPlane(_result, normal, _va); } - inline void calcPlane(float _result[4], const float _normal[3], const float _pos[3]) + inline void calcPlane(float _result[4], const bx::Vec3& _normal, const bx::Vec3& _pos) { - _result[0] = _normal[0]; - _result[1] = _normal[1]; - _result[2] = _normal[2]; - _result[3] = -dot(load(_normal), load(_pos) ); + _result[0] = _normal.x; + _result[1] = _normal.y; + _result[2] = _normal.z; + _result[3] = -dot(_normal, _pos); } inline BX_CONST_FUNC float toLinear(float _a) diff --git a/include/bx/math.h b/include/bx/math.h index c894372..29d2aed 100644 --- a/include/bx/math.h +++ b/include/bx/math.h @@ -390,10 +390,10 @@ namespace bx void mtxScale(float* _result, float _scale); /// - void mtxFromNormal(float* _result, const float* _normal, float _scale, const float* _pos); + void mtxFromNormal(float* _result, const Vec3& _normal, float _scale, const Vec3& _pos); /// - void mtxFromNormal(float* _result, const float* _normal, float _scale, const float* _pos, float _angle); + void mtxFromNormal(float* _result, const Vec3& _normal, float _scale, const Vec3& _pos, float _angle); /// void mtxQuat(float* _result, const Quaternion& _quat); @@ -554,13 +554,13 @@ namespace bx void mtxViewFlipHandedness(float* _dst, const float* _src); /// - void calcNormal(float _result[3], const float _va[3], const float _vb[3], const float _vc[3]); + bx::Vec3 calcNormal(const bx::Vec3& _va, const bx::Vec3& _vb, const bx::Vec3& _vc); /// - void calcPlane(float _result[4], const float _va[3], const float _vb[3], const float _vc[3]); + void calcPlane(float _result[4], const bx::Vec3& _va, const bx::Vec3& _vb, const bx::Vec3& _vc); /// - void calcPlane(float _result[4], const float _normal[3], const float _pos[3]); + void calcPlane(float _result[4], const bx::Vec3& _normal, const bx::Vec3& _pos); /// void calcLinearFit2D(float _result[2], const void* _points, uint32_t _stride, uint32_t _numPoints);