[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58741] trunk/blender/source/blender: function renaming for own recently added BLI_math functions, suggested by Brecht.

Campbell Barton ideasman42 at gmail.com
Tue Jul 30 12:58:36 CEST 2013


Revision: 58741
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58741
Author:   campbellbarton
Date:     2013-07-30 10:58:36 +0000 (Tue, 30 Jul 2013)
Log Message:
-----------
function renaming for own recently added BLI_math functions, suggested by Brecht.

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

Modified: trunk/blender/source/blender/blenlib/BLI_math_matrix.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_matrix.h	2013-07-30 09:50:17 UTC (rev 58740)
+++ trunk/blender/source/blender/blenlib/BLI_math_matrix.h	2013-07-30 10:58:36 UTC (rev 58741)
@@ -175,7 +175,7 @@
 void translate_m4(float mat[4][4], float tx, float ty, float tz);
 void rotate_m4(float mat[4][4], const char axis, const float angle);
 void rotate_m2(float mat[2][2], const float angle);
-void pivot_m4(float mat[4][4], const float pivot[3]);
+void transform_pivot_set_m4(float mat[4][4], const float pivot[3]);
 
 void mat3_to_rot_size(float rot[3][3], float size[3], float mat3[3][3]);
 void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], float wmat[4][4]);

Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h	2013-07-30 09:50:17 UTC (rev 58740)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h	2013-07-30 10:58:36 UTC (rev 58741)
@@ -116,9 +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 float dot_m3_v3_row_x(float M[3][3], const float a[3]);
+MINLINE float dot_m3_v3_row_y(float M[3][3], const float a[3]);
+MINLINE float dot_m3_v3_row_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_matrix.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_matrix.c	2013-07-30 09:50:17 UTC (rev 58740)
+++ trunk/blender/source/blender/blenlib/intern/math_matrix.c	2013-07-30 10:58:36 UTC (rev 58741)
@@ -1374,8 +1374,15 @@
 	mat[1][0] = -mat[0][1];
 }
 
-/* scale or rotate around a non zero pivot */
-void pivot_m4(float mat[4][4], const float pivot[3])
+/**
+ * Scale or rotate around a pivot point,
+ * a convenience function to avoid having to do inline.
+ *
+ * Since its common to make a scale/rotation matrix that pivots around an arbitrary point.
+ *
+ * Typical use case is to make 3x3 matrix, copy to 4x4, then pass to this function.
+ */
+void transform_pivot_set_m4(float mat[4][4], const float pivot[3])
 {
 	float tmat[4][4];
 

Modified: trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2013-07-30 09:50:17 UTC (rev 58740)
+++ trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2013-07-30 10:58:36 UTC (rev 58741)
@@ -418,15 +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])
+/**
+ * Has the effect of mul_m3_v3(), on a single axis.
+ */
+MINLINE float dot_m3_v3_row_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])
+MINLINE float dot_m3_v3_row_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])
+MINLINE float dot_m3_v3_row_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];
 }

Modified: trunk/blender/source/blender/bmesh/operators/bmo_connect_nonplanar.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_connect_nonplanar.c	2013-07-30 09:50:17 UTC (rev 58740)
+++ trunk/blender/source/blender/bmesh/operators/bmo_connect_nonplanar.c	2013-07-30 10:58:36 UTC (rev 58741)
@@ -77,9 +77,9 @@
 
 	axis_dominant_v3_to_m3(axis_mat, no);
 
-	z_prev = mul_m3_v3_single_z(axis_mat, l_last->v->co);
+	z_prev = dot_m3_v3_row_z(axis_mat, l_last->v->co);
 	do {
-		z_curr = mul_m3_v3_single_z(axis_mat, l_iter->v->co);
+		z_curr = dot_m3_v3_row_z(axis_mat, l_iter->v->co);
 		delta_z += fabsf(z_curr - z_prev);
 		z_prev = z_curr;
 	} while ((l_iter = l_iter->next) != l_term);

Modified: trunk/blender/source/blender/bmesh/operators/bmo_connect_pair.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_connect_pair.c	2013-07-30 09:50:17 UTC (rev 58740)
+++ trunk/blender/source/blender/bmesh/operators/bmo_connect_pair.c	2013-07-30 10:58:36 UTC (rev 58741)
@@ -87,8 +87,8 @@
 static int state_isect_co_pair(const PathContext *pc,
                                const float co_a[3], const float co_b[3])
 {
-	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 float diff_a = dot_m3_v3_row_x((float (*)[3])pc->matrix, co_a) - pc->axis_sep;
+	const float diff_b = dot_m3_v3_row_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;
@@ -104,7 +104,7 @@
 static int state_isect_co_exact(const PathContext *pc,
                                 const float co[3])
 {
-	const float diff = mul_m3_v3_single_x((float (*)[3])pc->matrix, co) - pc->axis_sep;
+	const float diff = dot_m3_v3_row_x((float (*)[3])pc->matrix, co) - pc->axis_sep;
 	return (fabsf(diff) <= CONNECT_EPS);
 }
 
@@ -113,8 +113,8 @@
 {
 	float diff_a, diff_b, diff_tot;
 
-	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_a = fabsf(dot_m3_v3_row_x((float (*)[3])pc->matrix, co_a) - pc->axis_sep);
+	diff_b = fabsf(dot_m3_v3_row_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;
 }
@@ -437,7 +437,7 @@
 		normalize_v3_v3(pc.matrix[2], basis_nor);
 		invert_m3(pc.matrix);
 
-		pc.axis_sep = mul_m3_v3_single_x(pc.matrix, pc.v_a->co);
+		pc.axis_sep = dot_m3_v3_row_x(pc.matrix, pc.v_a->co);
 	}
 
 	/* add first vertex */

Modified: trunk/blender/source/blender/bmesh/operators/bmo_utils.c
===================================================================
--- trunk/blender/source/blender/bmesh/operators/bmo_utils.c	2013-07-30 09:50:17 UTC (rev 58740)
+++ trunk/blender/source/blender/bmesh/operators/bmo_utils.c	2013-07-30 10:58:36 UTC (rev 58741)
@@ -103,7 +103,7 @@
 
 	BMO_slot_vec_get(op->slots_in, "cent", center);
 	BMO_slot_mat4_get(op->slots_in, "matrix", mat);
-	pivot_m4(mat, center);
+	transform_pivot_set_m4(mat, center);
 
 	BMO_op_callf(bm, op->flag, "transform matrix=%m4 space=%s verts=%s", mat, op, "space", op, "verts");
 }




More information about the Bf-blender-cvs mailing list