From c3b9a4e001057f9f9ec9296b53dd9cca86dfc21c Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Tue, 19 Jul 2022 22:34:32 -0500 Subject: Cleanup: Access attributes with new API instead of geometry components Remove the boilerplate of using a local geometry component just to use the attribute API that was necessary before b876ce2a4a4638142439. --- source/blender/geometry/GEO_point_merge_by_distance.hh | 2 +- source/blender/geometry/intern/point_merge_by_distance.cc | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'source/blender/geometry') diff --git a/source/blender/geometry/GEO_point_merge_by_distance.hh b/source/blender/geometry/GEO_point_merge_by_distance.hh index 1e977cf3bdc..92d871c62ab 100644 --- a/source/blender/geometry/GEO_point_merge_by_distance.hh +++ b/source/blender/geometry/GEO_point_merge_by_distance.hh @@ -17,7 +17,7 @@ namespace blender::geometry { * Merge selected points into other selected points within the \a merge_distance. The merged * indices favor speed over accuracy, since the results will depend on the order of the points. */ -PointCloud *point_merge_by_distance(const PointCloudComponent &src_points, +PointCloud *point_merge_by_distance(const PointCloud &src_points, const float merge_distance, const IndexMask selection); diff --git a/source/blender/geometry/intern/point_merge_by_distance.cc b/source/blender/geometry/intern/point_merge_by_distance.cc index ac10f4ef00c..42fac849667 100644 --- a/source/blender/geometry/intern/point_merge_by_distance.cc +++ b/source/blender/geometry/intern/point_merge_by_distance.cc @@ -13,13 +13,12 @@ namespace blender::geometry { -PointCloud *point_merge_by_distance(const PointCloudComponent &src_points, +PointCloud *point_merge_by_distance(const PointCloud &src_points, const float merge_distance, const IndexMask selection) { - const PointCloud &src_pointcloud = *src_points.get_for_read(); - bke::AttributeAccessor attributes = bke::pointcloud_attributes(src_pointcloud); - VArraySpan positions = attributes.lookup_or_default( + const bke::AttributeAccessor src_attributes = bke::pointcloud_attributes(src_points); + VArraySpan positions = src_attributes.lookup_or_default( "position", ATTR_DOMAIN_POINT, float3(0)); const int src_size = positions.size(); @@ -42,8 +41,8 @@ PointCloud *point_merge_by_distance(const PointCloudComponent &src_points, /* Create the new point cloud and add it to a temporary component for the attribute API. */ const int dst_size = src_size - duplicate_count; PointCloud *dst_pointcloud = BKE_pointcloud_new_nomain(dst_size); - PointCloudComponent dst_points; - dst_points.replace(dst_pointcloud, GeometryOwnershipType::Editable); + bke::MutableAttributeAccessor dst_attributes = bke::pointcloud_attributes_for_write( + *dst_pointcloud); /* By default, every point is just "merged" with itself. Then fill in the results of the merge * finding, converting from indices into the selection to indices into the full input point @@ -106,8 +105,6 @@ PointCloud *point_merge_by_distance(const PointCloudComponent &src_points, point_merge_counts[dst_index]++; } - const bke::AttributeAccessor src_attributes = *src_points.attributes(); - bke::MutableAttributeAccessor dst_attributes = *dst_points.attributes_for_write(); Set attribute_ids = src_attributes.all_ids(); /* Transfer the ID attribute if it exists, using the ID of the first merged point. */ -- cgit v1.2.3