35 b.use_custom_socket_order();
36 b.allow_any_socket_order();
38 b.add_default_layout();
42 "Geometry to evaluate the given fields and store the resulting attributes on. All "
43 "geometry types except volumes are supported");
44 b.add_output<
decl::Geometry>(
"Geometry"_ustr).propagate_all_geometry().align_with_previous();
48 .evaluated_geometry_field();
49 b.add_output<
decl::Bool>(
"Selection"_ustr).anonymous_attribute_output().align_with_previous();
50 if (
node !=
nullptr) {
59 const UString output_identifier(
61 b.add_input(data_type, name, input_identifier)
62 .evaluated_geometry_field()
64 b.add_output(data_type, name, output_identifier)
65 .anonymous_attribute_output()
66 .align_with_previous();
71 .custom_draw(socket_items::ui::draw_extend_socket_fn<CaptureAttributeItemsAccessor>());
74 .align_with_previous();
99 C,
"capture_attribute_items",
false,
IFACE_(
"Capture Items")))
101 socket_items::ui::draw_items_list_with_operators<CaptureAttributeItemsAccessor>(
102 C, panel, tree,
node);
103 socket_items::ui::draw_active_item_props<CaptureAttributeItemsAccessor>(
105 panel->use_property_split_set(
true);
106 panel->use_property_decorate_set(
false);
107 panel->prop(item_ptr,
"data_type",
UI_ITEM_NONE, std::nullopt, ICON_NONE);
122 if (!attributes.has_value()) {
140 for (
const std::string &unused_id : unused_ids) {
141 attributes->remove(unused_id);
152 TIP_(
"The attribute output cannot be used without the geometry output"));
166 const std::string input_identifier =
168 const std::string output_identifier =
176 out_attribute_names.
add_new(std::move(*attribute_id));
180 std::optional<std::string> selection_attribute_id =
182 if (selection_attribute_id) {
183 fields.append(selection);
184 out_attribute_names.
add_new(std::move(*selection_attribute_id));
188 if (fields.is_empty()) {
189 params.
set_output(
"Geometry"_ustr, geometry_set);
198 component, out_attribute_name_refs, domain, selection, fields);
206 if (domain == AttrDomain::Instance) {
219 if (geometry_set.
has(type)) {
226 params.
set_output(
"Geometry"_ustr, geometry_set);
246 dst_node->
storage = dst_storage;
265 bNode &
node = params.add_node(
"GeometryNodeCaptureAttribute"_ustr);
269 const std::string identifier =
273 params.update_and_connect_available_socket_by_identifier(
node,
UString(identifier));
281 return &
node.input_socket(output_socket.index());
298 ntype.
ui_name =
"Capture Attribute";
300 "Store the result of a field on a geometry and output the data as a node socket. Allows "
301 "remembering or interpolating data as the geometry changes, such as positions before "
#define NODE_STORAGE_FUNCS(StorageT)
#define NODE_CLASS_ATTRIBUTE
#define GEO_NODE_CAPTURE_ATTRIBUTE
#define NOD_REGISTER_NODE(REGISTER_FUNC)
bool contains(const Key &key) const
Span< Key > as_span() const
void add_new(const Key &key)
void append(const T &value)
virtual std::optional< MutableAttributeAccessor > attributes_for_write()
void add_item(std::string socket_name, SocketLinkOperation::LinkSocketFn fn, int weight=0)
const bNodeTree & node_tree() const
const bNodeSocket & other_socket() const
eNodeSocketInOut in_out() const
void error_message_add(const NodeWarningType type, StringRef message) const
NodeAttributeFilter get_attribute_filter(const UString output_identifier) const
std::optional< std::string > get_output_anonymous_attribute_id_if_needed(const UString output_identifier, const bool force_create=false)
T extract_input(const UString identifier)
bool output_is_required(const UString identifier) const
const bNode & node() const
void set_default_remaining_outputs()
void set_output(const UString identifier, T &&value)
bNode & add_node(UString idname)
void connect_available_socket(bNode &new_node, UString socket_name)
StructureType structure_type
#define storage(slot, qualifiers)
bool attribute_name_is_anonymous(const StringRef name)
bool try_capture_fields_on_geometry(MutableAttributeAccessor attributes, const fn::FieldContext &field_context, Span< StringRef > names, AttrDomain domain, const fn::Field< bool > &selection, Span< fn::GField > fields)
void node_register_type(bNodeType &ntype)
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))
internal::ShallowDataConstRef< T > shallow_copy(const T &other)
void foreach_real_geometry(bke::GeometrySet &geometry, FunctionRef< void(bke::GeometrySet &geometry_set)> fn)
static void node_operators()
static void node_free_storage(bNode *node)
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
static void node_layout_ex(ui::Layout &layout, bContext *C, PointerRNA *ptr)
static void node_init(bNodeTree *, bNode *node)
static void clean_unused_attributes(const AttributeFilter &attribute_filter, const VectorSet< std::string > &keep, GeometryComponent &component)
static void node_blend_read(bNodeTree &, bNode &node, BlendDataReader &reader)
static void node_blend_write(const bNodeTree &, const bNode &node, BlendWriter &writer)
static bool node_insert_link(bke::NodeInsertLinkParams ¶ms)
static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms)
static void node_register()
static const bNodeSocket * node_internally_linked_input(const bNodeTree &, const bNode &node, const bNodeSocket &output_socket)
static void node_layout(ui::Layout &layout, bContext *, PointerRNA *ptr)
static void node_copy_storage(bNodeTree *, bNode *dst_node, const bNode *src_node)
void make_common_operators()
void blend_write(BlendWriter *writer, const bNode &node)
void destruct_array(bNode &node)
void blend_read_data(BlendDataReader *reader, bNode &node)
void copy_array(const bNode &src_node, bNode &dst_node)
Accessor::ItemT * add_item_with_socket_type_and_name(bNodeTree &ntree, bNode &node, const eNodeSocketDatatype socket_type, const char *name, std::optional< int > dimensions=std::nullopt)
bool try_add_item_via_any_extend_socket(bNodeTree &ntree, bNode &extend_node, bNode &storage_node, bNodeLink &link, const std::optional< StringRef > socket_identifier=std::nullopt, typename Accessor::ItemT **r_new_item=nullptr)
BMesh const char void * data
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
void BLO_read_string(BlendDataReader *reader, char **ptr_p)
void write_string(const char *data)
bool allow_skip(const StringRef name) const
GeometryComponent & get_component_for_write(GeometryComponent::Type component_type)
bool has(const GeometryComponent::Type component_type) const
bool has_instances() const
NodeInternallyLinkedInputFunction internally_linked_input
void(*) draw_buttons(ui::Layout &, bContext *C, PointerRNA *ptr)
NodeBlendWriteFunction blend_write_storage_content
void(*) register_operators()
std::string ui_description
NodeBlendDataReadFunction blend_data_read_storage_content
NodeGeometryExecFunction geometry_node_execute
void(*) draw_buttons_ex(ui::Layout &, bContext *C, PointerRNA *ptr)
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeGatherSocketLinkOperationsFunction gather_link_search_ops
NodeDeclareFunction declare
bool(*) insert_link(NodeInsertLinkParams ¶ms)
static StructRNA ** item_srna
NodeGeometryAttributeCaptureItem ItemT
static std::string input_socket_identifier_for_item(const NodeGeometryAttributeCaptureItem &item)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int)
static std::string output_socket_identifier_for_item(const NodeGeometryAttributeCaptureItem &item)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
void use_property_decorate_set(bool is_decorate)
void use_property_split_set(bool is_sep)
PanelLayout panel(const bContext *C, StringRef idname, bool default_closed)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< StringRef > name_opt, int icon, std::optional< StringRef > placeholder=std::nullopt)