aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordatenwolf <code+github@datenwolf.net>2015-01-26 03:53:30 +0100
committerdatenwolf <code+github@datenwolf.net>2015-01-26 03:53:30 +0100
commita9b12ac7c333e52ca0a28664f5fa50d5a93a89db (patch)
treea22e9c0bb91f3bef71684df1f74a395a968e05cd
parentcc811835476a7f230a2a348ce48b9ee07139b6dc (diff)
parentfed4a4c3ab0fc392c6583ce1fc87c9e881619814 (diff)
downloadlinmath.h-a9b12ac7c333e52ca0a28664f5fa50d5a93a89db.tar.gz
linmath.h-a9b12ac7c333e52ca0a28664f5fa50d5a93a89db.tar.bz2
Merge pull request #18 from dv343/master
In-place matrix multiplication
-rw-r--r--linmath.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/linmath.h b/linmath.h
index f852c00..2cf047d 100644
--- a/linmath.h
+++ b/linmath.h
@@ -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)
{