Page MenuHome

Geometry Nodes: Basic point cloud merge by distance node
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Dec 21 2021, 9:27 PM.

Details

Summary

This implements a merge by distance operation for point clouds.
Besides the geometry input, there are two others-- a selection
input to limit the operation to certain points, and the merge
distance. While it would be a reasonable feature, the distance
does not support a field currently, since that would make
the algorithm significantly more complex.

All attributes are merged to the merged points, with the values
mixed together. This same generic method is used for all attributes,
including position. The id attribute uses the value from the
first index merged into it.

For the implementation, I fiddled for quite a trying to give the
algorithm an optimal structure. Some parts are inherently single-
threaded, like finding the final indices accounting for the merged
points. However, by far most of the time is spend balancing the
KD tree.

Here's a test with 2.4 million points merging into 110, with four
attributes to merge, including position (on a Ryzen 3700x):

ActionTimePortion of Total (618ms)
BLI_kdtree_3d_balance432 ms70%
BLI_kdtree_3d_calc_duplicates_fast94 ms15%
Attribute mixing36 ms6%
BLI_kdtree_3d_insert21 ms3%
Build merge_map8 ms1%
Build merge_indices7 ms1%
BLI_kdtree_3d_free4 ms0.7%
Build src_to_dst_indices4 ms0.6%
Build map_offsets0.25 ms0%

The total is probably be a bit higher, because these timings don't
include allocations of temporary arrays and the new point cloud.


This is a first step towards implementing T86913. I'm adding a patch
for point cloud support separately, because this is new code. The weld
modifier code will be adapted for the mesh case.

Diff Detail

Repository
rB Blender
Branch
geometry-nodes-merge-by-distance (branched from master)
Build Status
Buildable 19577
Build 19577: arc lint + arc unit

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Dec 21 2021, 9:27 PM
Hans Goudey (HooglyBoogly) created this revision.
  • Merge branch 'master' into geometry-nodes-merge-by-distance
  • Cleanup
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
  • Cleanup, comments, improve attribute mixing algorithm
  • Move code to geometry module

Seems to work well.

I'm unsure about the goal of the patch. Did you plan to merge this node without support for meshes?

I'm unsure about the goal of the patch. Did you plan to merge this node without support for meshes?

What I wanted was to keep the two changes separate. We can wait to merge this until the mesh support is ready if you'd prefer.

Alright. Yeah I think this node should have support for meshes before we merge it.

Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
Hans Goudey (HooglyBoogly) set the repository for this revision to rB Blender.
  • Merge master (fix build error)
  • Cleanup: Small reoganization
This revision is now accepted and ready to land.Jan 25 2022, 3:41 PM