[Bf-blender-cvs] [c5d508c3626] temp-sculpt-brush-channel: temp-sculpt-brush-channel: Implement new input mapping UI

Joseph Eagar noreply at git.blender.org
Sun Aug 14 23:03:17 CEST 2022


Commit: c5d508c3626918fea6da4014f6f270546a0681e5
Author: Joseph Eagar
Date:   Sun Aug 14 14:02:58 2022 -0700
Branches: temp-sculpt-brush-channel
https://developer.blender.org/rBc5d508c3626918fea6da4014f6f270546a0681e5

temp-sculpt-brush-channel: Implement new input mapping UI

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/BKE_brush.h
M	source/blender/blenkernel/BKE_brush_channel.h
M	source/blender/blenkernel/intern/brush.cc
M	source/blender/blenkernel/intern/brush_channel.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_comb.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_delete.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_density.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_grow_shrink.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_intern.hh
M	source/blender/editors/sculpt_paint/curves_sculpt_ops.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_pinch.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_puff.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_selection_paint.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_slide.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_smooth.cc
M	source/blender/editors/sculpt_paint/curves_sculpt_snake_hook.cc
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/editors/sculpt_paint/paint_stroke.c
M	source/blender/editors/sculpt_paint/paint_vertex.cc
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/makesdna/DNA_brush_channel_types.h
M	source/blender/makesrna/intern/rna_brush_channels.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index 3512b053fd9..9b36f65ded5 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0-or-later
-from bpy.types import Menu
+from bpy.types import Menu, Panel
 
 def template_curve(layout, base, propname, full_path, use_negative_slope=None):
     layout.template_curve_mapping(base, propname, brush=True, use_negative_slope=use_negative_slope)
@@ -18,6 +18,67 @@ def template_curve(layout, base, propname, full_path, use_negative_slope=None):
         props.shape = shape
         props.path = path
 
+class BRUSH_PT_channel_panel(Panel):
+    bl_label = "Settings"
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        scene = context.scene
+        ts = context.tool_settings
+
+        print("\n")
+        for k in dir(context):
+            print(k)
+        print("\n")
+
+        ch = context.active_brush_channel
+        finalch = context.final_brush_channel
+
+        mp = ch.mappings[ch.active_mapping]
+
+        ch_inherit = ch.inherit
+        ch_inherit = ch_inherit or (finalch.unified and not ch.disable_unified)
+
+        inherit = mp.inherit_mode == "ALWAYS" or (mp.inherit_mode == "USE_CHANNEL" and ch_inherit)
+        finalmp = finalch.mappings[ch.active_mapping] if inherit else mp
+        finalid = context.active_brush if finalmp == mp else context.scene
+
+        col = layout.column()
+        row = col.row()
+        row.prop(ch, "active_mapping", text="")
+        row.prop(finalmp, "enabled", text="", icon="STYLUS_PRESSURE")
+
+        col.prop(mp, "inherit_mode", text="Unified Mode")
+
+        if finalmp == mp:
+            path2 = UnifiedPaintPanel.paint_settings(context).path_from_id()
+            path2 += ".brush."
+        else:
+            path2 = "scene."
+
+        path2 += finalmp.path_from_id()
+
+        print("PATH2", path2)
+
+        col.prop(finalmp.curve, "curve_preset", text="Curve")
+        if finalmp.curve.curve_preset == "CUSTOM":
+            template_curve(col, mp.curve, "curve", path2 + ".curve.curve", use_negative_slope=True)                            
+
+        #col.label(text="Input Mapping")
+        col.prop(finalmp, "premultiply")
+        #col.prop(mp, "mapfunc", text="Repeat")
+
+        #col.label(text="Output Mapping")
+        row = col.row()
+        row.prop(mp, "min", slider=True)
+        row.prop(mp, "max", slider=True)
+
+        #col.prop(finalmp, "blendmode")
+        
+
 class UnifiedPaintPanel:
     # subclass must set
     # bl_space_type = 'IMAGE_EDITOR'
@@ -184,11 +245,12 @@ class UnifiedPaintPanel:
 
         finalowner = context.path_resolve(proppath)
         
-        if not (inherit and ch.mappings["PRESSURE"].inherit_mode == "NEVER"):
-            pressurech = finalch
+        inherit_pressure = ch.mappings["PRESSURE"].inherit_mode == "ALWAYS"
+        if ch.mappings["PRESSURE"].inherit_mode == "USE_CHANNEL":
+            inherit_pressure = inherit
 
-            if pressurech == ch and ch.mappings["PRESSURE"].inherit_mode == "ALWAYS":
-                pressurech = context.tool_settings.unified_channels[ch.idname]
+        if pressurech == ch and inherit_pressure:
+            pressurech = context.tool_settings.unified_channels[ch.idname]
 
         if show_reorder:
             props = row.operator("brush.change_channel_order", text="", icon="TRIA_UP")
@@ -272,9 +334,14 @@ class UnifiedPaintPanel:
             if not show_mappings and not show_reorder:
                 return
 
-            row.prop(ch, "ui_expanded",  emboss=False, text="", icon="DOWNARROW_HLT" if ch.ui_expanded else "RIGHTARROW")
+            row.context_pointer_set("active_brush", brush)
+            row.context_pointer_set("active_brush_channel", ch)
+            row.context_pointer_set("final_brush_channel", finalch)
+
+            row.popover("BRUSH_PT_channel_panel", icon="DOWNARROW_HLT", text="")
+            #row.prop(ch, "ui_expanded",  emboss=False, text="", icon="DOWNARROW_HLT" if ch.ui_expanded else "RIGHTARROW")
 
-            if ch.ui_expanded:
+            if 0: #ch.ui_expanded:
                 layout = baselayout.column()
 
                 for i, mp in enumerate(ch.mappings):
@@ -1823,7 +1890,7 @@ def brush_basic_gpencil_vertex_settings(layout, _context, brush, *, compact=Fals
         row.prop(gp_settings, "vertex_mode", text="Mode")
 
 
-classes = (VIEW3D_MT_tools_projectpaint_clone,)
+classes = (VIEW3D_MT_tools_projectpaint_clone, BRUSH_PT_channel_panel)
 
 if __name__ == "__main__":  # only for live edit.
     from bpy.utils import register_class
diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index a904b4d00ad..95e04b41653 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -151,7 +151,7 @@ void BKE_brush_weight_set(const struct Scene *scene, struct Brush *brush, float
 
 bool BKE_brush_use_locked_size(const struct Scene *scene, const struct Brush *brush);
 bool BKE_brush_use_alpha_pressure(const struct Brush *brush);
-bool BKE_brush_use_size_pressure(const struct Brush *brush);
+bool BKE_brush_use_size_pressure(const struct Scene *scene, const struct Brush *brush);
 
 bool BKE_brush_sculpt_has_secondary_color(const struct Brush *brush);
 
diff --git a/source/blender/blenkernel/BKE_brush_channel.h b/source/blender/blenkernel/BKE_brush_channel.h
index 008b72cbf48..9ffc11a8216 100644
--- a/source/blender/blenkernel/BKE_brush_channel.h
+++ b/source/blender/blenkernel/BKE_brush_channel.h
@@ -247,6 +247,14 @@ void _BKE_brush_channelset_mark_update(BrushChannelSet *chset, const char *idnam
 
 void BKE_brush_channelset_ui_order_check(BrushChannelSet *chset);
 
+bool _BKE_brush_mapping_enabled(const struct Scene *scene,
+                                const struct Brush *brush,
+                                const char *idname,
+                                eBrushMappingType mapping_type);
+
+#define BKE_brush_mapping_enabled(scene, brush, idname, mapping_type) \
+  _BKE_brush_mapping_enabled(scene, brush, make_builtin_ch_name(idname), mapping_type)
+
 #if 0
 /* Call when active brush changes. */
 void BKE_brush_channels_update(struct Brush *active_brush, struct Scene *scene);
diff --git a/source/blender/blenkernel/intern/brush.cc b/source/blender/blenkernel/intern/brush.cc
index 5bc2af54ddc..8ef11c89bbf 100644
--- a/source/blender/blenkernel/intern/brush.cc
+++ b/source/blender/blenkernel/intern/brush.cc
@@ -2302,9 +2302,16 @@ bool BKE_brush_use_locked_size(const Scene *scene, const Brush *brush)
                                           (brush->flag & BRUSH_LOCK_SIZE);
 }
 
-bool BKE_brush_use_size_pressure(const Brush *brush)
+bool BKE_brush_use_size_pressure(const Scene *scene, const Brush *brush)
 {
-  return brush->flag & BRUSH_SIZE_PRESSURE;
+  if (!BKE_brush_use_locked_size(scene, brush)) {
+    return BKE_brush_mapping_enabled(scene, brush, size, BRUSH_MAPPING_PRESSURE);
+  }
+  else {
+    return BKE_brush_mapping_enabled(scene, brush, unprojected_radius, BRUSH_MAPPING_PRESSURE);
+  }
+
+  //return brush->flag & BRUSH_SIZE_PRESSURE;
 }
 
 bool BKE_brush_use_alpha_pressure(const Brush *brush)
diff --git a/source/blender/blenkernel/intern/brush_channel.cc b/source/blender/blenkernel/intern/brush_channel.cc
index 9f06a3fcaed..9d41b6005b4 100644
--- a/source/blender/blenkernel/intern/brush_channel.cc
+++ b/source/blender/blenkernel/intern/brush_channel.cc
@@ -40,9 +40,7 @@
 
 const char builtin_brush_categories[][128] = {"Basic", "Smooth", "Color"};
 
-static BrushChannelType empty_brush_type = {
-  "error", "error", "error", "error"
-};
+static BrushChannelType empty_brush_type = {"error", "error", "error", "error"};
 
 #define BRUSH_CHANNEL_DEFINE_INTERNAL_NAMES
 #include "brush_channel_define.h"
@@ -584,9 +582,9 @@ static BrushChannel *brush_channel_final(const Brush *brush,
 }
 
 float _BKE_brush_eval_float(const Brush *brush,
-                                       const Scene *scene,
-                                       const char *idname,
-                                       BrushMappingData *mapping)
+                            const Scene *scene,
+                            const char *idname,
+                            BrushMappingData *mapping)
 {
   BrushChannel *ch = brush_channel_final(brush, scene, idname);
 
@@ -594,9 +592,9 @@ float _BKE_brush_eval_float(const Brush *brush,
 }
 
 int _BKE_brush_eval_int(const Brush *brush,
-                                   const Scene *scene,
-                                   const char *idname,
-                                   BrushMappingData *mapping)
+                        const Scene *scene,
+                        const char *idname,
+                        BrushMappingData *mapping)
 {
   BrushChannel *ch = brush_channel_final(brush, scene, idname);
 
@@ -755,10 +753,7 @@ float _BKE_brush_float_get(const ID *id, BrushChannelSet *chset, const char *idn
   return ret;
 }
 
-void _BKE_brush_float_set(ID *id,
-                                         BrushChannelSet *chset,
-                                         const char *idname,
-                                         float f)
+void _BKE_brush_float_set(ID *id, BrushChannelSet *chset, const char *idname, float f)
 {
   PointerRNA ptr;
   PropertyRNA *prop;
@@ -856,7 +851,7 @@ void BKE_brush_channelset_blend_read(BrushChannelSet *chset, BlendDataReader *re
       ch->def = &empty_brush_type;
     }
     /* Read user-defined category if it exists. */
-    BLO_read_data_address(reader, &ch->category); 
+    BLO_read_data_address(reader, &ch->category);
     BLO_read_data_address(reader, &ch->curve.curve);
 
     if (ch->curve.curve) {
@@ -1154,8 +1149,8 @@ void BKE_brush_channels_update(Brush *active_brush, Scene *scene)
 #endif
 
 int _BKE_brush_int_get_unified(const struct Scene *scene,
-                                              const struct Brush *brush,
-                          

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list