Blender V4.3
NOD_geo_foreach_geometry_element.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 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
16 static int node_type;
17 static constexpr const char *node_idname = "GeometryNodeForeachGeometryElementOutput";
18 static constexpr bool has_type = true;
19 static constexpr bool has_name = true;
20 static constexpr bool has_single_identifier_str = true;
21
23 {
24 auto *storage = static_cast<NodeGeometryForeachGeometryElementOutput *>(node.storage);
25 return {&storage->input_items.items,
26 &storage->input_items.items_num,
27 &storage->input_items.active_index};
28 }
29
30 static void copy_item(const ItemT &src, ItemT &dst)
31 {
32 dst = src;
33 dst.name = BLI_strdup_null(dst.name);
34 }
35
36 static void destruct_item(ItemT *item)
37 {
38 MEM_SAFE_FREE(item->name);
39 }
40
41 static void blend_write(BlendWriter *writer, const bNode &node);
42 static void blend_read_data(BlendDataReader *reader, bNode &node);
43
45 {
47 }
48
49 static char **get_name(ItemT &item)
50 {
51 return &item.name;
52 }
53
54 static bool supports_socket_type(const eNodeSocketDatatype socket_type)
55 {
56 return ELEM(socket_type,
64 SOCK_MENU);
65 }
66
68 ItemT &item,
69 const eNodeSocketDatatype socket_type,
70 const char *name)
71 {
72 auto *storage = static_cast<NodeGeometryForeachGeometryElementOutput *>(node.storage);
73 item.socket_type = socket_type;
74 item.identifier = storage->generation_items.next_identifier++;
76 node, item, name);
77 }
78
79 static std::string socket_identifier_for_item(const ItemT &item)
80 {
81 return "Input_" + std::to_string(item.identifier);
82 }
83};
84
88 static int node_type;
89 static constexpr const char *node_idname = "GeometryNodeForeachGeometryElementOutput";
90 static constexpr bool has_type = true;
91 static constexpr bool has_name = true;
92 static constexpr bool has_single_identifier_str = true;
93
95 {
96 auto *storage = static_cast<NodeGeometryForeachGeometryElementOutput *>(node.storage);
97 return {&storage->main_items.items,
98 &storage->main_items.items_num,
99 &storage->main_items.active_index};
100 }
101
102 static void copy_item(const ItemT &src, ItemT &dst)
103 {
104 dst = src;
105 dst.name = BLI_strdup_null(dst.name);
106 }
107
108 static void destruct_item(ItemT *item)
109 {
110 MEM_SAFE_FREE(item->name);
111 }
112
113 static void blend_write(BlendWriter *writer, const bNode &node);
114 static void blend_read_data(BlendDataReader *reader, bNode &node);
115
117 {
118 return eNodeSocketDatatype(item.socket_type);
119 }
120
121 static char **get_name(ItemT &item)
122 {
123 return &item.name;
124 }
125
126 static bool supports_socket_type(const eNodeSocketDatatype socket_type)
127 {
128 return ELEM(socket_type,
131 SOCK_RGBA,
135 SOCK_INT);
136 }
137
139 ItemT &item,
140 const eNodeSocketDatatype socket_type,
141 const char *name)
142 {
143 auto *storage = static_cast<NodeGeometryForeachGeometryElementOutput *>(node.storage);
144 item.socket_type = socket_type;
145 item.identifier = storage->generation_items.next_identifier++;
147 node, item, name);
148 }
149
150 static std::string socket_identifier_for_item(const ItemT &item)
151 {
152 return "Main_" + std::to_string(item.identifier);
153 }
154};
155
159 static int node_type;
160 static constexpr const char *node_idname = "GeometryNodeForeachGeometryElementOutput";
161 static constexpr bool has_type = true;
162 static constexpr bool has_name = true;
163 static constexpr bool has_single_identifier_str = true;
164
166 {
167 auto *storage = static_cast<NodeGeometryForeachGeometryElementOutput *>(node.storage);
168 return {&storage->generation_items.items,
169 &storage->generation_items.items_num,
170 &storage->generation_items.active_index};
171 }
172
173 static void copy_item(const ItemT &src, ItemT &dst)
174 {
175 dst = src;
176 dst.name = BLI_strdup_null(dst.name);
177 }
178
179 static void destruct_item(ItemT *item)
180 {
181 MEM_SAFE_FREE(item->name);
182 }
183
184 static void blend_write(BlendWriter *writer, const bNode &node);
185 static void blend_read_data(BlendDataReader *reader, bNode &node);
186
188 {
189 return eNodeSocketDatatype(item.socket_type);
190 }
191
192 static char **get_name(ItemT &item)
193 {
194 return &item.name;
195 }
196
197 static bool supports_socket_type(const eNodeSocketDatatype socket_type)
198 {
199 return ELEM(socket_type,
202 SOCK_RGBA,
206 SOCK_INT,
208 }
209
211 ItemT &item,
212 const eNodeSocketDatatype socket_type,
213 const char *name)
214 {
215 auto *storage = static_cast<NodeGeometryForeachGeometryElementOutput *>(node.storage);
216 item.socket_type = socket_type;
217 item.identifier = storage->generation_items.next_identifier++;
219 node, item, name);
220 }
221
222 static std::string socket_identifier_for_item(const ItemT &item)
223 {
224 return "Generation_" + std::to_string(item.identifier);
225 }
226};
227
228} // namespace blender::nodes
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
Definition string.c:45
#define ELEM(...)
struct NodeForeachGeometryElementMainItem NodeForeachGeometryElementMainItem
struct NodeForeachGeometryElementInputItem NodeForeachGeometryElementInputItem
eNodeSocketDatatype
@ SOCK_INT
@ SOCK_VECTOR
@ SOCK_BOOLEAN
@ SOCK_MATRIX
@ SOCK_FLOAT
@ SOCK_GEOMETRY
@ SOCK_ROTATION
@ SOCK_RGBA
@ SOCK_MENU
struct NodeForeachGeometryElementGenerationItem NodeForeachGeometryElementGenerationItem
#define MEM_SAFE_FREE(v)
void set_item_name_and_make_unique(bNode &node, typename Accessor::ItemT &item, const char *value)
NodeForeachGeometryElementGenerationItem * items
NodeForeachGeometryElementInputItem * items
NodeForeachGeometryElementMainItem * items
NodeForeachGeometryElementInputItems input_items
NodeForeachGeometryElementMainItems main_items
NodeForeachGeometryElementGenerationItems generation_items
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 socket_items::SocketItemsRef< ItemT > get_items_from_node(bNode &node)
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 blend_read_data(BlendDataReader *reader, bNode &node)
static void blend_write(BlendWriter *writer, const bNode &node)
static bool supports_socket_type(const eNodeSocketDatatype socket_type)
static void blend_read_data(BlendDataReader *reader, bNode &node)
static socket_items::SocketItemsRef< ItemT > get_items_from_node(bNode &node)
static void blend_write(BlendWriter *writer, const bNode &node)
static void init_with_socket_type_and_name(bNode &node, ItemT &item, const eNodeSocketDatatype socket_type, const char *name)