Commit: baf69b064b91e8300830ab4e7d9a86060d80f7d6 Author: Hans Goudey Date: Thu Jan 19 15:35:58 2023 -0600 Branches: master https://developer.blender.org/rBbaf69b064b91e8300830ab4e7d9a86060d80f7d6
Geometry Nodes: Avoid creating cyclic attribute when redundant The default when there is no cyclic attribute is that none of the curves are cyclic. In the mesh to curve node, avoid creating the attribute with just false to save time and memory usage. Also avoid looking up the attribute twice in the trim node. =================================================================== M source/blender/geometry/intern/mesh_to_curve_convert.cc M source/blender/geometry/intern/trim_curves.cc =================================================================== diff --git a/source/blender/geometry/intern/mesh_to_curve_convert.cc b/source/blender/geometry/intern/mesh_to_curve_convert.cc index 06bef16dec7..22c925a1310 100644 --- a/source/blender/geometry/intern/mesh_to_curve_convert.cc +++ b/source/blender/geometry/intern/mesh_to_curve_convert.cc @@ -30,12 +30,16 @@ bke::CurvesGeometry create_curve_from_vert_indices( curves.offsets_for_write().last() = vert_indices.size(); curves.fill_curve_types(CURVE_TYPE_POLY); - curves.cyclic_for_write().fill(false); - curves.cyclic_for_write().slice(cyclic_curves).fill(true); - const bke::AttributeAccessor mesh_attributes = mesh.attributes(); bke::MutableAttributeAccessor curves_attributes = curves.attributes_for_write(); + if (!cyclic_curves.is_empty()) { + bke::SpanAttributeWriter cyclic = curves_attributes.lookup_or_add_for_write_span<bool>( + "cyclic", ATTR_DOMAIN_CURVE); + cyclic.span.slice(cyclic_curves).fill(true); + cyclic.finish(); + } + Set<bke::AttributeIDRef> source_attribute_ids = mesh_attributes.all_ids(); for (const bke::AttributeIDRef &attribute_id : source_attribute_ids) { diff --git a/source/blender/geometry/intern/trim_curves.cc b/source/blender/geometry/intern/trim_curves.cc index 3097c2e8c4a..b7faf54bdc5 100644 --- a/source/blender/geometry/intern/trim_curves.cc +++ b/source/blender/geometry/intern/trim_curves.cc @@ -1064,8 +1064,9 @@ bke::CurvesGeometry trim_curves(const bke::CurvesGeometry &src_curves, } else { /* Only trimmed curves are no longer cyclic. */ - if (dst_curves.attributes().contains("cyclic")) { - dst_curves.cyclic_for_write().fill_indices(selection, false); + if (bke::SpanAttributeWriter cyclic = dst_attributes.lookup_for_write_span<bool>("cyclic")) { + cyclic.span.fill_indices(selection, false); + cyclic.finish(); } Set<std::string> copy_point_skip; _______________________________________________ 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