From ea182deeb9cdd2a9137e98eb0072f57c0fb1e09f Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Mon, 6 Jun 2022 22:59:32 -0300 Subject: Remove workaround for drawing the rotation gizmo Since [0], transform gizmos are no longer hidden during transform. The same can be observed for rotation gizmos. However, as a workaround for these rotation gizmos, there was already a drawing utility running. With the gizmo and the utility this drawing is now being done twice. So remove the utility/workaround and update the gizmo accordingly. [0] {648350e456490f8d6258e7de9bf94d3a6a34dbb2} Differential Revision: https://developer.blender.org/D9542 --- .../gizmo_library/gizmo_types/dial3d_gizmo.c | 77 +++++++++++++++------- 1 file changed, 52 insertions(+), 25 deletions(-) (limited to 'source/blender/editors/gizmo_library') 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 1d9fc35eda8..71db88419d5 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c @@ -77,6 +77,21 @@ typedef struct DialInteraction { #define DIAL_CLIP_BIAS 0.02 /* -------------------------------------------------------------------- */ +struct Dial3dParams { + int draw_options; + float angle_ofs; + float angle_delta; + float angle_increment; + float arc_partial_angle; + float arc_inner_factor; + float *clip_plane; +}; +static void dial_3d_draw_util(const float matrix_basis[4][4], + const float matrix_final[4][4], + const float line_width, + const float color[4], + const bool select, + struct Dial3dParams *params); static void dial_geom_draw(const float color[4], const float line_width, @@ -411,23 +426,24 @@ static void dial_draw_intern( if (WM_gizmo_target_property_is_valid(gz_prop)) { angle_delta = WM_gizmo_target_property_float_get(gz, gz_prop); } + angle_increment = RNA_float_get(gz->ptr, "incremental_angle"); } } - ED_gizmotypes_dial_3d_draw_util(gz->matrix_basis, - matrix_final, - gz->line_width, - color, - select, - &(struct Dial3dParams){ - .draw_options = draw_options, - .angle_ofs = angle_ofs, - .angle_delta = angle_delta, - .angle_increment = angle_increment, - .arc_partial_angle = arc_partial_angle, - .arc_inner_factor = arc_inner_factor, - .clip_plane = clip_plane, - }); + dial_3d_draw_util(gz->matrix_basis, + matrix_final, + gz->line_width, + color, + select, + &(struct Dial3dParams){ + .draw_options = draw_options, + .angle_ofs = angle_ofs, + .angle_delta = angle_delta, + .angle_increment = angle_increment, + .arc_partial_angle = arc_partial_angle, + .arc_inner_factor = arc_inner_factor, + .clip_plane = clip_plane, + }); } static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id) @@ -479,6 +495,10 @@ static int gizmo_dial_modal(bContext *C, eWM_GizmoFlagTweak tweak_flag) { DialInteraction *inter = gz->interaction_data; + if (!inter) { + return OPERATOR_CANCELLED; + } + if ((event->type != MOUSEMOVE) && (inter->prev.tweak_flag == tweak_flag)) { return OPERATOR_RUNNING_MODAL; } @@ -522,11 +542,13 @@ static void gizmo_dial_exit(bContext *C, wmGizmo *gz, const bool cancel) bool use_reset_value = false; float reset_value = 0.0f; if (cancel) { - /* Set the property for the operator and call its modal function. */ - wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); - if (WM_gizmo_target_property_is_valid(gz_prop)) { - use_reset_value = true; - reset_value = inter->init.prop_angle; + if (inter) { + /* Set the property for the operator and call its modal function. */ + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + use_reset_value = true; + reset_value = inter->init.prop_angle; + } } } else { @@ -564,6 +586,11 @@ static void gizmo_dial_setup(wmGizmo *gz) static int gizmo_dial_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { + if (gz->custom_modal) { + /* #DialInteraction is only used for the inner modal. */ + return OPERATOR_RUNNING_MODAL; + } + DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__); inter->init.mval[0] = event->mval[0]; @@ -583,12 +610,12 @@ static int gizmo_dial_invoke(bContext *UNUSED(C), wmGizmo *gz, const wmEvent *ev /** \name Dial Gizmo API * \{ */ -void ED_gizmotypes_dial_3d_draw_util(const float matrix_basis[4][4], - const float matrix_final[4][4], - const float line_width, - const float color[4], - const bool select, - struct Dial3dParams *params) +static void dial_3d_draw_util(const float matrix_basis[4][4], + const float matrix_final[4][4], + const float line_width, + const float color[4], + const bool select, + struct Dial3dParams *params) { GPU_matrix_push(); GPU_matrix_mul(matrix_final); -- cgit v1.2.3