[Bf-blender-cvs] [0a3b66cfb57] blender2.8: Gizmo: dial3d option to get angles w/o wrapping

Campbell Barton noreply at git.blender.org
Tue Sep 18 06:46:51 CEST 2018


Commit: 0a3b66cfb573a91ba3b19f30ead4a026bdfa6873
Author: Campbell Barton
Date:   Tue Sep 18 14:58:20 2018 +1000
Branches: blender2.8
https://developer.blender.org/rB0a3b66cfb573a91ba3b19f30ead4a026bdfa6873

Gizmo: dial3d option to get angles w/o wrapping

Needed for spinning multiple revolutions.

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

M	source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
M	source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c

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

diff --git a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
index 4acd033a6e2..7ceb46f20de 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c
@@ -267,8 +267,10 @@ static void dial_ghostarc_get_angles(
 	}
 	inter->prev.angle = delta;
 
+	const bool wrap_angle = RNA_boolean_get(gz->ptr, "wrap_angle");
+	const double delta_final = (double)delta + ((2 * M_PI) * (double)inter->rotations);
 	*r_start = start;
-	*r_delta = fmod(delta + 2.0f * (float)M_PI * inter->rotations, 2 * (float)M_PI);
+	*r_delta = (float)(wrap_angle ? fmod(delta_final, 2 * M_PI) : delta_final);
 	return;
 
 	/* If we can't project (unlikely). */
@@ -492,6 +494,7 @@ static void GIZMO_GT_dial_3d(wmGizmoType *gzt)
 		{0, NULL, 0, NULL, NULL}
 	};
 	RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", "");
+	RNA_def_boolean(gzt->srna, "wrap_angle", true, "Wrap Angle", "");
 
 	WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1);
 }
diff --git a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
index b7aca5811be..800e679b8a9 100644
--- a/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
+++ b/source/blender/editors/mesh/editmesh_extrude_spin_gizmo.c
@@ -557,6 +557,8 @@ static void gizmo_mesh_spin_redo_setup(const bContext *C, wmGizmoGroup *gzgroup)
 	RNA_enum_set(ggd->translate_z->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_NORMAL);
 	RNA_enum_set(ggd->translate_c->ptr, "draw_style", ED_GIZMO_MOVE_STYLE_RING_2D);
 
+	RNA_boolean_set(ggd->angle_z->ptr, "wrap_angle", false);
+
 	WM_gizmo_set_flag(ggd->translate_c, WM_GIZMO_DRAW_VALUE, true);
 	WM_gizmo_set_flag(ggd->rotate_c, WM_GIZMO_DRAW_VALUE, true);
 	WM_gizmo_set_flag(ggd->angle_z, WM_GIZMO_DRAW_VALUE, true);



More information about the Bf-blender-cvs mailing list