Sculpt: Add stroke stabilization to lasso tools

This PR adds stroke stabilization settings for the Sculpt mode lasso
tools:
* Mask
* Hide
* Trim
* Face Set

Only Sculpt tools have a user facing change, even though this was
implemented in `WM_gesture_lasso_modal` and related methods. Other
modes may choose to add these settings and toggles.

## Implementation
The implemented functionality is similar to the Annotate tool in both
interpolation of the new point and drawing the UI hint that
stabilization is happening.

The `radius` and `factor` properties have similar bounds as the same
Brush properties. All values are stored on a per-operator level, not on
a scene or otherwise global tool level.

Based off of [1].

[1] - https://blender.community/c/rightclickselect/ZWG5/

Pull Request: https://projects.blender.org/blender/blender/pulls/122062
This commit is contained in:
Sean Kim
2024-06-27 01:32:09 +02:00
committed by Sean Kim
parent 8da3b74ee2
commit 9d4d1aea98
5 changed files with 181 additions and 31 deletions

View File

@@ -1407,6 +1407,21 @@ class _defs_sculpt:
use_separators=False,
)
@staticmethod
def draw_lasso_stroke_settings(layout, props, draw_inline, draw_popover):
if draw_inline:
layout.prop(props, "use_smooth_stroke", text="Stabilize Stroke")
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column()
col.active = props.use_smooth_stroke
col.prop(props, "smooth_stroke_radius", text="Radius", slider=True)
col.prop(props, "smooth_stroke_factor", text="Factor", slider=True)
if draw_popover:
layout.popover("TOPBAR_PT_tool_settings_extra", text="Stroke")
@ToolDef.from_fn
def mask_border():
def draw_settings(_context, layout, tool):
@@ -1424,9 +1439,19 @@ class _defs_sculpt:
@ToolDef.from_fn
def mask_lasso():
def draw_settings(_context, layout, tool):
def draw_settings(_context, layout, tool, *, extra=False):
draw_popover = False
props = tool.operator_properties("paint.mask_lasso_gesture")
layout.prop(props, "use_front_faces_only", expand=False)
if not extra:
layout.prop(props, "use_front_faces_only", expand=False)
region_is_header = bpy.context.region.type == 'TOOL_HEADER'
if region_is_header:
draw_popover = True
else:
extra = True
_defs_sculpt.draw_lasso_stroke_settings(layout, props, extra, draw_popover)
return dict(
idname="builtin.lasso_mask",
@@ -1485,9 +1510,19 @@ class _defs_sculpt:
@ToolDef.from_fn
def hide_lasso():
def draw_settings(_context, layout, tool):
def draw_settings(_context, layout, tool, *, extra=False):
draw_popover = False
props = tool.operator_properties("paint.hide_show_lasso_gesture")
layout.prop(props, "area", expand=False)
if not extra:
layout.prop(props, "area", expand=False)
region_is_header = bpy.context.region.type == 'TOOL_HEADER'
if region_is_header:
draw_popover = True
else:
extra = True
_defs_sculpt.draw_lasso_stroke_settings(layout, props, extra, draw_popover)
return dict(
idname="builtin.lasso_hide",
@@ -1545,9 +1580,19 @@ class _defs_sculpt:
@ToolDef.from_fn
def face_set_lasso():
def draw_settings(_context, layout, tool):
def draw_settings(_context, layout, tool, *, extra=False):
draw_popover = False
props = tool.operator_properties("sculpt.face_set_lasso_gesture")
layout.prop(props, "use_front_faces_only", expand=False)
if not extra:
layout.prop(props, "use_front_faces_only", expand=False)
region_is_header = bpy.context.region.type == 'TOOL_HEADER'
if region_is_header:
draw_popover = True
else:
extra = True
_defs_sculpt.draw_lasso_stroke_settings(layout, props, extra, draw_popover)
return dict(
idname="builtin.lasso_face_set",
@@ -1609,13 +1654,24 @@ class _defs_sculpt:
@ToolDef.from_fn
def trim_lasso():
def draw_settings(_context, layout, tool):
def draw_settings(_context, layout, tool, *, extra=False):
draw_popover = False
props = tool.operator_properties("sculpt.trim_lasso_gesture")
layout.prop(props, "trim_solver", expand=False)
layout.prop(props, "trim_mode", expand=False)
layout.prop(props, "trim_orientation", expand=False)
layout.prop(props, "trim_extrude_mode", expand=False)
layout.prop(props, "use_cursor_depth", expand=False)
if not extra:
layout.prop(props, "trim_solver", expand=False)
layout.prop(props, "trim_mode", expand=False)
layout.prop(props, "trim_orientation", expand=False)
layout.prop(props, "trim_extrude_mode", expand=False)
layout.prop(props, "use_cursor_depth", expand=False)
region_is_header = bpy.context.region.type == 'TOOL_HEADER'
if region_is_header:
draw_popover = True
else:
extra = True
_defs_sculpt.draw_lasso_stroke_settings(layout, props, extra, draw_popover)
return dict(
idname="builtin.lasso_trim",
label="Lasso Trim",