Blender V4.3
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 const char *node_idname = "GeometryNodeSimulationOutput";
22 static constexpr bool has_type = true;
23 static constexpr bool has_name = true;
24 static constexpr bool has_single_identifier_str = true;
25
27 {
28 auto *storage = static_cast<NodeGeometrySimulationOutput *>(node.storage);
29 return {&storage->items, &storage->items_num, &storage->active_index};
30 }
31 static void copy_item(const NodeSimulationItem &src, NodeSimulationItem &dst)
32 {
33 dst = src;
34 dst.name = BLI_strdup_null(dst.name);
35 }
37 {
38 MEM_SAFE_FREE(item->name);
39 }
40 static void blend_write(BlendWriter *writer, const bNode &node);
41 static void blend_read_data(BlendDataReader *reader, bNode &node);
46 static char **get_name(NodeSimulationItem &item)
47 {
48 return &item.name;
49 }
50 static bool supports_socket_type(const eNodeSocketDatatype socket_type)
51 {
52 return ELEM(socket_type,
62 }
65 const eNodeSocketDatatype socket_type,
66 const char *name)
67 {
68 auto *storage = static_cast<NodeGeometrySimulationOutput *>(node.storage);
69 item.socket_type = socket_type;
70 item.identifier = storage->next_identifier++;
72 }
73 static std::string socket_identifier_for_item(const NodeSimulationItem &item)
74 {
75 return "Item_" + std::to_string(item.identifier);
76 }
77};
78
79} // namespace blender::nodes
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
Definition string.c:45
#define ELEM(...)
struct NodeSimulationItem NodeSimulationItem
eNodeSocketDatatype
@ SOCK_INT
@ SOCK_VECTOR
@ SOCK_BOOLEAN
@ SOCK_MATRIX
@ SOCK_FLOAT
@ 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)
static constexpr const char * node_idname
static char ** get_name(NodeSimulationItem &item)
static void blend_write(BlendWriter *writer, const bNode &node)
static socket_items::SocketItemsRef< NodeSimulationItem > get_items_from_node(bNode &node)
static std::string socket_identifier_for_item(const NodeSimulationItem &item)
static void destruct_item(NodeSimulationItem *item)
static void blend_read_data(BlendDataReader *reader, bNode &node)
static bool supports_socket_type(const eNodeSocketDatatype socket_type)
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)