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.
This commit is contained in:
Hans Goudey 2023-01-16 16:51:10 -06:00
parent 6769acbbba
commit 647a7da17d
2 changed files with 9 additions and 2 deletions

View File

@ -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!
*/

View File

@ -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();