Blender V5.3
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
14 const int ntree_type)
15{
16 return bke::node_tree_type_supports_socket_type_static(ntree_type, socket_type);
17}
18
22 static int node_type;
23 static constexpr StringRefNull node_idname = "NodeCombineBundle";
24 static constexpr bool has_type = true;
25 static constexpr bool has_name = true;
26 static constexpr bool has_name_validation = true;
27 static constexpr char unique_name_separator = '_';
29 static constexpr StringRefNull add_item = "NODE_OT_combine_bundle_item_add";
30 static constexpr StringRefNull remove_item = "NODE_OT_combine_bundle_item_remove";
31 static constexpr StringRefNull move_item = "NODE_OT_combine_bundle_item_move";
32 };
33 struct ui_idnames {
34 static constexpr StringRefNull list = "DATA_UL_combine_bundle_items";
35 };
36 struct rna_names {
37 static constexpr StringRefNull items = "bundle_items";
38 static constexpr StringRefNull active_index = "active_index";
39 };
40
42 {
43 auto *storage = static_cast<NodeCombineBundle *>(node.storage);
44 return {&storage->items, &storage->items_num, &storage->active_index};
45 }
46
47 static void copy_item(const ItemT &src, ItemT &dst)
48 {
49 dst = src;
50 dst.name = BLI_strdup_null(dst.name);
51 }
52
53 static void destruct_item(ItemT *item)
54 {
55 MEM_SAFE_DELETE(item->name);
56 }
57
58 static void blend_write_item(BlendWriter *writer, const ItemT &item);
59 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
60
62 {
63 return item.socket_type;
64 }
65
66 static char **get_name(ItemT &item)
67 {
68 return &item.name;
69 }
70
71 static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
72 {
73 return socket_type_supported_in_bundle(socket_type, ntree_type);
74 }
75
77 ItemT &item,
78 const eNodeSocketDatatype socket_type,
79 const char *name)
80 {
81 auto *storage = static_cast<NodeCombineBundle *>(node.storage);
82 item.socket_type = socket_type;
83 item.identifier = storage->next_identifier++;
85 }
86
87 static std::string socket_identifier_for_item(const ItemT &item)
88 {
89 return "Item_" + std::to_string(item.identifier);
90 }
91
92 static std::string validate_name(const StringRef name);
93};
94
98 static int node_type;
99 static constexpr StringRefNull node_idname = "NodeSeparateBundle";
100 static constexpr bool has_type = true;
101 static constexpr bool has_name = true;
102 static constexpr bool has_name_validation = true;
103 static constexpr char unique_name_separator = '_';
105 static constexpr StringRefNull add_item = "NODE_OT_separate_bundle_item_add";
106 static constexpr StringRefNull remove_item = "NODE_OT_separate_bundle_item_remove";
107 static constexpr StringRefNull move_item = "NODE_OT_separate_bundle_item_move";
108 };
109 struct ui_idnames {
110 static constexpr StringRefNull list = "DATA_UL_separate_bundle_items";
111 };
112 struct rna_names {
113 static constexpr StringRefNull items = "bundle_items";
114 static constexpr StringRefNull active_index = "active_index";
115 };
116
118 {
119 auto *storage = static_cast<NodeSeparateBundle *>(node.storage);
120 return {&storage->items, &storage->items_num, &storage->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_bundle(socket_type, ntree_type);
150 }
151
153 ItemT &item,
154 const eNodeSocketDatatype socket_type,
155 const char *name)
156 {
157 auto *storage = static_cast<NodeSeparateBundle *>(node.storage);
158 item.socket_type = socket_type;
159 item.identifier = storage->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 static std::string validate_name(const StringRef name)
169 {
171 }
172};
173
174std::optional<StringRefNull> combine_bundle_node_type(const bNodeTree &tree, const bNode &node);
175
176} // 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)
bool socket_type_supported_in_bundle(const eNodeSocketDatatype socket_type, const int ntree_type)
std::optional< StringRefNull > combine_bundle_node_type(const bNodeTree &tree, const bNode &node)
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
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)
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 validate_name(const StringRef name)
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, const int ntree_type)
static eNodeSocketDatatype get_socket_type(const ItemT &item)
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 std::string validate_name(const StringRef name)
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)