[Bf-blender-cvs] [f8a0e102cf5] master: Weightpaint Gradient tool: expose falloff to the UI

Philipp Oeser noreply at git.blender.org
Fri Sep 24 10:54:27 CEST 2021


Commit: f8a0e102cf5e33f92447fe6cd6db7838f6051aab
Author: Philipp Oeser
Date:   Thu Sep 23 15:48:32 2021 +0200
Branches: master
https://developer.blender.org/rBf8a0e102cf5e33f92447fe6cd6db7838f6051aab

Weightpaint Gradient tool: expose falloff to the UI

By default, we'll always get a falloff like this from the tool:
{F10559413}

But in the context of using vertexgroups in modifiers/modeling, a choice
on how the gradient falloff of the Weightpaint Gradient tool is shaped
would be desirable:
"real" linear:
{F10559416}
Custom:
{F10559421}
{F10559428}

The way the Weightpaint gradient tool works is a bit outside the usual
tools that use brushes [even though it creates a brush on the fly in
`WPGradient_userData`].
However, it does not have an entry in `eBrushWeightPaintTool` and adding
one there does not play nice for the same reasons (not "really" being
integrated in the brush-based tools).

So in order to expose the brush curve in the UI, we would have to do one
of the following:
- [1] try to use `VIEW3D_PT_tools_brush_falloff`, for this to work:
-- make all kinds of exception in python super classes [`FalloffPanel`,
`BrushPanel`, `UnifiedPaintPanel`, ... -- including making real entries
in `eBrushWeightPaintTool`] to get a proper tool mode and...
-- .. to also make sure Falloff Shape and Front-Face Falloff are not
available [which the tool seems to just not support in its current form]
- [2] just have a simple, contained panel for this tool alone

This patch implements [2] and adds it as part of the ToolDef (could also
be done in `VIEW3D_HT_tool_header`, but again, I think this is nice to
keep separate from the usual tools)
{F10559482}
{F10559485}

Testfile:
{F10559442}

Fixes T91636

Maniphest Tasks: T91636

Differential Revision: https://developer.blender.org/D12614

===================================================================

M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index a4a51cb9910..7bdc3ab160f 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1691,6 +1691,7 @@ class _defs_weight_paint:
 
             props = tool.operator_properties("paint.weight_gradient")
             layout.prop(props, "type", expand=True)
+            layout.popover("VIEW3D_PT_tools_weight_gradient")
 
         return dict(
             idname="builtin.gradient",
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 16b5ed33f3f..acc3d933b85 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -688,6 +688,39 @@ class VIEW3D_PT_tools_brush_stroke_smooth_stroke(Panel, View3DPaintPanel, Smooth
     bl_options = {'DEFAULT_CLOSED'}
 
 
+class VIEW3D_PT_tools_weight_gradient(Panel, View3DPaintPanel):
+    bl_context = ".weightpaint" # dot on purpose (access from topbar)
+    bl_label = "Falloff"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        settings = context.tool_settings.weight_paint
+        brush = settings.brush
+        return brush is not None
+
+    def draw(self, context):
+        layout = self.layout
+        settings = context.tool_settings.weight_paint
+        brush = settings.brush
+
+        col = layout.column(align=True)
+        row = col.row(align=True)
+        row.prop(brush, "curve_preset", text="")
+
+        if brush.curve_preset == 'CUSTOM':
+            layout.template_curve_mapping(brush, "curve", brush=True)
+
+            col = layout.column(align=True)
+            row = col.row(align=True)
+            row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
+            row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
+            row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
+            row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
+            row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
+            row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
+
+
 # TODO, move to space_view3d.py
 class VIEW3D_PT_tools_brush_falloff(Panel, View3DPaintPanel, FalloffPanel):
     bl_context = ".paint_common"  # dot on purpose (access from topbar)
@@ -2219,6 +2252,7 @@ classes = (
     VIEW3D_PT_tools_brush_falloff_frontface,
     VIEW3D_PT_tools_brush_falloff_normal,
     VIEW3D_PT_tools_brush_display,
+    VIEW3D_PT_tools_weight_gradient,
 
     VIEW3D_PT_sculpt_dyntopo,
     VIEW3D_PT_sculpt_voxel_remesh,



More information about the Bf-blender-cvs mailing list