[Bf-blender-cvs] [159211da8f5] sculpt-dev: Sculpt: fix various issues with clay brushes

Joseph Eagar noreply at git.blender.org
Wed Sep 29 11:55:22 CEST 2021


Commit: 159211da8f5128c8708a9ce99dce263e5859acd2
Author: Joseph Eagar
Date:   Wed Sep 29 02:54:32 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB159211da8f5128c8708a9ce99dce263e5859acd2

Sculpt: fix various issues with clay brushes

* No longer applies size pressure mapping twice
* Fixed hardness setting not being applied.

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

M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenkernel/intern/brush_channel_define.h
M	source/blender/blenkernel/intern/brush_engine_presets.c
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 1f25106404a..4a34a7ec2fc 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 25
+#define BLENDER_FILE_SUBVERSION 26
 
 /* 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/intern/brush_channel_define.h b/source/blender/blenkernel/intern/brush_channel_define.h
index b20e7eef182..232d77586f0 100644
--- a/source/blender/blenkernel/intern/brush_channel_define.h
+++ b/source/blender/blenkernel/intern/brush_channel_define.h
@@ -114,7 +114,7 @@ places in rna_engine_codebase are relevent:
 
 /* clang-format off */
   MAKE_FLOAT_EX(radius, "Radius", "Radius of the brush in pixels", 50.0f, 0.5f, MAX_BRUSH_PIXEL_RADIUS*10, 0.5, MAX_BRUSH_PIXEL_RADIUS, false)
-  MAKE_FLOAT_EX(strength, "Strength", "How powerful the effect of the brush is when applied", 0.5f, 0.0f, 10.0f, 0.0f, 1.0f, false)
+  MAKE_FLOAT_EX(strength, "Strength", "How powerful the effect of the brush is when applied", 0.5f, 0.0f, 10.0f, 0.0f, 1.0f, true)
   MAKE_FLOAT_EX(spacing, "Spacing", "", 10.0f, 0.25f, 1000.0f, 1.0f, 500.0f, false)
   MAKE_FLOAT_EX(topology_rake, "Topology Rake", "Automatically align edges to the brush direction to "
                            "generate cleaner topology and define sharp features. "
@@ -183,9 +183,9 @@ MAKE_FLOAT(normal_weight, "Normal Weight", "", 0.0f, 0.0f, 1.0f)
 MAKE_FLOAT(weight, "Weight", "", 0.5f, 0.0f, 1.0f)
 MAKE_FLOAT(jitter, "Jitter",  "Jitter the position of the brush while painting", 0.0f, 0.0f, 1.0f)
 MAKE_INT(jitter_absolute, "Absolute Jitter", "", 0, 0.0f, 1000.0f)
-MAKE_FLOAT(smooth_stroke_radius, "Smooth Stroke Radius", "Minimum distance from last point before stroke continues", 10.0f, 10.0f, 200.0f)
-MAKE_FLOAT(smooth_stroke_factor, "Smooth Stroke Factor", "", 0.5f, 0.5f, 0.99f)
-MAKE_FLOAT_EX(rate, "Rate", "", 0.5, 0.0001f, 10000.0f, 0.01f, 1.0f, false)
+MAKE_FLOAT(smooth_stroke_radius, "Smooth Stroke Radius", "Minimum distance from last point before stroke continues", 75.0f, 10.0f, 200.0f)
+MAKE_FLOAT(smooth_stroke_factor, "Smooth Stroke Factor", "", 0.9f, 0.5f, 0.99f)
+MAKE_FLOAT_EX(rate, "Rate", "", 0.1, 0.0001f, 10000.0f, 0.01f, 1.0f, false)
 MAKE_FLOAT(flow, "Flow", "Amount of paint that is applied per stroke sample", 1.0f, 0.0f, 1.0f)
 MAKE_FLOAT(wet_mix, "Wet Mix", "Amount of paint that is picked from the surface into the brush color", 0.0f, 0.0f, 1.0f)
 MAKE_FLOAT(wet_persistence, "Wet Persistence", "Amount of wet paint that stays in the brush after applying paint to the surface", 0.0f, 0.0f, 1.0f)
@@ -397,7 +397,7 @@ MAKE_ENUM(pose_origin_type, "Rotation Origins",
   {-1}
 })
 
-MAKE_FLOAT(crease_pinch_factor, "Crease Brush Pinch Factor", "How much the crease brush pinches", 0.0f, 0.0f, 1.0f)
+MAKE_FLOAT(crease_pinch_factor, "Crease Brush Pinch Factor", "How much the crease brush pinches", 0.5f, 0.0f, 1.0f)
 
 MAKE_ENUM(snake_hook_deform_type, "Deformation", "Deformation type that is used in the brush", BRUSH_SNAKE_HOOK_DEFORM_FALLOFF, {\
   {BRUSH_SNAKE_HOOK_DEFORM_FALLOFF,
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index 7e26d068784..20162d9cc04 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -280,6 +280,7 @@ static BrushSettingsMap brush_settings_map[] = {
   DEF(smooth_stroke_factor, smooth_stroke_factor, FLOAT, FLOAT)
   DEF(rate, rate, FLOAT, FLOAT)
   DEF(flow, flow, FLOAT, FLOAT)
+  DEF(hardness, hardness, FLOAT, FLOAT)
   DEF(wet_mix, wet_mix, FLOAT, FLOAT)
   DEF(wet_persistence, wet_persistence, FLOAT, FLOAT)
   DEF(density, density, FLOAT, FLOAT)
@@ -321,6 +322,7 @@ static BrushSettingsMap brush_settings_map[] = {
   DEF(tip_scale_x, tip_scale_x, FLOAT, FLOAT)
   DEF(height, height, FLOAT, FLOAT)
   DEF(elastic_deform_type, elastic_deform_type, INT, INT)
+  DEF(plane_offset, plane_offset, FLOAT, FLOAT)
 };
 
 static const int brush_settings_map_len = ARRAY_SIZE(brush_settings_map);
@@ -735,7 +737,7 @@ void BKE_brush_channelset_compat_load(BrushChannelSet *chset, Brush *brush, bool
   }
 }
 
-static void reset_clay_mappings(BrushChannelSet *chset, bool strips)
+void reset_clay_mappings(BrushChannelSet *chset, bool strips)
 {
   BrushMapping *mp = BRUSHSET_LOOKUP(chset, radius)->mappings + BRUSH_MAPPING_PRESSURE;
   BKE_brush_mapping_ensure_write(mp);
@@ -782,7 +784,11 @@ static void reset_clay_mappings(BrushChannelSet *chset, bool strips)
   BKE_curvemapping_init(curve);
 
   cuma = curve->cm;
-  BKE_curvemap_insert(cuma, 0.6f, 0.25f);
+  if (strips) {
+    BKE_curvemap_insert(cuma, 0.6f, 0.25f);
+  }
+  else {
+  }
   BKE_curvemapping_changed(curve, true);
 }
 // adds any missing channels to brushes
@@ -807,6 +813,8 @@ void BKE_brush_builtin_patch(Brush *brush, int tool)
   ADDCH(radius_unit);
   ADDCH(unprojected_radius);
 
+  ADDCH(plane_offset);
+
   ADDCH(use_ctrl_invert);
   ADDCH(tilt_strength_factor);
 
@@ -1060,6 +1068,7 @@ void BKE_brush_channelset_ui_init(Brush *brush, int tool)
       SHOWWRK(area_radius_factor);
       break;
     case SCULPT_TOOL_CLAY_STRIPS:
+      SHOWWRK(tip_roundness);
     case SCULPT_TOOL_CLAY:
     case SCULPT_TOOL_CLAY_THUMB:
     case SCULPT_TOOL_FLATTEN:
@@ -1148,6 +1157,25 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
     brush->channels = BKE_brush_channelset_create();
   }
 
+  if (brush->channels) {
+    // forcibly reset all non-user-defined channels for this brush
+
+    BrushChannelSet *chset = BKE_brush_channelset_create();
+    Brush tmp = *brush;
+    tmp.channels = chset;
+
+    BKE_brush_builtin_patch(&tmp, tool);
+
+    BrushChannel *ch;
+    for (ch = chset->channels.first; ch; ch = ch->next) {
+      BrushChannel *ch2 = BKE_brush_channelset_lookup(brush->channels, ch->idname);
+
+      if (ch2) {
+        BKE_brush_channel_copy_data(ch, ch2, false);
+      }
+    }
+  }
+
   BrushChannelSet *chset = brush->channels;
 
   BKE_brush_builtin_patch(brush, tool);
@@ -1230,11 +1258,16 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
       break;
     case SCULPT_TOOL_CLAY:
       GETCH(radius)->mappings[BRUSH_MAPPING_PRESSURE].flag |= BRUSH_MAPPING_ENABLED;
+      GETCH(strength)->mappings[BRUSH_MAPPING_PRESSURE].flag |= BRUSH_MAPPING_ENABLED;
+
       GETCH(spacing)->fvalue = 3;
       GETCH(autosmooth)->fvalue = 0.25f;
       GETCH(normal_radius_factor)->fvalue = 0.75f;
       GETCH(hardness)->fvalue = 0.65;
 
+      // ADDCH(autosmooth_falloff_curve);
+      // GETCH(autosmooth_falloff_curve)->curve.preset = BRUSH_CURVE_SPHERE;
+
       BRUSHSET_SET_BOOL(chset, autosmooth_use_spacing, true);
       BRUSHSET_SET_FLOAT(chset, autosmooth_spacing, 7);
 
@@ -1252,10 +1285,12 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
       BRUSHSET_SET_FLOAT(chset, spacing, 6.0f);
       BRUSHSET_SET_FLOAT(chset, normal_radius_factor, 1.0f);
       BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
-      BRUSHSET_LOOKUP(chset, radius)->mappings[BRUSH_MAPPING_PRESSURE].flag |=
-          BRUSH_MAPPING_ENABLED;
+      BRUSHSET_LOOKUP(chset, radius)->mappings[BRUSH_MAPPING_PRESSURE].flag &=
+          ~BRUSH_MAPPING_ENABLED;
       break;
     case SCULPT_TOOL_CLAY_STRIPS: {
+      // GETCH(falloff_curve)->curve.preset = BRUSH_CURVE_SMOOTHER;
+
       GETCH(radius)->mappings[BRUSH_MAPPING_PRESSURE].flag |= BRUSH_MAPPING_ENABLED;
       GETCH(strength)->mappings[BRUSH_MAPPING_PRESSURE].flag |= BRUSH_MAPPING_ENABLED;
 
@@ -1323,6 +1358,14 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
       break;
     case SCULPT_TOOL_ELASTIC_DEFORM:
       ADDCH(elastic_deform_type);
+      GETCH(strength)->mappings[BRUSH_MAPPING_PRESSURE].flag &= ~BRUSH_MAPPING_ENABLED;
+      BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
+      break;
+    case SCULPT_TOOL_GRAB:
+      GETCH(strength)->mappings[BRUSH_MAPPING_PRESSURE].flag &= ~BRUSH_MAPPING_ENABLED;
+      GETCH(strength)->fvalue = 0.4f;
+      GETCH(radius)->fvalue = 75.0f;
+      GETCH(dyntopo_disabled)->ivalue = 1;
       break;
     case SCULPT_TOOL_SNAKE_HOOK:
       GETCH(dyntopo_mode)->ivalue = DYNTOPO_LOCAL_COLLAPSE | DYNTOPO_SUBDIVIDE;
@@ -1338,10 +1381,12 @@ void BKE_brush_builtin_create(Brush *brush, int tool)
       BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
       break;
     case SCULPT_TOOL_BOUNDARY:
+      GETCH(strength)->mappings[BRUSH_MAPPING_PRESSURE].flag &= ~BRUSH_MAPPING_ENABLED;
       BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
       ADDCH(elastic_deform_type);
       break;
     case SCULPT_TOOL_POSE:
+      GETCH(strength)->mappings[BRUSH_MAPPING_PRESSURE].flag &= ~BRUSH_MAPPING_ENABLED;
       BRUSHSET_SET_BOOL(chset, use_space_attenuation, false);
       ADDCH(elastic_deform_type);
       break;
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index 9ada9d7d593..e1e07093ba8 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -4175,7 +4175,7 @@ void BKE_pbvh_update_vert_boundary_faces(int *face_sets,
       }
     }
 
-    int fset = face_sets[f_i];
+    int fset = face_sets ? face_sets[f_i] : -1;
 
     if (fset > 0) {
       visible = true;
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 1a7683fcbfc..0fda17bf3ba 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1317,11 +1317,27 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
     }
   }
 
-  if (!MAIN_VERSION_ATLEAST(bmain, 300, 25)) {
+  if (!MAIN_VERSION_ATLEAST(bmain, 300, 26)) {
     LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
-      if (brush->sculpt_tool == SCULPT_TOOL_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list