Blender V5.3
NOD_shader_raycast.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 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 "BLI_assert.hh"
10
11#include "BKE_customdata.hh"
12
13#include "NOD_socket_items.hh"
14
15namespace blender::nodes {
16
20 static int node_type;
21 static constexpr StringRefNull node_idname = "ShaderNodeRaycast";
22 static constexpr bool has_type = true;
23 static constexpr bool has_name = true;
24 static constexpr bool has_single_identifier_str = false;
26 static constexpr StringRefNull add_item = "NODE_OT_sample_attribute_items_item_add";
27 static constexpr StringRefNull remove_item = "NODE_OT_sample_attribute_items_item_remove";
28 static constexpr StringRefNull move_item = "NODE_OT_sample_attribute_items_item_move";
29 };
30 struct ui_idnames {
31 static constexpr StringRefNull list = "NODE_UL_capture_items_list";
32 };
33 struct rna_names {
34 static constexpr StringRefNull items = "sample_attribute_items";
35 static constexpr StringRefNull active_index = "active_index";
36 };
37
39 bNode &node)
40 {
41 auto *storage = static_cast<NodeShaderRaycast *>(node.storage);
42 return {&storage->sample_attribute_items,
43 &storage->sample_attribute_items_num,
44 &storage->active_index};
45 }
46
49 {
50 dst = src;
51 dst.name = BLI_strdup_null(dst.name);
52 }
53
55 {
56 MEM_SAFE_DELETE(item->name);
57 }
58
59 static void blend_write_item(BlendWriter *writer, const ItemT &item);
60 static void blend_read_data_item(BlendDataReader *reader, ItemT &item);
61
66
68 {
69 return &item.name;
70 }
71
72 static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int /*ntree_type*/)
73 {
74 return ELEM(socket_type, SOCK_FLOAT, SOCK_VECTOR, SOCK_RGBA);
75 }
76
79 const eNodeSocketDatatype socket_type,
80 const char *name)
81 {
82 auto *storage = static_cast<NodeShaderRaycast *>(node.storage);
84 item.identifier = storage->next_identifier++;
86 node, item, name);
87 }
88
90 {
91 return "Value_" + std::to_string(item.identifier);
92 }
94 {
95 return "Attribute_" + std::to_string(item.identifier);
96 }
99 {
101 return "Attribute_" + std::to_string(item.identifier) + "_Alpha";
102 }
103};
104
105} // namespace blender::nodes
CustomData interface, see also DNA_customdata_types.h.
#define ELEM(...)
#define storage(slot, qualifiers)
std::optional< eNodeSocketDatatype > custom_data_type_to_socket_type(eCustomDataType type)
Definition node.cc:5935
std::optional< eCustomDataType > socket_type_to_custom_data_type(eNodeSocketDatatype type)
Definition node.cc:5911
void set_item_name_and_make_unique(bNode &node, typename Accessor::ItemT &item, const char *value)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
static socket_items::SocketItemsRef< NodeRaycastSampleAttributeItem > get_items_from_node(bNode &node)
static std::string output_socket_identifier_for_item_alpha(const NodeRaycastSampleAttributeItem &item)
static char ** get_name(NodeRaycastSampleAttributeItem &item)
static void init_with_socket_type_and_name(bNode &node, NodeRaycastSampleAttributeItem &item, const eNodeSocketDatatype socket_type, const char *name)
static void destruct_item(NodeRaycastSampleAttributeItem *item)
static eNodeSocketDatatype get_socket_type(const NodeRaycastSampleAttributeItem &item)
static std::string input_socket_identifier_for_item(const NodeRaycastSampleAttributeItem &item)
static bool supports_socket_type(const eNodeSocketDatatype socket_type, const int)
static void blend_write_item(BlendWriter *writer, const ItemT &item)
static void copy_item(const NodeRaycastSampleAttributeItem &src, NodeRaycastSampleAttributeItem &dst)
static std::string output_socket_identifier_for_item(const NodeRaycastSampleAttributeItem &item)
static void blend_read_data_item(BlendDataReader *reader, ItemT &item)