Skip to content

Commit

Permalink
Added mtxFromNormal.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Jun 15, 2016
1 parent fff221b commit 7e2f79f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion include/bx/fpumath.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ namespace bx
_result[2] = 1.0f / _a[2];
}

inline void vec3TangentFrame(const float* _n, float* _t, float* _b)
inline void vec3TangentFrame(const float* __restrict _n, float* __restrict _t, float* __restrict _b)
{
const float nx = _n[0];
const float ny = _n[1];
Expand Down Expand Up @@ -550,6 +550,25 @@ namespace bx
_result[15] = 1.0f;
}

inline void mtxFromNormal(float* __restrict _result, const float* __restrict _normal, float _scale, const float* __restrict _pos)
{
float tangent[3];
float bitangent[3];
vec3TangentFrame(_normal, tangent, bitangent);

vec3Mul(&_result[ 0], bitangent, _scale);
vec3Mul(&_result[ 4], _normal, _scale);
vec3Mul(&_result[ 8], 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[15] = 1.0f;
}

inline void mtxQuat(float* __restrict _result, const float* __restrict _quat)
{
const float x = _quat[0];
Expand Down

0 comments on commit 7e2f79f

Please sign in to comment.