Blender V4.5
NOD_geo_closure.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 = "GeometryNodeClosureOutput";
38 static constexpr bool has_type = true;
39 static constexpr bool has_name = true;
41 static constexpr StringRefNull add_item = "NODE_OT_closure_input_item_add";
42 static constexpr StringRefNull remove_item = "NODE_OT_closure_input_item_remove";
43 static constexpr StringRefNull move_item = "NODE_OT_closure_input_item_move";
44 };
45 struct ui_idnames {
46 static constexpr StringRefNull list = "DATA_UL_closure_input_items";
47 };
48 struct rna_names {
49 static constexpr StringRefNull items = "input_items";
50 static constexpr StringRefNull active_index = "active_input_index";
51 };
52
54 {
55 auto *storage = static_cast<NodeGeometryClosureOutput *>(node.storage);
56 return {&storage->input_items.items,
57 &storage->input_items.items_num,
58 &storage->input_items.active_index};
59 }
60
61 static void copy_item(const ItemT &src, ItemT &dst)
62 {
63 dst = src;
64 dst.name = BLI_strdup_null(dst.name);
65 }
66
67 static void destruct_item(ItemT *item)
68 {
69 MEM_SAFE_FREE(item->name);
70 }
71
72 static void blend_write_item(BlendWriter *writer, const ItemT &item);
73 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
74
76 {
78 }
79
80 static char **get_name(ItemT &item)
81 {
82 return &item.name;
83 }
84
85 static bool supports_socket_type(const eNodeSocketDatatype socket_type)
86 {
87 return socket_type_supported_in_closure(socket_type);
88 }
89
91 ItemT &item,
92 const eNodeSocketDatatype socket_type,
93 const char *name)
94 {
95 auto *storage = static_cast<NodeGeometryClosureOutput *>(node.storage);
96 item.socket_type = socket_type;
97 item.identifier = storage->input_items.next_identifier++;
99 }
100
101 static std::string socket_identifier_for_item(const ItemT &item)
102 {
103 return "Item_" + std::to_string(item.identifier);
104 }
105};
106
110 static int node_type;
111 static constexpr StringRefNull node_idname = "GeometryNodeClosureOutput";
112 static constexpr bool has_type = true;
113 static constexpr bool has_name = true;
115 static constexpr StringRefNull add_item = "NODE_OT_closure_output_item_add";
116 static constexpr StringRefNull remove_item = "NODE_OT_closure_output_item_remove";
117 static constexpr StringRefNull move_item = "NODE_OT_closure_output_item_move";
118 };
119 struct ui_idnames {
120 static constexpr StringRefNull list = "DATA_UL_closure_output_items";
121 };
122 struct rna_names {
123 static constexpr StringRefNull items = "output_items";
124 static constexpr StringRefNull active_index = "active_output_index";
125 };
126
128 {
129 auto *storage = static_cast<NodeGeometryClosureOutput *>(node.storage);
130 return {&storage->output_items.items,
131 &storage->output_items.items_num,
132 &storage->output_items.active_index};
133 }
134
135 static void copy_item(const ItemT &src, ItemT &dst)
136 {
137 dst = src;
138 dst.name = BLI_strdup_null(dst.name);
139 }
140
141 static void destruct_item(ItemT *item)
142 {
143 MEM_SAFE_FREE(item->name);
144 }
145
146 static void blend_write_item(BlendWriter *writer, const ItemT &item);
147 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
148
150 {
151 return eNodeSocketDatatype(item.socket_type);
152 }
153
154 static char **get_name(ItemT &item)
155 {
156 return &item.name;
157 }
158
159 static bool supports_socket_type(const eNodeSocketDatatype socket_type)
160 {
161 return socket_type_supported_in_closure(socket_type);
162 }
163
165 ItemT &item,
166 const eNodeSocketDatatype socket_type,
167 const char *name)
168 {
169 auto *storage = static_cast<NodeGeometryClosureOutput *>(node.storage);
170 item.socket_type = socket_type;
171 item.identifier = storage->output_items.next_identifier++;
173 }
174
175 static std::string socket_identifier_for_item(const ItemT &item)
176 {
177 return "Item_" + std::to_string(item.identifier);
178 }
179};
180
184 static int node_type;
185 static constexpr StringRefNull node_idname = "GeometryNodeEvaluateClosure";
186 static constexpr bool has_type = true;
187 static constexpr bool has_name = true;
189 static constexpr StringRefNull add_item = "NODE_OT_evaluate_closure_input_item_add";
190 static constexpr StringRefNull remove_item = "NODE_OT_evaluate_closure_input_item_remove";
191 static constexpr StringRefNull move_item = "NODE_OT_evaluate_closure_input_item_move";
192 };
193 struct ui_idnames {
194 static constexpr StringRefNull list = "DATA_UL_evaluate_closure_input_items";
195 };
196 struct rna_names {
197 static constexpr StringRefNull items = "input_items";
198 static constexpr StringRefNull active_index = "active_input_index";
199 };
200
202 {
203 auto *storage = static_cast<NodeGeometryEvaluateClosure *>(node.storage);
204 return {&storage->input_items.items,
205 &storage->input_items.items_num,
206 &storage->input_items.active_index};
207 }
208
209 static void copy_item(const ItemT &src, ItemT &dst)
210 {
211 dst = src;
212 dst.name = BLI_strdup_null(dst.name);
213 }
214
215 static void destruct_item(ItemT *item)
216 {
217 MEM_SAFE_FREE(item->name);
218 }
219
220 static void blend_write_item(BlendWriter *writer, const ItemT &item);
221 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
222
224 {
225 return eNodeSocketDatatype(item.socket_type);
226 }
227
228 static char **get_name(ItemT &item)
229 {
230 return &item.name;
231 }
232
233 static bool supports_socket_type(const eNodeSocketDatatype socket_type)
234 {
235 return socket_type_supported_in_closure(socket_type);
236 }
237
239 ItemT &item,
240 const eNodeSocketDatatype socket_type,
241 const char *name)
242 {
243 auto *storage = static_cast<NodeGeometryEvaluateClosure *>(node.storage);
244 item.socket_type = socket_type;
245 item.identifier = storage->input_items.next_identifier++;
247 node, item, name);
248 }
249
250 static std::string socket_identifier_for_item(const ItemT &item)
251 {
252 return "Item_" + std::to_string(item.identifier);
253 }
254};
255
259 static int node_type;
260 static constexpr StringRefNull node_idname = "GeometryNodeEvaluateClosure";
261 static constexpr bool has_type = true;
262 static constexpr bool has_name = true;
264 static constexpr StringRefNull add_item = "NODE_OT_evaluate_closure_output_item_add";
265 static constexpr StringRefNull remove_item = "NODE_OT_evaluate_closure_output_item_remove";
266 static constexpr StringRefNull move_item = "NODE_OT_evaluate_closure_output_item_move";
267 };
268 struct ui_idnames {
269 static constexpr StringRefNull list = "DATA_UL_evaluate_closure_output_items";
270 };
271 struct rna_names {
272 static constexpr StringRefNull items = "output_items";
273 static constexpr StringRefNull active_index = "active_output_index";
274 };
275
277 {
278 auto *storage = static_cast<NodeGeometryEvaluateClosure *>(node.storage);
279 return {&storage->output_items.items,
280 &storage->output_items.items_num,
281 &storage->output_items.active_index};
282 }
283
284 static void copy_item(const ItemT &src, ItemT &dst)
285 {
286 dst = src;
287 dst.name = BLI_strdup_null(dst.name);
288 }
289
290 static void destruct_item(ItemT *item)
291 {
292 MEM_SAFE_FREE(item->name);
293 }
294
295 static void blend_write_item(BlendWriter *writer, const ItemT &item);
296 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
297
299 {
300 return eNodeSocketDatatype(item.socket_type);
301 }
302
303 static char **get_name(ItemT &item)
304 {
305 return &item.name;
306 }
307
308 static bool supports_socket_type(const eNodeSocketDatatype socket_type)
309 {
310 return socket_type_supported_in_closure(socket_type);
311 }
312
314 ItemT &item,
315 const eNodeSocketDatatype socket_type,
316 const char *name)
317 {
318 auto *storage = static_cast<NodeGeometryEvaluateClosure *>(node.storage);
319 item.socket_type = socket_type;
320 item.identifier = storage->output_items.next_identifier++;
322 node, item, name);
323 }
324
325 static std::string socket_identifier_for_item(const ItemT &item)
326 {
327 return "Item_" + std::to_string(item.identifier);
328 }
329};
330
336
337} // 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)
const bNodeSocket * evaluate_closure_node_internally_linked_input(const bNodeSocket &output_socket)
bool socket_type_supported_in_closure(const eNodeSocketDatatype socket_type)
void * storage
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static void copy_item(const ItemT &src, ItemT &dst)
static socket_items::SocketItemsRef< ItemT > get_items_from_node(bNode &node)
static eNodeSocketDatatype get_socket_type(const ItemT &item)
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 void blend_write_item(BlendWriter *writer, const ItemT &item)
static bool supports_socket_type(const eNodeSocketDatatype socket_type)
static constexpr StringRefNull node_idname
static socket_items::SocketItemsRef< ItemT > get_items_from_node(bNode &node)
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 void copy_item(const ItemT &src, ItemT &dst)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static std::string socket_identifier_for_item(const ItemT &item)
static eNodeSocketDatatype get_socket_type(const ItemT &item)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static constexpr StringRefNull node_idname
NodeGeometryEvaluateClosureInputItem ItemT
static eNodeSocketDatatype get_socket_type(const ItemT &item)
static bool supports_socket_type(const eNodeSocketDatatype socket_type)
static void copy_item(const ItemT &src, ItemT &dst)
static socket_items::SocketItemsRef< ItemT > get_items_from_node(bNode &node)
static void init_with_socket_type_and_name(bNode &node, ItemT &item, const eNodeSocketDatatype socket_type, const char *name)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static std::string socket_identifier_for_item(const ItemT &item)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static bool supports_socket_type(const eNodeSocketDatatype socket_type)
static void copy_item(const ItemT &src, ItemT &dst)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
NodeGeometryEvaluateClosureOutputItem ItemT
static void blend_write_item(BlendWriter *writer, const ItemT &item)
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 eNodeSocketDatatype get_socket_type(const ItemT &item)