diff options
author | Hans Goudey <h.goudey@me.com> | 2022-01-25 19:51:52 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2022-01-25 19:51:52 +0300 |
commit | ec1b0c2014a8b91c27bc5478ffa1ca74b63c64e9 (patch) | |
tree | 9da750440079b5ec382afaca8ed8f186f0889184 /source/blender/geometry/GEO_point_merge_by_distance.hh | |
parent | 97a023a0d5db26eb09ada9003bb99f60fb7a3d38 (diff) |
Geometry Nodes: Initial merge by distance node
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 merged index for each point.
For the implementation, most of the effort goes into creating a
merge map to speed up attribute mixing. Some parts are inherently
single-threaded, like finding the final indices accounting for the
merged points. By far most of the time is spend balancing the
KD tree.
Mesh support will be added in the next commit.
Differential Revision: https://developer.blender.org/D13649
Diffstat (limited to 'source/blender/geometry/GEO_point_merge_by_distance.hh')
-rw-r--r-- | source/blender/geometry/GEO_point_merge_by_distance.hh | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/geometry/GEO_point_merge_by_distance.hh b/source/blender/geometry/GEO_point_merge_by_distance.hh new file mode 100644 index 00000000000..6766f3c559d --- /dev/null +++ b/source/blender/geometry/GEO_point_merge_by_distance.hh @@ -0,0 +1,38 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "BLI_index_mask.hh" + +#pragma once + +struct PointCloud; +class PointCloudComponent; + +/** \file + * \ingroup geo + */ + +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, + const float merge_distance, + const IndexMask selection); + +} // namespace blender::geometry |