From a731c75442f636f067a1c73bcf7b57e867daeb19 Mon Sep 17 00:00:00 2001 From: Mike Erwin Date: Sun, 25 Sep 2016 19:01:18 +0200 Subject: port math function from Viewport FX mul_v4_m4v3(r, M, v) means r = M * vec4(v, 1.0) Based on rB194998766c65 --- source/blender/blenlib/intern/math_matrix.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/blender/blenlib/intern/math_matrix.c') diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 2088ec8870e..d95371b4ebc 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -623,6 +623,15 @@ void mul_m4_v4d(const float mat[4][4], double r[4]) mul_v4d_m4v4d(r, mat, r); } +void mul_v4_m4v3(float r[4], const float M[4][4], const float v[3]) +{ + /* v has implicit w = 1.0f */ + r[0] = v[0] * M[0][0] + v[1] * M[1][0] + M[2][0] * v[2] + M[3][0]; + r[1] = v[0] * M[0][1] + v[1] * M[1][1] + M[2][1] * v[2] + M[3][1]; + r[2] = v[0] * M[0][2] + v[1] * M[1][2] + M[2][2] * v[2] + M[3][2]; + r[3] = v[0] * M[0][3] + v[1] * M[1][3] + M[2][3] * v[2] + M[3][3]; +} + void mul_v3_m3v3(float r[3], const float M[3][3], const float a[3]) { BLI_assert(r != a); -- cgit v1.2.3