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
43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
#include <optional>
|
|
|
|
#include "BLI_index_mask.hh"
|
|
|
|
#include "BKE_attribute_filter.hh"
|
|
|
|
struct Mesh;
|
|
namespace blender {
|
|
namespace fn {
|
|
template<typename T> class Field;
|
|
}
|
|
namespace bke {
|
|
enum class AttrDomain : int8_t;
|
|
} // namespace bke
|
|
} // namespace blender
|
|
|
|
namespace blender::geometry {
|
|
|
|
std::optional<Mesh *> mesh_copy_selection(const Mesh &src_mesh,
|
|
const VArray<bool> &selection,
|
|
bke::AttrDomain selection_domain,
|
|
const bke::AttributeFilter &attribute_filter = {});
|
|
|
|
std::optional<Mesh *> mesh_copy_selection_keep_verts(
|
|
const Mesh &src_mesh,
|
|
const VArray<bool> &selection,
|
|
bke::AttrDomain selection_domain,
|
|
const bke::AttributeFilter &attribute_filter = {});
|
|
|
|
std::optional<Mesh *> mesh_copy_selection_keep_edges(
|
|
const Mesh &mesh,
|
|
const VArray<bool> &selection,
|
|
bke::AttrDomain selection_domain,
|
|
const bke::AttributeFilter &attribute_filter = {});
|
|
|
|
} // namespace blender::geometry
|