diff options
-rw-r--r-- | release/scripts/startup/bl_ui/space_toolsystem_toolbar.py | 8 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_mask.c | 45 |
2 files changed, 41 insertions, 12 deletions
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index e021433bee3..af263bf5d53 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -1304,22 +1304,30 @@ class _defs_sculpt: @ToolDef.from_fn def trim_box(): + def draw_settings(_context, layout, tool): + props = tool.operator_properties("sculpt.trim_box_gesture") + layout.prop(props, "trim_mode", expand=False) return dict( idname="builtin.box_trim", label="Box Trim", icon="ops.sculpt.box_trim", widget=None, keymap=(), + draw_settings=draw_settings, ) @ToolDef.from_fn def trim_lasso(): + def draw_settings(_context, layout, tool): + props = tool.operator_properties("sculpt.trim_lasso_gesture") + layout.prop(props, "trim_mode", expand=False) return dict( idname="builtin.lasso_trim", label="Lasso Trim", icon="ops.sculpt.lasso_trim", widget=None, keymap=(), + draw_settings=draw_settings, ) @ToolDef.from_fn diff --git a/source/blender/editors/sculpt_paint/paint_mask.c b/source/blender/editors/sculpt_paint/paint_mask.c index f7e8abde021..622ea82bf25 100644 --- a/source/blender/editors/sculpt_paint/paint_mask.c +++ b/source/blender/editors/sculpt_paint/paint_mask.c @@ -821,11 +821,24 @@ static void paint_mask_gesture_operator_properties(wmOperatorType *ot) typedef enum eSculptTrimOperationType { SCULPT_GESTURE_TRIM_INTERSECT, SCULPT_GESTURE_TRIM_DIFFERENCE, + SCULPT_GESTURE_TRIM_UNION, + SCULPT_GESTURE_TRIM_JOIN, } eSculptTrimOperationType; +/* Intersect is not exposed in the UI because it does not work correctly with symmetry (it deletes + * the symmetrical part of the mesh in the first symmetry pass). */ static EnumPropertyItem prop_trim_operation_types[] = { - {SCULPT_GESTURE_TRIM_INTERSECT, "INTERSECT", 0, "Intersect", ""}, - {SCULPT_GESTURE_TRIM_DIFFERENCE, "DIFFERENCE", 0, "Difference", ""}, + {SCULPT_GESTURE_TRIM_DIFFERENCE, + "DIFFERENCE", + 0, + "Difference", + "Use a difference boolean operation"}, + {SCULPT_GESTURE_TRIM_UNION, "UNION", 0, "Union", "Use a union boolean operation"}, + {SCULPT_GESTURE_TRIM_JOIN, + "JOIN", + 0, + "Join", + "Join the new mesh as separate geometry, without preforming any boolean operation"}, {0, NULL, 0, NULL, NULL}, }; @@ -1088,18 +1101,26 @@ static void sculpt_gesture_apply_trim(SculptGestureContext *sgcontext) } } - int boolean_mode; - switch (trim_operation->mode) { - case SCULPT_GESTURE_TRIM_INTERSECT: - boolean_mode = eBooleanModifierOp_Intersect; - break; - case SCULPT_GESTURE_TRIM_DIFFERENCE: - boolean_mode = eBooleanModifierOp_Difference; - break; + /* Join does not do a boolean operation, it just adds the geometry. */ + if (trim_operation->mode != SCULPT_GESTURE_TRIM_JOIN) { + int boolean_mode = 0; + switch (trim_operation->mode) { + case SCULPT_GESTURE_TRIM_INTERSECT: + boolean_mode = eBooleanModifierOp_Intersect; + break; + case SCULPT_GESTURE_TRIM_DIFFERENCE: + boolean_mode = eBooleanModifierOp_Difference; + break; + case SCULPT_GESTURE_TRIM_UNION: + boolean_mode = eBooleanModifierOp_Union; + break; + case SCULPT_GESTURE_TRIM_JOIN: + BLI_assert(false); + break; + } + BM_mesh_boolean(bm, looptris, tottri, bm_face_isect_pair, NULL, 2, false, boolean_mode); } - BM_mesh_boolean(bm, looptris, tottri, bm_face_isect_pair, NULL, 2, false, boolean_mode); - Mesh *result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, sculpt_mesh); BM_mesh_free(bm); result->runtime.cd_dirty_vert |= CD_MASK_NORMAL; |