[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58698] trunk/blender/source/blender: add inline functions getting a single axis from mul_m3_v3()

Campbell Barton ideasman42 at gmail.com
Sun Jul 28 21:46:34 CEST 2013


Revision: 58698
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58698
Author:   campbellbarton
Date:     2013-07-28 19:46:33 +0000 (Sun, 28 Jul 2013)
Log Message:
-----------
add inline functions getting a single axis from mul_m3_v3()

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_vector.h
    trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
    trunk/blender/source/blender/bmesh/operators/bmo_connect_pair.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h	2013-07-28 18:22:08 UTC (rev 58697)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h	2013-07-28 19:46:33 UTC (rev 58698)
@@ -116,6 +116,9 @@
 MINLINE void mul_v4_fl(float r[4], float f);
 MINLINE void mul_v4_v4fl(float r[3], const float a[3], float f);
 MINLINE float mul_project_m4_v3_zfac(float mat[4][4], const float co[3]);
+MINLINE float mul_m3_v3_single_x(float M[3][3], const float a[3]);
+MINLINE float mul_m3_v3_single_y(float M[3][3], const float a[3]);
+MINLINE float mul_m3_v3_single_z(float M[3][3], const float a[3]);
 
 MINLINE void madd_v3_v3fl(float r[3], const float a[3], float f);
 MINLINE void madd_v3_v3v3(float r[3], const float a[3], const float b[3]);

Modified: trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2013-07-28 18:22:08 UTC (rev 58697)
+++ trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2013-07-28 19:46:33 UTC (rev 58698)
@@ -418,6 +418,18 @@
 	       (mat[2][3] * co[2]) + mat[3][3];
 }
 
+MINLINE float mul_m3_v3_single_x(float M[3][3], const float a[3])
+{
+	return M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
+}
+MINLINE float mul_m3_v3_single_y(float M[3][3], const float a[3])
+{
+	return M[0][1] * a[0] + M[1][1] * a[1] + M[2][1] * a[2];
+}
+MINLINE float mul_m3_v3_single_z(float M[3][3], const float a[3])
+{
+	return M[0][2] * a[0] + M[1][2] * a[1] + M[2][2] * a[2];
+}
 
 MINLINE void madd_v2_v2fl(float r[2], const float a[2], float f)
 {

Modified: trunk/blender/source/blender/bmesh/operators/bmo_connect_pair.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_connect_pair.c	2013-07-28 18:22:08 UTC (rev 58697)
+++ trunk/blender/source/blender/bmesh/operators/bmo_connect_pair.c	2013-07-28 19:46:33 UTC (rev 58698)
@@ -84,17 +84,11 @@
 	float co_prev[3];
 } PathLinkState;
 
-/* only the x axis */
-static float mul_v1_m3v3(float M[3][3], const float a[3])
-{
-	return M[0][0] * a[0] + M[1][0] * a[1] + M[2][0] * a[2];
-}
-
 static int state_isect_co_pair(const PathContext *pc,
                                const float co_a[3], const float co_b[3])
 {
-	const float diff_a = mul_v1_m3v3((float (*)[3])pc->matrix, co_a) - pc->axis_sep;
-	const float diff_b = mul_v1_m3v3((float (*)[3])pc->matrix, co_b) - pc->axis_sep;
+	const float diff_a = mul_m3_v3_single_x((float (*)[3])pc->matrix, co_a) - pc->axis_sep;
+	const float diff_b = mul_m3_v3_single_x((float (*)[3])pc->matrix, co_b) - pc->axis_sep;
 
 	const int test_a = (fabsf(diff_a) < CONNECT_EPS) ? 0 : (diff_a < 0.0f) ? -1 : 1;
 	const int test_b = (fabsf(diff_b) < CONNECT_EPS) ? 0 : (diff_b < 0.0f) ? -1 : 1;
@@ -110,7 +104,7 @@
 static int state_isect_co_exact(const PathContext *pc,
                                 const float co[3])
 {
-	const float diff = mul_v1_m3v3((float (*)[3])pc->matrix, co) - pc->axis_sep;
+	const float diff = mul_m3_v3_single_x((float (*)[3])pc->matrix, co) - pc->axis_sep;
 	return (fabsf(diff) <= CONNECT_EPS);
 }
 
@@ -119,8 +113,8 @@
 {
 	float diff_a, diff_b, diff_tot;
 
-	diff_a = fabsf(mul_v1_m3v3((float (*)[3])pc->matrix, co_a) - pc->axis_sep);
-	diff_b = fabsf(mul_v1_m3v3((float (*)[3])pc->matrix, co_b) - pc->axis_sep);
+	diff_a = fabsf(mul_m3_v3_single_x((float (*)[3])pc->matrix, co_a) - pc->axis_sep);
+	diff_b = fabsf(mul_m3_v3_single_x((float (*)[3])pc->matrix, co_b) - pc->axis_sep);
 	diff_tot = (diff_a + diff_b);
 	return (diff_tot > FLT_EPSILON) ? (diff_a / diff_tot) : 0.5f;
 }
@@ -443,7 +437,7 @@
 		normalize_v3_v3(pc.matrix[2], basis_nor);
 		invert_m3(pc.matrix);
 
-		pc.axis_sep = mul_v1_m3v3(pc.matrix, pc.v_a->co);
+		pc.axis_sep = mul_m3_v3_single_x(pc.matrix, pc.v_a->co);
 	}
 
 	/* add first vertex */




More information about the Bf-blender-cvs mailing list