aboutsummaryrefslogtreecommitdiffstats
path: root/linmath.h
diff options
context:
space:
mode:
authorWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2012-01-07 17:24:06 +0100
committerWolfgang Draxinger <Wolfgang.Draxinger@draxit.de>2012-01-07 17:24:06 +0100
commit1b817e79ee8fbf4d387bae1777f90a11c30271e9 (patch)
tree727099bff416cde3ef0c8f900f5d1a4a4a323a30 /linmath.h
parent516f75ec1b866e016b7a6d44f933991579fe2fd6 (diff)
downloadlinmath-1b817e79ee8fbf4d387bae1777f90a11c30271e9.tar.gz
linmath-1b817e79ee8fbf4d387bae1777f90a11c30271e9.tar.xz
linmath-1b817e79ee8fbf4d387bae1777f90a11c30271e9.zip
inplace mat4x4_invert now possible
Diffstat (limited to 'linmath.h')
-rw-r--r--linmath.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/linmath.h b/linmath.h
index 9d08448..5e51e3c 100644
--- a/linmath.h
+++ b/linmath.h
@@ -250,8 +250,9 @@ static inline void mat4x4_transpose(mat4x4 M, mat4x4 N)
}
}
}
-static inline void mat4x4_invert(mat4x4 R, mat4x4 M)
+static inline void mat4x4_invert(mat4x4 T, mat4x4 M)
{
+ mat4x4 R;
R[0][0] = M[1][1]*(M[2][2]*M[3][3] - M[2][3]*M[3][2]) - M[2][1]*(M[1][2]*M[3][3] - M[1][3]*M[3][2]) - M[3][1]*(M[1][3]*M[2][2] - M[1][2]*M[2][3]);
R[0][1] = M[0][1]*(M[2][3]*M[3][2] - M[2][2]*M[3][3]) - M[2][1]*(M[0][3]*M[3][2] - M[0][2]*M[3][3]) - M[3][1]*(M[0][2]*M[2][3] - M[0][3]*M[2][2]);
R[0][2] = M[0][1]*(M[1][2]*M[3][3] - M[1][3]*M[3][2]) - M[1][1]*(M[0][2]*M[3][3] - M[0][3]*M[3][2]) - M[3][1]*(M[0][3]*M[1][2] - M[0][2]*M[1][3]);
@@ -271,6 +272,7 @@ static inline void mat4x4_invert(mat4x4 R, mat4x4 M)
R[3][1] = M[0][0]*(M[2][1]*M[3][2] - M[2][2]*M[3][1]) - M[2][0]*(M[0][1]*M[3][2] - M[0][2]*M[3][1]) - M[3][0]*(M[0][2]*M[2][1] - M[0][1]*M[2][2]);
R[3][2] = M[0][0]*(M[1][2]*M[3][1] - M[1][1]*M[3][2]) - M[1][0]*(M[0][2]*M[3][1] - M[0][1]*M[3][2]) - M[3][0]*(M[0][1]*M[1][2] - M[0][2]*M[1][1]);
R[3][3] = M[0][0]*(M[1][1]*M[2][2] - M[1][2]*M[2][1]) - M[1][0]*(M[0][1]*M[2][2] - M[0][2]*M[2][1]) - M[2][0]*(M[0][2]*M[1][1] - M[0][1]*M[1][2]);
+ memcpy(T, R, sizeof(T));
}
static inline void mat4x4_frustum(mat4x4 M, float l, float r, float b, float t, float n, float f)
{