diff options
author | David M <manxi.david@gmail.com> | 2015-01-25 21:21:27 +0100 |
---|---|---|
committer | David M <manxi.david@gmail.com> | 2015-01-25 21:21:27 +0100 |
commit | fed4a4c3ab0fc392c6583ce1fc87c9e881619814 (patch) | |
tree | a22e9c0bb91f3bef71684df1f74a395a968e05cd | |
parent | 1000e36d1bc4555f5fd2f65082399b437b9cf7c3 (diff) | |
download | linmath-fed4a4c3ab0fc392c6583ce1fc87c9e881619814.tar.gz linmath-fed4a4c3ab0fc392c6583ce1fc87c9e881619814.tar.xz linmath-fed4a4c3ab0fc392c6583ce1fc87c9e881619814.zip |
In-place matrix multiplication
In-place matrix multiplication (mat4x4_mul(m1, m1,m2)) and
the operations that depends on it (mat4x4_rotate...) do not work.
I think that this feature will be appreciated, even if it has a
performance cost.
-rw-r--r-- | linmath.h | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -140,12 +140,14 @@ static inline void mat4x4_scale_aniso(mat4x4 M, mat4x4 a, float x, float y, floa } static inline void mat4x4_mul(mat4x4 M, mat4x4 a, mat4x4 b) { + mat4x4 temp; int k, r, c; for(c=0; c<4; ++c) for(r=0; r<4; ++r) { - M[c][r] = 0.f; + temp[c][r] = 0.f; for(k=0; k<4; ++k) - M[c][r] += a[k][r] * b[c][k]; + temp[c][r] += a[k][r] * b[c][k]; } + mat4x4_dup(M, temp); } static inline void mat4x4_mul_vec4(vec4 r, mat4x4 M, vec4 v) { |