GPencil: New Sculpt Auto masking options

Now it's possible to use auto masking at 3 levels:

* Stroke
* Layer
* Material

The masking options can be combined and allows to limit the effect of the sculpt brush.

Diff Revision: https://developer.blender.org/D14589
This commit is contained in:
Antonio Vazquez
2022-05-02 16:05:04 +02:00
parent 4c3efb4320
commit ab5d52a6db
7 changed files with 244 additions and 32 deletions

View File

@@ -3977,6 +3977,8 @@ def km_grease_pencil_stroke_sculpt_mode(params):
("gpencil.active_frames_delete_all", {"type": 'DEL', "value": 'PRESS', "shift": True}, None),
# Active layer
op_menu("GPENCIL_MT_layer_active", {"type": 'Y', "value": 'PRESS'}),
# Active material
op_menu("GPENCIL_MT_material_active", {"type": 'U', "value": 'PRESS'}),
# Merge Layer
("gpencil.layer_merge", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, None),
# Keyframe menu

View File

@@ -41,17 +41,7 @@ class AnnotationDrawingToolsPanel:
row.prop_enum(tool_settings, "annotation_stroke_placement_view2d", 'IMAGE', text="Image")
class GreasePencilSculptOptionsPanel:
bl_label = "Sculpt Strokes"
@classmethod
def poll(cls, context):
tool_settings = context.scene.tool_settings
settings = tool_settings.gpencil_sculpt_paint
brush = settings.brush
tool = brush.gpencil_sculpt_tool
return bool(tool in {'SMOOTH', 'RANDOMIZE'})
class GreasePencilSculptAdvancedPanel:
def draw(self, context):
layout = self.layout
@@ -59,17 +49,21 @@ class GreasePencilSculptOptionsPanel:
layout.use_property_decorate = False
tool_settings = context.scene.tool_settings
settings = tool_settings.gpencil_sculpt_paint
brush = settings.brush
gp_settings = brush.gpencil_settings
brush = context.tool_settings.gpencil_sculpt_paint.brush
tool = brush.gpencil_sculpt_tool
gp_settings = brush.gpencil_settings
col = layout.column(heading="Auto-Masking", align=True)
col.prop(gp_settings, "use_automasking_stroke", text="Stroke")
col.prop(gp_settings, "use_automasking_layer", text="Layer")
col.prop(gp_settings, "use_automasking_material", text="Material")
if tool in {'SMOOTH', 'RANDOMIZE'}:
layout.prop(gp_settings, "use_edit_position", text="Affect Position")
layout.prop(gp_settings, "use_edit_strength", text="Affect Strength")
layout.prop(gp_settings, "use_edit_thickness", text="Affect Thickness")
layout.prop(gp_settings, "use_edit_uv", text="Affect UV")
col = layout.column(heading="Affect", align=True)
col.prop(gp_settings, "use_edit_position", text="Position")
col.prop(gp_settings, "use_edit_strength", text="Strength")
col.prop(gp_settings, "use_edit_thickness", text="Thickness")
col.prop(gp_settings, "use_edit_uv", text="UV")
# GP Object Tool Settings

View File

@@ -109,8 +109,8 @@ class VIEW3D_HT_tool_header(Header):
if is_valid_context:
brush = context.tool_settings.gpencil_sculpt_paint.brush
tool = brush.gpencil_sculpt_tool
if tool in {'SMOOTH', 'RANDOMIZE'}:
layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_options")
if tool != 'CLONE':
layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_brush_popover")
layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_appearance")
elif tool_mode == 'WEIGHT_GPENCIL':
if is_valid_context:

View File

@@ -3,7 +3,7 @@
# <pep8 compliant>
from bpy.types import Menu, Panel, UIList
from bl_ui.properties_grease_pencil_common import (
GreasePencilSculptOptionsPanel,
GreasePencilSculptAdvancedPanel,
GreasePencilDisplayPanel,
GreasePencilBrushFalloff,
)
@@ -1907,6 +1907,41 @@ class VIEW3D_PT_tools_grease_pencil_brush_sculpt_falloff(GreasePencilBrushFallof
return (settings and settings.brush and settings.brush.curve)
class VIEW3D_PT_tools_grease_pencil_sculpt_brush_advanced(GreasePencilSculptAdvancedPanel, View3DPanel, Panel):
bl_context = ".greasepencil_sculpt"
bl_label = "Advanced"
bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_sculpt_settings'
bl_category = "Tool"
bl_options = {'DEFAULT_CLOSED'}
@classmethod
def poll(cls, context):
brush = context.tool_settings.gpencil_sculpt_paint.brush
if brush is None:
return False
tool = brush.gpencil_sculpt_tool
return tool != 'CLONE'
class VIEW3D_PT_tools_grease_pencil_sculpt_brush_popover(GreasePencilSculptAdvancedPanel, View3DPanel, Panel):
bl_context = ".greasepencil_sculpt"
bl_label = "Brush"
bl_category = "Tool"
@classmethod
def poll(cls, context):
if context.region.type != 'TOOL_HEADER':
return False
brush = context.tool_settings.gpencil_sculpt_paint.brush
if brush is None:
return False
tool = brush.gpencil_sculpt_tool
return tool != 'CLONE'
# Grease Pencil weight painting tools
class GreasePencilWeightPanel:
bl_context = ".greasepencil_weight"
@@ -2240,13 +2275,6 @@ class VIEW3D_PT_tools_grease_pencil_brush_mix_palette(View3DPanel, Panel):
col.template_palette(settings, "palette", color=True)
class VIEW3D_PT_tools_grease_pencil_sculpt_options(GreasePencilSculptOptionsPanel, Panel, View3DPanel):
bl_context = ".greasepencil_sculpt"
bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_sculpt_settings'
bl_category = "Tool"
bl_label = "Sculpt Strokes"
# Grease Pencil Brush Appearance (one for each mode)
class VIEW3D_PT_tools_grease_pencil_paint_appearance(GreasePencilDisplayPanel, Panel, View3DPanel):
bl_context = ".greasepencil_paint"
@@ -2357,7 +2385,8 @@ classes = (
VIEW3D_PT_tools_grease_pencil_paint_appearance,
VIEW3D_PT_tools_grease_pencil_sculpt_select,
VIEW3D_PT_tools_grease_pencil_sculpt_settings,
VIEW3D_PT_tools_grease_pencil_sculpt_options,
VIEW3D_PT_tools_grease_pencil_sculpt_brush_advanced,
VIEW3D_PT_tools_grease_pencil_sculpt_brush_popover,
VIEW3D_PT_tools_grease_pencil_sculpt_appearance,
VIEW3D_PT_tools_grease_pencil_weight_paint_select,
VIEW3D_PT_tools_grease_pencil_weight_paint_settings,