[Bf-blender-cvs] [07049bd2175] sculpt-dev: Sculpt: more clay fixes

Joseph Eagar noreply at git.blender.org
Thu Sep 30 07:04:35 CEST 2021


Commit: 07049bd217523171a89b51ed1cf3471b28a862f7
Author: Joseph Eagar
Date:   Wed Sep 29 22:03:39 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB07049bd217523171a89b51ed1cf3471b28a862f7

Sculpt: more clay fixes

For some reason I have to
take the sqrt of pressure
to match previous behavior,
but for the life of me I can't
find the offending double
multiplication.

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

M	release/scripts/startup/bl_ui/properties_paint_common.py
M	source/blender/blenkernel/BKE_brush_engine.h
M	source/blender/blenkernel/intern/brush_engine.c
M	source/blender/blenkernel/intern/brush_engine_presets.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 e519cd0c5bc..8d898fa75aa 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -836,19 +836,43 @@ class StrokePanel(BrushPanel):
 
         if brush.use_space:
             row = col.row(align=True)
-            row.prop(brush, "spacing", text="Spacing")
-            row.prop(brush, "use_pressure_spacing", toggle=True, text="")
+            if mode == 'SCULPT':
+                UnifiedPaintPanel.channel_unified(
+                    col,
+                    context,
+                    brush,
+                    "spacing"
+                )
+            else:
+                row.prop(brush, "spacing", text="Spacing")
+                row.prop(brush, "use_pressure_spacing", toggle=True, text="")
 
         if brush.use_line or brush.use_curve:
             row = col.row(align=True)
-            row.prop(brush, "spacing", text="Spacing")
+            if mode == 'SCULPT':
+                UnifiedPaintPanel.channel_unified(
+                    col,
+                    context,
+                    brush,
+                    "spacing"
+                )
+            else:
+                row.prop(brush, "spacing", text="Spacing")
 
         if mode == 'SCULPT':
             col.row().prop(brush, "use_scene_spacing", text="Spacing Distance", expand=True)
 
-        if mode in {'PAINT_TEXTURE', 'PAINT_2D', 'SCULPT'}:
+        if mode in {'PAINT_TEXTURE', 'PAINT_2D'}:
             if brush.image_paint_capabilities.has_space_attenuation or brush.sculpt_capabilities.has_space_attenuation:
                 col.prop(brush, "use_space_attenuation")
+        elif mode == 'SCULPT':
+            if brush.image_paint_capabilities.has_space_attenuation or brush.sculpt_capabilities.has_space_attenuation:
+                UnifiedPaintPanel.channel_unified(
+                    col,
+                    context,
+                    brush,
+                    "use_space_attenuation"
+                )
 
         if brush.use_curve:
             col.separator()
diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 0d57644ff06..7f9ff3ad2f8 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -347,6 +347,7 @@ 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_clear_inherit(BrushChannelSet *chset);
 void BKE_brush_channelset_apply_mapping(BrushChannelSet *chset, BrushMappingData *mapdata);
 void BKE_brush_check_toolsettings(struct Sculpt *sd);
 void BKE_brush_channelset_ui_init(struct Brush *brush, int tool);
diff --git a/source/blender/blenkernel/intern/brush_engine.c b/source/blender/blenkernel/intern/brush_engine.c
index 638f7f32c8c..6bc201c14f3 100644
--- a/source/blender/blenkernel/intern/brush_engine.c
+++ b/source/blender/blenkernel/intern/brush_engine.c
@@ -697,6 +697,15 @@ BrushChannel *BKE_brush_channelset_ensure_builtin(BrushChannelSet *chset, const
   return ch;
 }
 
+void BKE_brush_channelset_clear_inherit(BrushChannelSet *chset)
+{
+  BrushChannel *ch;
+
+  for (ch = chset->channels.first; ch; ch = ch->next) {
+    ch->flag &= ~(BRUSH_CHANNEL_INHERIT | BRUSH_CHANNEL_INHERIT_IF_UNSET);
+  }
+}
+
 void BKE_brush_channelset_ensure_existing(BrushChannelSet *chset, BrushChannel *existing)
 {
   if (BKE_brush_channelset_has(chset, existing->idname)) {
@@ -798,6 +807,7 @@ BrushChannelSet *BKE_brush_channelset_copy(BrushChannelSet *src)
 void BKE_brush_channelset_apply_mapping(BrushChannelSet *chset, BrushMappingData *mapdata)
 {
   BrushChannel *ch;
+  int n;
 
   for (ch = chset->channels.first; ch; ch = ch->next) {
     switch (ch->type) {
@@ -810,6 +820,16 @@ void BKE_brush_channelset_apply_mapping(BrushChannelSet *chset, BrushMappingData
       case BRUSH_CHANNEL_BOOL:
         ch->ivalue = BKE_brush_channel_get_int(ch, mapdata);
         break;
+      case BRUSH_CHANNEL_VEC4:
+        n = 4;
+      case BRUSH_CHANNEL_VEC3:
+        n = 3;
+
+        for (int i = 0; i < n; i++) {
+          ch->vector[i] = (float)BKE_brush_channel_eval_mappings(
+              ch, mapdata, (double)ch->vector[i], i);
+        }
+        break;
     }
 
     // disable input mapping
@@ -865,10 +885,10 @@ static bool channel_has_mappings(BrushChannel *ch)
 }
 
 // idx is used by vector channels
-double BKE_brush_channel_eval_mappings(BrushChannel *ch,
-                                       BrushMappingData *mapdata,
-                                       double f,
-                                       int idx)
+ATTR_NO_OPT double BKE_brush_channel_eval_mappings(BrushChannel *ch,
+                                                   BrushMappingData *mapdata,
+                                                   double f,
+                                                   int idx)
 {
 
   if (idx == 3 && !(ch->flag & BRUSH_CHANNEL_APPLY_MAPPING_TO_ALPHA)) {
@@ -886,6 +906,7 @@ double BKE_brush_channel_eval_mappings(BrushChannel *ch,
       }
 
       float inputf = ((float *)mapdata)[i];
+
       if (mp->flag & BRUSH_MAPPING_INVERT) {
         inputf = 1.0 - inputf;
       }
diff --git a/source/blender/blenkernel/intern/brush_engine_presets.c b/source/blender/blenkernel/intern/brush_engine_presets.c
index 0bae49a50e1..cede7b32657 100644
--- a/source/blender/blenkernel/intern/brush_engine_presets.c
+++ b/source/blender/blenkernel/intern/brush_engine_presets.c
@@ -348,6 +348,7 @@ typedef struct BrushSettingsMap {
 static BrushSettingsMap brush_settings_map[] = {
   DEF(size, radius, INT, FLOAT)
   DEF(alpha, strength, FLOAT, FLOAT)
+  DEF(spacing, spacing, INT, FLOAT)
   DEF(autosmooth_factor, autosmooth, FLOAT, FLOAT)
   DEF(area_radius_factor, area_radius_factor, FLOAT, FLOAT)
   DEF(autosmooth_projection, SMOOTH_PROJECTION, FLOAT, FLOAT)
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index ff251d10e4d..5f981f3e0ac 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3790,7 +3790,7 @@ ATTR_NO_OPT static float brush_strength(const Sculpt *sd,
   const Brush *brush = cache->brush;  // BKE_paint_brush((Paint *)&sd->paint);
 
   /* Primary strength input; square it to make lower values more sensitive. */
-  const float root_alpha = BKE_brush_alpha_get(scene, brush);
+  const float root_alpha = brush->alpha;  // BKE_brush_alpha_get(scene, brush);
   const float alpha = root_alpha * root_alpha;
   const float dir = (brush->flag & BRUSH_DIR_IN) ? -1.0f : 1.0f;
   const float pen_flip = cache->pen_flip ? -1.0f : 1.0f;
@@ -9220,7 +9220,7 @@ static void SCULPT_run_command_list(
     ss->cache->radius_squared = old_radius * old_radius;
   }
   else {
-    nodes = sculpt_pbvh_gather_generic(ob, sd, brush, use_original, radius_scale, &totnode);
+    nodes = sculpt_pbvh_gather_generic(ob, sd, brush, use_original, radius_scale * 1.2, &totnode);
   }
 
   /* Draw Face Sets in draw mode makes a single undo push, in alt-smooth mode deforms the
@@ -9316,6 +9316,7 @@ static void SCULPT_run_command_list(
     BKE_brush_channelset_free(cmd->params_mapped);
     cmd->params_mapped = BKE_brush_channelset_copy(cmd->params_final);
     BKE_brush_channelset_apply_mapping(cmd->params_mapped, &ss->cache->input_mapping);
+    BKE_brush_channelset_clear_inherit(cmd->params_mapped);
 
     float radius = BRUSHSET_GET_FLOAT(cmd->params_mapped, radius, NULL);
     radius = paint_calc_object_space_radius(ss->cache->vc, ss->cache->true_location, radius);
@@ -9372,6 +9373,7 @@ static void SCULPT_run_command_list(
     ss->cache->channels_final = cmd->params_mapped;
 
     ss->cache->brush = brush2;
+
     ups->alpha = BRUSHSET_GET_FLOAT(cmd->params_mapped, strength, NULL);
 
     if (cmd->tool == SCULPT_TOOL_SMOOTH) {
@@ -9386,7 +9388,7 @@ static void SCULPT_run_command_list(
       ss->cache->bstrength = fabsf(ss->cache->bstrength);
     }
 
-    brush2->alpha = fabs(ss->cache->bstrength);
+    // brush2->alpha = fabs(ss->cache->bstrength);
 
     // printf("brush2->alpha: %f\n", brush2->alpha);
     // printf("ss->cache->bstrength: %f\n", ss->cache->bstrength);
@@ -10824,7 +10826,7 @@ static void sculpt_update_cache_variants(bContext *C, Sculpt *sd, Object *ob, Po
    * events. We should avoid this after events system re-design. */
   if (paint_supports_dynamic_size(brush, PAINT_MODE_SCULPT) || cache->first_time) {
     cache->pressure = RNA_float_get(ptr, "pressure");
-    cache->input_mapping.pressure = cache->pressure;
+    cache->input_mapping.pressure = sqrtf(cache->pressure);
     // printf("pressure: %f\n", cache->pressure);
   }



More information about the Bf-blender-cvs mailing list