23 b.use_custom_socket_order();
24 b.allow_any_socket_order();
25 b.add_default_layout();
27 b.add_output<
decl::Geometry>(
"Geometry").propagate_all().align_with_previous();
39 const std::string pattern =
params.extract_input<std::string>(
"Name");
40 if (pattern.empty()) {
41 params.set_output(
"Geometry", std::move(geometry_set));
47 const int wildcard_count =
Span(pattern.c_str(), pattern.size()).
count(
'*');
48 if (wildcard_count == 0) {
51 else if (wildcard_count >= 2) {
53 TIP_(
"Only one * is supported in the pattern"));
54 params.set_output(
"Geometry", std::move(geometry_set));
62 const int wildcard_index = pattern.find(
'*');
67 Mutex attribute_log_mutex;
73 GeometryComponent::Type::PointCloud,
74 GeometryComponent::Type::Curve,
75 GeometryComponent::Type::Instance,
76 GeometryComponent::Type::GreasePencil})
78 if (!geometry_set.
has(type)) {
85 switch (pattern_mode) {
87 if (read_only_component.
attributes()->contains(pattern)) {
88 attributes_to_remove.
append(pattern);
98 if (attribute_name.
startswith(wildcard_prefix) &&
99 attribute_name.
endswith(wildcard_suffix))
101 attributes_to_remove.
append(attribute_name);
108 if (attributes_to_remove.
is_empty()) {
113 for (
const StringRef attribute_name : attributes_to_remove) {
118 std::lock_guard
lock{attribute_log_mutex};
119 removed_attributes.
add(attribute_name);
122 std::lock_guard
lock{attribute_log_mutex};
123 failed_attributes.
add(attribute_name);
129 for (
const StringRef attribute_name : removed_attributes) {
130 params.used_named_attribute(attribute_name, NamedAttributeUsage::Remove);
133 if (!failed_attributes.
is_empty()) {
135 for (
const StringRef attribute_name : failed_attributes) {
136 quoted_attribute_names.
append(fmt::format(
"\"{}\"", attribute_name));
138 const std::string message = fmt::format(
139 fmt::runtime(
TIP_(
"Cannot remove built-in attributes: {}")),
140 fmt::join(quoted_attribute_names,
", "));
144 const std::string message = fmt::format(fmt::runtime(
TIP_(
"Attribute does not exist: \"{}\"")),
149 params.set_output(
"Geometry", std::move(geometry_set));
159 "Remove the one attribute with the given name"},
164 "Remove all attributes that match the pattern which is allowed to contain a single "
166 {0,
nullptr, 0,
nullptr,
nullptr},
171 "How the attributes to remove are chosen",
181 ntype.
ui_name =
"Remove Named Attribute";
183 "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)
#define NOD_inline_enum_accessors(member)
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 node_geo_exec(GeoNodeExecParams params)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_rna(StructRNA *srna)
static void node_register()
PropertyRNA * RNA_def_node_enum(StructRNA *srna, const char *identifier, const char *ui_name, const char *ui_description, const EnumPropertyItem *static_items, const EnumRNAAccessors accessors, std::optional< int > default_value, const EnumPropertyItemFunc item_func, const bool allow_animation)
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)
bool has(const GeometryComponent::Type component_type) const
const GeometryComponent * get_component(GeometryComponent::Type component_type) const
void modify_geometry_sets(ForeachSubGeometryCallback callback)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)