diff options
Diffstat (limited to 'source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc')
-rw-r--r-- | source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc b/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc index 577b001fd06..74fff8efeee 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_points_to_vertices.cc @@ -18,14 +18,6 @@ static void node_declare(NodeDeclarationBuilder &b) b.add_output<decl::Geometry>(N_("Mesh")); } -template<typename T> -static void copy_attribute_to_vertices(const Span<T> src, const IndexMask mask, MutableSpan<T> dst) -{ - for (const int i : mask.index_range()) { - dst[i] = src[mask[i]]; - } -} - /* One improvement would be to move the attribute arrays directly to the mesh when possible. */ static void geometry_set_points_to_vertices(GeometrySet &geometry_set, Field<bool> &selection_field) @@ -38,7 +30,7 @@ static void geometry_set_points_to_vertices(GeometrySet &geometry_set, } GeometryComponentFieldContext field_context{*point_component, ATTR_DOMAIN_POINT}; - const int domain_num = point_component->attribute_domain_num(ATTR_DOMAIN_POINT); + const int domain_num = point_component->attribute_domain_size(ATTR_DOMAIN_POINT); if (domain_num == 0) { geometry_set.keep_only({GEO_COMPONENT_TYPE_INSTANCES}); return; @@ -59,19 +51,15 @@ static void geometry_set_points_to_vertices(GeometrySet &geometry_set, for (Map<AttributeIDRef, AttributeKind>::Item entry : attributes.items()) { const AttributeIDRef attribute_id = entry.key; - const CustomDataType data_type = entry.value.data_type; - GVArray src = point_component->attribute_get_for_read( - attribute_id, ATTR_DOMAIN_POINT, data_type); - OutputAttribute dst = mesh_component.attribute_try_get_for_output_only( + const eCustomDataType data_type = entry.value.data_type; + GVArray src = point_component->attributes()->lookup_or_default( attribute_id, ATTR_DOMAIN_POINT, data_type); + GSpanAttributeWriter dst = + mesh_component.attributes_for_write()->lookup_or_add_for_write_only_span( + attribute_id, ATTR_DOMAIN_POINT, data_type); if (dst && src) { - attribute_math::convert_to_static_type(data_type, [&](auto dummy) { - using T = decltype(dummy); - VArray<T> src_typed = src.typed<T>(); - VArray_Span<T> src_typed_span{src_typed}; - copy_attribute_to_vertices(src_typed_span, selection, dst.as_span().typed<T>()); - }); - dst.save(); + src.materialize_compressed_to_uninitialized(selection, dst.span.data()); + dst.finish(); } } |