Blender V5.3
NOD_geo_repeat.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
20 static int node_type;
21 static constexpr StringRefNull node_idname = "GeometryNodeRepeatOutput";
22 static constexpr bool has_type = true;
23 static constexpr bool has_name = true;
25 static constexpr StringRefNull add_item = "NODE_OT_repeat_zone_item_add";
26 static constexpr StringRefNull remove_item = "NODE_OT_repeat_zone_item_remove";
27 static constexpr StringRefNull move_item = "NODE_OT_repeat_zone_item_move";
28 };
29 struct ui_idnames {
30 static constexpr StringRefNull list = "DATA_UL_repeat_zone_state";
31 };
32 struct rna_names {
33 static constexpr StringRefNull items = "repeat_items";
34 static constexpr StringRefNull active_index = "active_index";
35 };
36
38 {
39 auto *storage = static_cast<NodeGeometryRepeatOutput *>(node.storage);
40 return {&storage->items, &storage->items_num, &storage->active_index};
41 }
42
43 static void copy_item(const NodeRepeatItem &src, NodeRepeatItem &dst)
44 {
45 dst = src;
46 dst.name = BLI_strdup_null(dst.name);
47 }
48
49 static void destruct_item(NodeRepeatItem *item)
50 {
51 MEM_SAFE_DELETE(item->name);
52 }
53
54 static void blend_write_item(BlendWriter *writer, const ItemT &item);
55 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
56
58 {
59 return item.socket_type;
60 }
61
62 static char **get_name(NodeRepeatItem &item)
63 {
64 return &item.name;
65 }
66
67 static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
68 {
69 return bke::node_tree_type_supports_socket_type_static(ntree_type, socket_type);
70 }
71
73 NodeRepeatItem &item,
74 const eNodeSocketDatatype socket_type,
75 const char *name)
76 {
77 auto *storage = static_cast<NodeGeometryRepeatOutput *>(node.storage);
78 item.socket_type = socket_type;
79 item.identifier = storage->next_identifier++;
81 }
82
83 static std::string socket_identifier_for_item(const NodeRepeatItem &item)
84 {
85 return "Item_" + std::to_string(item.identifier);
86 }
87};
88
89} // 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)
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
eNodeSocketDatatype socket_type
static constexpr StringRefNull active_index
static void init_with_socket_type_and_name(bNode &node, NodeRepeatItem &item, const eNodeSocketDatatype socket_type, const char *name)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static socket_items::SocketItemsRef< NodeRepeatItem > get_items_from_node(bNode &node)
static char ** get_name(NodeRepeatItem &item)
static constexpr StringRefNull node_idname
static void copy_item(const NodeRepeatItem &src, NodeRepeatItem &dst)
static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int ntree_type)
static eNodeSocketDatatype get_socket_type(const NodeRepeatItem &item)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static void destruct_item(NodeRepeatItem *item)
static std::string socket_identifier_for_item(const NodeRepeatItem &item)