25#include <fmt/format.h>
33 b.use_custom_socket_order();
34 b.allow_any_socket_order();
35 b.add_default_layout();
36 const bNode *node =
b.node_or_null();
39 .
description(
"Geometry to store a new attribute with the given name on");
40 b.add_output<
decl::Geometry>(
"Geometry").propagate_all().align_with_previous();
44 if (node !=
nullptr) {
47 b.add_input(data_type,
"Value").field_on_all();
63 data->domain = int8_t(AttrDomain::Point);
79 bNode &node =
params.add_node(
"GeometryNodeStoreNamedAttribute");
80 node_storage(node).data_type = *type;
81 params.update_and_connect_available_socket(node,
"Value");
90 const std::string
name =
params.extract_input<std::string>(
"Name");
93 params.set_output(
"Geometry", std::move(geometry_set));
98 params.set_output(
"Geometry", std::move(geometry_set));
103 TIP_(
"Anonymous attributes cannot be created here"));
104 params.set_output(
"Geometry", std::move(geometry_set));
108 params.used_named_attribute(
name, NamedAttributeUsage::Write);
123 std::atomic<bool> failure =
false;
126 if (domain == AttrDomain::Instance) {
129 GeometryComponent::Type::Instance);
152 GeometryComponent::Type::PointCloud,
153 GeometryComponent::Type::Curve,
154 GeometryComponent::Type::GreasePencil})
156 if (geometry_set.
has(type)) {
159 if (component.
type() == GeometryComponent::Type::Mesh) {
173 const char *domain_name =
nullptr;
175 const char *type_name =
nullptr;
177 const std::string message = fmt::format(
179 TIP_(
"Failed to write to attribute \"{}\" with domain \"{}\" and type \"{}\"")),
186 params.set_output(
"Geometry", std::move(geometry_set));
195 "Type of data stored in attribute",
208 "Which domain to store the data in",
211 int(AttrDomain::Point));
219 ntype.
ui_name =
"Store Named Attribute";
221 "Store the result of a field on a geometry as an attribute with the specified name";
225 "NodeGeometryStoreNamedAttribute",
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_ATTRIBUTE
#define GEO_NODE_STORE_NAMED_ATTRIBUTE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
#define NOD_storage_enum_accessors(member)
BMesh const char void * data
GVArray try_convert(GVArray varray, const CPPType &to_type) const
int attribute_domain_size(AttrDomain domain) const
int instances_num() const
void set_selection(Field< bool > selection)
int add_with_destination(GField field, GVMutableArray dst)
Vector< SocketDeclaration * > inputs
Vector< SocketDeclaration * > outputs
void * MEM_callocN(size_t len, const char *str)
bool attribute_name_is_anonymous(const StringRef name)
const DataTypeConversions & get_implicit_type_conversions()
bool allow_procedural_attribute_access(StringRef attribute_name)
std::optional< AttrType > custom_data_type_to_attr_type(eCustomDataType data_type)
void node_type_size(bNodeType &ntype, int width, int minwidth, int maxwidth)
void node_register_type(bNodeType &ntype)
const char * no_procedural_access_message
bool try_capture_field_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, const StringRef attribute_id, AttrDomain domain, const fn::Field< bool > &selection, const fn::GField &field)
void mesh_ensure_default_color_attribute_on_add(Mesh &mesh, StringRef id, AttrDomain domain, bke::AttrType data_type)
VMutableArray< float3 > instance_position_varray_for_write(Instances &instances)
const CPPType & attribute_type_to_cpp_type(AttrType type)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
std::optional< eCustomDataType > socket_type_to_custom_data_type(eNodeSocketDatatype type)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
bool generic_attribute_type_supported(const EnumPropertyItem &item)
static void node_layout(uiLayout *layout, bContext *, PointerRNA *ptr)
static void node_init(bNodeTree *, bNode *node)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static void node_rna(StructRNA *srna)
static void node_declare(NodeDeclarationBuilder &b)
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
void search_link_ops_for_declarations(GatherLinkSearchOpParams ¶ms, Span< SocketDeclaration * > declarations)
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)
const EnumPropertyItem * enum_items_filter(const EnumPropertyItem *original_item_array, FunctionRef< bool(const EnumPropertyItem &item)> fn)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
bool RNA_enum_name_from_value(const EnumPropertyItem *item, int value, const char **r_name)
const EnumPropertyItem rna_enum_attribute_domain_items[]
const EnumPropertyItem rna_enum_attribute_type_items[]
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
Instances * get_instances_for_write()
bool has(const GeometryComponent::Type component_type) const
bool has_instances() const
Mesh * get_mesh_for_write()
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGeometryExecFunction geometry_node_execute
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
void use_property_decorate_set(bool is_sep)
void use_property_split_set(bool value)
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)