Add support for mat4 * vec3

This commit is contained in:
Bill Currie 2012-05-09 12:17:52 +09:00
parent 50af8a562e
commit 730f9668bd
2 changed files with 12 additions and 0 deletions

View file

@ -589,6 +589,7 @@ void QuatToMatrix (const quat_t q, vec_t *m, int homogenous, int vertical);
void Mat4Transpose (const mat4_t a, mat4_t b);
void Mat4Mult (const mat4_t a, const mat4_t b, mat4_t c);
void Mat4MultVec (const mat4_t a, const vec3_t b, vec3_t c);
// Column major matrix
int Mat4Decompose (const mat4_t m, quat_t rot, vec3_t scale, vec3_t shear,
vec3_t trans);

View file

@ -832,6 +832,17 @@ Mat4Mult (const mat4_t a, const mat4_t b, mat4_t c)
}
}
void
Mat4MultVec (const mat4_t a, const vec3_t b, vec3_t c)
{
int i;
vec3_t tb;
VectorCopy (b, tb);
for (i = 0; i < 3; i++)
c[i] = a[i + 0] * tb[0] + a[i + 4] * b[1] + a[i + 8] * b[2] + a[i +12];
}
int
Mat4Decompose (const mat4_t m, quat_t rot, vec3_t scale, vec3_t shear,
vec3_t trans)