This introduces the concept of an #AttributeFilter. It's used to tell a geometry algorithm which attributes it should process/propagate and which can be ignored. We already had something similar before named `AnonymousAttributePropagationInfo`. However, as the name implies, this was specific to anonymous attributes. This had some downsides: * A lot of code had to be aware of the concept of anonymous attributes even if it did nothing special with anonymous attributes. * For non-anonymous attributes we often had a separate `Set<std::string> skip` parameter. It's not nice to have to pass two kinds of filters around and to have to construct a `Set<std::string>` in many cases. `AttributeFilter` solves both of these downsides. Technically, `AttributeFilter` could also just be a `FunctionRef<bool(StringRef attribute_name)>`, but that also has some issues: * The `bool` return value is often ambiguous, i.e. it's not clear if it means that the attribute should be processed or not. Using an enum works better. * Passing function refs around and combining them works, but can very easily lead to dangling references. * The default value of a `FunctionRef` is "empty", i.e. it can't be called. It's generally more nice to not have a special case for the default value. Now the default `AttributeFilter` propagates all attributes without any extra handling on the call-site. Pull Request: https://projects.blender.org/blender/blender/pulls/127155
29 lines
771 B
C++
29 lines
771 B
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include "BLI_index_mask.hh"
|
|
|
|
#include "BKE_attribute_filter.hh"
|
|
|
|
struct PointCloud;
|
|
|
|
/** \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 PointCloud &src_points,
|
|
const float merge_distance,
|
|
const IndexMask &selection,
|
|
const bke::AttributeFilter &attribute_filter);
|
|
|
|
} // namespace blender::geometry
|