Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2022-07-20 06:34:32 +0300
committerHans Goudey <h.goudey@me.com>2022-07-20 06:34:32 +0300
commitc3b9a4e001057f9f9ec9296b53dd9cca86dfc21c (patch)
treeb81e4f1c289a2c05251f2c8d896b40090e4fa7b9 /source/blender/geometry
parent215f805ce6b540177dedd71721e62c56a764a5ea (diff)
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.
Diffstat (limited to 'source/blender/geometry')
-rw-r--r--source/blender/geometry/GEO_point_merge_by_distance.hh2
-rw-r--r--source/blender/geometry/intern/point_merge_by_distance.cc13
2 files changed, 6 insertions, 9 deletions
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<float3> positions = attributes.lookup_or_default<float3>(
+ const bke::AttributeAccessor src_attributes = bke::pointcloud_attributes(src_points);
+ VArraySpan<float3> positions = src_attributes.lookup_or_default<float3>(
"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<bke::AttributeIDRef> attribute_ids = src_attributes.all_ids();
/* Transfer the ID attribute if it exists, using the ID of the first merged point. */