22 N_(
"Remove the one attribute with the given name")},
27 N_(
"Remove all attributes that match the pattern which is allowed to contain a single "
29 {0,
nullptr, 0,
nullptr,
nullptr},
34 b.use_custom_socket_order();
35 b.allow_any_socket_order();
36 b.add_input<
decl::Geometry>(
"Geometry").description(
"Geometry to remove attributes from");
37 b.add_output<
decl::Geometry>(
"Geometry").propagate_all().align_with_previous();
41 .description(
"How the attributes to remove are chosen");
58 GeometryComponent::Type::PointCloud,
59 GeometryComponent::Type::Curve,
60 GeometryComponent::Type::Instance,
61 GeometryComponent::Type::GreasePencil})
63 if (!geometry_set.
has(type)) {
70 switch (
params.pattern_mode) {
86 attributes_to_remove.
append(attribute_name);
93 if (attributes_to_remove.
is_empty()) {
98 for (
const StringRef attribute_name : attributes_to_remove) {
103 params.removed_attributes.add(attribute_name);
106 params.failed_attributes.add(attribute_name);
112 instances->ensure_geometry_instances();
124 const std::string pattern =
params.extract_input<std::string>(
"Name");
125 if (pattern.empty()) {
126 params.set_output(
"Geometry", std::move(geometry_set));
132 const int wildcard_count =
Span(pattern.c_str(), pattern.size()).
count(
'*');
133 if (wildcard_count == 0) {
136 else if (wildcard_count >= 2) {
138 TIP_(
"Only one * is supported in the pattern"));
139 params.set_output(
"Geometry", std::move(geometry_set));
146 removal_params.
pattern = pattern;
148 const int wildcard_index = pattern.find(
'*');
156 params.used_named_attribute(attribute_name, NamedAttributeUsage::Remove);
162 quoted_attribute_names.
append(fmt::format(
"\"{}\"", attribute_name));
164 const std::string message = fmt::format(
165 fmt::runtime(
TIP_(
"Cannot remove built-in attributes: {}")),
166 fmt::join(quoted_attribute_names,
", "));
170 const std::string message = fmt::format(fmt::runtime(
TIP_(
"Attribute does not exist: \"{}\"")),
175 params.set_output(
"Geometry", std::move(geometry_set));
183 ntype.
ui_name =
"Remove Named Attribute";
185 "Delete an attribute with a specified name from a geometry. Typically used to optimize "
#define NODE_CLASS_ATTRIBUTE
#define GEO_NODE_REMOVE_ATTRIBUTE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
constexpr int64_t count(const T &value) const
constexpr StringRef substr(int64_t start, int64_t size) const
constexpr bool startswith(StringRef prefix) const
constexpr bool endswith(StringRef suffix) const
void append(const T &value)
virtual std::optional< AttributeAccessor > attributes() const
virtual std::optional< MutableAttributeAccessor > attributes_for_write()
bool attribute_name_is_anonymous(const StringRef name)
bool allow_procedural_attribute_access(StringRef attribute_name)
void node_type_size(bNodeType &ntype, int width, int minwidth, int maxwidth)
void node_register_type(bNodeType &ntype)
static void node_declare(NodeDeclarationBuilder &b)
static void remove_attributes_recursive(GeometrySet &geometry_set, RemoveAttributeParams ¶ms)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static const EnumPropertyItem pattern_mode_items[]
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
Instances * get_instances_for_write()
bool has(const GeometryComponent::Type component_type) const
const GeometryComponent * get_component(GeometryComponent::Type component_type) const
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
NodeDeclareFunction declare
Set< std::string > failed_attributes
std::string wildcard_prefix
Set< std::string > removed_attributes
std::string wildcard_suffix