From 647a7da17dccca02cd31d9d8cd216b997edd5bfc Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Mon, 16 Jan 2023 16:51:10 -0600 Subject: [PATCH] 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. --- source/blender/blenkernel/BKE_curves_utils.hh | 2 +- source/blender/blenkernel/intern/curves_geometry.cc | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) 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 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();