[Bf-blender-cvs] [87feba04ddc] sculpt-dev: Sculpt: more brush engine stuff; do not test.

Joseph Eagar noreply at git.blender.org
Sun Sep 19 10:12:01 CEST 2021


Commit: 87feba04ddcef58e119eba903fcc7e36cb8e09cf
Author: Joseph Eagar
Date:   Sun Sep 19 01:02:00 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB87feba04ddcef58e119eba903fcc7e36cb8e09cf

Sculpt: more brush engine stuff; do not test.

Pushing this commit early due to computer
weirdness

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/BKE_brush.h
M	source/blender/blenkernel/BKE_brush_engine.h
M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/brush_engine.c
A	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/blenloader/intern/versioning_300.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/paint_image_proj.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_stroke.c
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h
M	source/blender/editors/sculpt_paint/sculpt_smooth.c
M	source/blender/editors/sculpt_paint/sculpt_uv.c
M	source/blender/makesdna/DNA_color_types.h
M	source/blender/makesdna/DNA_sculpt_brush_types.h
M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_brush_engine.c
M	source/blender/python/intern/bpy_rna.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index c8d7817e5a7..b011750bd14 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -19,6 +19,15 @@
 # <pep8 compliant>
 from bpy.types import Menu
 
+channel_name_map = {
+    "size" : "RADIUS",
+    "autosmooth_fset_slide":"FSET_SLIDE",
+    "auto_smooth_factor": "AUTOSMOOTH",
+    "auto_smooth_projection": "SMOOTH_PROJECTION",
+    "auto_smooth_radius_factor": "AUTOSMOOTH_RADIUS_SCALE",
+    "boundary_smooth_factor": "BOUNDARY_SMOOTH",
+};
+
 class UnifiedPaintPanel:
     # subclass must set
     # bl_space_type = 'IMAGE_EDITOR'
@@ -105,11 +114,15 @@ class UnifiedPaintPanel:
 
         l1 = layout
 
-        if ch.ui_expanded:
-            layout = layout.box().column() #.column() is a bit more compact
+        #if ch.ui_expanded:
+        #    layout = layout.box().column() #.column() is a bit more compact
 
         row = layout.row(align=True)
-            
+
+        typeprop = "float_value"
+        if ch.type == "INT":
+            typeprop = "int_value"
+
         if text is None:
             s = prop_name.lower().replace("_", " ").split(" ");
             text = ''
@@ -124,7 +137,7 @@ class UnifiedPaintPanel:
 
             finalch = sd.channels.channels[prop_name]
 
-        row.prop(finalch, "value", icon=icon, text=text, slider=slider)
+        row.prop(finalch, typeprop, icon=icon, text=text, slider=slider)
 
         if pressure:
             row.prop(finalch.mappings["PRESSURE"], "enabled", text="", icon="STYLUS_PRESSURE")
@@ -154,6 +167,15 @@ class UnifiedPaintPanel:
 
                     if mp.ui_expanded:
                         layout.template_curve_mapping(mp, "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'
                     #row2.prop(mp, "curve")
 
         return row
@@ -173,6 +195,16 @@ class UnifiedPaintPanel:
     ):
         """ Generalized way of adding brush options to the UI,
             along with their pen pressure setting and global toggle, if they exist. """
+
+        if prop_name in channel_name_map:
+            prop_name = channel_name_map[prop_name]
+        else:
+            prop_name = prop_name.upper()
+
+        if prop_name in brush.channels.channels:
+            #    def channel_unified(layout, context, brush, prop_name, icon='NONE', pressure=True, text=None, slider=False, header=False):
+            return UnifiedPaintPanel.channel_unified(layout, context, brush, prop_name, icon=icon, text=text, slider=slider, header=header)
+
         row = layout.row(align=True)
         ups = context.tool_settings.unified_paint_settings
         prop_owner = brush
@@ -1017,7 +1049,21 @@ def brush_shared_settings(layout, context, brush, popover=False):
     size_prop = "size"
     if size_mode and (size_owner.use_locked_size == 'SCENE'):
         size_prop = "unprojected_radius"
+
     if size or size_mode:
+        if size:
+            UnifiedPaintPanel.channel_unified(
+                layout,
+                context,
+                brush,
+                "RADIUS" if size_prop == "size" else size_prop.upper(),
+                text="Radius",
+                slider=True,
+            )
+        if size_mode:
+            layout.row().prop(size_owner, "use_locked_size", expand=True)
+            layout.separator()
+    elif size or size_mode:
         if size:
             UnifiedPaintPanel.prop_unified(
                 layout,
@@ -1033,7 +1079,7 @@ def brush_shared_settings(layout, context, brush, popover=False):
             layout.row().prop(size_owner, "use_locked_size", expand=True)
             layout.separator()
 
-    if 0 and strength:    
+    if strength:    
         UnifiedPaintPanel.channel_unified(
             layout,
             context,
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index 729956bdbc5..795f220871b 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -110,8 +110,13 @@ const float *BKE_brush_color_get(const struct Scene *scene, const struct Brush *
 const float *BKE_brush_secondary_color_get(const struct Scene *scene, const struct Brush *brush);
 void BKE_brush_color_set(struct Scene *scene, struct Brush *brush, const float color[3]);
 
-int BKE_brush_size_get(const struct Scene *scene, const struct Brush *brush);
-void BKE_brush_size_set(struct Scene *scene, struct Brush *brush, int size);
+int BKE_brush_size_get(const struct Scene *scene,
+                       const struct Brush *brush,
+                       bool use_brush_channel);
+void BKE_brush_size_set(struct Scene *scene,
+                        struct Brush *brush,
+                        int size,
+                        bool use_brush_channel);
 
 float BKE_brush_unprojected_radius_get(const struct Scene *scene, const struct Brush *brush);
 void BKE_brush_unprojected_radius_set(struct Scene *scene,
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 6b038f6d063..92e5e33ba02 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -44,17 +44,21 @@ is controller via BrushChannel->flag.
 
 This should completely replace UnifiedPaintSettings.
 */
-struct BrushChannel;
 
-#include "BLO_read_write.h"
 #include "DNA_sculpt_brush_types.h"
 
+struct BrushChannel;
+struct BlendWriter;
+struct BlendDataReader;
+struct Brush;
+
 typedef struct BrushMappingDef {
   int curve;
   bool enabled;
   bool inv;
   float min, max;
   int blendmode;
+  float factor;  // if 0, will default to 1.0
 } BrushMappingDef;
 
 typedef struct BrushMappingPreset {
@@ -62,6 +66,10 @@ typedef struct BrushMappingPreset {
   struct BrushMappingDef pressure, xtilt, ytilt, angle, speed;
 } BrushMappingPreset;
 
+typedef struct BrushMappingData {
+  float pressure, xtilt, ytilt, angle, speed;
+} BrushMappingData;
+
 #define MAX_BRUSH_ENUM_DEF 32
 
 typedef struct BrushEnumDef {
@@ -69,7 +77,7 @@ typedef struct BrushEnumDef {
 } BrushEnumDef;
 
 typedef struct BrushChannelType {
-  char name[32], idname[32];
+  char name[32], idname[32], tooltip[512];
   float min, max, soft_min, soft_max;
   BrushMappingPreset mappings;
 
@@ -83,7 +91,6 @@ typedef struct BrushCommand {
   int tool;
   struct BrushChannelSet *params;
   struct BrushChannelSet *params_final;
-  int totparam;
 } BrushCommand;
 
 typedef struct BrushCommandList {
@@ -117,22 +124,70 @@ void BKE_brush_channelset_merge(BrushChannelSet *dst,
                                 BrushChannelSet *parent);
 
 void BKE_brush_resolve_channels(struct Brush *brush, struct Sculpt *sd);
-int BKE_brush_channel_get_int(BrushChannelSet *chset, char *idname);
-float BKE_brush_channel_get_float(BrushChannelSet *chset, char *idname);
-float BKE_brush_channel_set_float(BrushChannelSet *chset, char *idname, float val);
+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,
+                                        BrushChannelSet *toolset,
+                                        char *idname,
+                                        BrushMappingData *mapdata);
+void BKE_brush_channel_set_final_float(BrushChannelSet *brushset,
+                                       BrushChannelSet *toolset,
+                                       char *idname,
+                                       float value);
+
+/* mapdata may be NULL */
+float BKE_brush_channel_get_float(BrushChannel *ch, BrushMappingData *mapdata);
+void BKE_brush_channel_set_float(BrushChannel *ch, float val);
+
+/* mapdata may be NULL */
+float BKE_brush_channelset_get_float(BrushChannelSet *chset,
+                                     char *idname,
+                                     BrushMappingData *mapdata);
+bool BKE_brush_channelset_set_float(BrushChannelSet *chset, char *idname, float val);
+
+float BKE_brush_channelset_get_final_float(BrushChannelSet *child,
+                                           BrushChannelSet *parent,
+                                           char *idname,
+                                           BrushMappingData *mapdata);
+
+void BKE_brush_channelset_set_final_float(BrushChannelSet *child,
+                                          BrushChannelSet *parent,
+                                          char *idname,
+                                          float value);
+
 void BKE_brush_init_toolsettings(struct Sculpt *sd);
 void BKE_brush_builtin_create(struct Brush *brush, int tool);
 BrushCommandList *BKE_brush_commandlist_create();
 void BKE_brush_commandlist_free(BrushCommandList *cl);
-BrushCommand *BKE_brush_commandlist_add(BrushCommandList *cl);
+BrushCommand *BKE_brush_commandlist_add(BrushCommandList *cl,
+                                        BrushChannelSet *chset_template,
+                                        bool auto_inherit);
 BrushCommand *BKE_brush_command_init(BrushCommand *command, int tool);
-void BKE_builtin_commandlist_create(BrushChannelSet *chset, BrushCommandList *cl, int tool);
-void BKE_brush_channelset_read(BlendDataReader *reader, BrushChannelSet *cset);
-void BKE_brush_channelset_write(BlendWriter *writer, BrushChannelSet *cset);
+void BKE_builtin_commandlist_create(struct Brush *brush,
+                                    BrushChannelSet *chse

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list