diff options
3 files changed, 45 insertions, 1 deletions
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py index 80ebff8982f..6556c2f34e0 100644 --- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py +++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py @@ -6347,6 +6347,18 @@ def km_3d_view_tool_sculpt_mask_by_color(params): ]}, ) +def km_3d_view_tool_sculpt_face_set_edit(params): + return ( + "3D View Tool: Sculpt, Face Set Edit", + {"space_type": 'VIEW_3D', "region_type": 'WINDOW'}, + {"items": [ + ("sculpt.face_set_edit", {"type": params.tool_mouse, "value": 'ANY'}, + None), + ("sculpt.face_set_edit", {"type": params.tool_tweak, "value": 'ANY'}, + None) + ]}, + ) + def km_3d_view_tool_paint_weight_sample_weight(params): return ( "3D View Tool: Paint Weight, Sample Weight", @@ -6890,6 +6902,7 @@ def generate_keymaps(params=None): km_3d_view_tool_sculpt_cloth_filter(params), km_3d_view_tool_sculpt_color_filter(params), km_3d_view_tool_sculpt_mask_by_color(params), + km_3d_view_tool_sculpt_face_set_edit(params), km_3d_view_tool_paint_weight_sample_weight(params), km_3d_view_tool_paint_weight_sample_vertex_group(params), km_3d_view_tool_paint_weight_gradient(params), diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index ae144d9e8d0..38879d41a64 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -1335,6 +1335,22 @@ class _defs_sculpt: draw_settings=draw_settings, ) + @ToolDef.from_fn + def face_set_edit(): + def draw_settings(_context, layout, tool): + props = tool.operator_properties("sculpt.face_set_edit") + layout.prop(props, "mode", expand=False) + layout.prop(props, "modify_hidden") + + return dict( + idname="builtin.face_set_edit", + label="Edit Face Set", + icon="ops.sculpt.face_set_edit", + widget=None, + keymap="3D View Tool: Sculpt, Face Set Edit", + draw_settings=draw_settings, + ) + class _defs_vertex_paint: @@ -2595,6 +2611,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): else () ), None, + _defs_sculpt.face_set_edit, + None, _defs_transform.translate, _defs_transform.rotate, _defs_transform.scale, diff --git a/source/blender/editors/sculpt_paint/sculpt_face_set.c b/source/blender/editors/sculpt_paint/sculpt_face_set.c index a8de3be3baf..2afa3556dd9 100644 --- a/source/blender/editors/sculpt_paint/sculpt_face_set.c +++ b/source/blender/editors/sculpt_paint/sculpt_face_set.c @@ -1082,7 +1082,7 @@ static void sculpt_face_set_apply_edit(Object *ob, MEM_SAFE_FREE(prev_face_sets); } -static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) +static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEvent *event) { Object *ob = CTX_data_active_object(C); SculptSession *ss = ob->sculpt; @@ -1096,8 +1096,21 @@ static int sculpt_face_set_edit_invoke(bContext *C, wmOperator *op, const wmEven return OPERATOR_CANCELLED; } + /* Ignore other events to avoid repeated operations. */ + if (event->val != KM_PRESS) { + return OPERATOR_CANCELLED; + } + BKE_sculpt_update_object_for_edit(depsgraph, ob, true, false, false); + /* Update the current active Face Set and Vertex as the operator can be used directly from the + * tool without brush cursor. */ + SculptCursorGeometryInfo sgi; + float mouse[2]; + mouse[0] = event->mval[0]; + mouse[1] = event->mval[1]; + SCULPT_cursor_geometry_info_update(C, &sgi, mouse, false); + PBVH *pbvh = ob->sculpt->pbvh; PBVHNode **nodes; int totnode; |