[Bf-blender-cvs] [6b382e7fb02] sculpt-dev: Fix a few regressions in other paint modes.

Joseph Eagar noreply at git.blender.org
Sat Sep 25 09:19:50 CEST 2021


Commit: 6b382e7fb025e4df4f608f81e56fafd748c89aae
Author: Joseph Eagar
Date:   Sat Sep 25 00:19:31 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB6b382e7fb025e4df4f608f81e56fafd748c89aae

Fix a few regressions in other paint modes.

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/BKE_brush_engine.h
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/blenlib/BLI_utildefines.h
M	source/blender/editors/sculpt_paint/paint_vertex.c
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py b/release/scripts/startup/bl_ui/properties_paint_common.py
index be3e115b9a8..39c918ac5fa 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -1353,31 +1353,38 @@ def brush_shared_settings(layout, context, brush, popover=False):
 
     if size or size_mode:
         if size:
-            UnifiedPaintPanel.channel_unified(
+            UnifiedPaintPanel.prop_unified(
                 layout,
                 context,
                 brush,
                 size_prop,
+                unified_name="use_unified_size",
+                pressure_name="use_pressure_size",
                 text="Radius",
                 slider=True,
             )
         if size_mode:
             #layout.row().prop(size_owner, "use_locked_size", expand=True)
-            UnifiedPaintPanel.channel_unified(
+            UnifiedPaintPanel.prop_unified(
                 layout.row(),
                 context,
                 brush,
                 "use_locked_size",
-                expand=True
+                unified_name="use_unified_size",
+                pressure_name="use_pressure_size",
+                expand=True,
+                slider=True
             )
             layout.separator()
 
     if strength:    
-        UnifiedPaintPanel.channel_unified(
+        UnifiedPaintPanel.prop_unified(
             layout,
             context,
             brush,
             "strength",
+            unified_name="use_unified_strength",
+            pressure_name="use_pressure_strength",
             slider=True
         )
         layout.separator()
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index f1fcbf80610..bfd29b559ae 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -46,6 +46,7 @@ This should completely replace UnifiedPaintSettings.
 */
 
 #include "DNA_sculpt_brush_types.h"
+#include "DNA_texture_types.h"
 
 struct BrushChannel;
 struct BlendWriter;
@@ -76,6 +77,7 @@ struct Sculpt;
   BKE_brush_channelset_set_float(chset, MAKE_BUILTIN_CH_NAME(channel), val)
 #define BRUSHSET_SET_INT(chset, channel, val) \
   BKE_brush_channelset_set_int(chset, MAKE_BUILTIN_CH_NAME(channel), val)
+#define BRUSHSET_SET_BOOL(chset, channel, val) BRUSHSET_SET_INT(chset, channel, (val) ? 1 : 0)
 
 //#define DEBUG_CURVE_MAPPING_ALLOC
 #ifdef DEBUG_CURVE_MAPPING_ALLOC
@@ -128,12 +130,40 @@ typedef struct BrushChannelType {
   bool user_defined;
 } BrushChannelType;
 
+/* since MTex is going away lets'
+   keep the texture abstraction
+   and simple.  From the brush engine's
+   point of view it's just a bunch of
+   BrushChannels.
+
+   This will eventually end up in DNA.*/
+
+typedef struct BrushTex {
+  struct BrushTex *next, *prev;
+  char idname[64], name[64];
+
+  BrushChannelSet *channels;
+  MTex *__mtex;  // do not access directly. except for the actual evaluation code.
+} BrushTex;
+
+BrushTex *BKE_brush_tex_create();
+void BKE_brush_tex_free(BrushTex *btex);
+void BKE_brush_tex_patch_channels(BrushTex *btex);
+void BKE_brush_tex_from_mtex(BrushTex *btex, MTex *mtex);
+
+// initializes the internal mtex struct
+void BKE_brush_tex_start(BrushTex *btex, BrushChannelSet *chset);
+
+#define MAKE_BRUSHTEX_SLOTS 5
+
 typedef struct BrushCommand {
   int tool;
-  float last_spacing_t[512];  // for different symmetry passes
+  float last_spacing_t[512];  // this is an array for different symmetry passes
   struct BrushChannelSet *params;
-  struct BrushChannelSet *params_final;
-  struct BrushChannelSet *params_mapped;
+  struct BrushChannelSet *params_final;   // with inheritence applied
+  struct BrushChannelSet *params_mapped;  // with pressure etc applied
+
+  BrushTex *texture_slots[MAKE_BRUSHTEX_SLOTS];
 } BrushCommand;
 
 typedef struct BrushCommandList {
diff --git a/source/blender/blenkernel/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index 3f239487cd6..014f17d0c45 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -27,7 +27,12 @@ places in rna_engine_codebase are relevent:
 #  ifdef MAKE_FLOAT_EX_INV
 #    undef MAKE_FLOAT_EX_INV
 #  endif
-
+#  ifdef MAKE_FLOAT3
+#    undef MAKE_FLOAT3
+#  endif
+#  ifdef MAKE_FLOAT3_EX
+#    undef MAKE_FLOAT3_EX
+#  endif
 #  ifdef MAKE_INT
 #    undef MAKE_INT
 #  endif
@@ -65,6 +70,9 @@ places in rna_engine_codebase are relevent:
 #  ifdef MAKE_BUILTIN_CH_DEF
 #    undef MAKE_BUILTIN_CH_DEF
 #  endif
+#  ifdef MAKE_FLOAT_EX_FLAG
+#    undef MAKE_FLOAT_EX_FLAG
+#  endif
 
 #  ifdef BRUSH_CHANNEL_DEFINE_TYPES
 #    define MAKE_BUILTIN_CH_DEF(idname) const char *BRUSH_BUILTIN_##idname = #    idname;
@@ -91,6 +99,9 @@ places in rna_engine_codebase are relevent:
 #  define MAKE_BOOL_EX(idname, name, tooltip, val, flag) MAKE_BUILTIN_CH_DEF(idname);
 #  define MAKE_COLOR3(idname, name, tooltip, r, g, b) MAKE_BUILTIN_CH_DEF(idname);
 #  define MAKE_COLOR4(idname, name, tooltip, r, g, b, a) MAKE_BUILTIN_CH_DEF(idname);
+#  define MAKE_FLOAT3(idname, name, tooltip, x, y, z, min, max) MAKE_BUILTIN_CH_DEF(idname);
+#  define MAKE_FLOAT3_EX(idname, name, tooltip, x, y, z, min, max, smin, smax, flag) \
+    MAKE_BUILTIN_CH_DEF(idname);
 #  define MAKE_ENUM(idname1, name1, tooltip1, value1, enumdef1) MAKE_BUILTIN_CH_DEF(idname1);
 #  define MAKE_ENUM_EX(idname1, name1, tooltip1, value1, enumdef1, flag) \
     MAKE_BUILTIN_CH_DEF(idname1);
@@ -243,7 +254,7 @@ MAKE_ENUM(cloth_deform_type, "Deformation", "Deformation type that is used in th
 }))
 
 MAKE_ENUM(cloth_simulation_area_type, "Simulation Area", "Part of the mesh that is going to be simulated when the stroke is active", BRUSH_CLOTH_SIMULATION_AREA_LOCAL, _({
-  {BRUSH_CLOTH_SIMULATION_AREA_LOCAL,
+  {BRUSH_CLOTH_SIMULATION_AREA_DYNAMIC,
     "LOCAL",
     "NONE",
     "Local",
@@ -403,6 +414,25 @@ MAKE_ENUM(snake_hook_deform_type, "Deformation", "Deformation type that is used
   {-1}
 }))
 
+/*   MTex paramters (not stored directly inside of brushes)  */
+MAKE_FLOAT3(mtex_offset, "Offset", "Fine tune of the texture mapping X, Y and Z locations", 0.0f, 0.0f, 0.0f, -10.0f, 10.0f)
+MAKE_FLOAT3(mtex_scale, "Size", "Set scaling for the texture's X, Y and Z sizes", 1.0f, 1.0f, 1.0f, -100.0f, 100.0f)
+MAKE_FLOAT3_EX(mtex_color,  "Color", "Default color for textures that don't return RGB or when RGB to intensity is enabled", 1, 1, 1, 0, 1, -5, 5, BRUSH_CHANNEL_COLOR)
+MAKE_ENUM(mtex_map_mode, "Mode", "", MTEX_MAP_MODE_TILED, _({
+    {MTEX_MAP_MODE_VIEW, "VIEW_PLANE", "NONE", "View Plane", ""},
+    {MTEX_MAP_MODE_AREA, "AREA_PLANE", "NONE", "Area Plane", ""},
+    {MTEX_MAP_MODE_TILED, "TILED", "NONE", "Tiled", ""},
+    {MTEX_MAP_MODE_3D, "3D", "NONE", "3D", ""},
+    {MTEX_MAP_MODE_RANDOM, "RANDOM", "NONE", "Random", ""},
+    {MTEX_MAP_MODE_STENCIL, "STENCIL", "NONE", "Stencil", ""},
+    {-1}
+}))
+MAKE_BOOL(mtex_use_rake, "Rake", "", false)
+MAKE_BOOL(mtex_use_random, "Random", "", false)
+MAKE_FLOAT(mtex_random_angle, "Random Angle", "Brush texture random angle", 0.0f, 0.0f, M_PI*2.0f)
+MAKE_FLOAT(mtex_angle, "Angle", "", 0.0f, 0.0f, M_PI*2.0f)
+
+//MAKE_FLOAT3_EX
 /* clang-format on */
 #if defined(BRUSH_CHANNEL_DEFINE_TYPES) || defined(BRUSH_CHANNEL_DEFINE_EXTERNAL)
 #  ifdef MAKE_FLOAT
@@ -430,6 +460,12 @@ MAKE_ENUM(snake_hook_deform_type, "Deformation", "Deformation type that is used
 #  ifdef MAKE_COLOR4
 #    undef MAKE_COLOR4
 #  endif
+#  ifdef MAKE_FLOAT3
+#    undef MAKE_FLOAT3
+#  endif
+#  ifdef MAKE_FLOAT3_EX
+#    undef MAKE_FLOAT3_EX
+#  endif
 #  ifdef MAKE_BOOL
 #    undef MAKE_BOOL
 #  endif
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index b3e5cf5d841..954bec58090 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -1772,32 +1772,48 @@ void BKE_brush_channelset_to_unified_settings(BrushChannelSet *chset, UnifiedPai
     ups->weight = ch->fvalue;
   }
 }
+
+BrushTex *BKE_brush_tex_create()
+{
+  BrushTex *bt = MEM_callocN(sizeof(BrushTex), "BrushTex");
+
+  bt->channels = BKE_brush_channelset_create();
+
+  return bt;
+}
+
+void BKE_brush_tex_free(BrushTex *btex)
+{
+  BKE_brush_channelset_free(btex->channels);
+  MEM_freeN(btex);
+}
+
 /* idea for building built-in preset node graphs:
 from brush_builder import Builder;
 
 def build(input, output):
-  input.add("Strength", "float", "strength").range(0.0, 3.0)
-  input.add("Radius", "float", "radius").range(0.01, 1024.0)
-  input.add("Autosmooth", "float", "autosmooth").range(0.0, 4.0)
-  input.add("Topology Rake", "float", "topology rake").range(0.0, 4.0)
-  input.add("Smooth Radius Scale", "float", "autosmooth_radius_scale").range(0.01, 5.0)
-  input.add("Rake Radius Scale", "float", "toporake_radius_scale").range(0.01, 5.0)
-
-  draw = input.make.tool("DRAW")
-  draw.radius = input.radius
-  draw.strength = input.strength
-
-  smooth = input.make.tool("SMOOTH")
-  smooth.radius = input.radius * input.autosmooth_radius_scale
-  smooth.strength = input.autosmooth;
-  smooth.flow = draw.outflow
-
-  rake = input.make.tool("TOPORAKE")
-  rake.radius = input.radius * input.toporake_radius_scale
-  rake.strength = input.topology;
-  rake.flow = smooth.outflow
-
-  output.out = rake.outflow
+input.add("Strength", "float", "strength").range(0.0, 3.0)
+input.add("Radius", "float", "radius").range(0.01, 1024.0)
+input.add("Autosmooth", "float", "autosmooth").range(0.0, 4.0)
+input.add("Topology Rake", "float", "topology rake").range(0.0, 4.0)
+input.add("Smooth Radius Scale", "float", "autosmooth_radius_scale").range(0.01, 5.0)
+input.add("Rake Radius Scale", "float", "toporake_radius_scale").range(0.01, 5.0)
+
+draw = input.make.tool("DRAW")
+draw.radius = input.radius
+draw.strength = input.strength
+
+smooth = input.make.tool("SMOOTH")
+smooth.radius = input.radius * input.autosmooth_radius_scale
+smooth.strength = input.autosmooth;
+smooth.flow = draw.outflow
+
+rake = input.make.tool("TOPORAKE")


@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list