From ff7826fe46d4b9db8cab2012a9888fd55f16a934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 6 Dec 2018 22:26:08 -0800 Subject: [PATCH] Removing old vector math. --- include/bx/inline/math.inl | 64 +++++++++----------------------------- include/bx/math.h | 8 ----- 2 files changed, 14 insertions(+), 58 deletions(-) diff --git a/include/bx/inline/math.inl b/include/bx/inline/math.inl index 9508d6c..531ab5a 100644 --- a/include/bx/inline/math.inl +++ b/include/bx/inline/math.inl @@ -815,44 +815,6 @@ namespace bx return len; } - inline void vec3TangentFrame(const float* _n, float* _t, float* _b) - { - const float nx = _n[0]; - const float ny = _n[1]; - const float nz = _n[2]; - - if (abs(nx) > abs(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 / sqrt(ny*ny + nz*nz); - _t[0] = 0.0f; - _t[1] = nz * invLen; - _t[2] = -ny * invLen; - } - - vec3Cross(_b, _n, _t); - } - - inline void vec3TangentFrame(const float* _n, float* _t, float* _b, float _angle) - { - vec3TangentFrame(_n, _t, _b); - - 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]; - - vec3Cross(_b, _n, _t); - } - inline void vec3FromLatLong(float* _vec, float _u, float _v) { const float phi = _u * kPi2; @@ -907,13 +869,14 @@ namespace bx inline void mtxFromNormal(float* _result, const float* _normal, float _scale, const float* _pos) { - float tangent[3]; - float bitangent[3]; - vec3TangentFrame(_normal, tangent, bitangent); + const bx::Vec3 normal = bx::load(_normal); + bx::Vec3 tangent; + bx::Vec3 bitangent; + calcTangentFrame(tangent, bitangent, normal); - vec3Mul(&_result[ 0], bitangent, _scale); - vec3Mul(&_result[ 4], _normal, _scale); - vec3Mul(&_result[ 8], tangent, _scale); + store(&_result[ 0], mul(bitangent, _scale) ); + store(&_result[ 4], mul(normal, _scale) ); + store(&_result[ 8], mul(tangent, _scale) ); _result[ 3] = 0.0f; _result[ 7] = 0.0f; @@ -926,13 +889,14 @@ namespace bx inline void mtxFromNormal(float* _result, const float* _normal, float _scale, const float* _pos, float _angle) { - float tangent[3]; - float bitangent[3]; - vec3TangentFrame(_normal, tangent, bitangent, _angle); + const bx::Vec3 normal = bx::load(_normal); + bx::Vec3 tangent; + bx::Vec3 bitangent; + calcTangentFrame(tangent, bitangent, normal, _angle); - vec3Mul(&_result[ 0], bitangent, _scale); - vec3Mul(&_result[ 4], _normal, _scale); - vec3Mul(&_result[ 8], tangent, _scale); + store(&_result[0], mul(bitangent, _scale) ); + store(&_result[4], mul(normal, _scale) ); + store(&_result[8], mul(tangent, _scale) ); _result[ 3] = 0.0f; _result[ 7] = 0.0f; diff --git a/include/bx/math.h b/include/bx/math.h index 58ea1a6..b0c64a8 100644 --- a/include/bx/math.h +++ b/include/bx/math.h @@ -396,14 +396,6 @@ namespace bx /// float vec3Norm(float* _result, const float* _a); - /// Calculate tangent frame from normal. - /// - void vec3TangentFrame(const float* _n, float* _t, float* _b); - - /// Calculate tangent frame from normal and angle. - /// - void vec3TangentFrame(const float* _n, float* _t, float* _b, float _angle); - /// void vec3FromLatLong(float* _vec, float _u, float _v);