Gizmo: dial3d option to get angles w/o wrapping

Needed for spinning multiple revolutions.
This commit is contained in:
2018-09-18 14:58:20 +10:00
parent 2b57222ece
commit 0a3b66cfb5
2 changed files with 6 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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);