diff options
author | Germano Cavalcante <germano.costa@ig.com.br> | 2022-09-26 20:18:29 +0300 |
---|---|---|
committer | Germano Cavalcante <germano.costa@ig.com.br> | 2022-09-26 20:18:39 +0300 |
commit | 236fda7faf58921f9f4b6d0d0300313b0ab1976a (patch) | |
tree | 194d1ee9dc13740332672f18b0cb92ff98d68be6 /source/blender/editors/transform/transform_ops.c | |
parent | 125ac1f91433344e5b3948ee4c9b3c95ddaaf8a0 (diff) |
Fix T101343: useless Snapping menu in transform operators
Changes:
- Use the "snap_elements" property only for operators that support snapping to geometry.
- Remove unused properties:
- "use_snap_to_same_target",
- "snap_face_nearest_steps").
- Fix property with wrong name "use_snap_selectable_only" -> "use_snap_selectable"
- Fix use of dependent property flags.
- Remove redundant initialization of variables
- Simplify `poll_propety`. Only the "use_snap_project" is not hidden.
>>! In rBc484599687ba it's said:
> These options are needed for Python tools to control snapping without requiring the tool settings to be adjusted.
If that's the case, there doesn't seem to be any need to display them in the redo panel. Therefore:
- Hide snapping properties in redo panel.
Many properties have been added that can be independent of ToolSettings. Therefore:
- Save snapping properties in the operator itself. For Redo.
Diffstat (limited to 'source/blender/editors/transform/transform_ops.c')
-rw-r--r-- | source/blender/editors/transform/transform_ops.c | 47 |
1 files changed, 16 insertions, 31 deletions
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 99919c0ed78..f15ad99dbc3 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -570,10 +570,8 @@ static bool transform_poll_property(const bContext *UNUSED(C), /* Snapping. */ { - PropertyRNA *prop_snap = RNA_struct_find_property(op->ptr, "snap"); - if (prop_snap && (prop_snap != prop) && - (RNA_property_boolean_get(op->ptr, prop_snap) == false)) { - if (STRPREFIX(prop_id, "snap") || STRPREFIX(prop_id, "use_snap")) { + if (STREQ(prop_id, "use_snap_project")) { + if (RNA_boolean_get(op->ptr, "snap") == false) { return false; } } @@ -626,7 +624,7 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) if (flags & P_MIRROR) { prop = RNA_def_boolean(ot->srna, "mirror", 0, "Mirror Editing", ""); - if (flags & P_MIRROR_DUMMY) { + if ((flags & P_MIRROR_DUMMY) == P_MIRROR_DUMMY) { /* only used so macros can disable this option */ RNA_def_property_flag(prop, PROP_HIDDEN); } @@ -660,17 +658,17 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) prop = RNA_def_boolean(ot->srna, "snap", false, "Use Snapping Options", ""); RNA_def_property_flag(prop, PROP_HIDDEN); - prop = RNA_def_enum(ot->srna, - "snap_elements", - rna_enum_snap_element_items, - SCE_SNAP_MODE_INCREMENT, - "Snap to Elements", - ""); - RNA_def_property_flag(prop, PROP_ENUM_FLAG); + if ((flags & P_GEO_SNAP) == P_GEO_SNAP) { + prop = RNA_def_enum(ot->srna, + "snap_elements", + rna_enum_snap_element_items, + SCE_SNAP_MODE_INCREMENT, + "Snap to Elements", + ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_ENUM_FLAG); - RNA_def_boolean(ot->srna, "use_snap_project", false, "Project Individual Elements", ""); + RNA_def_boolean(ot->srna, "use_snap_project", false, "Project Individual Elements", ""); - if (flags & P_GEO_SNAP) { /* TODO(@gfxcoder): Rename `snap_target` to `snap_source` to avoid previous ambiguity of * "target" (now, "source" is geometry to be moved and "target" is geometry to which moved * geometry is snapped). Use "Source snap point" and "Point on source that will snap to @@ -686,22 +684,14 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) prop = RNA_def_boolean(ot->srna, "use_snap_nonedit", true, "Target: Include Non-Edited", ""); RNA_def_property_flag(prop, PROP_HIDDEN); prop = RNA_def_boolean( - ot->srna, "use_snap_selectable_only", false, "Target: Exclude Non-Selectable", ""); - RNA_def_property_flag(prop, PROP_HIDDEN); - - /* Face Nearest options */ - prop = RNA_def_boolean( - ot->srna, "use_snap_to_same_target", false, "Snap to Same Target", ""); - RNA_def_property_flag(prop, PROP_HIDDEN); - prop = RNA_def_int( - ot->srna, "snap_face_nearest_steps", 1, 1, 32767, "Face Nearest Steps", "", 1, 32767); + ot->srna, "use_snap_selectable", true, "Target: Exclude Non-Selectable", ""); RNA_def_property_flag(prop, PROP_HIDDEN); prop = RNA_def_float_vector( ot->srna, "snap_point", 3, NULL, -FLT_MAX, FLT_MAX, "Point", "", -FLT_MAX, FLT_MAX); RNA_def_property_flag(prop, PROP_HIDDEN); - if (flags & P_ALIGN_SNAP) { + if ((flags & P_ALIGN_SNAP) == P_ALIGN_SNAP) { prop = RNA_def_boolean(ot->srna, "snap_align", false, "Align with Point Normal", ""); RNA_def_property_flag(prop, PROP_HIDDEN); prop = RNA_def_float_vector( @@ -709,11 +699,6 @@ void Transform_Properties(struct wmOperatorType *ot, int flags) RNA_def_property_flag(prop, PROP_HIDDEN); } } - else { - prop = RNA_def_boolean( - ot->srna, "use_snap_selectable_only", false, "Target: Exclude Non-Selectable", ""); - RNA_def_property_flag(prop, PROP_HIDDEN); - } } if (flags & P_GPENCIL_EDIT) { @@ -1165,7 +1150,7 @@ static void TRANSFORM_OT_edge_slide(struct wmOperatorType *ot) "When Even mode is active, flips between the two adjacent edge loops"); RNA_def_boolean(ot->srna, "use_clamp", true, "Clamp", "Clamp within the edge extents"); - Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV); + Transform_Properties(ot, P_MIRROR | P_GEO_SNAP | P_CORRECT_UV); } static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot) @@ -1200,7 +1185,7 @@ static void TRANSFORM_OT_vert_slide(struct wmOperatorType *ot) "When Even mode is active, flips between the two adjacent edge loops"); RNA_def_boolean(ot->srna, "use_clamp", true, "Clamp", "Clamp within the edge extents"); - Transform_Properties(ot, P_MIRROR | P_SNAP | P_CORRECT_UV); + Transform_Properties(ot, P_MIRROR | P_GEO_SNAP | P_CORRECT_UV); } static void TRANSFORM_OT_edge_crease(struct wmOperatorType *ot) |