[Bf-blender-cvs] [a7947a233d9] sculpt-dev: Sculpt: New "auto-fset" setting

Joseph Eagar noreply at git.blender.org
Tue Oct 26 11:03:01 CEST 2021


Commit: a7947a233d9d711260a5a921df114aea3e7b1518
Author: Joseph Eagar
Date:   Tue Oct 26 01:55:13 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rBa7947a233d9d711260a5a921df114aea3e7b1518

Sculpt: New "auto-fset" setting

Added a new "auto face set" setting for brushes.
It basically invokes the draw face set tool,
with a few differences:

* The painted face set is fixed by user setting.
* More then one face set can be created,
  these are assigned based on distance to
  the stroke line.
* TODO: write a proper API for wrangling stroke
        curves (should interpolate at least G2!).

The point of this is to enable better hard surface
brushes.  Since the settings are extremely finicky
I've added an example of one (based on clay strips)
to startup.blend.

The necassary steps to make a hard brush out of this
are as follows:

1. Autosmooth: ~0.4;
2. Autosmooth radius scale: ~1.5.
3. Auto fset: on.
4. Hard edge mode: on (but turn off inherit).

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

M	release/datafiles/startup.blend
M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/intern/brush_channel_define.h
M	source/blender/blenkernel/intern/brush_engine.c
M	source/blender/blenkernel/intern/brush_engine_presets.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_brushes.c
M	source/blender/editors/sculpt_paint/sculpt_face_set.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/makesdna/DNA_brush_enums.h

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

diff --git a/release/datafiles/startup.blend b/release/datafiles/startup.blend
index c9419dabf03..31a190f7c45 100644
Binary files a/release/datafiles/startup.blend and b/release/datafiles/startup.blend differ
diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 282143c4afe..fc1497dc1c0 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -1183,12 +1183,15 @@ def brush_settings(layout, context, brush, popover=False):
 
         # auto_smooth_factor and use_inverse_smooth_pressure
         if capabilities.has_auto_smooth:
-            box = layout.column()  # .column() is a bit more compact
+            box = layout.box().column()  # .column() is a bit more compact
+
+            box.label(text="Auto-Smooth")
 
             UnifiedPaintPanel.prop_unified(box,
                 context,
                 brush,
                 "auto_smooth_factor",
+                text="Factor",
                 pressure_name="use_inverse_smooth_pressure",
                 slider=True,)
 
@@ -1220,6 +1223,7 @@ def brush_settings(layout, context, brush, popover=False):
                 context,
                 brush,
                 "auto_smooth_projection",
+                text="Projection",
                 slider=True)
 
             if advanced:
@@ -1239,11 +1243,59 @@ def brush_settings(layout, context, brush, popover=False):
                 "projection",
                 slider=True)
 
+        UnifiedPaintPanel.prop_unified(layout,
+            context,
+            brush,
+            "use_smoothed_rake")
+
+        box = layout.box().column()  # .column() is a bit more compact
+        box.label(text="Auto Face Set")
+
+        UnifiedPaintPanel.prop_unified(box,
+            context,
+            brush,
+            "use_autofset")
+
+        if UnifiedPaintPanel.get_channel_value(context, brush, "use_autofset"):
+            UnifiedPaintPanel.channel_unified(box,
+                context,
+                brush,
+                "autofset_radius_scale",
+                slider=True)
+            UnifiedPaintPanel.channel_unified(box,
+                context,
+                brush,
+                "autofset_use_spacing")
+            if UnifiedPaintPanel.get_channel_value(context, brush, "autofset_use_spacing"):
+                UnifiedPaintPanel.channel_unified(box,
+                    context,
+                    brush,
+                    "autofset_spacing")
+            UnifiedPaintPanel.channel_unified(box,
+                context,
+                brush,
+                "autofset_start")
+            UnifiedPaintPanel.channel_unified(box,
+                context,
+                brush,
+                "autofset_count")
+            UnifiedPaintPanel.channel_unified(box,
+                context,
+                brush,
+                "autofset_curve")
+
+        
         if capabilities.has_vcol_boundary_smooth:
-            layout.prop(brush, "vcol_boundary_factor", slider=True)
+            UnifiedPaintPanel.prop_unified(layout,
+                context,
+                brush,
+                "vcol_boundary_factor",
+                slider=True)
 
         if (capabilities.has_topology_rake and context.sculpt_object.use_dynamic_topology_sculpting):
-            box = layout.column()  # .column() is a bit more compact
+            box = layout.box().column()  # .column() is a bit more compact
+
+            box.label(text="Topology Rake")
 
             #box.prop(brush, "topology_rake_factor", slider=True)
             UnifiedPaintPanel.prop_unified(box,
@@ -1251,7 +1303,7 @@ def brush_settings(layout, context, brush, popover=False):
                 brush,
                 "topology_rake_factor",
                 slider=True,
-                text="Topology Rake")
+                text="Factor")
 
             if advanced:
                 box.prop(brush, "use_custom_topology_rake_spacing", text="Custom Spacing")
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index 1e7716125cb..1ee6a175bb3 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -207,8 +207,8 @@ places in rna_engine_codebase are relevent:
                            "used for DynTopo", 1.0f, 0.001f, 5.0f, 0.01f, 2.0f, false, BRUSH_CHANNEL_INHERIT)
   MAKE_BOOL(dyntopo_disable_smooth, "Disable Dyntopo Smooth", "Disable the small amount of smoothing dyntopo applies to improve numerical stability", false)
   MAKE_FLOAT_EX(projection, "Projection", "Amount of volume preserving projection", 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, false)
-  MAKE_FLOAT_EX(autosmooth_projection, "Auto-Smooth Projection", "Amount of volume preserving projection for autosmooth", 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, false)
-  MAKE_FLOAT_EX(topology_rake_projection, "Rake Projection", "Amount of volume preserving projection", 0.975f, 0.0f, 1.0f, 0.0f, 1.0f, false)
+  MAKE_FLOAT_EX(autosmooth_projection, "Projection", "Amount of volume preserving projection for autosmooth", 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, false)
+  MAKE_FLOAT_EX(topology_rake_projection, "Projection", "Amount of volume preserving projection", 0.975f, 0.0f, 1.0f, 0.0f, 1.0f, false)
   MAKE_FLOAT(fset_slide, "Face Set Projection", "Stick face set boundaries to surface of mesh", 1.0f, 0.0f, 1.0f)
   MAKE_FLOAT(boundary_smooth, "Boundary Smooth", "Smooth hard boundaries", 0.0f, 0.0f, 1.0f)
   MAKE_BOOL(topology_rake_use_spacing, "Use Rake Spacing", "Use custom spacing for topology rake", false)
@@ -599,6 +599,14 @@ MAKE_ENUM_EX(sharp_mode, "Sharp Mode", "", 0, 0, {
     {-1}
 })
 
+MAKE_BOOL_EX(use_autofset, "Auto Face Set", "Automatically make a face set", false, 0)
+MAKE_FLOAT_EX_FLAG(autofset_radius_scale, "Radius Scale", "Scale brush radius for auto face set", 1.0f, 0.001f, 10.0f, 0.01f, 3.0f, false, false)
+MAKE_CURVE(autofset_curve, "Curve", "", CURVE_PRESET_LINE)
+MAKE_INT_EX(autofset_count, "Face Set Count", "", 2, 1, 10, 1, 5)
+MAKE_INT_EX(autofset_start, "Face Set Start", "", 2, 1, 1024, 1, 1024)
+MAKE_FLOAT_EX_FLAG(autofset_spacing, "Spacing", "Spacing for auto face set", 4, 1, 1000, 1, 300, false, 0)
+MAKE_BOOL_EX(autofset_use_spacing, "Use Spacing", "Use spacing for auto face set", false, 0)
+
 //MAKE_FLOAT3_EX
 /* clang-format on */
 #if defined(BRUSH_CHANNEL_DEFINE_TYPES) || defined(BRUSH_CHANNEL_DEFINE_EXTERNAL)
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index dce81430b78..7fce1d8ab5c 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -1533,6 +1533,42 @@ void BKE_brush_commandset_inherit_all_mappings(BrushChannelSet *chset)
   }
 }
 
+static void commandlist_add_auto_fset(BrushChannelSet *chset,
+                                      BrushCommandList *cl,
+                                      Brush *brush,
+                                      int tool,
+                                      BrushMappingData *mapdata)
+{
+  if (!BRUSHSET_GET_INT(chset, use_autofset, NULL)) {
+    return;
+  }
+
+  BrushCommand *cmd = BKE_brush_command_init(BKE_brush_commandlist_add(cl, chset, true),
+                                             SCULPT_TOOL_AUTO_FSET);
+
+  float radius = BRUSHSET_GET_FLOAT(chset, radius, NULL) *
+                 BRUSHSET_GET_FLOAT(chset, autofset_radius_scale, NULL);
+  float spacing = BRUSHSET_GET_FLOAT(chset, spacing, NULL);
+
+  if (BRUSHSET_GET_INT(chset, autofset_use_spacing, NULL)) {
+    spacing = BRUSHSET_GET_FLOAT(chset, autofset_spacing, NULL);
+    float_set_uninherit(cmd->params, spacing, spacing);
+  }
+
+  float_set_uninherit(cmd->params, radius, radius);
+
+  BrushChannel *ch = BRUSHSET_ENSURE_BUILTIN(cmd->params, falloff_curve);
+  BrushChannel *ch2 = BRUSHSET_LOOKUP(chset, autofset_curve);
+
+  if (ch2) {
+    BKE_brush_channel_curve_assign(ch, &ch2->curve);
+    ch->flag &= ~BRUSH_CHANNEL_INHERIT;
+  }
+  else {
+    ch->flag |= BRUSH_CHANNEL_INHERIT;
+  }
+}
+
 static void commandlist_add_dyntopo(BrushChannelSet *chset,
                                     BrushCommandList *cl,
                                     Brush *brush,
@@ -1588,6 +1624,9 @@ static void bke_builtin_commandlist_create_paint(Brush *brush,
   bool hard_edge_mode = BRUSHSET_GET_INT(chset, hard_edge_mode, NULL);
   commandlist_add_dyntopo(chset, cl, brush, tool, hard_edge_mode, radius);
 
+  /*build auto fset command*/
+  commandlist_add_auto_fset(chset, cl, brush, tool, mapdata);
+
   float autosmooth = BRUSHSET_GET_FLOAT(chset, autosmooth, NULL);
   if (autosmooth > 0.0f) {
     cmd = BKE_brush_command_init(BKE_brush_commandlist_add(cl, chset, true), SCULPT_TOOL_SMOOTH);
@@ -1627,8 +1666,6 @@ static void bke_builtin_commandlist_create_paint(Brush *brush,
   }
 
 #undef GETF
-
-  // float
 }
 
 void BKE_builtin_apply_hard_edge_mode(BrushChannelSet *chset, bool do_apply)
@@ -1719,6 +1756,9 @@ void BKE_builtin_commandlist_create(Brush *brush,
     autosmooth_spacing = BKE_brush_channelset_get_float(chset, "spacing", NULL);
   }
 
+  /*build auto fset command*/
+  commandlist_add_auto_fset(chset, cl, brush, tool, mapdata);
+
   float autosmooth = BKE_brush_channelset_get_float(chset, "autosmooth", NULL);
   if (!no_autosmooth && autosmooth > 0.0f) {
     cmd = BKE_brush_command_init(BKE_brush_commandlist_add(cl, chset, true), SCULPT_TOOL_SMOOTH);
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index 70482402527..5ab0e8a8c14 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -257,8 +257,12 @@ static bool check_builtin_init()
 
   SUBTYPE_SET(radius, BRUSH_CHANNEL_PIXEL);
   SUBTYPE_SET(spacing, BRUSH_CHANNEL_PERCENT);
+
+  SUBTYPE_SET(autofset_spacing, BRUSH_CHANNEL_PERCENT);
   SUBTYPE_SET(autosmooth_spacing, BRUSH_CHANNEL_PERCENT);
   SUBTYPE_SET(topology_rake_spacing, BRUSH_CHANNEL_PERCENT);
+
+  SUBTYPE_SET(autofse

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list