From e094d971276d6959662de186fe82ca1876d0d88a Mon Sep 17 00:00:00 2001 From: Wolfgang Draxinger Date: Sun, 30 Sep 2012 09:45:43 +0200 Subject: fixed several bugs in matrix processing --- linmath.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/linmath.h b/linmath.h index 7207dd7..6c06269 100644 --- a/linmath.h +++ b/linmath.h @@ -124,12 +124,18 @@ static inline void mat4x4_sub(mat4x4 M, mat4x4 a, mat4x4 b) for(i=0; i<4; ++i) vec4_sub(M[i], a[i], b[i]); } -static inline void mat4x4_scale(mat4x4 M, mat4x4 a, float k) +static inline void mat4x4_scale_isotropic(mat4x4 M, mat4x4 a, float k) { int i; for(i=0; i<4; ++i) vec4_scale(M[i], a[i], k); } +static inline void mat4x4_scale(mat4x4 R, mat4x4 M, float sx, float sy, float sz) +{ + vec4_scale(R[0], M[0], sx); + vec4_scale(R[1], M[1], sy); + vec4_scale(R[2], M[2], sz); +} static inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b) { int k, r, c; @@ -183,14 +189,14 @@ static inline void mat4x4_rotate(mat4x4 Q, mat4x4 M, float x, float y, float z, { u[1], -u[0], 0, 0}, { 0, 0, 0, 1} }; - mat4x4_scale(S, S, s); + mat4x4_scale_isotropic(S, S, s); mat4x4 R; mat4x4_from_vec3_mul_outer(R, u, u); mat4x4_identity(T); mat4x4_sub(T, T, Q); T[3][3] = 0.; - mat4x4_scale(T, T, c); + mat4x4_scale_isotropic(T, T, c); mat4x4_add(R, R, T); mat4x4_add(Q, R, S); @@ -413,7 +419,7 @@ static inline void mat4x4_mul_quat(mat4x4 R, mat4x4 M, quat q) } static inline void quat_from_mat4x4(quat q, mat4x4 M) { - float r=0., r2; + float r=0.; int i; int perm[] = { 0, 1, 2, 0, 1 }; -- cgit v1.2.3-54-g00ecf