diff options
Diffstat (limited to 'source/blender/editors/mesh/editmesh_bisect.c')
-rw-r--r-- | source/blender/editors/mesh/editmesh_bisect.c | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/source/blender/editors/mesh/editmesh_bisect.c b/source/blender/editors/mesh/editmesh_bisect.c index 386c56a1e62..e35e97c0054 100644 --- a/source/blender/editors/mesh/editmesh_bisect.c +++ b/source/blender/editors/mesh/editmesh_bisect.c @@ -458,47 +458,47 @@ typedef struct GizmoGroup { * This is needed because changing the RNA doesn't cause a redo * and we're not using operator UI which does just this. */ -static void gizmo_bisect_exec(GizmoGroup *man) +static void gizmo_bisect_exec(GizmoGroup *ggd) { - wmOperator *op = man->data.op; - if (op == WM_operator_last_redo((bContext *)man->data.context)) { - ED_undo_operator_repeat((bContext *)man->data.context, op); + wmOperator *op = ggd->data.op; + if (op == WM_operator_last_redo((bContext *)ggd->data.context)) { + ED_undo_operator_repeat((bContext *)ggd->data.context, op); } } -static void gizmo_mesh_bisect_update_from_op(GizmoGroup *man) +static void gizmo_mesh_bisect_update_from_op(GizmoGroup *ggd) { - wmOperator *op = man->data.op; + wmOperator *op = ggd->data.op; float plane_co[3], plane_no[3]; - RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co); - RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no); + RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_co, plane_co); + RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_no, plane_no); - WM_gizmo_set_matrix_location(man->translate_z, plane_co); - WM_gizmo_set_matrix_location(man->rotate_c, plane_co); + WM_gizmo_set_matrix_location(ggd->translate_z, plane_co); + WM_gizmo_set_matrix_location(ggd->rotate_c, plane_co); /* translate_c location comes from the property. */ - WM_gizmo_set_matrix_rotation_from_z_axis(man->translate_z, plane_no); + WM_gizmo_set_matrix_rotation_from_z_axis(ggd->translate_z, plane_no); - WM_gizmo_set_scale(man->translate_c, 0.2); + WM_gizmo_set_scale(ggd->translate_c, 0.2); - RegionView3D *rv3d = ED_view3d_context_rv3d(man->data.context); + RegionView3D *rv3d = ED_view3d_context_rv3d(ggd->data.context); if (rv3d) { - normalize_v3_v3(man->data.rotate_axis, rv3d->viewinv[2]); - normalize_v3_v3(man->data.rotate_up, rv3d->viewinv[1]); + normalize_v3_v3(ggd->data.rotate_axis, rv3d->viewinv[2]); + normalize_v3_v3(ggd->data.rotate_up, rv3d->viewinv[1]); /* ensure its orthogonal */ - project_plane_normalized_v3_v3v3(man->data.rotate_up, man->data.rotate_up, man->data.rotate_axis); - normalize_v3(man->data.rotate_up); + project_plane_normalized_v3_v3v3(ggd->data.rotate_up, ggd->data.rotate_up, ggd->data.rotate_axis); + normalize_v3(ggd->data.rotate_up); - WM_gizmo_set_matrix_rotation_from_z_axis(man->translate_c, plane_no); + WM_gizmo_set_matrix_rotation_from_z_axis(ggd->translate_c, plane_no); float plane_no_cross[3]; - cross_v3_v3v3(plane_no_cross, plane_no, man->data.rotate_axis); + cross_v3_v3v3(plane_no_cross, plane_no, ggd->data.rotate_axis); - WM_gizmo_set_matrix_offset_rotation_from_yz_axis(man->rotate_c, plane_no_cross, man->data.rotate_axis); - RNA_enum_set(man->rotate_c->ptr, "draw_options", + WM_gizmo_set_matrix_offset_rotation_from_yz_axis(ggd->rotate_c, plane_no_cross, ggd->data.rotate_axis); + RNA_enum_set(ggd->rotate_c->ptr, "draw_options", ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_MIRROR | ED_GIZMO_DIAL_DRAW_FLAG_ANGLE_START_Y); } @@ -509,16 +509,16 @@ static void gizmo_bisect_prop_depth_get( const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroup *man = gz->parent_gzgroup->customdata; - wmOperator *op = man->data.op; + GizmoGroup *ggd = gz->parent_gzgroup->customdata; + wmOperator *op = ggd->data.op; float *value = value_p; BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); float plane_co[3], plane_no[3]; - RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co); - RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no); + RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_co, plane_co); + RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_no, plane_no); value[0] = dot_v3v3(plane_no, plane_co) - dot_v3v3(plane_no, gz->matrix_basis[3]); } @@ -527,16 +527,16 @@ static void gizmo_bisect_prop_depth_set( const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroup *man = gz->parent_gzgroup->customdata; - wmOperator *op = man->data.op; + GizmoGroup *ggd = gz->parent_gzgroup->customdata; + wmOperator *op = ggd->data.op; const float *value = value_p; BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); float plane_co[3], plane[4]; - RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, plane_co); - RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane); + RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_co, plane_co); + RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_no, plane); normalize_v3(plane); plane[3] = -value[0] - dot_v3v3(plane, gz->matrix_basis[3]); @@ -544,9 +544,9 @@ static void gizmo_bisect_prop_depth_set( /* Keep our location, may be offset simply to be inside the viewport. */ closest_to_plane_normalized_v3(plane_co, plane, plane_co); - RNA_property_float_set_array(op->ptr, man->data.prop_plane_co, plane_co); + RNA_property_float_set_array(op->ptr, ggd->data.prop_plane_co, plane_co); - gizmo_bisect_exec(man); + gizmo_bisect_exec(ggd); } /* translate callbacks */ @@ -554,28 +554,28 @@ static void gizmo_bisect_prop_translate_get( const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroup *man = gz->parent_gzgroup->customdata; - wmOperator *op = man->data.op; + GizmoGroup *ggd = gz->parent_gzgroup->customdata; + wmOperator *op = ggd->data.op; BLI_assert(gz_prop->type->array_length == 3); UNUSED_VARS_NDEBUG(gz_prop); - RNA_property_float_get_array(op->ptr, man->data.prop_plane_co, value_p); + RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_co, value_p); } static void gizmo_bisect_prop_translate_set( const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroup *man = gz->parent_gzgroup->customdata; - wmOperator *op = man->data.op; + GizmoGroup *ggd = gz->parent_gzgroup->customdata; + wmOperator *op = ggd->data.op; BLI_assert(gz_prop->type->array_length == 3); UNUSED_VARS_NDEBUG(gz_prop); - RNA_property_float_set_array(op->ptr, man->data.prop_plane_co, value_p); + RNA_property_float_set_array(op->ptr, ggd->data.prop_plane_co, value_p); - gizmo_bisect_exec(man); + gizmo_bisect_exec(ggd); } /* angle callbacks */ @@ -583,22 +583,22 @@ static void gizmo_bisect_prop_angle_get( const wmGizmo *gz, wmGizmoProperty *gz_prop, void *value_p) { - GizmoGroup *man = gz->parent_gzgroup->customdata; - wmOperator *op = man->data.op; + GizmoGroup *ggd = gz->parent_gzgroup->customdata; + wmOperator *op = ggd->data.op; float *value = value_p; BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); float plane_no[4]; - RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no); + RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_no, plane_no); normalize_v3(plane_no); float plane_no_proj[3]; - project_plane_normalized_v3_v3v3(plane_no_proj, plane_no, man->data.rotate_axis); + project_plane_normalized_v3_v3v3(plane_no_proj, plane_no, ggd->data.rotate_axis); if (!is_zero_v3(plane_no_proj)) { - const float angle = -angle_signed_on_axis_v3v3_v3(plane_no_proj, man->data.rotate_up, man->data.rotate_axis); + const float angle = -angle_signed_on_axis_v3v3_v3(plane_no_proj, ggd->data.rotate_up, ggd->data.rotate_axis); value[0] = angle; } else { @@ -610,32 +610,32 @@ static void gizmo_bisect_prop_angle_set( const wmGizmo *gz, wmGizmoProperty *gz_prop, const void *value_p) { - GizmoGroup *man = gz->parent_gzgroup->customdata; - wmOperator *op = man->data.op; + GizmoGroup *ggd = gz->parent_gzgroup->customdata; + wmOperator *op = ggd->data.op; const float *value = value_p; BLI_assert(gz_prop->type->array_length == 1); UNUSED_VARS_NDEBUG(gz_prop); float plane_no[4]; - RNA_property_float_get_array(op->ptr, man->data.prop_plane_no, plane_no); + RNA_property_float_get_array(op->ptr, ggd->data.prop_plane_no, plane_no); normalize_v3(plane_no); float plane_no_proj[3]; - project_plane_normalized_v3_v3v3(plane_no_proj, plane_no, man->data.rotate_axis); + project_plane_normalized_v3_v3v3(plane_no_proj, plane_no, ggd->data.rotate_axis); if (!is_zero_v3(plane_no_proj)) { - const float angle = -angle_signed_on_axis_v3v3_v3(plane_no_proj, man->data.rotate_up, man->data.rotate_axis); + const float angle = -angle_signed_on_axis_v3v3_v3(plane_no_proj, ggd->data.rotate_up, ggd->data.rotate_axis); const float angle_delta = angle - angle_compat_rad(value[0], angle); if (angle_delta != 0.0f) { float mat[3][3]; - axis_angle_normalized_to_mat3(mat, man->data.rotate_axis, angle_delta); + axis_angle_normalized_to_mat3(mat, ggd->data.rotate_axis, angle_delta); mul_m3_v3(mat, plane_no); /* re-normalize - seems acceptable */ - RNA_property_float_set_array(op->ptr, man->data.prop_plane_no, plane_no); + RNA_property_float_set_array(op->ptr, ggd->data.prop_plane_no, plane_no); - gizmo_bisect_exec(man); + gizmo_bisect_exec(ggd); } } } @@ -658,40 +658,40 @@ static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *gzgroup) return; } - struct GizmoGroup *man = MEM_callocN(sizeof(GizmoGroup), __func__); - gzgroup->customdata = man; + struct GizmoGroup *ggd = MEM_callocN(sizeof(GizmoGroup), __func__); + gzgroup->customdata = ggd; const wmGizmoType *gzt_arrow = WM_gizmotype_find("GIZMO_GT_arrow_3d", true); const wmGizmoType *gzt_move = WM_gizmotype_find("GIZMO_GT_move_3d", true); const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true); - man->translate_z = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); - man->translate_c = WM_gizmo_new_ptr(gzt_move, gzgroup, NULL); - man->rotate_c = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); + ggd->translate_z = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); + ggd->translate_c = WM_gizmo_new_ptr(gzt_move, gzgroup, NULL); + ggd->rotate_c = WM_gizmo_new_ptr(gzt_dial, gzgroup, NULL); - UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_z->color); - UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, man->translate_c->color); - UI_GetThemeColor3fv(TH_GIZMO_SECONDARY, man->rotate_c->color); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, ggd->translate_z->color); + UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, ggd->translate_c->color); + UI_GetThemeColor3fv(TH_GIZMO_SECONDARY, ggd->rotate_c->color); - RNA_enum_set(man->translate_z->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_NORMAL); - RNA_enum_set(man->translate_c->ptr, "draw_style", ED_GIZMO_MOVE_STYLE_RING_2D); + RNA_enum_set(ggd->translate_z->ptr, "draw_style", ED_GIZMO_ARROW_STYLE_NORMAL); + RNA_enum_set(ggd->translate_c->ptr, "draw_style", ED_GIZMO_MOVE_STYLE_RING_2D); - WM_gizmo_set_flag(man->translate_c, WM_GIZMO_DRAW_VALUE, true); - WM_gizmo_set_flag(man->rotate_c, WM_GIZMO_DRAW_VALUE, true); + WM_gizmo_set_flag(ggd->translate_c, WM_GIZMO_DRAW_VALUE, true); + WM_gizmo_set_flag(ggd->rotate_c, WM_GIZMO_DRAW_VALUE, true); { - man->data.context = (bContext *)C; - man->data.op = op; - man->data.prop_plane_co = RNA_struct_find_property(op->ptr, "plane_co"); - man->data.prop_plane_no = RNA_struct_find_property(op->ptr, "plane_no"); + ggd->data.context = (bContext *)C; + ggd->data.op = op; + ggd->data.prop_plane_co = RNA_struct_find_property(op->ptr, "plane_co"); + ggd->data.prop_plane_no = RNA_struct_find_property(op->ptr, "plane_no"); } - gizmo_mesh_bisect_update_from_op(man); + gizmo_mesh_bisect_update_from_op(ggd); /* Setup property callbacks */ { WM_gizmo_target_property_def_func( - man->translate_z, "offset", + ggd->translate_z, "offset", &(const struct wmGizmoPropertyFnParams) { .value_get_fn = gizmo_bisect_prop_depth_get, .value_set_fn = gizmo_bisect_prop_depth_set, @@ -700,7 +700,7 @@ static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *gzgroup) }); WM_gizmo_target_property_def_func( - man->translate_c, "offset", + ggd->translate_c, "offset", &(const struct wmGizmoPropertyFnParams) { .value_get_fn = gizmo_bisect_prop_translate_get, .value_set_fn = gizmo_bisect_prop_translate_set, @@ -709,7 +709,7 @@ static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *gzgroup) }); WM_gizmo_target_property_def_func( - man->rotate_c, "offset", + ggd->rotate_c, "offset", &(const struct wmGizmoPropertyFnParams) { .value_get_fn = gizmo_bisect_prop_angle_get, .value_set_fn = gizmo_bisect_prop_angle_set, @@ -722,11 +722,11 @@ static void gizmo_mesh_bisect_setup(const bContext *C, wmGizmoGroup *gzgroup) static void gizmo_mesh_bisect_draw_prepare( const bContext *UNUSED(C), wmGizmoGroup *gzgroup) { - GizmoGroup *man = gzgroup->customdata; - if (man->data.op->next) { - man->data.op = WM_operator_last_redo((bContext *)man->data.context); + GizmoGroup *ggd = gzgroup->customdata; + if (ggd->data.op->next) { + ggd->data.op = WM_operator_last_redo((bContext *)ggd->data.context); } - gizmo_mesh_bisect_update_from_op(man); + gizmo_mesh_bisect_update_from_op(ggd); } static void MESH_GGT_bisect(struct wmGizmoGroupType *gzgt) |