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
927 B
C++
29 lines
927 B
C++
/* SPDX-FileCopyrightText: 2024 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include "BKE_attribute.hh"
|
|
#include "BKE_geometry_set.hh"
|
|
|
|
#include "DNA_node_types.h"
|
|
|
|
#include "FN_field.hh"
|
|
|
|
namespace blender::geometry {
|
|
|
|
/**
|
|
* Returns the parts of the geometry that are on the selection for the given domain. If the domain
|
|
* is not applicable for the component, e.g. face domain for point cloud, nothing happens to that
|
|
* component. If no component can work with the domain, then `error_message` is set to true.
|
|
*/
|
|
void separate_geometry(bke::GeometrySet &geometry_set,
|
|
bke::AttrDomain domain,
|
|
GeometryNodeDeleteGeometryMode mode,
|
|
const fn::Field<bool> &selection_field,
|
|
const bke::AttributeFilter &attribute_filter,
|
|
bool &r_is_error);
|
|
|
|
} // namespace blender::geometry
|