Commit: dbba5c4df973a0120ed9ed115cd9044b2f1d24a5
Author: Jacques Lucke
Date:   Thu May 5 12:11:50 2022 +0200
Branches: master
https://developer.blender.org/rBdbba5c4df973a0120ed9ed115cd9044b2f1d24a5

Curves: control number of control points in new curves

Previously, the number of control points in a new curve was hardcoded.

Differential Revision: https://developer.blender.org/D14857

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

M       release/scripts/startup/bl_ui/properties_paint_common.py
M       release/scripts/startup/bl_ui/space_view3d.py
M       source/blender/blenkernel/intern/brush.c
M       source/blender/blenloader/intern/versioning_300.c
M       source/blender/editors/sculpt_paint/curves_sculpt_add.cc
M       source/blender/makesdna/DNA_brush_types.h
M       source/blender/makesrna/intern/rna_brush.c

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

diff --git a/release/scripts/startup/bl_ui/properties_paint_common.py 
b/release/scripts/startup/bl_ui/properties_paint_common.py
index e14172873bc..5283a3691c0 100644
--- a/release/scripts/startup/bl_ui/properties_paint_common.py
+++ b/release/scripts/startup/bl_ui/properties_paint_common.py
@@ -929,6 +929,7 @@ def brush_settings_advanced(layout, context, brush, 
popover=False):
     elif mode == 'SCULPT_CURVES':
         if brush.curves_sculpt_tool == 'ADD':
             layout.prop(brush.curves_sculpt_settings, "add_amount")
+            layout.prop(brush.curves_sculpt_settings, "points_per_curve")
             layout.prop(brush.curves_sculpt_settings, "curve_length")
             layout.prop(brush.curves_sculpt_settings, "interpolate_length")
             layout.prop(brush.curves_sculpt_settings, "interpolate_shape")
diff --git a/release/scripts/startup/bl_ui/space_view3d.py 
b/release/scripts/startup/bl_ui/space_view3d.py
index b27122d94ce..b65079c0f36 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -519,6 +519,7 @@ class _draw_tool_settings_context_mode:
             layout.prop(brush, "use_frontface", text="Front Faces Only")
             layout.prop(brush, "falloff_shape", expand=True)
             layout.prop(brush.curves_sculpt_settings, "add_amount")
+            layout.prop(brush.curves_sculpt_settings, "points_per_curve")
             layout.prop(brush.curves_sculpt_settings, "curve_length")
             layout.prop(brush.curves_sculpt_settings, "interpolate_length")
             layout.prop(brush.curves_sculpt_settings, "interpolate_shape")
diff --git a/source/blender/blenkernel/intern/brush.c 
b/source/blender/blenkernel/intern/brush.c
index 0593db34e20..e8c95869910 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -1559,6 +1559,7 @@ void BKE_brush_init_curves_sculpt_settings(Brush *brush)
   }
   BrushCurvesSculptSettings *settings = brush->curves_sculpt_settings;
   settings->add_amount = 1;
+  settings->points_per_curve = 8;
   settings->minimum_length = 0.01f;
   settings->curve_length = 0.3f;
 }
diff --git a/source/blender/blenloader/intern/versioning_300.c 
b/source/blender/blenloader/intern/versioning_300.c
index 1708b532b91..7fd72fec3d0 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -3024,5 +3024,15 @@ void blo_do_versions_300(FileData *fd, Library 
*UNUSED(lib), Main *bmain)
       }
     }
     FOREACH_NODETREE_END;
+
+    /* Initialize brush curves sculpt settings. */
+    LISTBASE_FOREACH (Brush *, brush, &bmain->brushes) {
+      if (brush->ob_mode != OB_MODE_SCULPT_CURVES) {
+        continue;
+      }
+      if (brush->curves_sculpt_settings->points_per_curve == 0) {
+        brush->curves_sculpt_settings->points_per_curve = 8;
+      }
+    }
   }
 }
diff --git a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc 
b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
index 5fcb1d2850d..64dac56ecfb 100644
--- a/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
+++ b/source/blender/editors/sculpt_paint/curves_sculpt_add.cc
@@ -107,7 +107,7 @@ struct AddOperationExecutor {
   bool use_interpolation_;
   float new_curve_length_;
   int add_amount_;
-  int points_per_curve_ = 8;
+  int points_per_curve_;
 
   /** Various matrices to convert between coordinate spaces. */
   float4x4 curves_to_world_mat_;
@@ -171,6 +171,7 @@ struct AddOperationExecutor {
     const eBrushFalloffShape falloff_shape = static_cast<eBrushFalloffShape>(
         brush_->falloff_shape);
     add_amount_ = std::max(0, brush_settings_->add_amount);
+    points_per_curve_ = std::max(2, brush_settings_->points_per_curve);
     interpolate_length_ = brush_settings_->flag & 
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_LENGTH;
     interpolate_shape_ = brush_settings_->flag & 
BRUSH_CURVES_SCULPT_FLAG_INTERPOLATE_SHAPE;
     use_interpolation_ = interpolate_length_ || interpolate_shape_;
diff --git a/source/blender/makesdna/DNA_brush_types.h 
b/source/blender/makesdna/DNA_brush_types.h
index 7d230b7d7a3..24e77ecf87f 100644
--- a/source/blender/makesdna/DNA_brush_types.h
+++ b/source/blender/makesdna/DNA_brush_types.h
@@ -140,6 +140,8 @@ typedef struct BrushGpencilSettings {
 typedef struct BrushCurvesSculptSettings {
   /** Number of curves added by the add brush. */
   int add_amount;
+  /** Number of control points in new curves added by the add brush. */
+  int points_per_curve;
   /* eBrushCurvesSculptFlag. */
   uint32_t flag;
   /** When shrinking curves, they shouldn't become shorter than this length. */
diff --git a/source/blender/makesrna/intern/rna_brush.c 
b/source/blender/makesrna/intern/rna_brush.c
index c42cbdbbb56..f7edba24dea 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1953,6 +1953,11 @@ static void rna_def_curves_sculpt_options(BlenderRNA 
*brna)
   RNA_def_property_range(prop, 1, INT32_MAX);
   RNA_def_property_ui_text(prop, "Add Amount", "Number of curves added by the 
Add brush");
 
+  prop = RNA_def_property(srna, "points_per_curve", PROP_INT, PROP_NONE);
+  RNA_def_property_range(prop, 2, INT32_MAX);
+  RNA_def_property_ui_text(
+      prop, "Points per Curve", "Number of control points in a newly added 
curve");
+
   prop = RNA_def_property(srna, "scale_uniform", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "flag", 
BRUSH_CURVES_SCULPT_FLAG_SCALE_UNIFORM);
   RNA_def_property_ui_text(prop,

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to