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 future improvement,
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 the `position`. When many points are merged to a single point,
floating point innaaccuracy hads an effect. Possibly aAveraging floatss as doubles
with doublestemporarily would help resolve that, but it would have a performance cost,
cost, and I don't expect it to be a common use case.
For the implementation, I fiddled for quite a while trying to givee the
the algorithm an optimal structure. Some parts are inherently single-
single threaded, like finding the final indices accounting for the merged
merged points. Merging the attributes is multi-threaded, though it might
might be possible to localize memory access there more. I expect most
most of the time to be spent in the KD tree anyway.
This is a first step towards implementing T86913. I'm adding a patch
for the point cloud pasupport separately, because this is new code. The weld
modifier code will be adapted for the mesh case.