[Bf-blender-cvs] [4785f80d511] sculpt-dev: Fix multiple crashes with custom input curves

Pablo Dobarro noreply at git.blender.org
Fri Jan 1 20:13:03 CET 2021


Commit: 4785f80d511b4b789d1456a911c248fd49df1bd7
Author: Pablo Dobarro
Date:   Fri Jan 1 20:12:46 2021 +0100
Branches: sculpt-dev
https://developer.blender.org/rB4785f80d511b4b789d1456a911c248fd49df1bd7

Fix multiple crashes with custom input curves

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

M	source/blender/blenkernel/BKE_brush.h
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenloader/intern/versioning_290.c
M	source/blender/editors/sculpt_paint/paint_stroke.c
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/blenkernel/BKE_brush.h b/source/blender/blenkernel/BKE_brush.h
index e551ed76b6f..cdc7f324623 100644
--- a/source/blender/blenkernel/BKE_brush.h
+++ b/source/blender/blenkernel/BKE_brush.h
@@ -140,6 +140,8 @@ void BKE_brush_scale_size(int *r_brush_size,
                           float new_unprojected_radius,
                           float old_unprojected_radius);
 
+void BKE_brush_default_input_curves_set(struct Brush *brush);
+
 /* Accessors */
 #define BKE_brush_tool_get(brush, p) \
   (CHECK_TYPE_ANY(brush, struct Brush *, const struct Brush *), \
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 12a8d0782d0..759c2d735f6 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -265,9 +265,10 @@ static void brush_reset_input_curve(CurveMapping *cumap)
   CurveMap *cuma = cumap->cm;
   BKE_curvemap_reset(cuma, &cumap->clipr, cumap->preset, CURVEMAP_SLOPE_POSITIVE);
   BKE_curvemapping_changed(cumap, false);
+  BKE_curvemapping_init(cumap);
 }
 
-static void BKE_brush_default_input_curves_set(Brush *brush)
+void BKE_brush_default_input_curves_set(Brush *brush)
 {
   if (!brush->pressure_size_curve) {
     brush->pressure_size_curve = BKE_curvemapping_add(1, 0, 0, 1, 1);
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c
index 63ef436d8e2..b583326cd01 100644
--- a/source/blender/blenloader/intern/versioning_290.c
+++ b/source/blender/blenloader/intern/versioning_290.c
@@ -51,6 +51,7 @@
 
 #include "BKE_animsys.h"
 #include "BKE_armature.h"
+#include "BKE_brush.h"
 #include "BKE_collection.h"
 #include "BKE_colortools.h"
 #include "BKE_cryptomatte.h"
@@ -1490,5 +1491,10 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
    */
   {
     /* Keep this block, even when empty. */
+    LISTBASE_FOREACH (Brush *, br, &bmain->brushes) {
+      if (!br->pressure_size_curve || !br->pressure_strength_curve) {
+        BKE_brush_default_input_curves_set(br);
+      }
+    }
   }
 }
diff --git a/source/blender/editors/sculpt_paint/paint_stroke.c b/source/blender/editors/sculpt_paint/paint_stroke.c
index a44709ef071..629664738ff 100644
--- a/source/blender/editors/sculpt_paint/paint_stroke.c
+++ b/source/blender/editors/sculpt_paint/paint_stroke.c
@@ -681,6 +681,7 @@ static float paint_space_stroke_spacing(bContext *C,
   float size_clamp = 0.0f;
   float final_size_pressure = size_pressure;
   if (brush->pressure_size_curve) {
+    BKE_curvemapping_init(brush->pressure_size_curve);
     final_size_pressure = BKE_curvemapping_evaluateF(brush->pressure_size_curve, 0, size_pressure);
   }
   float size = BKE_brush_size_get(scene, stroke->brush) * final_size_pressure;
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 98485b769bd..ea6bd77722d 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2309,6 +2309,9 @@ static float brush_strength(const Sculpt *sd,
   }
 
   float pressure = BKE_brush_use_alpha_pressure(brush) ? cache->pressure : 1.0f;
+  if (brush->pressure_strength_curve) {
+    BKE_curvemapping_init(brush->pressure_strength_curve);
+  }
   pressure = BKE_brush_use_alpha_pressure(brush) && brush->pressure_strength_curve ?
                  BKE_curvemapping_evaluateF(brush->pressure_strength_curve, 0, cache->pressure) :
                  pressure;



More information about the Bf-blender-cvs mailing list