[Bf-blender-cvs] [a731c75] blender2.8: port math function from Viewport FX

Mike Erwin noreply at git.blender.org
Sun Sep 25 19:29:53 CEST 2016


Commit: a731c75442f636f067a1c73bcf7b57e867daeb19
Author: Mike Erwin
Date:   Sun Sep 25 19:01:18 2016 +0200
Branches: blender2.8
https://developer.blender.org/rBa731c75442f636f067a1c73bcf7b57e867daeb19

port math function from Viewport FX

mul_v4_m4v3(r, M, v) means r = M * vec4(v, 1.0)
Based on rB194998766c65

===================================================================

M	source/blender/blenlib/BLI_math_matrix.h
M	source/blender/blenlib/intern/math_matrix.c

===================================================================

diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 73effb3..fc4bca1 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -121,6 +121,7 @@ void mul_mat3_m4_v3(const float M[4][4], float r[3]);
 void mul_v3_mat3_m4v3(float r[3], const float M[4][4], const float v[3]);
 void mul_m4_v4(const float M[4][4], float r[4]);
 void mul_v4_m4v4(float r[4], const float M[4][4], const float v[4]);
+void mul_v4_m4v3(float r[4], const float M[4][4], const float v[3]); /* v has implicit w = 1.0f */
 void mul_project_m4_v3(const float M[4][4], float vec[3]);
 void mul_v3_project_m4_v3(float r[3], const float mat[4][4], const float vec[3]);
 void mul_v2_project_m4_v3(float r[2], const float M[4][4], const float vec[3]);
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index 2088ec8..d95371b 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);




More information about the Bf-blender-cvs mailing list