Blender V5.0
NOD_geo_index_switch.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 = "GeometryNodeIndexSwitch";
22 static constexpr bool has_type = false;
23 static constexpr bool has_name = false;
24
26 {
27 auto &storage = *static_cast<NodeIndexSwitch *>(node.storage);
28 return {&storage.items, &storage.items_num, nullptr};
29 }
30
31 static void copy_item(const IndexSwitchItem &src, IndexSwitchItem &dst)
32 {
33 dst = src;
34 }
35
36 static void destruct_item(IndexSwitchItem * /*item*/) {}
37
38 static void blend_write_item(BlendWriter *writer, const ItemT &item);
39 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
40
41 static void init(bNode &node, IndexSwitchItem &item)
42 {
43 auto &storage = *static_cast<NodeIndexSwitch *>(node.storage);
44 item.identifier = storage.next_identifier++;
45 }
46
47 static std::string socket_identifier_for_item(const IndexSwitchItem &item)
48 {
49 return "Item_" + std::to_string(item.identifier);
50 }
51};
52
53} // namespace blender::nodes
void * storage
static void init(bNode &node, IndexSwitchItem &item)
static std::string socket_identifier_for_item(const IndexSwitchItem &item)
static void destruct_item(IndexSwitchItem *)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static socket_items::SocketItemsRef< IndexSwitchItem > get_items_from_node(bNode &node)
static void copy_item(const IndexSwitchItem &src, IndexSwitchItem &dst)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static constexpr StringRefNull node_idname