Blender V5.3
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
11#include "BKE_node.hh"
12
13namespace blender::nodes {
14
16 const int ntree_type)
17{
18 return bke::node_tree_type_supports_socket_type_static(ntree_type, socket_type);
19}
20
24 static int node_type;
25 static constexpr StringRefNull node_idname = "NodeClosureOutput";
26 static constexpr bool has_type = true;
27 static constexpr bool has_name = true;
29 static constexpr StringRefNull add_item = "NODE_OT_closure_input_item_add";
30 static constexpr StringRefNull remove_item = "NODE_OT_closure_input_item_remove";
31 static constexpr StringRefNull move_item = "NODE_OT_closure_input_item_move";
32 };
33 struct ui_idnames {
34 static constexpr StringRefNull list = "DATA_UL_closure_input_items";
35 };
36 struct rna_names {
37 static constexpr StringRefNull items = "input_items";
38 static constexpr StringRefNull active_index = "active_input_index";
39 };
40
42 {
43 auto *storage = static_cast<NodeClosureOutput *>(node.storage);
44 return {&storage->input_items.items,
45 &storage->input_items.items_num,
46 &storage->input_items.active_index};
47 }
48
49 static void copy_item(const ItemT &src, ItemT &dst)
50 {
51 dst = src;
52 dst.name = BLI_strdup_null(dst.name);
53 }
54
55 static void destruct_item(ItemT *item)
56 {
57 MEM_SAFE_DELETE(item->name);
58 }
59
60 static void blend_write_item(BlendWriter *writer, const ItemT &item);
61 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
62
64 {
65 return item.socket_type;
66 }
67
68 static char **get_name(ItemT &item)
69 {
70 return &item.name;
71 }
72
73 static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
74 {
75 return socket_type_supported_in_closure(socket_type, ntree_type);
76 }
77
79 ItemT &item,
80 const eNodeSocketDatatype socket_type,
81 const char *name)
82 {
83 auto *storage = static_cast<NodeClosureOutput *>(node.storage);
84 item.socket_type = socket_type;
85 item.identifier = storage->input_items.next_identifier++;
87 }
88
89 static std::string socket_identifier_for_item(const ItemT &item)
90 {
91 return "Item_" + std::to_string(item.identifier);
92 }
93};
94
98 static int node_type;
99 static constexpr StringRefNull node_idname = "NodeClosureOutput";
100 static constexpr bool has_type = true;
101 static constexpr bool has_name = true;
103 static constexpr StringRefNull add_item = "NODE_OT_closure_output_item_add";
104 static constexpr StringRefNull remove_item = "NODE_OT_closure_output_item_remove";
105 static constexpr StringRefNull move_item = "NODE_OT_closure_output_item_move";
106 };
107 struct ui_idnames {
108 static constexpr StringRefNull list = "DATA_UL_closure_output_items";
109 };
110 struct rna_names {
111 static constexpr StringRefNull items = "output_items";
112 static constexpr StringRefNull active_index = "active_output_index";
113 };
114
116 {
117 auto *storage = static_cast<NodeClosureOutput *>(node.storage);
118 return {&storage->output_items.items,
119 &storage->output_items.items_num,
120 &storage->output_items.active_index};
121 }
122
123 static void copy_item(const ItemT &src, ItemT &dst)
124 {
125 dst = src;
126 dst.name = BLI_strdup_null(dst.name);
127 }
128
129 static void destruct_item(ItemT *item)
130 {
131 MEM_SAFE_DELETE(item->name);
132 }
133
134 static void blend_write_item(BlendWriter *writer, const ItemT &item);
135 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
136
138 {
139 return item.socket_type;
140 }
141
142 static char **get_name(ItemT &item)
143 {
144 return &item.name;
145 }
146
147 static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
148 {
149 return socket_type_supported_in_closure(socket_type, ntree_type);
150 }
151
153 ItemT &item,
154 const eNodeSocketDatatype socket_type,
155 const char *name)
156 {
157 auto *storage = static_cast<NodeClosureOutput *>(node.storage);
158 item.socket_type = socket_type;
159 item.identifier = storage->output_items.next_identifier++;
161 }
162
163 static std::string socket_identifier_for_item(const ItemT &item)
164 {
165 return "Item_" + std::to_string(item.identifier);
166 }
167};
168
172 static int node_type;
173 static constexpr StringRefNull node_idname = "NodeEvaluateClosure";
174 static constexpr bool has_type = true;
175 static constexpr bool has_name = true;
177 static constexpr StringRefNull add_item = "NODE_OT_evaluate_closure_input_item_add";
178 static constexpr StringRefNull remove_item = "NODE_OT_evaluate_closure_input_item_remove";
179 static constexpr StringRefNull move_item = "NODE_OT_evaluate_closure_input_item_move";
180 };
181 struct ui_idnames {
182 static constexpr StringRefNull list = "DATA_UL_evaluate_closure_input_items";
183 };
184 struct rna_names {
185 static constexpr StringRefNull items = "input_items";
186 static constexpr StringRefNull active_index = "active_input_index";
187 };
188
190 {
191 auto *storage = static_cast<NodeEvaluateClosure *>(node.storage);
192 return {&storage->input_items.items,
193 &storage->input_items.items_num,
194 &storage->input_items.active_index};
195 }
196
197 static void copy_item(const ItemT &src, ItemT &dst)
198 {
199 dst = src;
200 dst.name = BLI_strdup_null(dst.name);
201 }
202
203 static void destruct_item(ItemT *item)
204 {
205 MEM_SAFE_DELETE(item->name);
206 }
207
208 static void blend_write_item(BlendWriter *writer, const ItemT &item);
209 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
210
212 {
213 return item.socket_type;
214 }
215
216 static char **get_name(ItemT &item)
217 {
218 return &item.name;
219 }
220
221 static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
222 {
223 return socket_type_supported_in_closure(socket_type, ntree_type);
224 }
225
227 ItemT &item,
228 const eNodeSocketDatatype socket_type,
229 const char *name)
230 {
231 auto *storage = static_cast<NodeEvaluateClosure *>(node.storage);
232 item.socket_type = socket_type;
233 item.identifier = storage->input_items.next_identifier++;
235 node, item, name);
236 }
237
238 static std::string socket_identifier_for_item(const ItemT &item)
239 {
240 return "Item_" + std::to_string(item.identifier);
241 }
242};
243
247 static int node_type;
248 static constexpr StringRefNull node_idname = "NodeEvaluateClosure";
249 static constexpr bool has_type = true;
250 static constexpr bool has_name = true;
252 static constexpr StringRefNull add_item = "NODE_OT_evaluate_closure_output_item_add";
253 static constexpr StringRefNull remove_item = "NODE_OT_evaluate_closure_output_item_remove";
254 static constexpr StringRefNull move_item = "NODE_OT_evaluate_closure_output_item_move";
255 };
256 struct ui_idnames {
257 static constexpr StringRefNull list = "DATA_UL_evaluate_closure_output_items";
258 };
259 struct rna_names {
260 static constexpr StringRefNull items = "output_items";
261 static constexpr StringRefNull active_index = "active_output_index";
262 };
263
265 {
266 auto *storage = static_cast<NodeEvaluateClosure *>(node.storage);
267 return {&storage->output_items.items,
268 &storage->output_items.items_num,
269 &storage->output_items.active_index};
270 }
271
272 static void copy_item(const ItemT &src, ItemT &dst)
273 {
274 dst = src;
275 dst.name = BLI_strdup_null(dst.name);
276 }
277
278 static void destruct_item(ItemT *item)
279 {
280 MEM_SAFE_DELETE(item->name);
281 }
282
283 static void blend_write_item(BlendWriter *writer, const ItemT &item);
284 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
285
287 {
288 return item.socket_type;
289 }
290
291 static char **get_name(ItemT &item)
292 {
293 return &item.name;
294 }
295
296 static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
297 {
298 return socket_type_supported_in_closure(socket_type, ntree_type);
299 }
300
302 ItemT &item,
303 const eNodeSocketDatatype socket_type,
304 const char *name)
305 {
306 auto *storage = static_cast<NodeEvaluateClosure *>(node.storage);
307 item.socket_type = socket_type;
308 item.identifier = storage->output_items.next_identifier++;
310 node, item, name);
311 }
312
313 static std::string socket_identifier_for_item(const ItemT &item)
314 {
315 return "Item_" + std::to_string(item.identifier);
316 }
317};
318
324
325} // namespace blender::nodes
#define storage(slot, qualifiers)
bool node_tree_type_supports_socket_type_static(const int ntree_type, const eNodeSocketDatatype socket_type)
Definition node.cc:6295
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, const int ntree_type)
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
eNodeSocketDatatype socket_type
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, const int ntree_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 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
static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
static eNodeSocketDatatype get_socket_type(const ItemT &item)
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 bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
static std::string socket_identifier_for_item(const ItemT &item)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static void copy_item(const ItemT &src, ItemT &dst)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
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 bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
static eNodeSocketDatatype get_socket_type(const ItemT &item)