Blender V4.5
NOD_geo_bundle.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "DNA_node_types.h"
8
9#include "NOD_socket_items.hh"
10
11namespace blender::nodes {
12
32
36 static int node_type;
37 static constexpr StringRefNull node_idname = "GeometryNodeCombineBundle";
38 static constexpr bool has_type = true;
39 static constexpr bool has_name = true;
41 static constexpr StringRefNull add_item = "NODE_OT_combine_bundle_item_add";
42 static constexpr StringRefNull remove_item = "NODE_OT_combine_bundle_item_remove";
43 static constexpr StringRefNull move_item = "NODE_OT_combine_bundle_item_move";
44 };
45 struct ui_idnames {
46 static constexpr StringRefNull list = "DATA_UL_combine_bundle_items";
47 };
48 struct rna_names {
49 static constexpr StringRefNull items = "bundle_items";
50 static constexpr StringRefNull active_index = "active_index";
51 };
52
54 {
55 auto *storage = static_cast<NodeGeometryCombineBundle *>(node.storage);
56 return {&storage->items, &storage->items_num, &storage->active_index};
57 }
58
59 static void copy_item(const ItemT &src, ItemT &dst)
60 {
61 dst = src;
62 dst.name = BLI_strdup_null(dst.name);
63 }
64
65 static void destruct_item(ItemT *item)
66 {
67 MEM_SAFE_FREE(item->name);
68 }
69
70 static void blend_write_item(BlendWriter *writer, const ItemT &item);
71 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
72
74 {
76 }
77
78 static char **get_name(ItemT &item)
79 {
80 return &item.name;
81 }
82
83 static bool supports_socket_type(const eNodeSocketDatatype socket_type)
84 {
85 return socket_type_supported_in_bundle(socket_type);
86 }
87
89 ItemT &item,
90 const eNodeSocketDatatype socket_type,
91 const char *name)
92 {
93 auto *storage = static_cast<NodeGeometryCombineBundle *>(node.storage);
94 item.socket_type = socket_type;
95 item.identifier = storage->next_identifier++;
97 }
98
99 static std::string socket_identifier_for_item(const ItemT &item)
100 {
101 return "Item_" + std::to_string(item.identifier);
102 }
103};
104
108 static int node_type;
109 static constexpr StringRefNull node_idname = "GeometryNodeSeparateBundle";
110 static constexpr bool has_type = true;
111 static constexpr bool has_name = true;
113 static constexpr StringRefNull add_item = "NODE_OT_separate_bundle_item_add";
114 static constexpr StringRefNull remove_item = "NODE_OT_separate_bundle_item_remove";
115 static constexpr StringRefNull move_item = "NODE_OT_separate_bundle_item_move";
116 };
117 struct ui_idnames {
118 static constexpr StringRefNull list = "DATA_UL_separate_bundle_items";
119 };
120 struct rna_names {
121 static constexpr StringRefNull items = "bundle_items";
122 static constexpr StringRefNull active_index = "active_index";
123 };
124
126 {
127 auto *storage = static_cast<NodeGeometrySeparateBundle *>(node.storage);
128 return {&storage->items, &storage->items_num, &storage->active_index};
129 }
130
131 static void copy_item(const ItemT &src, ItemT &dst)
132 {
133 dst = src;
134 dst.name = BLI_strdup_null(dst.name);
135 }
136
137 static void destruct_item(ItemT *item)
138 {
139 MEM_SAFE_FREE(item->name);
140 }
141
142 static void blend_write_item(BlendWriter *writer, const ItemT &item);
143 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
144
146 {
147 return eNodeSocketDatatype(item.socket_type);
148 }
149
150 static char **get_name(ItemT &item)
151 {
152 return &item.name;
153 }
154
155 static bool supports_socket_type(const eNodeSocketDatatype socket_type)
156 {
157 return socket_type_supported_in_bundle(socket_type);
158 }
159
161 ItemT &item,
162 const eNodeSocketDatatype socket_type,
163 const char *name)
164 {
165 auto *storage = static_cast<NodeGeometrySeparateBundle *>(node.storage);
166 item.socket_type = socket_type;
167 item.identifier = storage->next_identifier++;
169 }
170
171 static std::string socket_identifier_for_item(const ItemT &item)
172 {
173 return "Item_" + std::to_string(item.identifier);
174 }
175};
176
177} // namespace blender::nodes
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
Definition string.cc:46
#define ELEM(...)
eNodeSocketDatatype
@ SOCK_INT
@ SOCK_VECTOR
@ SOCK_CLOSURE
@ SOCK_BOOLEAN
@ SOCK_MATERIAL
@ SOCK_MATRIX
@ SOCK_FLOAT
@ SOCK_IMAGE
@ SOCK_COLLECTION
@ SOCK_BUNDLE
@ SOCK_GEOMETRY
@ SOCK_ROTATION
@ SOCK_OBJECT
@ SOCK_STRING
@ SOCK_RGBA
#define MEM_SAFE_FREE(v)
void set_item_name_and_make_unique(bNode &node, typename Accessor::ItemT &item, const char *value)
bool socket_type_supported_in_bundle(const eNodeSocketDatatype socket_type)
void * storage
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static eNodeSocketDatatype get_socket_type(const ItemT &item)
static void copy_item(const ItemT &src, ItemT &dst)
NodeGeometryCombineBundleItem ItemT
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static constexpr StringRefNull node_idname
static socket_items::SocketItemsRef< ItemT > get_items_from_node(bNode &node)
static std::string socket_identifier_for_item(const ItemT &item)
static void init_with_socket_type_and_name(bNode &node, ItemT &item, const eNodeSocketDatatype socket_type, const char *name)
static bool supports_socket_type(const eNodeSocketDatatype socket_type)
static eNodeSocketDatatype get_socket_type(const ItemT &item)
static bool supports_socket_type(const eNodeSocketDatatype socket_type)
static constexpr StringRefNull node_idname
static void copy_item(const ItemT &src, ItemT &dst)
static socket_items::SocketItemsRef< ItemT > get_items_from_node(bNode &node)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static void init_with_socket_type_and_name(bNode &node, ItemT &item, const eNodeSocketDatatype socket_type, const char *name)
static std::string socket_identifier_for_item(const ItemT &item)