Blender V5.0
NOD_geo_simulation.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 = "GeometryNodeSimulationOutput";
22 static constexpr bool has_type = true;
23 static constexpr bool has_name = true;
25 static constexpr StringRefNull add_item = "NODE_OT_simulation_zone_item_add";
26 static constexpr StringRefNull remove_item = "NODE_OT_simulation_zone_item_remove";
27 static constexpr StringRefNull move_item = "NODE_OT_simulation_zone_item_move";
28 };
29 struct ui_idnames {
30 static constexpr StringRefNull list = "DATA_UL_simulation_zone_state";
31 };
32 struct rna_names {
33 static constexpr StringRefNull items = "state_items";
34 static constexpr StringRefNull active_index = "active_index";
35 };
36
38 {
39 auto *storage = static_cast<NodeGeometrySimulationOutput *>(node.storage);
40 return {&storage->items, &storage->items_num, &storage->active_index};
41 }
42
43 static void copy_item(const NodeSimulationItem &src, NodeSimulationItem &dst)
44 {
45 dst = src;
46 dst.name = BLI_strdup_null(dst.name);
47 }
48
50 {
51 MEM_SAFE_FREE(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
61
62 static char **get_name(NodeSimulationItem &item)
63 {
64 return &item.name;
65 }
66
67 static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int /*ntree_type*/)
68 {
69 /* Data-block types and closures are not supported. */
70 return ELEM(socket_type,
81 }
82
85 const eNodeSocketDatatype socket_type,
86 const char *name)
87 {
88 auto *storage = static_cast<NodeGeometrySimulationOutput *>(node.storage);
89 item.socket_type = socket_type;
90 item.identifier = storage->next_identifier++;
92 }
93
94 static std::string socket_identifier_for_item(const NodeSimulationItem &item)
95 {
96 return "Item_" + std::to_string(item.identifier);
97 }
98};
99
100} // namespace blender::nodes
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
Definition string.cc:46
#define ELEM(...)
eNodeSocketDatatype
@ SOCK_INT
@ SOCK_VECTOR
@ SOCK_BOOLEAN
@ SOCK_MATRIX
@ SOCK_FLOAT
@ SOCK_BUNDLE
@ SOCK_GEOMETRY
@ SOCK_ROTATION
@ SOCK_STRING
@ SOCK_RGBA
#define MEM_SAFE_FREE(v)
void set_item_name_and_make_unique(bNode &node, typename Accessor::ItemT &item, const char *value)
const char * name
void * storage
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)
static char ** get_name(NodeSimulationItem &item)
static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int)
static socket_items::SocketItemsRef< NodeSimulationItem > get_items_from_node(bNode &node)
static std::string socket_identifier_for_item(const NodeSimulationItem &item)
static constexpr StringRefNull node_idname
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static void destruct_item(NodeSimulationItem *item)
static void init_with_socket_type_and_name(bNode &node, NodeSimulationItem &item, const eNodeSocketDatatype socket_type, const char *name)
static eNodeSocketDatatype get_socket_type(const NodeSimulationItem &item)
static void copy_item(const NodeSimulationItem &src, NodeSimulationItem &dst)