[Bf-blender-cvs] [b2cad79] master: Math lib: add negate_m3, negate_m4

Campbell Barton noreply at git.blender.org
Thu May 29 16:29:52 CEST 2014


Commit: b2cad79500bb1af92153928479ca7d7144463e00
Author: Campbell Barton
Date:   Fri May 30 00:26:05 2014 +1000
https://developer.blender.org/rBb2cad79500bb1af92153928479ca7d7144463e00

Math lib: add negate_m3, negate_m4

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

M	source/blender/blenlib/BLI_math_matrix.h
M	source/blender/blenlib/intern/math_matrix.c
M	source/blender/editors/sculpt_paint/paint_hide.c
M	source/blender/editors/sculpt_paint/paint_mask.c
M	source/blender/editors/sculpt_paint/paint_utils.c

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

diff --git a/source/blender/blenlib/BLI_math_matrix.h b/source/blender/blenlib/BLI_math_matrix.h
index 8ce78e5..d149ad7 100644
--- a/source/blender/blenlib/BLI_math_matrix.h
+++ b/source/blender/blenlib/BLI_math_matrix.h
@@ -111,6 +111,9 @@ void mul_m3_fl(float R[3][3], float f);
 void mul_m4_fl(float R[4][4], float f);
 void mul_mat3_m4_fl(float R[4][4], float f);
 
+void negate_m3(float R[4][4]);
+void negate_m4(float R[4][4]);
+
 bool invert_m3_ex(float m[3][3], const float epsilon);
 bool invert_m3_m3_ex(float m1[3][3], float m2[3][3], const float epsilon);
 
diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c
index f375a5c..7fc30e3 100644
--- a/source/blender/blenlib/intern/math_matrix.c
+++ b/source/blender/blenlib/intern/math_matrix.c
@@ -519,7 +519,6 @@ void mul_transposed_mat3_m4_v3(float mat[4][4], float vec[3])
 	vec[2] = x * mat[2][0] + y * mat[2][1] + mat[2][2] * vec[2];
 }
 
-
 void mul_m3_fl(float m[3][3], float f)
 {
 	int i, j;
@@ -547,6 +546,24 @@ void mul_mat3_m4_fl(float m[4][4], float f)
 			m[i][j] *= f;
 }
 
+void negate_m3(float m[4][4])
+{
+	int i, j;
+
+	for (i = 0; i < 3; i++)
+		for (j = 0; j < 3; j++)
+			m[i][j] *= -1.0f;
+}
+
+void negate_m4(float m[4][4])
+{
+	int i, j;
+
+	for (i = 0; i < 4; i++)
+		for (j = 0; j < 4; j++)
+			m[i][j] *= -1.0f;
+}
+
 void mul_m3_v3_double(float mat[3][3], double vec[3])
 {
 	double x, y;
diff --git a/source/blender/editors/sculpt_paint/paint_hide.c b/source/blender/editors/sculpt_paint/paint_hide.c
index 3d86014..bc37a88 100644
--- a/source/blender/editors/sculpt_paint/paint_hide.c
+++ b/source/blender/editors/sculpt_paint/paint_hide.c
@@ -329,7 +329,7 @@ static void clip_planes_from_rect(bContext *C,
 	view3d_set_viewcontext(C, &vc);
 	view3d_get_transformation(vc.ar, vc.rv3d, vc.obact, &mats);
 	ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect);
-	mul_m4_fl(clip_planes, -1.0f);
+	negate_m4(clip_planes);
 }
 
 /* If mode is inside, get all PBVH nodes that lie at least partially
diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c
index a5f0fcd..9363542 100644
--- a/source/blender/editors/sculpt_paint/paint_mask.c
+++ b/source/blender/editors/sculpt_paint/paint_mask.c
@@ -208,7 +208,7 @@ int do_sculpt_mask_box_select(struct bContext *C, ViewContext *vc, rcti *rect, b
 	/* transform the clip planes in object space */
 	view3d_get_transformation(vc->ar, vc->rv3d, vc->obact, &mats);
 	ED_view3d_clipping_calc(&bb, clip_planes, &mats, rect);
-	mul_m4_fl(clip_planes, -1.0f);
+	negate_m4(clip_planes);
 
 	BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true);
 	pbvh = ob->sculpt->pbvh;
@@ -355,7 +355,7 @@ static int paint_mask_gesture_lasso_exec(bContext *C, wmOperator *op)
 		       mask_lasso_px_cb, &data);
 
 		ED_view3d_clipping_calc(&bb, clip_planes, &mats, &data.rect);
-		mul_m4_fl(clip_planes, -1.0f);
+		negate_m4(clip_planes);
 
 		BKE_sculpt_update_mesh_elements(scene, sd, ob, false, true);
 		pbvh = ob->sculpt->pbvh;
diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c
index 642c1dd..25308f6 100644
--- a/source/blender/editors/sculpt_paint/paint_utils.c
+++ b/source/blender/editors/sculpt_paint/paint_utils.c
@@ -146,7 +146,7 @@ void paint_calc_redraw_planes(float planes[4][4],
 	rect.ymax += 2;
 
 	ED_view3d_clipping_calc(&bb, planes, &mats, &rect);
-	mul_m4_fl(planes, -1.0f);
+	negate_m4(planes);
 }
 
 float paint_calc_object_space_radius(ViewContext *vc, const float center[3],




More information about the Bf-blender-cvs mailing list