From bbb1778707ef95c26d5d8d35bf77217eba1a28e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 27 May 2016 20:27:19 -0700 Subject: [PATCH] Cleanup. --- include/bx/fpumath.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/bx/fpumath.h b/include/bx/fpumath.h index 2335ad4..5f64564 100644 --- a/include/bx/fpumath.h +++ b/include/bx/fpumath.h @@ -341,6 +341,30 @@ namespace bx _result[2] = 1.0f / _a[2]; } + 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 (bx::fabsolute(nx) > bx::fabsolute(nz) ) + { + float invLen = 1.0f / bx::fsqrt(nx*nx + nz*nz); + _t[0] = -nz * invLen; + _t[1] = 0.0f; + _t[2] = nx * invLen; + } + else + { + float invLen = 1.0f / bx::fsqrt(ny*ny + nz*nz); + _t[0] = 0.0f; + _t[1] = nz * invLen; + _t[2] = -ny * invLen; + } + + bx::vec3Cross(_b, _n, _t); + } + inline void quatIdentity(float* _result) { _result[0] = 0.0f;