[Bf-blender-cvs] [73150981c8a] sculpt-dev: Sculpt: More brush channel stuff

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


Commit: 73150981c8a5f17b17e5e370e28287f5f0b96b86
Author: Joseph Eagar
Date:   Mon Sep 20 03:01:30 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB73150981c8a5f17b17e5e370e28287f5f0b96b86

Sculpt: More brush channel stuff

* The input device curves for brush channels
  now use a copy on write mechanism.
  + It's based on a global cache of curves.
    The alternative is to reference count
    BrushChannels, which I also implemented
    then abandoned.
  + Profiling showed that copying CurveMapping
    instances was actually a problem.

* Lots of small fixes to the old<-> new brush setting
  conversion code;

* Brush commands can now, sortof, have individual
  spacing.  The default brush spacing still acts
  as a minimum though.

* Added a BLI_ghash_lookup_p_ex method that
  returns the key ptr inside the ghash (it
  returns the actual key, not a pointer to
  Entry.key).
* Added a general 1d CurveMapping preset operator
  that uses an RNA path to get the curve.

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/BKE_brush_engine.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/brush_engine.c
M	source/blender/blenkernel/intern/brush_engine_presets.c
M	source/blender/blenkernel/intern/colortools.c
M	source/blender/blenkernel/intern/scene.c
M	source/blender/blenlib/BLI_ghash.h
M	source/blender/blenlib/intern/BLI_ghash.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/sculpt_paint/paint_intern.h
M	source/blender/editors/sculpt_paint/paint_ops.c
M	source/blender/editors/sculpt_paint/paint_utils.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/makesdna/DNA_color_types.h
M	source/blender/makesdna/DNA_sculpt_brush_types.h
M	source/blender/makesrna/intern/rna_brush_engine.c
M	source/blender/windowmanager/intern/wm_init_exit.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index b147ff90e2c..dacde89a72c 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -23,7 +23,7 @@ channel_name_map = {
     "size" : "radius",
     "autosmooth_fset_slide":"fset_slide",
     "auto_smooth_factor": "autosmooth",
-    "auto_smooth_projection": "smooth_projection",
+    "auto_smooth_projection": "autosmooth_projection",
     "auto_smooth_radius_factor": "autosmooth_radius_scale",
     "boundary_smooth_factor": "boundary_smooth",
     "autosmooth_fset_slide": "fset_slide",
@@ -108,7 +108,7 @@ class UnifiedPaintPanel:
         return None
 
     @staticmethod
-    def channel_unified(layout, context, brush, prop_name, icon='NONE', pressure=True, text=None, slider=False, header=False):
+    def channel_unified(layout, context, brush, prop_name, icon='NONE', pressure=True, text=None, slider=False, header=False, expand=None):
         """ Generalized way of adding brush options to the UI,
             along with their pen pressure setting and global toggle, if they exist. """
         ch = brush.channels.channels[prop_name]
@@ -126,6 +126,10 @@ class UnifiedPaintPanel:
             typeprop = "int_value"
         elif ch.type == "BOOL":
             typeprop = "bool_value"
+        elif ch.type == "ENUM":
+            typeprop = "enum_value"
+        elif ch.type == "BITMASK":
+            typeprop = "flags_value"
 
         if text is None:
             s = prop_name.lower().replace("_", " ").split(" ");
@@ -134,16 +138,24 @@ class UnifiedPaintPanel:
                 text += k[0].upper() + k[1:] + " "
             text = text.strip()
 
+        path = ""
+
         if ch.inherit:
             sd = context.tool_settings.sculpt
             #ensure channel exists in tool settings channel set
             sd.channels.ensure(ch)
 
             finalch = sd.channels.channels[prop_name]
+            path = "tool_settings.sculpt.channels.channels[\"%s\"]" % ch.idname
+        else:
+            path = "tool_settings.sculpt.brush.channels.channels[\"%s\"]" % ch.idname
 
-        row.prop(finalch, typeprop, icon=icon, text=text, slider=slider)
+        if expand is not None:
+            row.prop(finalch, typeprop, icon=icon, text=text, slider=slider, expand=expand)
+        else:
+            row.prop(finalch, typeprop, icon=icon, text=text, slider=slider)
 
-        pressure = pressure and ch.type != "BOOL"
+        pressure = pressure and ch.type not in ["BOOL", "ENUM", "BITMASK"]
             
         if pressure:
             row.prop(finalch.mappings["PRESSURE"], "enabled", text="", icon="STYLUS_PRESSURE")
@@ -176,12 +188,17 @@ class UnifiedPaintPanel:
 
                         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'
+
+                        path2 = path + ".mappings[\"%s\"].curve" % (mp.type)
+
+                        shapes = ['SMOOTH', 'ROUND', 'ROOT', 'SHARP', 'LINE', 'MAX']
+                        icons = ['SMOOTHCURVE', 'SPHERECURVE', 'ROOTCURVE', 'SHARPCURVE', 'LINCURVE', 'NOCURVE']
+
+                        for i, shape in enumerate(shapes):
+                            props = row.operator("brush.curve_preset_load", icon=icons[i], text="")
+                            props.shape = shape
+                            props.path = path2
+                        
                     #row2.prop(mp, "curve")
 
         return row
@@ -1073,7 +1090,7 @@ def brush_shared_settings(layout, context, brush, popover=False):
                 layout,
                 context,
                 brush,
-                "RADIUS" if size_prop == "size" else size_prop.upper(),
+                "radius" if size_prop == "size" else size_prop.upper(),
                 text="Radius",
                 slider=True,
             )
@@ -1101,7 +1118,7 @@ def brush_shared_settings(layout, context, brush, popover=False):
             layout,
             context,
             brush,
-            "STRENGTH",
+            "strength",
             slider=True
         )
         layout.separator()
@@ -1118,7 +1135,12 @@ def brush_shared_settings(layout, context, brush, popover=False):
         )
         layout.separator()
     if direction:
-        layout.row().prop(brush, "direction", expand=True)
+        UnifiedPaintPanel.channel_unified(
+                layout,
+                context,
+                brush,
+                "direction", expand=True)
+        #layout.row().prop(brush, "direction", expand=True)
 
 
 def brush_settings_advanced(layout, context, brush, popover=False):
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 92a0c69f00c..7990878f48d 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -880,8 +880,11 @@ class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
         col.prop(sculpt, "use_smooth_shading")
         col.prop(sculpt, "use_flat_vcol_shading")
 
-        col.prop(sculpt, "dyntopo_spacing")
-        col.prop(sculpt, "dyntopo_radius_scale");
+        UnifiedPaintPanel.channel_unified(layout, context, brush, "dyntopo_spacing", slider=True)
+        UnifiedPaintPanel.channel_unified(layout, context, brush, "dyntopo_radius_scale", slider=True)
+        
+        #col.prop(sculpt, "dyntopo_spacing")
+        #col.prop(sculpt, "dyntopo_radius_scale");
 
 
 class VIEW3D_PT_sculpt_voxel_remesh(Panel, View3DPaintPanel):
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 63d6b9121d2..b3ee2f411d7 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 23
+#define BLENDER_FILE_SUBVERSION 24
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 03f9fb55cc4..eaf56f89751 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -51,6 +51,7 @@ struct BrushChannel;
 struct BlendWriter;
 struct BlendDataReader;
 struct Brush;
+struct Sculpt;
 
 typedef struct BrushMappingDef {
   int curve;
@@ -97,8 +98,10 @@ typedef struct BrushChannelType {
 
 typedef struct BrushCommand {
   int tool;
+  float last_spacing_t[512];  // for different symmetry passes
   struct BrushChannelSet *params;
   struct BrushChannelSet *params_final;
+  struct BrushChannelSet *params_mapped;
 } BrushCommand;
 
 typedef struct BrushCommandList {
@@ -144,18 +147,24 @@ void BKE_brush_channelset_merge(BrushChannelSet *dst,
                                 BrushChannelSet *parent);
 
 void BKE_brush_resolve_channels(struct Brush *brush, struct Sculpt *sd);
-int BKE_brush_channelset_get_int(BrushChannelSet *chset, char *idname);
 
-// mapdata is optional, can be NULL
-
-float BKE_brush_channel_get_final_float(BrushChannelSet *brushset,
+void BKE_brush_channelset_set_final_int(BrushChannelSet *brushset,
                                         BrushChannelSet *toolset,
                                         char *idname,
-                                        BrushMappingData *mapdata);
-void BKE_brush_channel_set_final_float(BrushChannelSet *brushset,
+                                        int value);
+
+int BKE_brush_channelset_get_final_int(BrushChannelSet *brushset,
                                        BrushChannelSet *toolset,
                                        char *idname,
-                                       float value);
+                                       BrushMappingData *mapdata);
+
+int BKE_brush_channelset_get_int(BrushChannelSet *chset, char *idname, BrushMappingData *mapdata);
+bool BKE_brush_channelset_set_int(BrushChannelSet *chset, char *idname, int val);
+
+void BKE_brush_channel_set_int(BrushChannel *ch, int val);
+float BKE_brush_channel_get_int(BrushChannel *ch, BrushMappingData *mapdata);
+
+// mapdata is optional, can be NULL
 
 /* mapdata may be NULL */
 float BKE_brush_channel_get_float(BrushChannel *ch, BrushMappingData *mapdata);
@@ -212,6 +221,10 @@ void BKE_brush_channelset_compat_load(BrushChannelSet *chset,
 void BKE_brush_apply_queued_channels(BrushChannelSet *chset, bool do_override);
 void BKE_brush_channeltype_rna_check(BrushChannelType *def,
                                      int (*getIconFromName)(const char *name));
+bool BKE_brush_mapping_ensure_write(BrushMapping *mp);
+
+void BKE_brush_channelset_apply_mapping(BrushChannelSet *chset, BrushMappingData *mapdata);
+void BKE_brush_check_toolsettings(struct Sculpt *sd);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index f08b52cf1e5..a2058b1017f 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -291,6 +291,7 @@ set(SRC
   intern/writeavi.c
   intern/brush_engine.c
   intern/brush_engine_presets.c
+  intern/curvemapping_cache.c
 
   BKE_DerivedMesh.h
   BKE_action.h
@@ -339,6 +340,7 @@ set(SRC
   BKE_curveprofile.h
   BKE_customdata.h
   BKE_customdata_file.h
+  BKE_curvemapping_c

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list