[Bf-blender-cvs] [b3ed969b862] sculpt-dev: commit prior to small refactor

Joseph Eagar noreply at git.blender.org
Mon Sep 20 12:14:53 CEST 2021


Commit: b3ed969b862dc8f8eaefaac361800cc6ae316909
Author: Joseph Eagar
Date:   Sun Sep 19 13:30:43 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rBb3ed969b862dc8f8eaefaac361800cc6ae316909

commit prior to small refactor

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/BKE_brush_engine.h
M	source/blender/blenkernel/intern/brush_engine.c
M	source/blender/blenkernel/intern/brush_engine_presets.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_smooth.c
M	source/blender/makesdna/DNA_sculpt_brush_types.h
M	source/blender/makesrna/intern/rna_brush_engine.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index b011750bd14..b3d9230974e 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -26,6 +26,8 @@ channel_name_map = {
     "auto_smooth_projection": "SMOOTH_PROJECTION",
     "auto_smooth_radius_factor": "AUTOSMOOTH_RADIUS_SCALE",
     "boundary_smooth_factor": "BOUNDARY_SMOOTH",
+    "autosmooth_fset_slide": "FSET_SLIDE",
+    "topology_rake_factor": "TOPOLOGY_RAKE"
 };
 
 class UnifiedPaintPanel:
@@ -122,6 +124,8 @@ class UnifiedPaintPanel:
         typeprop = "float_value"
         if ch.type == "INT":
             typeprop = "int_value"
+        elif ch.type == "BOOL":
+            typeprop = "bool_value"
 
         if text is None:
             s = prop_name.lower().replace("_", " ").split(" ");
@@ -133,12 +137,14 @@ class UnifiedPaintPanel:
         if ch.inherit:
             sd = context.tool_settings.sculpt
             #ensure channel exists in tool settings channel set
-            sd.channels.ensure(ch)
+            sd.channels.ensure(ch, queue=True)
 
             finalch = sd.channels.channels[prop_name]
 
         row.prop(finalch, typeprop, icon=icon, text=text, slider=slider)
 
+        pressure = pressure and ch.type != "BOOL"
+            
         if pressure:
             row.prop(finalch.mappings["PRESSURE"], "enabled", text="", icon="STYLUS_PRESSURE")
         #if pressure_name:
@@ -147,7 +153,7 @@ class UnifiedPaintPanel:
         #if unified_name and not header:
         #    # NOTE: We don't draw UnifiedPaintSettings in the header to reduce clutter. D5928#136281
         #    row.prop(ups, unified_name, text="", icon='BRUSHES_ALL')
-        if not header:
+        if not header and ch.type != "BOOL":
             row.prop(ch, "inherit", text="", icon='BRUSHES_ALL')
             row.prop(ch, "ui_expanded", text="", icon="TRIA_DOWN" if ch.ui_expanded else "TRIA_RIGHT")
 
@@ -670,12 +676,17 @@ def brush_settings(layout, context, brush, popover=False):
                 slider=True,
             )
 
-            box.prop(brush, "boundary_smooth_factor")
-            box.prop(brush, "use_weighted_smooth")
-            box.prop(brush, "preserve_faceset_boundary")
+            #box.prop(brush, "boundary_smooth_factor")
+            #box.prop(brush, "use_weighted_smooth")
+            #box.prop(brush, "preserve_faceset_boundary")
 
-            if brush.preserve_faceset_boundary:
-                box.prop(brush, "autosmooth_fset_slide")
+            UnifiedPaintPanel.prop_unified(box, context, brush, "boundary_smooth_factor", slider=True)
+            UnifiedPaintPanel.prop_unified(box, context, brush, "use_weighted_smooth")
+            UnifiedPaintPanel.prop_unified(box, context, brush, "preserve_faceset_boundary")
+
+            if 1: #brush.preserve_faceset_boundary:
+                UnifiedPaintPanel.prop_unified(box, context, brush, "autosmooth_fset_slide", slider=True)
+                #box.prop(brush, "autosmooth_fset_slide")
 
             box.prop(brush, "use_custom_auto_smooth_spacing", text="Custom Spacing")
             if brush.use_custom_auto_smooth_spacing:
@@ -720,7 +731,15 @@ def brush_settings(layout, context, brush, popover=False):
         ):
             box = layout.box().column() #.column() is a bit more compact
             
-            box.prop(brush, "topology_rake_factor", slider=True)
+            #box.prop(brush, "topology_rake_factor", slider=True)
+            UnifiedPaintPanel.prop_unified(
+                    box,
+                    context,
+                    brush,
+                    "topology_rake_factor",
+                    slider=True,
+                    text="Topology Rake"
+                ) 
             box.prop(brush, "use_custom_topology_rake_spacing", text="Custom Spacing")
 
             if brush.use_custom_topology_rake_spacing:
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 92e5e33ba02..25c6227cf32 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -108,9 +108,12 @@ void BKE_brush_channelset_free(BrushChannelSet *chset);
 
 // makes a copy of ch
 void BKE_brush_channelset_add(BrushChannelSet *chset, BrushChannel *ch);
+void BKE_brush_channelset_queue(BrushChannelSet *chset, BrushChannel *ch);
 
 // checks is a channel with existing->idname exists; if not a copy of existing is made and inserted
-void BKE_brush_channelset_ensure_existing(BrushChannelSet *chset, BrushChannel *existing);
+void BKE_brush_channelset_ensure_existing(BrushChannelSet *chset,
+                                          BrushChannel *existing,
+                                          bool queue);
 
 BrushChannel *BKE_brush_channelset_lookup(BrushChannelSet *chset, const char *idname);
 
@@ -188,6 +191,9 @@ void BKE_brush_channelset_compat_load(BrushChannelSet *chset,
                                       struct Brush *brush,
                                       bool to_channels);
 
+// merge in channels the ui requested
+void BKE_brush_apply_queued_channels(BrushChannelSet *chset, bool do_override);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index da465140d52..ee345bccd3a 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -200,15 +200,53 @@ BrushChannelSet *BKE_brush_channelset_create()
   return (BrushChannelSet *)MEM_callocN(sizeof(BrushChannelSet), "BrushChannelSet");
 }
 
-void BKE_brush_channelset_free(BrushChannelSet *chset)
+void BKE_brush_apply_queued_channels(BrushChannelSet *chset, bool do_override)
 {
-  if (chset->channels) {
-    for (int i = 0; i < chset->totchannel; i++) {
-      BKE_brush_channel_free(chset->channels + i);
+  if (!chset->tot_queued_channel) {
+    return;
+  }
+
+  for (int i = 0; i < chset->tot_queued_channel; i++) {
+    BrushChannel *ch = chset->queued_channels;
+
+    BrushChannel *exist = BKE_brush_channelset_lookup(chset, ch->idname);
+
+    if (exist) {
+      if (!do_override) {
+        continue;
+      }
+
+      BKE_brush_channel_free(exist);
+      *exist = *ch;
+
+      continue;
+    }
+    else {
+      BKE_brush_channelset_add(chset, ch);
+      BKE_brush_channel_free(ch);
     }
+  }
+
+  MEM_SAFE_FREE(chset->queued_channels);
+  chset->queued_channels = NULL;
+  chset->tot_queued_channel = NULL;
+}
 
-    MEM_freeN(chset->channels);
+void BKE_brush_channelset_free(BrushChannelSet *chset)
+{
+  for (int step = 0; step < 2; step++) {
+    BrushChannel *channels = step ? chset->queued_channels : chset->channels;
+    int totchannel = step ? chset->tot_queued_channel : chset->totchannel;
+
+    if (channels) {
+      for (int i = 0; i < totchannel; i++) {
+        BKE_brush_channel_free(channels + i);
+      }
+
+      MEM_freeN(channels);
+    }
   }
+
   MEM_freeN(chset);
 }
 
@@ -229,6 +267,26 @@ void BKE_brush_channelset_add(BrushChannelSet *chset, BrushChannel *ch)
   namestack_pop();
 }
 
+// used to avoid messing up pointers in ui
+void BKE_brush_channelset_queue(BrushChannelSet *chset, BrushChannel *ch)
+{
+  chset->tot_queued_channel++;
+
+  if (!chset->queued_channels) {
+    chset->queued_channels = MEM_callocN(sizeof(BrushChannel) * chset->tot_queued_channel,
+                                         "chset->channels");
+  }
+  else {
+    chset->queued_channels = MEM_recallocN_id(chset->queued_channels,
+                                              sizeof(BrushChannel) * chset->tot_queued_channel,
+                                              "chset->queued_channels");
+  }
+
+  namestack_push(__func__);
+  BKE_brush_channel_copy_data(chset->queued_channels + chset->tot_queued_channel - 1, ch);
+  namestack_pop();
+}
+
 ATTR_NO_OPT BrushChannel *BKE_brush_channelset_lookup(BrushChannelSet *chset, const char *idname)
 {
   for (int i = 0; i < chset->totchannel; i++) {
@@ -318,14 +376,22 @@ bool BKE_brush_channelset_ensure_builtin(BrushChannelSet *chset, const char *idn
   return false;
 }
 
-void BKE_brush_channelset_ensure_existing(BrushChannelSet *chset, BrushChannel *existing)
+void BKE_brush_channelset_ensure_existing(BrushChannelSet *chset,
+                                          BrushChannel *existing,
+                                          bool queue)
 {
   if (BKE_brush_channelset_has(chset, existing->idname)) {
     return;
   }
 
   namestack_push(__func__);
-  BKE_brush_channelset_add(chset, existing);
+  if (!queue) {
+    BKE_brush_channelset_add(chset, existing);
+  }
+  else {
+    BKE_brush_channelset_queue(chset, existing);
+  }
+
   namestack_pop();
 }
 #define ADDCH(name) BKE_brush_channelset_ensure_builtin(chset, name)
@@ -667,6 +733,14 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
   ADDCH("ORIGINAL_PLANE");
   ADDCH("JITTER");
   ADDCH("JITTER_ABSOLUTE");
+  ADDCH("USE_WEIGHTED_SMOOTH");
+  ADDCH("PRESERVE_FACESET_BOUNDARY");
+  ADDCH("HARD_EDGE_MODE");
+  ADDCH("GRAB_SILHOUETTE");
+
+  ADDCH("PROJECTION");
+  ADDCH("BOUNDARY_SMOOTH");
+  ADDCH("FSET_SLIDE");
 
   switch (tool) {
     case SCULPT_TOOL_DRAW: {
@@ -680,6 +754,15 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
   namestack_pop();
 }
 
+void BKE_brush_init_scene_defaults(Sculpt *sd)
+{
+  if (!sd->channels) {
+    sd->channels = BKE_brush_channelset_create();
+  }
+
+  BrushChannelSet *chset = sd->channels;
+}
+
 void BKE_brush_builtin_create(Brush *brush, int tool)
 {
   namestack_push(__func__);
@@ -801,6 +884,10 @@ static BrushSettingsMap brush_settings_map[] = {
   DEF(topology_rake_projection, TOPOLOGY_RAKE_PROJECTION, FLOAT, FLOAT)
   DEF(topology_rake_radius_factor, TOPOLOGY_RAKE_RADIUS_SCALE, FLOAT, FLOAT)
   DEF(topology_rake_spacing, TOPOLOGY_RAKE_SPACING, INT, FLOAT)
+  DEF(topology_rake_factor, TOPOLOGY_RAKE, FLOAT, FLOAT)
+  DEF(autosmooth_fset_slide, FSET_SLIDE, FLOAT, FLOAT)
+  DEF(boundary_smooth_factor, BOUNDARY_SMOOTH, FLOAT, FLOAT)
+  DEF(autosmooth_radius_factor, AUTOSMOOTH_RADIUS_SCALE, FLOAT, FLOAT)
   D

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list