diff options
author | Hans Goudey <h.goudey@me.com> | 2022-07-08 23:35:18 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-07-08 23:35:18 +0300 |
commit | 111bf7d76b080555fd524b2b4a138bcad2e5b206 (patch) | |
tree | e9e14ca4102ec0c73261745a9ff7b7aa2de1cc57 /source/blender/geometry/intern/mesh_to_curve_convert.cc | |
parent | b4db5a93bcf92b731d0e358602816cce2dbbd7cb (diff) | |
parent | 2ee68917287627a3803a8eae91d4d788ac316185 (diff) |
Merge branch 'master' into temp-legacy-mesh-format-option
Diffstat (limited to 'source/blender/geometry/intern/mesh_to_curve_convert.cc')
-rw-r--r-- | source/blender/geometry/intern/mesh_to_curve_convert.cc | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/source/blender/geometry/intern/mesh_to_curve_convert.cc b/source/blender/geometry/intern/mesh_to_curve_convert.cc index 38f9da2a60c..681dfd15137 100644 --- a/source/blender/geometry/intern/mesh_to_curve_convert.cc +++ b/source/blender/geometry/intern/mesh_to_curve_convert.cc @@ -8,7 +8,7 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" -#include "BKE_attribute_access.hh" +#include "BKE_attribute.hh" #include "BKE_attribute_math.hh" #include "BKE_curves.hh" #include "BKE_geometry_set.hh" @@ -44,14 +44,13 @@ static Curves *create_curve_from_vert_indices(const MeshComponent &mesh_componen curves.cyclic_for_write().fill(false); curves.cyclic_for_write().slice(cyclic_curves).fill(true); - Set<bke::AttributeIDRef> source_attribute_ids = mesh_component.attribute_ids(); + bke::MutableAttributeAccessor curves_attributes = curves.attributes_for_write(); + const bke::AttributeAccessor mesh_attributes = *mesh_component.attributes(); - CurveComponent curves_component; - curves_component.replace(curves_id, GeometryOwnershipType::Editable); + Set<bke::AttributeIDRef> source_attribute_ids = mesh_attributes.all_ids(); for (const bke::AttributeIDRef &attribute_id : source_attribute_ids) { - if (mesh_component.attribute_is_builtin(attribute_id) && - !curves_component.attribute_is_builtin(attribute_id)) { + if (mesh_attributes.is_builtin(attribute_id) && !curves_attributes.is_builtin(attribute_id)) { /* Don't copy attributes that are built-in on meshes but not on curves. */ continue; } @@ -60,8 +59,7 @@ static Curves *create_curve_from_vert_indices(const MeshComponent &mesh_componen continue; } - const GVArray mesh_attribute = mesh_component.attribute_try_get_for_read(attribute_id, - ATTR_DOMAIN_POINT); + const GVArray mesh_attribute = mesh_attributes.lookup(attribute_id, ATTR_DOMAIN_POINT); /* Some attributes might not exist if they were builtin attribute on domains that don't * have any elements, i.e. a face attribute on the output of the line primitive node. */ if (!mesh_attribute) { @@ -71,10 +69,10 @@ static Curves *create_curve_from_vert_indices(const MeshComponent &mesh_componen /* Copy attribute based on the map for this curve. */ attribute_math::convert_to_static_type(mesh_attribute.type(), [&](auto dummy) { using T = decltype(dummy); - bke::OutputAttribute_Typed<T> attribute = - curves_component.attribute_try_get_for_output_only<T>(attribute_id, ATTR_DOMAIN_POINT); - copy_with_map<T>(mesh_attribute.typed<T>(), vert_indices, attribute.as_span()); - attribute.save(); + bke::SpanAttributeWriter<T> attribute = + curves_attributes.lookup_or_add_for_write_only_span<T>(attribute_id, ATTR_DOMAIN_POINT); + copy_with_map<T>(mesh_attribute.typed<T>(), vert_indices, attribute.span); + attribute.finish(); }); } |