[Bf-blender-cvs] [647a7da17dc] master: Curves: Avoid adding curve type attribute when setting default

Hans Goudey noreply at git.blender.org
Mon Jan 16 23:58:47 CET 2023


Commit: 647a7da17dccca02cd31d9d8cd216b997edd5bfc
Author: Hans Goudey
Date:   Mon Jan 16 16:51:10 2023 -0600
Branches: master
https://developer.blender.org/rB647a7da17dccca02cd31d9d8cd216b997edd5bfc

Curves: Avoid adding curve type attribute when setting default

The default curve type when there is no "curve_type" attribute is
Catmull ROM. In order to avoid allocating an entire array of values
just to set this default type, remove the attribute instead. This will
be less important when we can store attributes as single values.

Also fix a curve utility API comment.

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

M	source/blender/blenkernel/BKE_curves_utils.hh
M	source/blender/blenkernel/intern/curves_geometry.cc

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

diff --git a/source/blender/blenkernel/BKE_curves_utils.hh b/source/blender/blenkernel/BKE_curves_utils.hh
index 1e06cb2d4c7..77998b24a32 100644
--- a/source/blender/blenkernel/BKE_curves_utils.hh
+++ b/source/blender/blenkernel/BKE_curves_utils.hh
@@ -519,7 +519,7 @@ void fill_points(const CurvesGeometry &curves,
 }
 
 /**
- * Copy only the information on the point domain, but not the offsets or any point attributes,
+ * Copy only the attributes on the curve domain, but not the offsets or any point attributes,
  * meant for operations that change the number of points but not the number of curves.
  * \warning The returned curves have invalid offsets!
  */
diff --git a/source/blender/blenkernel/intern/curves_geometry.cc b/source/blender/blenkernel/intern/curves_geometry.cc
index 65117ab00bb..0dc6a24fd9e 100644
--- a/source/blender/blenkernel/intern/curves_geometry.cc
+++ b/source/blender/blenkernel/intern/curves_geometry.cc
@@ -242,7 +242,14 @@ MutableSpan<int8_t> CurvesGeometry::curve_types_for_write()
 
 void CurvesGeometry::fill_curve_types(const CurveType type)
 {
-  this->curve_types_for_write().fill(type);
+  if (type == CURVE_TYPE_CATMULL_ROM) {
+    /* Avoid creating the attribute for Catmull Rom which is the default when the attribute doesn't
+     * exist anyway. */
+    this->attributes_for_write().remove("curve_type");
+  }
+  else {
+    this->curve_types_for_write().fill(type);
+  }
   this->runtime->type_counts.fill(0);
   this->runtime->type_counts[type] = this->curves_num();
   this->tag_topology_changed();



More information about the Bf-blender-cvs mailing list