diff options
author | Mike Erwin <significant.bit@gmail.com> | 2016-09-25 20:01:18 +0300 |
---|---|---|
committer | Mike Erwin <significant.bit@gmail.com> | 2016-09-25 20:01:18 +0300 |
commit | a731c75442f636f067a1c73bcf7b57e867daeb19 (patch) | |
tree | b216952b80d33c6e30e1d93dd1e4104f38738432 /source/blender/blenlib/intern | |
parent | 9bea012b8ca081a1bf696bf0af354ac327334354 (diff) |
port math function from Viewport FX
mul_v4_m4v3(r, M, v) means r = M * vec4(v, 1.0)
Based on rB194998766c65
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 9 |
1 files changed, 9 insertions, 0 deletions
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); |