From b457cae397054a1be4e60f3007995f97c198b2b6 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 15 Jul 2018 14:24:10 +0200 Subject: Cleanup: use variable names based on term gizmo --- .../editors/gizmo_library/gizmo_library_intern.h | 10 +- .../editors/gizmo_library/gizmo_library_presets.c | 24 +-- .../editors/gizmo_library/gizmo_library_utils.c | 36 ++-- .../gizmo_library/gizmo_types/arrow2d_gizmo.c | 66 +++---- .../gizmo_library/gizmo_types/arrow3d_gizmo.c | 124 ++++++------ .../gizmo_library/gizmo_types/button2d_gizmo.c | 94 +++++----- .../gizmo_library/gizmo_types/cage2d_gizmo.c | 208 ++++++++++----------- .../gizmo_library/gizmo_types/cage3d_gizmo.c | 188 +++++++++---------- .../gizmo_library/gizmo_types/dial3d_gizmo.c | 136 +++++++------- .../gizmo_library/gizmo_types/grab3d_gizmo.c | 124 ++++++------ .../gizmo_library/gizmo_types/primitive3d_gizmo.c | 50 ++--- 11 files changed, 530 insertions(+), 530 deletions(-) (limited to 'source/blender/editors/gizmo_library') diff --git a/source/blender/editors/gizmo_library/gizmo_library_intern.h b/source/blender/editors/gizmo_library/gizmo_library_intern.h index f1689ee93db..f5584d86847 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_intern.h +++ b/source/blender/editors/gizmo_library/gizmo_library_intern.h @@ -76,25 +76,25 @@ float gizmo_value_from_offset( const bool constrained, const bool inverted, const bool use_precision); void gizmo_property_data_update( - struct wmGizmo *mpr, GizmoCommonData *data, wmGizmoProperty *mpr_prop, + struct wmGizmo *gz, GizmoCommonData *data, wmGizmoProperty *gz_prop, const bool constrained, const bool inverted); void gizmo_property_value_reset( - bContext *C, const struct wmGizmo *mpr, GizmoInteraction *inter, wmGizmoProperty *mpr_prop); + bContext *C, const struct wmGizmo *gz, GizmoInteraction *inter, wmGizmoProperty *gz_prop); /* -------------------------------------------------------------------- */ void gizmo_color_get( - const struct wmGizmo *mpr, const bool highlight, + const struct wmGizmo *gz, const bool highlight, float r_color[4]); bool gizmo_window_project_2d( - bContext *C, const struct wmGizmo *mpr, const float mval[2], int axis, bool use_offset, + bContext *C, const struct wmGizmo *gz, const float mval[2], int axis, bool use_offset, float r_co[2]); bool gizmo_window_project_3d( - bContext *C, const struct wmGizmo *mpr, const float mval[2], bool use_offset, + bContext *C, const struct wmGizmo *gz, const float mval[2], bool use_offset, float r_co[3]); /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/gizmo_library/gizmo_library_presets.c b/source/blender/editors/gizmo_library/gizmo_library_presets.c index 8a6b92e48d6..e16f8ed21bf 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_presets.c +++ b/source/blender/editors/gizmo_library/gizmo_library_presets.c @@ -81,14 +81,14 @@ static void single_axis_convert( * Use for all geometry. */ static void ed_gizmo_draw_preset_geometry( - const struct wmGizmo *mpr, float mat[4][4], int select_id, + const struct wmGizmo *gz, float mat[4][4], int select_id, const GizmoGeomInfo *info) { const bool is_select = (select_id != -1); - const bool is_highlight = is_select && (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_highlight = is_select && (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; float color[4]; - gizmo_color_get(mpr, is_highlight, color); + gizmo_color_get(gz, is_highlight, color); if (is_select) { GPU_select_load_id(select_id); @@ -105,35 +105,35 @@ static void ed_gizmo_draw_preset_geometry( } void ED_gizmo_draw_preset_box( - const struct wmGizmo *mpr, float mat[4][4], int select_id) + const struct wmGizmo *gz, float mat[4][4], int select_id) { - ed_gizmo_draw_preset_geometry(mpr, mat, select_id, &wm_gizmo_geom_data_cube); + ed_gizmo_draw_preset_geometry(gz, mat, select_id, &wm_gizmo_geom_data_cube); } void ED_gizmo_draw_preset_arrow( - const struct wmGizmo *mpr, float mat[4][4], int axis, int select_id) + const struct wmGizmo *gz, float mat[4][4], int axis, int select_id) { float mat_rotate[4][4]; single_axis_convert(OB_POSZ, mat, axis, mat_rotate); - ed_gizmo_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_gizmo_geom_data_arrow); + ed_gizmo_draw_preset_geometry(gz, mat_rotate, select_id, &wm_gizmo_geom_data_arrow); } void ED_gizmo_draw_preset_circle( - const struct wmGizmo *mpr, float mat[4][4], int axis, int select_id) + const struct wmGizmo *gz, float mat[4][4], int axis, int select_id) { float mat_rotate[4][4]; single_axis_convert(OB_POSZ, mat, axis, mat_rotate); - ed_gizmo_draw_preset_geometry(mpr, mat_rotate, select_id, &wm_gizmo_geom_data_dial); + ed_gizmo_draw_preset_geometry(gz, mat_rotate, select_id, &wm_gizmo_geom_data_dial); } void ED_gizmo_draw_preset_facemap( - const bContext *C, const struct wmGizmo *mpr, struct Scene *scene, Object *ob, const int facemap, int select_id) + const bContext *C, const struct wmGizmo *gz, struct Scene *scene, Object *ob, const int facemap, int select_id) { const bool is_select = (select_id != -1); - const bool is_highlight = is_select && (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_highlight = is_select && (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; float color[4]; - gizmo_color_get(mpr, is_highlight, color); + gizmo_color_get(gz, is_highlight, color); if (is_select) { GPU_select_load_id(select_id); diff --git a/source/blender/editors/gizmo_library/gizmo_library_utils.c b/source/blender/editors/gizmo_library/gizmo_library_utils.c index 6e6bc2ed824..07c230c5503 100644 --- a/source/blender/editors/gizmo_library/gizmo_library_utils.c +++ b/source/blender/editors/gizmo_library/gizmo_library_utils.c @@ -107,13 +107,13 @@ float gizmo_value_from_offset( } void gizmo_property_data_update( - wmGizmo *mpr, GizmoCommonData *data, wmGizmoProperty *mpr_prop, + wmGizmo *gz, GizmoCommonData *data, wmGizmoProperty *gz_prop, const bool constrained, const bool inverted) { - if (mpr_prop->custom_func.value_get_fn != NULL) { + if (gz_prop->custom_func.value_get_fn != NULL) { /* pass */ } - else if (mpr_prop->prop != NULL) { + else if (gz_prop->prop != NULL) { /* pass */ } else { @@ -121,12 +121,12 @@ void gizmo_property_data_update( return; } - float value = WM_gizmo_target_property_value_get(mpr, mpr_prop); + float value = WM_gizmo_target_property_value_get(gz, gz_prop); if (constrained) { if ((data->flag & GIZMO_CUSTOM_RANGE_SET) == 0) { float range[2]; - if (WM_gizmo_target_property_range_get(mpr, mpr_prop, range)) { + if (WM_gizmo_target_property_range_get(gz, gz_prop, range)) { data->range = range[1] - range[0]; data->min = range[0]; } @@ -142,23 +142,23 @@ void gizmo_property_data_update( } void gizmo_property_value_reset( - bContext *C, const wmGizmo *mpr, GizmoInteraction *inter, - wmGizmoProperty *mpr_prop) + bContext *C, const wmGizmo *gz, GizmoInteraction *inter, + wmGizmoProperty *gz_prop) { - WM_gizmo_target_property_value_set(C, mpr, mpr_prop, inter->init_value); + WM_gizmo_target_property_value_set(C, gz, gz_prop, inter->init_value); } /* -------------------------------------------------------------------- */ void gizmo_color_get( - const wmGizmo *mpr, const bool highlight, + const wmGizmo *gz, const bool highlight, float r_col[4]) { - if (highlight && !(mpr->flag & WM_GIZMO_DRAW_HOVER)) { - copy_v4_v4(r_col, mpr->color_hi); + if (highlight && !(gz->flag & WM_GIZMO_DRAW_HOVER)) { + copy_v4_v4(r_col, gz->color_hi); } else { - copy_v4_v4(r_col, mpr->color); + copy_v4_v4(r_col, gz->color); } } @@ -169,7 +169,7 @@ void gizmo_color_get( * Both 2D & 3D supported, use so we can use 2D gizmos in the 3D view. */ bool gizmo_window_project_2d( - bContext *C, const struct wmGizmo *mpr, const float mval[2], int axis, bool use_offset, + bContext *C, const struct wmGizmo *gz, const float mval[2], int axis, bool use_offset, float r_co[2]) { float mat[4][4]; @@ -180,11 +180,11 @@ bool gizmo_window_project_2d( unit_m4(mat_identity); params.matrix_offset = mat_identity; } - WM_gizmo_calc_matrix_final_params(mpr, ¶ms, mat); + WM_gizmo_calc_matrix_final_params(gz, ¶ms, mat); } /* rotate mouse in relation to the center and relocate it */ - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { /* For 3d views, transform 2D mouse pos onto plane. */ View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); @@ -221,7 +221,7 @@ bool gizmo_window_project_2d( } bool gizmo_window_project_3d( - bContext *C, const struct wmGizmo *mpr, const float mval[2], bool use_offset, + bContext *C, const struct wmGizmo *gz, const float mval[2], bool use_offset, float r_co[3]) { float mat[4][4]; @@ -232,10 +232,10 @@ bool gizmo_window_project_3d( unit_m4(mat_identity); params.matrix_offset = mat_identity; } - WM_gizmo_calc_matrix_final_params(mpr, ¶ms, mat); + WM_gizmo_calc_matrix_final_params(gz, ¶ms, mat); } - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); /* Note: we might want a custom reference point passed in, diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c index dfa2eeeb38b..0faeeefb4a3 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow2d_gizmo.c @@ -61,14 +61,14 @@ #include "../gizmo_library_intern.h" -static void arrow2d_draw_geom(wmGizmo *mpr, const float matrix[4][4], const float color[4]) +static void arrow2d_draw_geom(wmGizmo *gz, const float matrix[4][4], const float color[4]) { const float size = 0.11f; const float size_breadth = size / 2.0f; const float size_length = size * 1.7f; /* Subtract the length so the arrow fits in the hotspot. */ - const float arrow_length = RNA_float_get(mpr->ptr, "length") - size_length; - const float arrow_angle = RNA_float_get(mpr->ptr, "angle"); + const float arrow_length = RNA_float_get(gz->ptr, "length") - size_length; + const float arrow_angle = RNA_float_get(gz->ptr, "angle"); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -96,60 +96,60 @@ static void arrow2d_draw_geom(wmGizmo *mpr, const float matrix[4][4], const floa gpuPopMatrix(); } -static void gizmo_arrow2d_draw(const bContext *UNUSED(C), wmGizmo *mpr) +static void gizmo_arrow2d_draw(const bContext *UNUSED(C), wmGizmo *gz) { float color[4]; float matrix_final[4][4]; - gizmo_color_get(mpr, mpr->state & WM_GIZMO_STATE_HIGHLIGHT, color); + gizmo_color_get(gz, gz->state & WM_GIZMO_STATE_HIGHLIGHT, color); - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); - WM_gizmo_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(gz, matrix_final); GPU_blend(true); - arrow2d_draw_geom(mpr, matrix_final, color); + arrow2d_draw_geom(gz, matrix_final, color); GPU_blend(false); - if (mpr->interaction_data) { - GizmoInteraction *inter = mpr->interaction_data; + if (gz->interaction_data) { + GizmoInteraction *inter = gz->interaction_data; GPU_blend(true); - arrow2d_draw_geom(mpr, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); + arrow2d_draw_geom(gz, inter->init_matrix_final, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}); GPU_blend(false); } } -static void gizmo_arrow2d_setup(wmGizmo *mpr) +static void gizmo_arrow2d_setup(wmGizmo *gz) { - mpr->flag |= WM_GIZMO_DRAW_MODAL; + gz->flag |= WM_GIZMO_DRAW_MODAL; } static int gizmo_arrow2d_invoke( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *UNUSED(event)) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *UNUSED(event)) { GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__); - copy_m4_m4(inter->init_matrix_basis, mpr->matrix_basis); - WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); + copy_m4_m4(inter->init_matrix_basis, gz->matrix_basis); + WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final); - mpr->interaction_data = inter; + gz->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } static int gizmo_arrow2d_test_select( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { const float mval[2] = {event->mval[0], event->mval[1]}; - const float arrow_length = RNA_float_get(mpr->ptr, "length"); - const float arrow_angle = RNA_float_get(mpr->ptr, "angle"); - const float line_len = arrow_length * mpr->scale_final; + const float arrow_length = RNA_float_get(gz->ptr, "length"); + const float arrow_angle = RNA_float_get(gz->ptr, "angle"); + const float line_len = arrow_length * gz->scale_final; float mval_local[2]; copy_v2_v2(mval_local, mval); - sub_v2_v2(mval_local, mpr->matrix_basis[3]); + sub_v2_v2(mval_local, gz->matrix_basis[3]); float line[2][2]; line[0][0] = line[0][1] = line[1][0] = 0.0f; @@ -165,7 +165,7 @@ static int gizmo_arrow2d_test_select( /* arrow line intersection check */ float isect_1[2], isect_2[2]; const int isect = isect_line_sphere_v2( - line[0], line[1], mval_local, GIZMO_HOTSPOT + mpr->line_width * 0.5f, + line[0], line[1], mval_local, GIZMO_HOTSPOT + gz->line_width * 0.5f, isect_1, isect_2); if (isect > 0) { @@ -197,29 +197,29 @@ static int gizmo_arrow2d_test_select( * * \{ */ -static void GIZMO_WT_arrow_2d(wmGizmoType *wt) +static void GIZMO_GT_arrow_2d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_arrow_2d"; + gzt->idname = "GIZMO_GT_arrow_2d"; /* api callbacks */ - wt->draw = gizmo_arrow2d_draw; - wt->setup = gizmo_arrow2d_setup; - wt->invoke = gizmo_arrow2d_invoke; - wt->test_select = gizmo_arrow2d_test_select; + gzt->draw = gizmo_arrow2d_draw; + gzt->setup = gizmo_arrow2d_setup; + gzt->invoke = gizmo_arrow2d_invoke; + gzt->test_select = gizmo_arrow2d_test_select; - wt->struct_size = sizeof(wmGizmo); + gzt->struct_size = sizeof(wmGizmo); /* rna */ - RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); + RNA_def_float(gzt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); RNA_def_float_rotation( - wt->srna, "angle", 0, NULL, DEG2RADF(-360.0f), DEG2RADF(360.0f), + gzt->srna, "angle", 0, NULL, DEG2RADF(-360.0f), DEG2RADF(360.0f), "Roll", "", DEG2RADF(-360.0f), DEG2RADF(360.0f)); } void ED_gizmotypes_arrow_2d(void) { - WM_gizmotype_append(GIZMO_WT_arrow_2d); + WM_gizmotype_append(GIZMO_GT_arrow_2d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c index 9807a111d26..09c6485c29e 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/arrow3d_gizmo.c @@ -80,9 +80,9 @@ typedef struct ArrowGizmo3D { /* -------------------------------------------------------------------- */ -static void gizmo_arrow_matrix_basis_get(const wmGizmo *mpr, float r_matrix[4][4]) +static void gizmo_arrow_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4]) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; copy_m4_m4(r_matrix, arrow->gizmo.matrix_basis); madd_v3_v3fl(r_matrix[3], arrow->gizmo.matrix_basis[2], arrow->data.offset); @@ -182,13 +182,13 @@ static void arrow_draw_geom(const ArrowGizmo3D *arrow, const bool select, const static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool highlight) { - wmGizmo *mpr = &arrow->gizmo; + wmGizmo *gz = &arrow->gizmo; float color[4]; float matrix_final[4][4]; - gizmo_color_get(mpr, highlight, color); + gizmo_color_get(gz, highlight, color); - WM_gizmo_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(gz, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); @@ -198,8 +198,8 @@ static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool gpuPopMatrix(); - if (mpr->interaction_data) { - GizmoInteraction *inter = mpr->interaction_data; + if (gz->interaction_data) { + GizmoInteraction *inter = gz->interaction_data; gpuPushMatrix(); gpuMultMatrix(inter->init_matrix_final); @@ -214,16 +214,16 @@ static void arrow_draw_intern(ArrowGizmo3D *arrow, const bool select, const bool } static void gizmo_arrow_draw_select( - const bContext *UNUSED(C), wmGizmo *mpr, + const bContext *UNUSED(C), wmGizmo *gz, int select_id) { GPU_select_load_id(select_id); - arrow_draw_intern((ArrowGizmo3D *)mpr, true, false); + arrow_draw_intern((ArrowGizmo3D *)gz, true, false); } -static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *mpr) +static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *gz) { - arrow_draw_intern((ArrowGizmo3D *)mpr, false, (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0); + arrow_draw_intern((ArrowGizmo3D *)gz, false, (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0); } /** @@ -231,11 +231,11 @@ static void gizmo_arrow_draw(const bContext *UNUSED(C), wmGizmo *mpr) * meaning the range will not be offset by min value first. */ static int gizmo_arrow_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; - GizmoInteraction *inter = mpr->interaction_data; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; + GizmoInteraction *inter = gz->interaction_data; View3D *v3d = CTX_wm_view3d(C); ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; @@ -299,19 +299,19 @@ static int gizmo_arrow_modal( GizmoCommonData *data = &arrow->data; const float ofs_new = facdir * len_v3(offset); - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); /* set the property for the operator and call its modal function */ - if (WM_gizmo_target_property_is_valid(mpr_prop)) { + if (WM_gizmo_target_property_is_valid(gz_prop)) { const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform"); const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0; const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0; const bool use_precision = (tweak_flag & WM_GIZMO_TWEAK_PRECISE) != 0; float value = gizmo_value_from_offset(data, inter, ofs_new, constrained, inverted, use_precision); - WM_gizmo_target_property_value_set(C, mpr, mpr_prop, value); + WM_gizmo_target_property_value_set(C, gz, gz_prop, value); /* get clamped value */ - value = WM_gizmo_target_property_value_get(mpr, mpr_prop); + value = WM_gizmo_target_property_value_get(gz, gz_prop); data->offset = gizmo_offset_from_value(data, value, constrained, inverted); } @@ -326,9 +326,9 @@ static int gizmo_arrow_modal( return OPERATOR_RUNNING_MODAL; } -static void gizmo_arrow_setup(wmGizmo *mpr) +static void gizmo_arrow_setup(wmGizmo *gz) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; arrow->gizmo.flag |= WM_GIZMO_DRAW_MODAL; @@ -336,15 +336,15 @@ static void gizmo_arrow_setup(wmGizmo *mpr) } static int gizmo_arrow_invoke( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__); - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); /* Some gizmos don't use properties. */ - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - inter->init_value = WM_gizmo_target_property_value_get(mpr, mpr_prop); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + inter->init_value = WM_gizmo_target_property_value_get(gz, gz_prop); } inter->init_offset = arrow->data.offset; @@ -352,42 +352,42 @@ static int gizmo_arrow_invoke( inter->init_mval[0] = event->mval[0]; inter->init_mval[1] = event->mval[1]; - gizmo_arrow_matrix_basis_get(mpr, inter->init_matrix_basis); - WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); + gizmo_arrow_matrix_basis_get(gz, inter->init_matrix_basis); + WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final); - mpr->interaction_data = inter; + gz->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } -static void gizmo_arrow_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) +static void gizmo_arrow_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; const int transform_flag = RNA_enum_get(arrow->gizmo.ptr, "transform"); const bool constrained = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_CONSTRAINED) != 0; const bool inverted = (transform_flag & ED_GIZMO_ARROW_XFORM_FLAG_INVERTED) != 0; - gizmo_property_data_update(mpr, &arrow->data, mpr_prop, constrained, inverted); + gizmo_property_data_update(gz, &arrow->data, gz_prop, constrained, inverted); } -static void gizmo_arrow_exit(bContext *C, wmGizmo *mpr, const bool cancel) +static void gizmo_arrow_exit(bContext *C, wmGizmo *gz, const bool cancel) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; GizmoCommonData *data = &arrow->data; - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - const bool is_prop_valid = WM_gizmo_target_property_is_valid(mpr_prop); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + const bool is_prop_valid = WM_gizmo_target_property_is_valid(gz_prop); if (!cancel) { /* Assign incase applying the opetration needs an updated offset * editmesh bisect needs this. */ if (is_prop_valid) { - data->offset = WM_gizmo_target_property_value_get(mpr, mpr_prop); + data->offset = WM_gizmo_target_property_value_get(gz, gz_prop); } return; } - GizmoInteraction *inter = mpr->interaction_data; + GizmoInteraction *inter = gz->interaction_data; if (is_prop_valid) { - gizmo_property_value_reset(C, mpr, inter, mpr_prop); + gizmo_property_value_reset(C, gz, inter, gz_prop); } data->offset = inter->init_offset; } @@ -403,12 +403,12 @@ static void gizmo_arrow_exit(bContext *C, wmGizmo *mpr, const bool cancel) * * \note Needs to be called before WM_gizmo_target_property_def_rna! */ -void ED_gizmo_arrow3d_set_ui_range(wmGizmo *mpr, const float min, const float max) +void ED_gizmo_arrow3d_set_ui_range(wmGizmo *gz, const float min, const float max) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; BLI_assert(min < max); - BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(mpr, "offset")) && + BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(gz, "offset")) && "Make sure this function is called before WM_gizmo_target_property_def_rna")); arrow->data.range = max - min; @@ -421,31 +421,31 @@ void ED_gizmo_arrow3d_set_ui_range(wmGizmo *mpr, const float min, const float ma * * \note Needs to be called before WM_gizmo_target_property_def_rna! */ -void ED_gizmo_arrow3d_set_range_fac(wmGizmo *mpr, const float range_fac) +void ED_gizmo_arrow3d_set_range_fac(wmGizmo *gz, const float range_fac) { - ArrowGizmo3D *arrow = (ArrowGizmo3D *)mpr; - BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(mpr, "offset")) && + ArrowGizmo3D *arrow = (ArrowGizmo3D *)gz; + BLI_assert(!(WM_gizmo_target_property_is_valid(WM_gizmo_target_property_find(gz, "offset")) && "Make sure this function is called before WM_gizmo_target_property_def_rna")); arrow->data.range_fac = range_fac; } -static void GIZMO_WT_arrow_3d(wmGizmoType *wt) +static void GIZMO_GT_arrow_3d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_arrow_3d"; + gzt->idname = "GIZMO_GT_arrow_3d"; /* api callbacks */ - wt->draw = gizmo_arrow_draw; - wt->draw_select = gizmo_arrow_draw_select; - wt->matrix_basis_get = gizmo_arrow_matrix_basis_get; - wt->modal = gizmo_arrow_modal; - wt->setup = gizmo_arrow_setup; - wt->invoke = gizmo_arrow_invoke; - wt->property_update = gizmo_arrow_property_update; - wt->exit = gizmo_arrow_exit; + gzt->draw = gizmo_arrow_draw; + gzt->draw_select = gizmo_arrow_draw_select; + gzt->matrix_basis_get = gizmo_arrow_matrix_basis_get; + gzt->modal = gizmo_arrow_modal; + gzt->setup = gizmo_arrow_setup; + gzt->invoke = gizmo_arrow_invoke; + gzt->property_update = gizmo_arrow_property_update; + gzt->exit = gizmo_arrow_exit; - wt->struct_size = sizeof(ArrowGizmo3D); + gzt->struct_size = sizeof(ArrowGizmo3D); /* rna */ static EnumPropertyItem rna_enum_draw_style_items[] = { @@ -466,27 +466,27 @@ static void GIZMO_WT_arrow_3d(wmGizmoType *wt) }; RNA_def_enum( - wt->srna, "draw_style", rna_enum_draw_style_items, + gzt->srna, "draw_style", rna_enum_draw_style_items, ED_GIZMO_ARROW_STYLE_NORMAL, "Draw Style", ""); RNA_def_enum_flag( - wt->srna, "draw_options", rna_enum_draw_options_items, + gzt->srna, "draw_options", rna_enum_draw_options_items, ED_GIZMO_ARROW_DRAW_FLAG_STEM, "Draw Options", ""); RNA_def_enum_flag( - wt->srna, "transform", rna_enum_transform_items, + gzt->srna, "transform", rna_enum_transform_items, 0, "Transform", ""); - RNA_def_float(wt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); - RNA_def_float_vector(wt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX); + RNA_def_float(gzt->srna, "length", 1.0f, 0.0f, FLT_MAX, "Arrow Line Length", "", 0.0f, FLT_MAX); + RNA_def_float_vector(gzt->srna, "aspect", 2, NULL, 0, FLT_MAX, "Aspect", "Cone/box style only", 0.0f, FLT_MAX); - WM_gizmotype_target_property_def(wt, "offset", PROP_FLOAT, 1); + WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1); } void ED_gizmotypes_arrow_3d(void) { - WM_gizmotype_append(GIZMO_WT_arrow_3d); + WM_gizmotype_append(GIZMO_GT_arrow_3d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index ede070f0bed..dfe2c8b2413 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -80,9 +80,9 @@ typedef struct ButtonGizmo2D { /* -------------------------------------------------------------------- */ static void button2d_geom_draw_backdrop( - const wmGizmo *mpr, const float color[4], const bool select) + const wmGizmo *gz, const float color[4], const bool select) { - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -100,24 +100,24 @@ static void button2d_geom_draw_backdrop( } static void button2d_draw_intern( - const bContext *C, wmGizmo *mpr, + const bContext *C, wmGizmo *gz, const bool select, const bool highlight) { - ButtonGizmo2D *button = (ButtonGizmo2D *)mpr; + ButtonGizmo2D *button = (ButtonGizmo2D *)gz; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); if (button->is_init == false) { button->is_init = true; - PropertyRNA *prop = RNA_struct_find_property(mpr->ptr, "icon"); - if (RNA_property_is_set(mpr->ptr, prop)) { - button->icon = RNA_property_enum_get(mpr->ptr, prop); + PropertyRNA *prop = RNA_struct_find_property(gz->ptr, "icon"); + if (RNA_property_is_set(gz->ptr, prop)) { + button->icon = RNA_property_enum_get(gz->ptr, prop); } else { - prop = RNA_struct_find_property(mpr->ptr, "shape"); - const uint polys_len = RNA_property_string_length(mpr->ptr, prop); + prop = RNA_struct_find_property(gz->ptr, "shape"); + const uint polys_len = RNA_property_string_length(gz->ptr, prop); /* We shouldn't need the +1, but a NULL char is set. */ char *polys = MEM_mallocN(polys_len + 1, __func__); - RNA_property_string_get(mpr->ptr, prop, polys); + RNA_property_string_get(gz->ptr, prop, polys); button->shape_batch[0] = GPU_batch_tris_from_poly_2d_encoded((uchar *)polys, polys_len, NULL); button->shape_batch[1] = GPU_batch_wire_from_poly_2d_encoded((uchar *)polys, polys_len, NULL); MEM_freeN(polys); @@ -127,20 +127,20 @@ static void button2d_draw_intern( float color[4]; float matrix_final[4][4]; - gizmo_color_get(mpr, highlight, color); - WM_gizmo_calc_matrix_final(mpr, matrix_final); + gizmo_color_get(gz, highlight, color); + WM_gizmo_calc_matrix_final(gz, matrix_final); - bool is_3d = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) != 0; + bool is_3d = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) != 0; if (draw_options & ED_GIZMO_BUTTON_SHOW_HELPLINE) { float matrix_final_no_offset[4][4]; - WM_gizmo_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); + WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset); uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); immUniformColor4fv(color); - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); immUniformColor4fv(color); immBegin(GWN_PRIM_LINE_STRIP, 2); immVertex3fv(pos, matrix_final[3]); @@ -166,7 +166,7 @@ static void button2d_draw_intern( if (select) { BLI_assert(is_3d); - button2d_geom_draw_backdrop(mpr, color, select); + button2d_geom_draw_backdrop(gz, color, select); } else { @@ -191,7 +191,7 @@ static void button2d_draw_intern( GPU_polygon_smooth(true); } else if (button->icon != ICON_NONE) { - button2d_geom_draw_backdrop(mpr, color, select); + button2d_geom_draw_backdrop(gz, color, select); float size[2]; if (is_3d) { const float fac = 2.0f; @@ -201,8 +201,8 @@ static void button2d_draw_intern( size[1] = 1.0f; } else { - size[0] = mpr->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; - size[1] = mpr->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; + size[0] = gz->matrix_basis[3][0] - (ICON_DEFAULT_WIDTH / 2.0) * UI_DPI_FAC; + size[1] = gz->matrix_basis[3][1] - (ICON_DEFAULT_HEIGHT / 2.0) * UI_DPI_FAC; gpuPopMatrix(); need_to_pop = false; } @@ -216,40 +216,40 @@ static void button2d_draw_intern( } } -static void gizmo_button2d_draw_select(const bContext *C, wmGizmo *mpr, int select_id) +static void gizmo_button2d_draw_select(const bContext *C, wmGizmo *gz, int select_id) { GPU_select_load_id(select_id); - button2d_draw_intern(C, mpr, true, false); + button2d_draw_intern(C, gz, true, false); } -static void gizmo_button2d_draw(const bContext *C, wmGizmo *mpr) +static void gizmo_button2d_draw(const bContext *C, wmGizmo *gz) { - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; GPU_blend(true); - button2d_draw_intern(C, mpr, false, is_highlight); + button2d_draw_intern(C, gz, false, is_highlight); GPU_blend(false); } static int gizmo_button2d_test_select( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { float point_local[2]; if (0) { /* correct, but unnecessarily slow. */ if (gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) { return -1; } } else { copy_v2_v2(point_local, (float[2]){UNPACK2(event->mval)}); - sub_v2_v2(point_local, mpr->matrix_basis[3]); - mul_v2_fl(point_local, 1.0f / (mpr->scale_basis * UI_DPI_FAC)); + sub_v2_v2(point_local, gz->matrix_basis[3]); + mul_v2_fl(point_local, 1.0f / (gz->scale_basis * UI_DPI_FAC)); } - /* The 'mpr->scale_final' is already applied when projecting. */ + /* The 'gz->scale_final' is already applied when projecting. */ if (len_squared_v2(point_local) < 1.0f) { return 0; } @@ -257,17 +257,17 @@ static int gizmo_button2d_test_select( return -1; } -static int gizmo_button2d_cursor_get(wmGizmo *mpr) +static int gizmo_button2d_cursor_get(wmGizmo *gz) { - if (RNA_boolean_get(mpr->ptr, "show_drag")) { + if (RNA_boolean_get(gz->ptr, "show_drag")) { return BC_NSEW_SCROLLCURSOR; } return CURSOR_STD; } -static void gizmo_button2d_free(wmGizmo *mpr) +static void gizmo_button2d_free(wmGizmo *gz) { - ButtonGizmo2D *shape = (ButtonGizmo2D *)mpr; + ButtonGizmo2D *shape = (ButtonGizmo2D *)gz; for (uint i = 0; i < ARRAY_SIZE(shape->shape_batch); i++) { GWN_BATCH_DISCARD_SAFE(shape->shape_batch[i]); @@ -281,19 +281,19 @@ static void gizmo_button2d_free(wmGizmo *mpr) * * \{ */ -static void GIZMO_WT_button_2d(wmGizmoType *wt) +static void GIZMO_GT_button_2d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_button_2d"; + gzt->idname = "GIZMO_GT_button_2d"; /* api callbacks */ - wt->draw = gizmo_button2d_draw; - wt->draw_select = gizmo_button2d_draw_select; - wt->test_select = gizmo_button2d_test_select; - wt->cursor_get = gizmo_button2d_cursor_get; - wt->free = gizmo_button2d_free; + gzt->draw = gizmo_button2d_draw; + gzt->draw_select = gizmo_button2d_draw_select; + gzt->test_select = gizmo_button2d_test_select; + gzt->cursor_get = gizmo_button2d_cursor_get; + gzt->free = gizmo_button2d_free; - wt->struct_size = sizeof(ButtonGizmo2D); + gzt->struct_size = sizeof(ButtonGizmo2D); /* rna */ static EnumPropertyItem rna_enum_draw_options[] = { @@ -303,21 +303,21 @@ static void GIZMO_WT_button_2d(wmGizmoType *wt) }; PropertyRNA *prop; - RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); + RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - prop = RNA_def_property(wt->srna, "icon", PROP_ENUM, PROP_NONE); + prop = RNA_def_property(gzt->srna, "icon", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, rna_enum_icon_items); /* Passed to 'GPU_batch_tris_from_poly_2d_encoded' */ - RNA_def_property(wt->srna, "shape", PROP_STRING, PROP_BYTESTRING); + RNA_def_property(gzt->srna, "shape", PROP_STRING, PROP_BYTESTRING); /* Currently only used for cursor display. */ - RNA_def_boolean(wt->srna, "show_drag", true, "Show Drag", ""); + RNA_def_boolean(gzt->srna, "show_drag", true, "Show Drag", ""); } void ED_gizmotypes_button_2d(void) { - WM_gizmotype_append(GIZMO_WT_button_2d); + WM_gizmotype_append(GIZMO_GT_button_2d); } /** \} */ // Button Gizmo API diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index a037727de58..8a830302f51 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -68,7 +68,7 @@ #define GIZMO_MARGIN_OFFSET_SCALE 1.5f static void gizmo_calc_rect_view_scale( - const wmGizmo *mpr, const float dims[2], float scale[2]) + const wmGizmo *gz, const float dims[2], float scale[2]) { float matrix_final_no_offset[4][4]; float asp[2] = {1.0f, 1.0f}; @@ -79,9 +79,9 @@ static void gizmo_calc_rect_view_scale( asp[1] = dims[0] / dims[1]; } float x_axis[3], y_axis[3]; - WM_gizmo_calc_matrix_final_no_offset(mpr, matrix_final_no_offset); - mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]); - mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]); + WM_gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset); + mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, gz->matrix_offset[0]); + mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, gz->matrix_offset[1]); mul_v2_v2(x_axis, asp); mul_v2_v2(y_axis, asp); @@ -91,18 +91,18 @@ static void gizmo_calc_rect_view_scale( } static void gizmo_calc_rect_view_margin( - const wmGizmo *mpr, const float dims[2], float margin[2]) + const wmGizmo *gz, const float dims[2], float margin[2]) { float handle_size; - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { handle_size = 0.15f; } else { handle_size = GIZMO_RESIZER_SIZE; } - handle_size *= mpr->scale_final; + handle_size *= gz->scale_final; float scale_xy[2]; - gizmo_calc_rect_view_scale(mpr, dims, scale_xy); + gizmo_calc_rect_view_scale(gz, dims, scale_xy); margin[0] = ((handle_size * scale_xy[0])); margin[1] = ((handle_size * scale_xy[1])); } @@ -536,26 +536,26 @@ static void cage2d_draw_circle_handles( /** \} */ static void gizmo_cage2d_draw_intern( - wmGizmo *mpr, const bool select, const bool highlight, const int select_id) + wmGizmo *gz, const bool select, const bool highlight, const int select_id) { - // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; + // const bool use_clamp = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); float matrix_final[4][4]; - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int transform_flag = RNA_enum_get(gz->ptr, "transform"); + const int draw_style = RNA_enum_get(gz->ptr, "draw_style"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f}; - WM_gizmo_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(gz, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); float margin[2]; - gizmo_calc_rect_view_margin(mpr, dims, margin); + gizmo_calc_rect_view_margin(gz, dims, margin); /* Handy for quick testing draw (if it's outside bounds). */ if (false) { @@ -588,18 +588,18 @@ static void gizmo_cage2d_draw_intern( for (int i = 0; i < ARRAY_SIZE(scale_parts); i++) { GPU_select_load_id(select_id | scale_parts[i]); cage2d_draw_box_interaction( - mpr->color, scale_parts[i], size, margin, mpr->line_width, true, draw_options); + gz->color, scale_parts[i], size, margin, gz->line_width, true, draw_options); } } if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { const int transform_part = ED_GIZMO_CAGE2D_PART_TRANSLATE; GPU_select_load_id(select_id | transform_part); cage2d_draw_box_interaction( - mpr->color, transform_part, size, margin, mpr->line_width, true, draw_options); + gz->color, transform_part, size, margin, gz->line_width, true, draw_options); } if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { cage2d_draw_box_interaction( - mpr->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, true, draw_options); + gz->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, gz->line_width, true, draw_options); } } else { @@ -611,17 +611,17 @@ static void gizmo_cage2d_draw_intern( }; if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) { /* corner gizmos */ - GPU_line_width(mpr->line_width + 3.0f); + GPU_line_width(gz->line_width + 3.0f); cage2d_draw_box_corners(&r, margin, (const float[3]){0, 0, 0}); /* corner gizmos */ float color[4]; - gizmo_color_get(mpr, highlight, color); - GPU_line_width(mpr->line_width); + gizmo_color_get(gz, highlight, color); + GPU_line_width(gz->line_width); cage2d_draw_box_corners(&r, margin, color); bool show = false; - if (mpr->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { + if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { /* Only show if we're drawing the center handle * otherwise the entire rectangle is the hotspot. */ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { @@ -634,24 +634,24 @@ static void gizmo_cage2d_draw_intern( if (show) { cage2d_draw_box_interaction( - mpr->color, mpr->highlight_part, size_real, margin, mpr->line_width, false, draw_options); + gz->color, gz->highlight_part, size_real, margin, gz->line_width, false, draw_options); } if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_ROTATE) { cage2d_draw_box_interaction( - mpr->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, mpr->line_width, false, draw_options); + gz->color, ED_GIZMO_CAGE2D_PART_ROTATE, size_real, margin, gz->line_width, false, draw_options); } } else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) { float color[4]; - gizmo_color_get(mpr, highlight, color); + gizmo_color_get(gz, highlight, color); GPU_line_smooth(true); GPU_blend(true); - GPU_line_width(mpr->line_width + 3.0f); + GPU_line_width(gz->line_width + 3.0f); cage2d_draw_circle_wire(&r, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); cage2d_draw_circle_wire(&r, margin, color, transform_flag, draw_options); @@ -674,22 +674,22 @@ static void gizmo_cage2d_draw_intern( /** * For when we want to draw 2d cage in 3d views. */ -static void gizmo_cage2d_draw_select(const bContext *UNUSED(C), wmGizmo *mpr, int select_id) +static void gizmo_cage2d_draw_select(const bContext *UNUSED(C), wmGizmo *gz, int select_id) { - gizmo_cage2d_draw_intern(mpr, true, false, select_id); + gizmo_cage2d_draw_intern(gz, true, false, select_id); } -static void gizmo_cage2d_draw(const bContext *UNUSED(C), wmGizmo *mpr) +static void gizmo_cage2d_draw(const bContext *UNUSED(C), wmGizmo *gz) { - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; - gizmo_cage2d_draw_intern(mpr, false, is_highlight, -1); + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + gizmo_cage2d_draw_intern(gz, false, is_highlight, -1); } -static int gizmo_cage2d_get_cursor(wmGizmo *mpr) +static int gizmo_cage2d_get_cursor(wmGizmo *gz) { - int highlight_part = mpr->highlight_part; + int highlight_part = gz->highlight_part; - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { return BC_NSEW_SCROLLCURSOR; } @@ -718,26 +718,26 @@ static int gizmo_cage2d_get_cursor(wmGizmo *mpr) } static int gizmo_cage2d_test_select( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { float point_local[2]; float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); const float size_real[2] = {dims[0] / 2.0f, dims[1] / 2.0f}; if (gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) { return -1; } float margin[2]; - gizmo_calc_rect_view_margin(mpr, dims, margin); + gizmo_calc_rect_view_margin(gz, dims, margin); /* expand for hotspot */ const float size[2] = {size_real[0] + margin[0] / 2, size_real[1] + margin[1] / 2}; - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int transform_flag = RNA_enum_get(gz->ptr, "transform"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { rctf r; @@ -821,32 +821,32 @@ typedef struct RectTransformInteraction { Dial *dial; } RectTransformInteraction; -static void gizmo_cage2d_setup(wmGizmo *mpr) +static void gizmo_cage2d_setup(wmGizmo *gz) { - mpr->flag |= WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_NO_SCALE; + gz->flag |= WM_GIZMO_DRAW_MODAL | WM_GIZMO_DRAW_NO_SCALE; } static int gizmo_cage2d_invoke( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); - copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset); - WM_gizmo_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset); + copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset); + WM_gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset); if (gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0) + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, data->orig_mouse) == 0) { zero_v2(data->orig_mouse); } - mpr->interaction_data = data; + gz->interaction_data = data; return OPERATOR_RUNNING_MODAL; } static int gizmo_cage2d_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag)) { /* For transform logic to be managable we operate in -0.5..0.5 2D space, @@ -856,40 +856,40 @@ static int gizmo_cage2d_modal( * - The cursor offset are multiplied by 'dims'. * - Matrix translation is also multiplied by 'dims'. */ - RectTransformInteraction *data = mpr->interaction_data; + RectTransformInteraction *data = gz->interaction_data; float point_local[2]; float dims[2]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); { float matrix_back[4][4]; - copy_m4_m4(matrix_back, mpr->matrix_offset); - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(matrix_back, gz->matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); bool ok = gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local); - copy_m4_m4(mpr->matrix_offset, matrix_back); + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, point_local); + copy_m4_m4(gz->matrix_offset, matrix_back); if (!ok) { return OPERATOR_RUNNING_MODAL; } } - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - wmGizmoProperty *mpr_prop; + const int transform_flag = RNA_enum_get(gz->ptr, "transform"); + wmGizmoProperty *gz_prop; - mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + gz_prop = WM_gizmo_target_property_find(gz, "matrix"); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]); } - if (mpr->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { + if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_TRANSLATE) { /* do this to prevent clamping from changing size */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); - mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); + gz->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); + gz->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); } - else if (mpr->highlight_part == ED_GIZMO_CAGE2D_PART_ROTATE) { + else if (gz->highlight_part == ED_GIZMO_CAGE2D_PART_ROTATE) { #define MUL_V2_V3_M4_FINAL(test_co, mouse_co) \ mul_v3_m4v3(test_co, data->orig_matrix_final_no_offset, ((const float[3]){UNPACK2(mouse_co), 0.0})) @@ -915,28 +915,28 @@ static int gizmo_cage2d_modal( copy_v3_v3(pivot, data->orig_matrix_offset[3]); - invert_m4_m4(matrix_space_inv, mpr->matrix_space); + invert_m4_m4(matrix_space_inv, gz->matrix_space); unit_m4(matrix_rotate); mul_m4_m4m4(matrix_rotate, matrix_rotate, matrix_space_inv); rotate_m4(matrix_rotate, 'Z', -angle); - mul_m4_m4m4(matrix_rotate, matrix_rotate, mpr->matrix_space); + mul_m4_m4m4(matrix_rotate, matrix_rotate, gz->matrix_space); zero_v3(matrix_rotate[3]); transform_pivot_set_m4(matrix_rotate, pivot); - mul_m4_m4m4(mpr->matrix_offset, matrix_rotate, data->orig_matrix_offset); + mul_m4_m4m4(gz->matrix_offset, matrix_rotate, data->orig_matrix_offset); #undef MUL_V2_V3_M4_FINAL } else { /* scale */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); float pivot[2]; bool constrain_axis[2] = {false}; if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { - gizmo_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); + gizmo_rect_pivot_from_scale_part(gz->highlight_part, pivot, constrain_axis); } else { zero_v2(pivot); @@ -991,11 +991,11 @@ static int gizmo_cage2d_modal( mul_v3_fl(matrix_scale[1], scale[1]); transform_pivot_set_m4(matrix_scale, (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], 0.0f}); - mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale); + mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale); } - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &gz->matrix_offset[0][0]); } /* tag the region for redraw */ @@ -1005,11 +1005,11 @@ static int gizmo_cage2d_modal( return OPERATOR_RUNNING_MODAL; } -static void gizmo_cage2d_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) +static void gizmo_cage2d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop) { - if (STREQ(mpr_prop->type->idname, "matrix")) { - if (WM_gizmo_target_property_array_length(mpr, mpr_prop) == 16) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + if (STREQ(gz_prop->type->idname, "matrix")) { + if (WM_gizmo_target_property_array_length(gz, gz_prop) == 16) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]); } else { BLI_assert(0); @@ -1020,24 +1020,24 @@ static void gizmo_cage2d_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop } } -static void gizmo_cage2d_exit(bContext *C, wmGizmo *mpr, const bool cancel) +static void gizmo_cage2d_exit(bContext *C, wmGizmo *gz, const bool cancel) { - RectTransformInteraction *data = mpr->interaction_data; + RectTransformInteraction *data = gz->interaction_data; MEM_SAFE_FREE(data->dial); if (!cancel) return; - wmGizmoProperty *mpr_prop; + wmGizmoProperty *gz_prop; /* reset properties */ - mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); + gz_prop = WM_gizmo_target_property_find(gz, "matrix"); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]); } - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); } @@ -1046,23 +1046,23 @@ static void gizmo_cage2d_exit(bContext *C, wmGizmo *mpr, const bool cancel) * * \{ */ -static void GIZMO_WT_cage_2d(wmGizmoType *wt) +static void GIZMO_GT_cage_2d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_cage_2d"; + gzt->idname = "GIZMO_GT_cage_2d"; /* api callbacks */ - wt->draw = gizmo_cage2d_draw; - wt->draw_select = gizmo_cage2d_draw_select; - wt->test_select = gizmo_cage2d_test_select; - wt->setup = gizmo_cage2d_setup; - wt->invoke = gizmo_cage2d_invoke; - wt->property_update = gizmo_cage2d_property_update; - wt->modal = gizmo_cage2d_modal; - wt->exit = gizmo_cage2d_exit; - wt->cursor_get = gizmo_cage2d_get_cursor; - - wt->struct_size = sizeof(wmGizmo); + gzt->draw = gizmo_cage2d_draw; + gzt->draw_select = gizmo_cage2d_draw_select; + gzt->test_select = gizmo_cage2d_test_select; + gzt->setup = gizmo_cage2d_setup; + gzt->invoke = gizmo_cage2d_invoke; + gzt->property_update = gizmo_cage2d_property_update; + gzt->modal = gizmo_cage2d_modal; + gzt->exit = gizmo_cage2d_exit; + gzt->cursor_get = gizmo_cage2d_get_cursor; + + gzt->struct_size = sizeof(wmGizmo); /* rna */ static EnumPropertyItem rna_enum_draw_style[] = { @@ -1082,19 +1082,19 @@ static void GIZMO_WT_cage_2d(wmGizmoType *wt) {0, NULL, 0, NULL, NULL} }; static float unit_v2[2] = {1.0f, 1.0f}; - RNA_def_float_vector(wt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); - RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); + RNA_def_float_vector(gzt->srna, "dimensions", 2, unit_v2, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); + RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); + RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); RNA_def_enum_flag( - wt->srna, "draw_options", rna_enum_draw_options, + gzt->srna, "draw_options", rna_enum_draw_options, ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); - WM_gizmotype_target_property_def(wt, "matrix", PROP_FLOAT, 16); + WM_gizmotype_target_property_def(gzt, "matrix", PROP_FLOAT, 16); } void ED_gizmotypes_cage_2d(void) { - WM_gizmotype_append(GIZMO_WT_cage_2d); + WM_gizmotype_append(GIZMO_GT_cage_2d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c index e266514855b..c3fb5a08cdb 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage3d_gizmo.c @@ -67,7 +67,7 @@ #define GIZMO_MARGIN_OFFSET_SCALE 1.5f static void gizmo_calc_matrix_final_no_offset( - const wmGizmo *mpr, float orig_matrix_final_no_offset[4][4], bool use_space) + const wmGizmo *gz, float orig_matrix_final_no_offset[4][4], bool use_space) { float mat_identity[4][4]; struct WM_GizmoMatrixParams params = {NULL}; @@ -76,11 +76,11 @@ static void gizmo_calc_matrix_final_no_offset( params.matrix_basis = mat_identity; } params.matrix_offset = mat_identity; - WM_gizmo_calc_matrix_final_params(mpr, ¶ms, orig_matrix_final_no_offset); + WM_gizmo_calc_matrix_final_params(gz, ¶ms, orig_matrix_final_no_offset); } static void gizmo_calc_rect_view_scale( - const wmGizmo *mpr, const float dims[3], float scale[3]) + const wmGizmo *gz, const float dims[3], float scale[3]) { UNUSED_VARS(dims); @@ -88,10 +88,10 @@ static void gizmo_calc_rect_view_scale( float matrix_final_no_offset[4][4]; float x_axis[3], y_axis[3], z_axis[3]; - gizmo_calc_matrix_final_no_offset(mpr, matrix_final_no_offset, false); - mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, mpr->matrix_offset[0]); - mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, mpr->matrix_offset[1]); - mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, mpr->matrix_offset[2]); + gizmo_calc_matrix_final_no_offset(gz, matrix_final_no_offset, false); + mul_v3_mat3_m4v3(x_axis, matrix_final_no_offset, gz->matrix_offset[0]); + mul_v3_mat3_m4v3(y_axis, matrix_final_no_offset, gz->matrix_offset[1]); + mul_v3_mat3_m4v3(z_axis, matrix_final_no_offset, gz->matrix_offset[2]); scale[0] = 1.0f / len_v3(x_axis); scale[1] = 1.0f / len_v3(y_axis); @@ -99,20 +99,20 @@ static void gizmo_calc_rect_view_scale( } static void gizmo_calc_rect_view_margin( - const wmGizmo *mpr, const float dims[3], float margin[3]) + const wmGizmo *gz, const float dims[3], float margin[3]) { float handle_size; - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { handle_size = 0.15f; } else { handle_size = GIZMO_RESIZER_SIZE; } // XXX, the scale isn't taking offset into account, we need to calculate scale per handle! - // handle_size *= mpr->scale_final; + // handle_size *= gz->scale_final; float scale_xyz[3]; - gizmo_calc_rect_view_scale(mpr, dims, scale_xyz); + gizmo_calc_rect_view_scale(gz, dims, scale_xyz); margin[0] = ((handle_size * scale_xyz[0])); margin[1] = ((handle_size * scale_xyz[1])); margin[2] = ((handle_size * scale_xyz[2])); @@ -281,26 +281,26 @@ static void cage3d_draw_circle_handles( static void gizmo_cage3d_draw_intern( RegionView3D *rv3d, - wmGizmo *mpr, const bool select, const bool highlight, const int select_id) + wmGizmo *gz, const bool select, const bool highlight, const int select_id) { - // const bool use_clamp = (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; + // const bool use_clamp = (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) == 0; float dims[3]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); float matrix_final[4][4]; - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int transform_flag = RNA_enum_get(gz->ptr, "transform"); + const int draw_style = RNA_enum_get(gz->ptr, "draw_style"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); const float size_real[3] = {dims[0] / 2.0f, dims[1] / 2.0f, dims[2] / 2.0f}; - WM_gizmo_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(gz, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); float margin[3]; - gizmo_calc_rect_view_margin(mpr, dims, margin); + gizmo_calc_rect_view_margin(gz, dims, margin); /* Handy for quick testing draw (if it's outside bounds). */ if (false) { @@ -338,14 +338,14 @@ static void gizmo_cage3d_draw_intern( } GPU_select_load_id(select_id | i); cage3d_draw_box_interaction( - mpr->color, i, size, margin); + gz->color, i, size, margin); } } if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { const int transform_part = ED_GIZMO_CAGE3D_PART_TRANSLATE; GPU_select_load_id(select_id | transform_part); cage3d_draw_box_interaction( - mpr->color, transform_part, size, margin); + gz->color, transform_part, size, margin); } } else { @@ -359,17 +359,17 @@ static void gizmo_cage3d_draw_intern( #endif if (draw_style == ED_GIZMO_CAGE2D_STYLE_BOX) { /* corner gizmos */ - GPU_line_width(mpr->line_width + 3.0f); + GPU_line_width(gz->line_width + 3.0f); cage3d_draw_box_corners(size_real, margin, (const float[3]){0, 0, 0}); /* corner gizmos */ float color[4]; - gizmo_color_get(mpr, highlight, color); - GPU_line_width(mpr->line_width); + gizmo_color_get(gz, highlight, color); + GPU_line_width(gz->line_width); cage3d_draw_box_corners(size_real, margin, color); bool show = false; - if (mpr->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) { + if (gz->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) { /* Only show if we're drawing the center handle * otherwise the entire rectangle is the hotspot. */ if (draw_options & ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE) { @@ -382,20 +382,20 @@ static void gizmo_cage3d_draw_intern( if (show) { cage3d_draw_box_interaction( - mpr->color, mpr->highlight_part, size_real, margin); + gz->color, gz->highlight_part, size_real, margin); } } else if (draw_style == ED_GIZMO_CAGE2D_STYLE_CIRCLE) { float color[4]; - gizmo_color_get(mpr, highlight, color); + gizmo_color_get(gz, highlight, color); GPU_line_smooth(true); GPU_polygon_smooth(true); GPU_blend(true); - GPU_line_width(mpr->line_width + 3.0f); + GPU_line_width(gz->line_width + 3.0f); cage3d_draw_circle_wire(size_real, margin, (const float[3]){0, 0, 0}, transform_flag, draw_options); - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); cage3d_draw_circle_wire(size_real, margin, color, transform_flag, draw_options); /* corner gizmos */ @@ -418,24 +418,24 @@ static void gizmo_cage3d_draw_intern( /** * For when we want to draw 3d cage in 3d views. */ -static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *mpr, int select_id) +static void gizmo_cage3d_draw_select(const bContext *C, wmGizmo *gz, int select_id) { ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - gizmo_cage3d_draw_intern(rv3d, mpr, true, false, select_id); + gizmo_cage3d_draw_intern(rv3d, gz, true, false, select_id); } -static void gizmo_cage3d_draw(const bContext *C, wmGizmo *mpr) +static void gizmo_cage3d_draw(const bContext *C, wmGizmo *gz) { ARegion *ar = CTX_wm_region(C); RegionView3D *rv3d = ar->regiondata; - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; - gizmo_cage3d_draw_intern(rv3d, mpr, false, is_highlight, -1); + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + gizmo_cage3d_draw_intern(rv3d, gz, false, is_highlight, -1); } -static int gizmo_cage3d_get_cursor(wmGizmo *mpr) +static int gizmo_cage3d_get_cursor(wmGizmo *gz) { - if (mpr->parent_mgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { + if (gz->parent_gzgroup->type->flag & WM_GIZMOGROUPTYPE_3D) { return BC_NSEW_SCROLLCURSOR; } @@ -448,33 +448,33 @@ typedef struct RectTransformInteraction { float orig_matrix_final_no_offset[4][4]; } RectTransformInteraction; -static void gizmo_cage3d_setup(wmGizmo *mpr) +static void gizmo_cage3d_setup(wmGizmo *gz) { - mpr->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */ + gz->flag |= /* WM_GIZMO_DRAW_MODAL | */ /* TODO */ WM_GIZMO_DRAW_NO_SCALE; } static int gizmo_cage3d_invoke( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { RectTransformInteraction *data = MEM_callocN(sizeof(RectTransformInteraction), "cage_interaction"); - copy_m4_m4(data->orig_matrix_offset, mpr->matrix_offset); - gizmo_calc_matrix_final_no_offset(mpr, data->orig_matrix_final_no_offset, true); + copy_m4_m4(data->orig_matrix_offset, gz->matrix_offset); + gizmo_calc_matrix_final_no_offset(gz, data->orig_matrix_final_no_offset, true); if (gizmo_window_project_3d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) + C, gz, (const float[2]){UNPACK2(event->mval)}, false, data->orig_mouse) == 0) { zero_v3(data->orig_mouse); } - mpr->interaction_data = data; + gz->interaction_data = data; return OPERATOR_RUNNING_MODAL; } static int gizmo_cage3d_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag)) { /* For transform logic to be managable we operate in -0.5..0.5 2D space, @@ -484,51 +484,51 @@ static int gizmo_cage3d_modal( * - The cursor offset are multiplied by 'dims'. * - Matrix translation is also multiplied by 'dims'. */ - RectTransformInteraction *data = mpr->interaction_data; + RectTransformInteraction *data = gz->interaction_data; float point_local[3]; float dims[3]; - RNA_float_get_array(mpr->ptr, "dimensions", dims); + RNA_float_get_array(gz->ptr, "dimensions", dims); { float matrix_back[4][4]; - copy_m4_m4(matrix_back, mpr->matrix_offset); - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(matrix_back, gz->matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); bool ok = gizmo_window_project_3d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, false, point_local); - copy_m4_m4(mpr->matrix_offset, matrix_back); + C, gz, (const float[2]){UNPACK2(event->mval)}, false, point_local); + copy_m4_m4(gz->matrix_offset, matrix_back); if (!ok) { return OPERATOR_RUNNING_MODAL; } } - const int transform_flag = RNA_enum_get(mpr->ptr, "transform"); - wmGizmoProperty *mpr_prop; + const int transform_flag = RNA_enum_get(gz->ptr, "transform"); + wmGizmoProperty *gz_prop; - mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + gz_prop = WM_gizmo_target_property_find(gz, "matrix"); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]); } - if (mpr->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) { + if (gz->highlight_part == ED_GIZMO_CAGE3D_PART_TRANSLATE) { /* do this to prevent clamping from changing size */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); - mpr->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); - mpr->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); - mpr->matrix_offset[3][2] = data->orig_matrix_offset[3][2] + (point_local[2] - data->orig_mouse[2]); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); + gz->matrix_offset[3][0] = data->orig_matrix_offset[3][0] + (point_local[0] - data->orig_mouse[0]); + gz->matrix_offset[3][1] = data->orig_matrix_offset[3][1] + (point_local[1] - data->orig_mouse[1]); + gz->matrix_offset[3][2] = data->orig_matrix_offset[3][2] + (point_local[2] - data->orig_mouse[2]); } - else if (mpr->highlight_part == ED_GIZMO_CAGE3D_PART_ROTATE) { + else if (gz->highlight_part == ED_GIZMO_CAGE3D_PART_ROTATE) { /* TODO (if needed) */ } else { /* scale */ - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); float pivot[3]; bool constrain_axis[3] = {false}; if (transform_flag & ED_GIZMO_CAGE2D_XFORM_FLAG_TRANSLATE) { - gizmo_rect_pivot_from_scale_part(mpr->highlight_part, pivot, constrain_axis); + gizmo_rect_pivot_from_scale_part(gz->highlight_part, pivot, constrain_axis); } else { zero_v3(pivot); @@ -587,11 +587,11 @@ static int gizmo_cage3d_modal( transform_pivot_set_m4( matrix_scale, (const float[3]){pivot[0] * dims[0], pivot[1] * dims[1], pivot[2] * dims[2]}); - mul_m4_m4m4(mpr->matrix_offset, data->orig_matrix_offset, matrix_scale); + mul_m4_m4m4(gz->matrix_offset, data->orig_matrix_offset, matrix_scale); } - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &mpr->matrix_offset[0][0]); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &gz->matrix_offset[0][0]); } /* tag the region for redraw */ @@ -601,11 +601,11 @@ static int gizmo_cage3d_modal( return OPERATOR_RUNNING_MODAL; } -static void gizmo_cage3d_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) +static void gizmo_cage3d_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop) { - if (STREQ(mpr_prop->type->idname, "matrix")) { - if (WM_gizmo_target_property_array_length(mpr, mpr_prop) == 16) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, &mpr->matrix_offset[0][0]); + if (STREQ(gz_prop->type->idname, "matrix")) { + if (WM_gizmo_target_property_array_length(gz, gz_prop) == 16) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, &gz->matrix_offset[0][0]); } else { BLI_assert(0); @@ -616,22 +616,22 @@ static void gizmo_cage3d_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop } } -static void gizmo_cage3d_exit(bContext *C, wmGizmo *mpr, const bool cancel) +static void gizmo_cage3d_exit(bContext *C, wmGizmo *gz, const bool cancel) { - RectTransformInteraction *data = mpr->interaction_data; + RectTransformInteraction *data = gz->interaction_data; if (!cancel) return; - wmGizmoProperty *mpr_prop; + wmGizmoProperty *gz_prop; /* reset properties */ - mpr_prop = WM_gizmo_target_property_find(mpr, "matrix"); - if (mpr_prop->type != NULL) { - WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, &data->orig_matrix_offset[0][0]); + gz_prop = WM_gizmo_target_property_find(gz, "matrix"); + if (gz_prop->type != NULL) { + WM_gizmo_target_property_value_set_array(C, gz, gz_prop, &data->orig_matrix_offset[0][0]); } - copy_m4_m4(mpr->matrix_offset, data->orig_matrix_offset); + copy_m4_m4(gz->matrix_offset, data->orig_matrix_offset); } @@ -640,22 +640,22 @@ static void gizmo_cage3d_exit(bContext *C, wmGizmo *mpr, const bool cancel) * * \{ */ -static void GIZMO_WT_cage_3d(wmGizmoType *wt) +static void GIZMO_GT_cage_3d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_cage_3d"; + gzt->idname = "GIZMO_GT_cage_3d"; /* api callbacks */ - wt->draw = gizmo_cage3d_draw; - wt->draw_select = gizmo_cage3d_draw_select; - wt->setup = gizmo_cage3d_setup; - wt->invoke = gizmo_cage3d_invoke; - wt->property_update = gizmo_cage3d_property_update; - wt->modal = gizmo_cage3d_modal; - wt->exit = gizmo_cage3d_exit; - wt->cursor_get = gizmo_cage3d_get_cursor; + gzt->draw = gizmo_cage3d_draw; + gzt->draw_select = gizmo_cage3d_draw_select; + gzt->setup = gizmo_cage3d_setup; + gzt->invoke = gizmo_cage3d_invoke; + gzt->property_update = gizmo_cage3d_property_update; + gzt->modal = gizmo_cage3d_modal; + gzt->exit = gizmo_cage3d_exit; + gzt->cursor_get = gizmo_cage3d_get_cursor; - wt->struct_size = sizeof(wmGizmo); + gzt->struct_size = sizeof(wmGizmo); /* rna */ static EnumPropertyItem rna_enum_draw_style[] = { @@ -674,19 +674,19 @@ static void GIZMO_WT_cage_3d(wmGizmoType *wt) {0, NULL, 0, NULL, NULL} }; static float unit_v3[3] = {1.0f, 1.0f, 1.0f}; - RNA_def_float_vector(wt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); - RNA_def_enum_flag(wt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); + RNA_def_float_vector(gzt->srna, "dimensions", 3, unit_v3, 0, FLT_MAX, "Dimensions", "", 0.0f, FLT_MAX); + RNA_def_enum_flag(gzt->srna, "transform", rna_enum_transform, 0, "Transform Options", ""); + RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_CAGE2D_STYLE_CIRCLE, "Draw Style", ""); RNA_def_enum_flag( - wt->srna, "draw_options", rna_enum_draw_options, + gzt->srna, "draw_options", rna_enum_draw_options, ED_GIZMO_CAGE2D_DRAW_FLAG_XFORM_CENTER_HANDLE, "Draw Options", ""); - WM_gizmotype_target_property_def(wt, "matrix", PROP_FLOAT, 16); + WM_gizmotype_target_property_def(gzt, "matrix", PROP_FLOAT, 16); } void ED_gizmotypes_cage_3d(void) { - WM_gizmotype_append(GIZMO_WT_cage_3d); + WM_gizmotype_append(GIZMO_GT_cage_3d); } /** \} */ 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 b93b87b1efa..b45f3d8a242 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/dial3d_gizmo.c @@ -71,7 +71,7 @@ // #define USE_GIZMO_CUSTOM_DIAL static int gizmo_dial_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag); typedef struct DialInteraction { @@ -101,30 +101,30 @@ typedef struct DialInteraction { /** * We can't use this for the #wmGizmoType.matrix_basis_get callback, it conflicts with depth picking. */ -static void dial_calc_matrix(const wmGizmo *mpr, float mat[4][4]) +static void dial_calc_matrix(const wmGizmo *gz, float mat[4][4]) { float rot[3][3]; const float up[3] = {0.0f, 0.0f, 1.0f}; - rotation_between_vecs_to_mat3(rot, up, mpr->matrix_basis[2]); + rotation_between_vecs_to_mat3(rot, up, gz->matrix_basis[2]); copy_m4_m3(mat, rot); - copy_v3_v3(mat[3], mpr->matrix_basis[3]); + copy_v3_v3(mat[3], gz->matrix_basis[3]); } /* -------------------------------------------------------------------- */ static void dial_geom_draw( - const wmGizmo *mpr, const float color[4], const bool select, + const wmGizmo *gz, const float color[4], const bool select, float axis_modal_mat[4][4], float clip_plane[4]) { #ifdef USE_GIZMO_CUSTOM_DIAL UNUSED_VARS(dial, col, axis_modal_mat, clip_plane); wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_dial, select); #else - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); const bool filled = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_FILL) != 0; - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -181,9 +181,9 @@ static void dial_ghostarc_draw_helpline(const float angle, const float co_outer[ } static void dial_ghostarc_draw( - const wmGizmo *mpr, const float angle_ofs, const float angle_delta, const float color[4]) + const wmGizmo *gz, const float angle_ofs, const float angle_delta, const float color[4]) { - const float width_inner = DIAL_WIDTH - mpr->line_width * 0.5f / U.gizmo_size; + const float width_inner = DIAL_WIDTH - gz->line_width * 0.5f / U.gizmo_size; Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -196,24 +196,24 @@ static void dial_ghostarc_draw( static void dial_ghostarc_get_angles( struct Depsgraph *depsgraph, - const wmGizmo *mpr, + const wmGizmo *gz, const wmEvent *event, const ARegion *ar, const View3D *v3d, float mat[4][4], const float co_outer[3], float *r_start, float *r_delta) { - DialInteraction *inter = mpr->interaction_data; + DialInteraction *inter = gz->interaction_data; const RegionView3D *rv3d = ar->regiondata; const float mval[2] = {event->x - ar->winrct.xmin, event->y - ar->winrct.ymin}; /* we might need to invert the direction of the angles */ float view_vec[3], axis_vec[3]; - ED_view3d_global_to_vector(rv3d, mpr->matrix_basis[3], view_vec); - normalize_v3_v3(axis_vec, mpr->matrix_basis[2]); + ED_view3d_global_to_vector(rv3d, gz->matrix_basis[3], view_vec); + normalize_v3_v3(axis_vec, gz->matrix_basis[2]); float proj_outer_rel[3]; mul_v3_project_m4_v3(proj_outer_rel, mat, co_outer); - sub_v3_v3(proj_outer_rel, mpr->matrix_basis[3]); + sub_v3_v3(proj_outer_rel, gz->matrix_basis[3]); float proj_mval_new_rel[3]; float proj_mval_init_rel[3]; @@ -221,7 +221,7 @@ static void dial_ghostarc_get_angles( float ray_co[3], ray_no[3]; float ray_lambda; - plane_from_point_normal_v3(dial_plane, mpr->matrix_basis[3], axis_vec); + plane_from_point_normal_v3(dial_plane, gz->matrix_basis[3], axis_vec); if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, inter->init_mval, ray_co, ray_no, false) || !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) @@ -229,7 +229,7 @@ static void dial_ghostarc_get_angles( goto fail; } madd_v3_v3v3fl(proj_mval_init_rel, ray_co, ray_no, ray_lambda); - sub_v3_v3(proj_mval_init_rel, mpr->matrix_basis[3]); + sub_v3_v3(proj_mval_init_rel, gz->matrix_basis[3]); if (!ED_view3d_win_to_ray(depsgraph, ar, v3d, mval, ray_co, ray_no, false) || !isect_ray_plane_v3(ray_co, ray_no, dial_plane, &ray_lambda, false)) @@ -237,14 +237,14 @@ static void dial_ghostarc_get_angles( goto fail; } madd_v3_v3v3fl(proj_mval_new_rel, ray_co, ray_no, ray_lambda); - sub_v3_v3(proj_mval_new_rel, mpr->matrix_basis[3]); + sub_v3_v3(proj_mval_new_rel, gz->matrix_basis[3]); - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); /* Start direction from mouse or set by user */ const float *proj_init_rel = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y) ? - mpr->matrix_basis[1] : proj_mval_init_rel; + gz->matrix_basis[1] : proj_mval_init_rel; /* return angles */ const float start = angle_wrap_rad(angle_signed_on_axis_v3v3_v3(proj_outer_rel, proj_init_rel, axis_vec)); @@ -274,7 +274,7 @@ fail: } static void dial_draw_intern( - const bContext *C, wmGizmo *mpr, + const bContext *C, wmGizmo *gz, const bool select, const bool highlight, float clip_plane[4]) { float matrix_basis_adjust[4][4]; @@ -283,12 +283,12 @@ static void dial_draw_intern( BLI_assert(CTX_wm_area(C)->spacetype == SPACE_VIEW3D); - gizmo_color_get(mpr, highlight, color); + gizmo_color_get(gz, highlight, color); - dial_calc_matrix(mpr, matrix_basis_adjust); + dial_calc_matrix(gz, matrix_basis_adjust); WM_gizmo_calc_matrix_final_params( - mpr, &((struct WM_GizmoMatrixParams) { + gz, &((struct WM_GizmoMatrixParams) { .matrix_basis = (void *)matrix_basis_adjust, }), matrix_final); @@ -296,17 +296,17 @@ static void dial_draw_intern( gpuMultMatrix(matrix_final); /* draw rotation indicator arc first */ - if ((mpr->flag & WM_GIZMO_DRAW_VALUE) && - (mpr->state & WM_GIZMO_STATE_MODAL)) + if ((gz->flag & WM_GIZMO_DRAW_VALUE) && + (gz->state & WM_GIZMO_STATE_MODAL)) { const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ - DialInteraction *inter = mpr->interaction_data; + DialInteraction *inter = gz->interaction_data; /* XXX, View3D rotation gizmo doesn't call modal. */ - if (!WM_gizmo_target_property_is_valid_any(mpr)) { + if (!WM_gizmo_target_property_is_valid_any(gz)) { wmWindow *win = CTX_wm_window(C); - gizmo_dial_modal((bContext *)C, mpr, win->eventstate, 0); + gizmo_dial_modal((bContext *)C, gz, win->eventstate, 0); } float angle_ofs = inter->output.angle_ofs; @@ -315,14 +315,14 @@ static void dial_draw_intern( /* draw! */ for (int i = 0; i < 2; i++) { GPU_polygon_smooth(false); - dial_ghostarc_draw(mpr, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f}); + dial_ghostarc_draw(gz, angle_ofs, angle_delta, (const float[4]){0.8f, 0.8f, 0.8f, 0.4f}); GPU_polygon_smooth(true); dial_ghostarc_draw_helpline(angle_ofs, co_outer, color); /* starting position */ dial_ghostarc_draw_helpline(angle_ofs + angle_delta, co_outer, color); /* starting position + current value */ if (i == 0) { - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); if ((draw_options & ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR) == 0) { break; } @@ -333,15 +333,15 @@ static void dial_draw_intern( } /* draw actual dial gizmo */ - dial_geom_draw(mpr, color, select, matrix_basis_adjust, clip_plane); + dial_geom_draw(gz, color, select, matrix_basis_adjust, clip_plane); gpuPopMatrix(); } -static void gizmo_dial_draw_select(const bContext *C, wmGizmo *mpr, int select_id) +static void gizmo_dial_draw_select(const bContext *C, wmGizmo *gz, int select_id) { float clip_plane_buf[4]; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); float *clip_plane = (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP) ? clip_plane_buf : NULL; /* enable clipping if needed */ @@ -350,25 +350,25 @@ static void gizmo_dial_draw_select(const bContext *C, wmGizmo *mpr, int select_i RegionView3D *rv3d = ar->regiondata; copy_v3_v3(clip_plane, rv3d->viewinv[2]); - clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]); - clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final; + clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]); + clip_plane[3] += DIAL_CLIP_BIAS * gz->scale_final; glEnable(GL_CLIP_DISTANCE0); } GPU_select_load_id(select_id); - dial_draw_intern(C, mpr, true, false, clip_plane); + dial_draw_intern(C, gz, true, false, clip_plane); if (clip_plane) { glDisable(GL_CLIP_DISTANCE0); } } -static void gizmo_dial_draw(const bContext *C, wmGizmo *mpr) +static void gizmo_dial_draw(const bContext *C, wmGizmo *gz) { - const bool is_modal = mpr->state & WM_GIZMO_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL; + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; float clip_plane_buf[4]; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); float *clip_plane = (!is_modal && (draw_options & ED_GIZMO_DIAL_DRAW_FLAG_CLIP)) ? clip_plane_buf : NULL; /* enable clipping if needed */ @@ -377,14 +377,14 @@ static void gizmo_dial_draw(const bContext *C, wmGizmo *mpr) RegionView3D *rv3d = ar->regiondata; copy_v3_v3(clip_plane, rv3d->viewinv[2]); - clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], mpr->matrix_basis[3]); - clip_plane[3] += DIAL_CLIP_BIAS * mpr->scale_final; + clip_plane[3] = -dot_v3v3(rv3d->viewinv[2], gz->matrix_basis[3]); + clip_plane[3] += DIAL_CLIP_BIAS * gz->scale_final; glEnable(GL_CLIP_DISTANCE0); } GPU_blend(true); - dial_draw_intern(C, mpr, false, is_highlight, clip_plane); + dial_draw_intern(C, gz, false, is_highlight, clip_plane); GPU_blend(false); if (clip_plane) { @@ -393,7 +393,7 @@ static void gizmo_dial_draw(const bContext *C, wmGizmo *mpr) } static int gizmo_dial_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag)) { const float co_outer[4] = {0.0f, DIAL_WIDTH, 0.0f}; /* coordinate at which the arc drawing will be started */ @@ -401,48 +401,48 @@ static int gizmo_dial_modal( float matrix[4][4]; - dial_calc_matrix(mpr, matrix); + dial_calc_matrix(gz, matrix); dial_ghostarc_get_angles( CTX_data_depsgraph(C), - mpr, event, CTX_wm_region(C), CTX_wm_view3d(C), matrix, co_outer, &angle_ofs, &angle_delta); + gz, event, CTX_wm_region(C), CTX_wm_view3d(C), matrix, co_outer, &angle_ofs, &angle_delta); - DialInteraction *inter = mpr->interaction_data; + DialInteraction *inter = gz->interaction_data; inter->output.angle_delta = angle_delta; inter->output.angle_ofs = angle_ofs; /* set the property for the operator and call its modal function */ - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - WM_gizmo_target_property_value_set(C, mpr, mpr_prop, inter->init_prop_angle + angle_delta); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + WM_gizmo_target_property_value_set(C, gz, gz_prop, inter->init_prop_angle + angle_delta); } return OPERATOR_RUNNING_MODAL; } -static void gizmo_dial_setup(wmGizmo *mpr) +static void gizmo_dial_setup(wmGizmo *gz) { const float dir_default[3] = {0.0f, 0.0f, 1.0f}; /* defaults */ - copy_v3_v3(mpr->matrix_basis[2], dir_default); + copy_v3_v3(gz->matrix_basis[2], dir_default); } static int gizmo_dial_invoke( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { DialInteraction *inter = MEM_callocN(sizeof(DialInteraction), __func__); inter->init_mval[0] = event->mval[0]; inter->init_mval[1] = event->mval[1]; - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - inter->init_prop_angle = WM_gizmo_target_property_value_get(mpr, mpr_prop); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + inter->init_prop_angle = WM_gizmo_target_property_value_get(gz, gz_prop); } - mpr->interaction_data = inter; + gz->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } @@ -452,19 +452,19 @@ static int gizmo_dial_invoke( * * \{ */ -static void GIZMO_WT_dial_3d(wmGizmoType *wt) +static void GIZMO_GT_dial_3d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_dial_3d"; + gzt->idname = "GIZMO_GT_dial_3d"; /* api callbacks */ - wt->draw = gizmo_dial_draw; - wt->draw_select = gizmo_dial_draw_select; - wt->setup = gizmo_dial_setup; - wt->invoke = gizmo_dial_invoke; - wt->modal = gizmo_dial_modal; + gzt->draw = gizmo_dial_draw; + gzt->draw_select = gizmo_dial_draw_select; + gzt->setup = gizmo_dial_setup; + gzt->invoke = gizmo_dial_invoke; + gzt->modal = gizmo_dial_modal; - wt->struct_size = sizeof(wmGizmo); + gzt->struct_size = sizeof(wmGizmo); /* rna */ static EnumPropertyItem rna_enum_draw_options[] = { @@ -474,14 +474,14 @@ static void GIZMO_WT_dial_3d(wmGizmoType *wt) {ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y, "ANGLE_START_Y", 0, "Angle Start Y", ""}, {0, NULL, 0, NULL, NULL} }; - RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); + RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - WM_gizmotype_target_property_def(wt, "offset", PROP_FLOAT, 1); + WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 1); } void ED_gizmotypes_dial_3d(void) { - WM_gizmotype_append(GIZMO_WT_dial_3d); + WM_gizmotype_append(GIZMO_GT_dial_3d); } /** \} */ diff --git a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c index 2a89c8cc4ab..c6d11347e9f 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/grab3d_gizmo.c @@ -68,16 +68,16 @@ typedef struct GrabGizmo3D { float prop_co[3]; } GrabGizmo3D; -static void gizmo_grab_matrix_basis_get(const wmGizmo *mpr, float r_matrix[4][4]) +static void gizmo_grab_matrix_basis_get(const wmGizmo *gz, float r_matrix[4][4]) { - GrabGizmo3D *grab = (GrabGizmo3D *)mpr; + GrabGizmo3D *grab = (GrabGizmo3D *)gz; copy_m4_m4(r_matrix, grab->gizmo.matrix_basis); add_v3_v3(r_matrix[3], grab->prop_co); } static int gizmo_grab_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak tweak_flag); typedef struct GrabInteraction { @@ -94,16 +94,16 @@ typedef struct GrabInteraction { /* -------------------------------------------------------------------- */ static void grab_geom_draw( - const wmGizmo *mpr, const float color[4], const bool select, const int draw_options) + const wmGizmo *gz, const float color[4], const bool select, const int draw_options) { #ifdef USE_GIZMO_CUSTOM_DIAL UNUSED_VARS(grab3d, col, axis_modal_mat); wm_gizmo_geometryinfo_draw(&wm_gizmo_geom_data_grab3d, select); #else - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); + const int draw_style = RNA_enum_get(gz->ptr, "draw_style"); const bool filled = (draw_options & ED_GIZMO_GRAB_DRAW_FLAG_FILL) != 0; - GPU_line_width(mpr->line_width); + GPU_line_width(gz->line_width); Gwn_VertFormat *format = immVertexFormat(); uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); @@ -140,10 +140,10 @@ static void grab_geom_draw( } static void grab3d_get_translate( - const wmGizmo *mpr, const wmEvent *event, const ARegion *ar, + const wmGizmo *gz, const wmEvent *event, const ARegion *ar, float co_delta[3]) { - GrabInteraction *inter = mpr->interaction_data; + GrabInteraction *inter = gz->interaction_data; const float mval_delta[2] = { event->mval[0] - inter->init_mval[0], event->mval[1] - inter->init_mval[1], @@ -151,30 +151,30 @@ static void grab3d_get_translate( RegionView3D *rv3d = ar->regiondata; float co_ref[3]; - mul_v3_mat3_m4v3(co_ref, mpr->matrix_space, inter->init_prop_co); + mul_v3_mat3_m4v3(co_ref, gz->matrix_space, inter->init_prop_co); const float zfac = ED_view3d_calc_zfac(rv3d, co_ref, NULL); ED_view3d_win_to_delta(ar, mval_delta, co_delta, zfac); float matrix_space_inv[3][3]; - copy_m3_m4(matrix_space_inv, mpr->matrix_space); + copy_m3_m4(matrix_space_inv, gz->matrix_space); invert_m3(matrix_space_inv); mul_m3_v3(matrix_space_inv, co_delta); } static void grab3d_draw_intern( - const bContext *C, wmGizmo *mpr, + const bContext *C, wmGizmo *gz, const bool select, const bool highlight) { - GrabInteraction *inter = mpr->interaction_data; - const int draw_options = RNA_enum_get(mpr->ptr, "draw_options"); + GrabInteraction *inter = gz->interaction_data; + const int draw_options = RNA_enum_get(gz->ptr, "draw_options"); const bool align_view = (draw_options & ED_GIZMO_GRAB_DRAW_FLAG_ALIGN_VIEW) != 0; float color[4]; float matrix_final[4][4]; float matrix_align[4][4]; - gizmo_color_get(mpr, highlight, color); - WM_gizmo_calc_matrix_final(mpr, matrix_final); + gizmo_color_get(gz, highlight, color); + WM_gizmo_calc_matrix_final(gz, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); @@ -190,11 +190,11 @@ static void grab3d_draw_intern( } GPU_blend(true); - grab_geom_draw(mpr, color, select, draw_options); + grab_geom_draw(gz, color, select, draw_options); GPU_blend(false); gpuPopMatrix(); - if (mpr->interaction_data) { + if (gz->interaction_data) { gpuPushMatrix(); gpuMultMatrix(inter->init_matrix_final); @@ -203,48 +203,48 @@ static void grab3d_draw_intern( } GPU_blend(true); - grab_geom_draw(mpr, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); + grab_geom_draw(gz, (const float[4]){0.5f, 0.5f, 0.5f, 0.5f}, select, draw_options); GPU_blend(false); gpuPopMatrix(); } } -static void gizmo_grab_draw_select(const bContext *C, wmGizmo *mpr, int select_id) +static void gizmo_grab_draw_select(const bContext *C, wmGizmo *gz, int select_id) { GPU_select_load_id(select_id); - grab3d_draw_intern(C, mpr, true, false); + grab3d_draw_intern(C, gz, true, false); } -static void gizmo_grab_draw(const bContext *C, wmGizmo *mpr) +static void gizmo_grab_draw(const bContext *C, wmGizmo *gz) { - const bool is_modal = mpr->state & WM_GIZMO_STATE_MODAL; - const bool is_highlight = (mpr->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; + const bool is_modal = gz->state & WM_GIZMO_STATE_MODAL; + const bool is_highlight = (gz->state & WM_GIZMO_STATE_HIGHLIGHT) != 0; (void)is_modal; GPU_blend(true); - grab3d_draw_intern(C, mpr, false, is_highlight); + grab3d_draw_intern(C, gz, false, is_highlight); GPU_blend(false); } static int gizmo_grab_modal( - bContext *C, wmGizmo *mpr, const wmEvent *event, + bContext *C, wmGizmo *gz, const wmEvent *event, eWM_GizmoFlagTweak UNUSED(tweak_flag)) { - GrabGizmo3D *grab = (GrabGizmo3D *)mpr; - GrabInteraction *inter = mpr->interaction_data; + GrabGizmo3D *grab = (GrabGizmo3D *)gz; + GrabInteraction *inter = gz->interaction_data; ARegion *ar = CTX_wm_region(C); float prop_delta[3]; if (CTX_wm_area(C)->spacetype == SPACE_VIEW3D) { - grab3d_get_translate(mpr, event, ar, prop_delta); + grab3d_get_translate(gz, event, ar, prop_delta); } else { float mval_proj_init[2], mval_proj_curr[2]; if ((gizmo_window_project_2d( - C, mpr, inter->init_mval, 2, false, mval_proj_init) == false) || + C, gz, inter->init_mval, 2, false, mval_proj_init) == false) || (gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false)) + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, false, mval_proj_curr) == false)) { return OPERATOR_RUNNING_MODAL; } @@ -254,9 +254,9 @@ static int gizmo_grab_modal( add_v3_v3v3(grab->prop_co, inter->init_prop_co, prop_delta); /* set the property for the operator and call its modal function */ - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - WM_gizmo_target_property_value_set_array(C, mpr, mpr_prop, grab->prop_co); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + WM_gizmo_target_property_value_set_array(C, gz, gz_prop, grab->prop_co); } else { zero_v3(grab->prop_co); @@ -268,7 +268,7 @@ static int gizmo_grab_modal( } static int gizmo_grab_invoke( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *event) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *event) { GrabInteraction *inter = MEM_callocN(sizeof(GrabInteraction), __func__); @@ -278,32 +278,32 @@ static int gizmo_grab_invoke( #if 0 copy_v3_v3(inter->init_prop_co, grab->prop_co); #else - wmGizmoProperty *mpr_prop = WM_gizmo_target_property_find(mpr, "offset"); - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, inter->init_prop_co); + wmGizmoProperty *gz_prop = WM_gizmo_target_property_find(gz, "offset"); + if (WM_gizmo_target_property_is_valid(gz_prop)) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, inter->init_prop_co); } #endif - WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); + WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final); - mpr->interaction_data = inter; + gz->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } static int gizmo_grab_test_select( - bContext *C, wmGizmo *mpr, const wmEvent *event) + bContext *C, wmGizmo *gz, const wmEvent *event) { float point_local[2]; if (gizmo_window_project_2d( - C, mpr, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) + C, gz, (const float[2]){UNPACK2(event->mval)}, 2, true, point_local) == false) { return -1; } - /* The 'mpr->scale_final' is already applied when projecting. */ + /* The 'gz->scale_final' is already applied when projecting. */ if (len_squared_v2(point_local) < 1.0f) { return 0; } @@ -311,18 +311,18 @@ static int gizmo_grab_test_select( return -1; } -static void gizmo_grab_property_update(wmGizmo *mpr, wmGizmoProperty *mpr_prop) +static void gizmo_grab_property_update(wmGizmo *gz, wmGizmoProperty *gz_prop) { - GrabGizmo3D *grab = (GrabGizmo3D *)mpr; - if (WM_gizmo_target_property_is_valid(mpr_prop)) { - WM_gizmo_target_property_value_get_array(mpr, mpr_prop, grab->prop_co); + GrabGizmo3D *grab = (GrabGizmo3D *)gz; + if (WM_gizmo_target_property_is_valid(gz_prop)) { + WM_gizmo_target_property_value_get_array(gz, gz_prop, grab->prop_co); } else { zero_v3(grab->prop_co); } } -static int gizmo_grab_cursor_get(wmGizmo *UNUSED(mpr)) +static int gizmo_grab_cursor_get(wmGizmo *UNUSED(gz)) { return BC_NSEW_SCROLLCURSOR; } @@ -332,22 +332,22 @@ static int gizmo_grab_cursor_get(wmGizmo *UNUSED(mpr)) * * \{ */ -static void GIZMO_WT_grab_3d(wmGizmoType *wt) +static void GIZMO_GT_grab_3d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_grab_3d"; + gzt->idname = "GIZMO_GT_grab_3d"; /* api callbacks */ - wt->draw = gizmo_grab_draw; - wt->draw_select = gizmo_grab_draw_select; - wt->test_select = gizmo_grab_test_select; - wt->matrix_basis_get = gizmo_grab_matrix_basis_get; - wt->invoke = gizmo_grab_invoke; - wt->property_update = gizmo_grab_property_update; - wt->modal = gizmo_grab_modal; - wt->cursor_get = gizmo_grab_cursor_get; + gzt->draw = gizmo_grab_draw; + gzt->draw_select = gizmo_grab_draw_select; + gzt->test_select = gizmo_grab_test_select; + gzt->matrix_basis_get = gizmo_grab_matrix_basis_get; + gzt->invoke = gizmo_grab_invoke; + gzt->property_update = gizmo_grab_property_update; + gzt->modal = gizmo_grab_modal; + gzt->cursor_get = gizmo_grab_cursor_get; - wt->struct_size = sizeof(GrabGizmo3D); + gzt->struct_size = sizeof(GrabGizmo3D); /* rna */ static EnumPropertyItem rna_enum_draw_style[] = { @@ -361,15 +361,15 @@ static void GIZMO_WT_grab_3d(wmGizmoType *wt) {0, NULL, 0, NULL, NULL} }; - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_GRAB_STYLE_RING_2D, "Draw Style", ""); - RNA_def_enum_flag(wt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); + RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_GRAB_STYLE_RING_2D, "Draw Style", ""); + RNA_def_enum_flag(gzt->srna, "draw_options", rna_enum_draw_options, 0, "Draw Options", ""); - WM_gizmotype_target_property_def(wt, "offset", PROP_FLOAT, 3); + WM_gizmotype_target_property_def(gzt, "offset", PROP_FLOAT, 3); } void ED_gizmotypes_grab_3d(void) { - WM_gizmotype_append(GIZMO_WT_grab_3d); + WM_gizmotype_append(GIZMO_GT_grab_3d); } /** \} */ // Grab Gizmo API diff --git a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c index ff02517dafa..be2bf7d2c56 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/primitive3d_gizmo.c @@ -86,18 +86,18 @@ static void gizmo_primitive_draw_geom( } static void gizmo_primitive_draw_intern( - wmGizmo *mpr, const bool UNUSED(select), + wmGizmo *gz, const bool UNUSED(select), const bool highlight) { float color_inner[4], color_outer[4]; float matrix_final[4][4]; - const int draw_style = RNA_enum_get(mpr->ptr, "draw_style"); + const int draw_style = RNA_enum_get(gz->ptr, "draw_style"); - gizmo_color_get(mpr, highlight, color_outer); + gizmo_color_get(gz, highlight, color_outer); copy_v4_v4(color_inner, color_outer); color_inner[3] *= 0.5f; - WM_gizmo_calc_matrix_final(mpr, matrix_final); + WM_gizmo_calc_matrix_final(gz, matrix_final); gpuPushMatrix(); gpuMultMatrix(matrix_final); @@ -108,8 +108,8 @@ static void gizmo_primitive_draw_intern( gpuPopMatrix(); - if (mpr->interaction_data) { - GizmoInteraction *inter = mpr->interaction_data; + if (gz->interaction_data) { + GizmoInteraction *inter = gz->interaction_data; copy_v4_fl(color_inner, 0.5f); copy_v3_fl(color_outer, 0.5f); @@ -127,33 +127,33 @@ static void gizmo_primitive_draw_intern( } static void gizmo_primitive_draw_select( - const bContext *UNUSED(C), wmGizmo *mpr, + const bContext *UNUSED(C), wmGizmo *gz, int select_id) { GPU_select_load_id(select_id); - gizmo_primitive_draw_intern(mpr, true, false); + gizmo_primitive_draw_intern(gz, true, false); } -static void gizmo_primitive_draw(const bContext *UNUSED(C), wmGizmo *mpr) +static void gizmo_primitive_draw(const bContext *UNUSED(C), wmGizmo *gz) { gizmo_primitive_draw_intern( - mpr, false, - (mpr->state & WM_GIZMO_STATE_HIGHLIGHT)); + gz, false, + (gz->state & WM_GIZMO_STATE_HIGHLIGHT)); } -static void gizmo_primitive_setup(wmGizmo *mpr) +static void gizmo_primitive_setup(wmGizmo *gz) { - mpr->flag |= WM_GIZMO_DRAW_MODAL; + gz->flag |= WM_GIZMO_DRAW_MODAL; } static int gizmo_primitive_invoke( - bContext *UNUSED(C), wmGizmo *mpr, const wmEvent *UNUSED(event)) + bContext *UNUSED(C), wmGizmo *gz, const wmEvent *UNUSED(event)) { GizmoInteraction *inter = MEM_callocN(sizeof(GizmoInteraction), __func__); - WM_gizmo_calc_matrix_final(mpr, inter->init_matrix_final); + WM_gizmo_calc_matrix_final(gz, inter->init_matrix_final); - mpr->interaction_data = inter; + gz->interaction_data = inter; return OPERATOR_RUNNING_MODAL; } @@ -163,29 +163,29 @@ static int gizmo_primitive_invoke( * * \{ */ -static void GIZMO_WT_primitive_3d(wmGizmoType *wt) +static void GIZMO_GT_primitive_3d(wmGizmoType *gzt) { /* identifiers */ - wt->idname = "GIZMO_WT_primitive_3d"; + gzt->idname = "GIZMO_GT_primitive_3d"; /* api callbacks */ - wt->draw = gizmo_primitive_draw; - wt->draw_select = gizmo_primitive_draw_select; - wt->setup = gizmo_primitive_setup; - wt->invoke = gizmo_primitive_invoke; + gzt->draw = gizmo_primitive_draw; + gzt->draw_select = gizmo_primitive_draw_select; + gzt->setup = gizmo_primitive_setup; + gzt->invoke = gizmo_primitive_invoke; - wt->struct_size = sizeof(wmGizmo); + gzt->struct_size = sizeof(wmGizmo); static EnumPropertyItem rna_enum_draw_style[] = { {ED_GIZMO_PRIMITIVE_STYLE_PLANE, "PLANE", 0, "Plane", ""}, {0, NULL, 0, NULL, NULL} }; - RNA_def_enum(wt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_PRIMITIVE_STYLE_PLANE, "Draw Style", ""); + RNA_def_enum(gzt->srna, "draw_style", rna_enum_draw_style, ED_GIZMO_PRIMITIVE_STYLE_PLANE, "Draw Style", ""); } void ED_gizmotypes_primitive_3d(void) { - WM_gizmotype_append(GIZMO_WT_primitive_3d); + WM_gizmotype_append(GIZMO_GT_primitive_3d); } /** \} */ -- cgit v1.2.3