[Bf-blender-cvs] [ebdeb3eca0d] blender2.8: Gizmo: support spin tool normal flipping

Campbell Barton noreply at git.blender.org
Tue Sep 25 06:11:32 CEST 2018


Commit: ebdeb3eca0d6ea483a4ef057c5ffbbb20938d25b
Author: Campbell Barton
Date:   Tue Sep 25 14:15:12 2018 +1000
Branches: blender2.8
https://developer.blender.org/rBebdeb3eca0d6ea483a4ef057c5ffbbb20938d25b

Gizmo: support spin tool normal flipping

Use the 2x spin tool has 2x handles to control normal direction,
dragging either handle backwards now reverses normals.

Previously it was common for the spin result to have normals
flipped the wrong way.

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

M	source/blender/editors/mesh/editmesh_extrude_spin.c
M	source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c

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

diff --git a/source/blender/editors/mesh/editmesh_extrude_spin.c b/source/blender/editors/mesh/editmesh_extrude_spin.c
index c351d80dec8..4f9aab165d0 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin.c
@@ -70,8 +70,8 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
 	RNA_float_get_array(op->ptr, "center", cent);
 	RNA_float_get_array(op->ptr, "axis", axis);
 	const int steps = RNA_int_get(op->ptr, "steps");
-	const float angle = -RNA_float_get(op->ptr, "angle");
-	const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip");
+	const float angle = RNA_float_get(op->ptr, "angle");
+	const bool use_normal_flip = RNA_boolean_get(op->ptr, "use_normal_flip") ^ (angle < 0.0f);
 	const bool dupli = RNA_boolean_get(op->ptr, "dupli");
 
 	if (is_zero_v3(axis)) {
@@ -93,7 +93,7 @@ static int edbm_spin_exec(bContext *C, wmOperator *op)
 		            em, &spinop, op,
 		            "spin geom=%hvef cent=%v axis=%v dvec=%v steps=%i angle=%f space=%m4 "
 		            "use_normal_flip=%b use_duplicate=%b",
-		            BM_ELEM_SELECT, cent, axis, d, steps, angle, obedit->obmat, use_normal_flip, dupli))
+		            BM_ELEM_SELECT, cent, axis, d, steps, -angle, obedit->obmat, use_normal_flip, dupli))
 		{
 			continue;
 		}
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
index e3fa02e946e..5978f521bb9 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
@@ -197,7 +197,14 @@ static void gizmo_mesh_spin_init_refresh_axis_orientation(
 		for (int j = 0; j < 2; j++) {
 			gz = ggd->gizmos.icon_button[axis_index][j];
 			PointerRNA *ptr = WM_gizmo_operator_set(gz, 0, ggd->data.ot_spin, NULL);
-			RNA_float_set_array(ptr, "axis", axis_vec);
+			float axis_vec_flip[3];
+			if (0 == j) {
+				negate_v3_v3(axis_vec_flip, axis_vec);
+			}
+			else {
+				copy_v3_v3(axis_vec_flip, axis_vec);
+			}
+			RNA_float_set_array(ptr, "axis", axis_vec_flip);
 		}
 	}
 }



More information about the Bf-blender-cvs mailing list