Blender V5.0
node_register.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "NOD_composite.hh"
6#include "NOD_geometry.hh"
7#include "NOD_register.hh"
8#include "NOD_socket.hh"
9
10#include "BKE_node.hh"
12
13#include "BLT_translation.hh"
14
15#include "UI_resources.hh"
16
17static bool node_undefined_poll(const blender::bke::bNodeType * /*ntype*/,
18 const bNodeTree * /*nodetree*/,
19 const char ** /*r_disabled_hint*/)
20{
21 /* this type can not be added deliberately, it's just a placeholder */
22 return false;
23}
24
25/* register fallback types used for undefined tree, nodes, sockets */
27{
28 /* NOTE: these types are not registered in the type hashes,
29 * they are just used as placeholders in case the actual types are not registered.
30 */
31
33 blender::bke::NodeTreeTypeUndefined.idname = "NodeTreeUndefined";
34 blender::bke::NodeTreeTypeUndefined.ui_name = N_("Undefined");
35 blender::bke::NodeTreeTypeUndefined.ui_description = N_("Undefined Node Tree Type");
36
38 blender::bke::NodeTypeUndefined, "NodeUndefined", "Undefined", "UNDEFINED", 0);
40
41 blender::bke::NodeSocketTypeUndefined.idname = "NodeSocketUndefined";
42 /* extra type info for standard socket types */
45
46 blender::bke::NodeSocketTypeUndefined.use_link_limits_of_type = true;
47 blender::bke::NodeSocketTypeUndefined.input_link_limit = 0xFFF;
48 blender::bke::NodeSocketTypeUndefined.output_link_limit = 0xFFF;
49}
50
52 public:
54 {
55 this->input_idname = "GeometryNodeSimulationInput";
56 this->output_idname = "GeometryNodeSimulationOutput";
60 }
61
62 const int &get_corresponding_output_id(const bNode &input_bnode) const override
63 {
64 BLI_assert(input_bnode.type_legacy == this->input_type);
65 return static_cast<NodeGeometrySimulationInput *>(input_bnode.storage)->output_node_id;
66 }
67};
68
70 public:
72 {
73 this->input_idname = "GeometryNodeRepeatInput";
74 this->output_idname = "GeometryNodeRepeatOutput";
78 }
79
80 const int &get_corresponding_output_id(const bNode &input_bnode) const override
81 {
82 BLI_assert(input_bnode.type_legacy == this->input_type);
83 return static_cast<NodeGeometryRepeatInput *>(input_bnode.storage)->output_node_id;
84 }
85};
86
88 public:
90 {
91 this->input_idname = "GeometryNodeForeachGeometryElementInput";
92 this->output_idname = "GeometryNodeForeachGeometryElementOutput";
96 }
97
98 const int &get_corresponding_output_id(const bNode &input_bnode) const override
99 {
100 BLI_assert(input_bnode.type_legacy == this->input_type);
101 return static_cast<NodeGeometryForeachGeometryElementInput *>(input_bnode.storage)
102 ->output_node_id;
103 }
104};
105
107 public:
109 {
110 this->input_idname = "NodeClosureInput";
111 this->output_idname = "NodeClosureOutput";
115 }
116
117 const int &get_corresponding_output_id(const bNode &input_bnode) const override
118 {
119 BLI_assert(input_bnode.type_legacy == this->input_type);
120 return static_cast<NodeClosureInput *>(input_bnode.storage)->output_node_id;
121 }
122};
123
125{
126 static SimulationZoneType simulation_zone_type;
127 static RepeatZoneType repeat_zone_type;
128 static ForeachGeometryElementZoneType foreach_geometry_element_zone_type;
129 static ClosureZoneType closure_zone_type;
130 blender::bke::register_node_zone_type(simulation_zone_type);
132 blender::bke::register_node_zone_type(foreach_geometry_element_zone_type);
133 blender::bke::register_node_zone_type(closure_zone_type);
134}
135
#define GEO_NODE_FOREACH_GEOMETRY_ELEMENT_INPUT
#define GEO_NODE_FOREACH_GEOMETRY_ELEMENT_OUTPUT
#define GEO_NODE_SIMULATION_OUTPUT
#define NODE_CLOSURE_OUTPUT
#define GEO_NODE_REPEAT_OUTPUT
#define GEO_NODE_REPEAT_INPUT
#define GEO_NODE_SIMULATION_INPUT
#define NODE_CLOSURE_INPUT
#define BLI_assert(a)
Definition BLI_assert.h:46
@ NTREE_UNDEFINED
@ SOCK_CUSTOM
void register_shader_nodes()
void register_function_nodes()
void register_compositor_nodes()
void register_texture_nodes()
void register_geometry_nodes()
@ PROP_NONE
Definition RNA_types.hh:233
@ TH_NODE_ZONE_REPEAT
@ TH_NODE_ZONE_FOREACH_GEOMETRY_ELEMENT
@ TH_NODE_ZONE_CLOSURE
@ TH_NODE_ZONE_SIMULATION
const int & get_corresponding_output_id(const bNode &input_bnode) const override
const int & get_corresponding_output_id(const bNode &input_bnode) const override
const int & get_corresponding_output_id(const bNode &input_bnode) const override
const int & get_corresponding_output_id(const bNode &input_bnode) const override
bNodeSocketType NodeSocketTypeUndefined
Definition node.cc:127
bNodeTreeType NodeTreeTypeUndefined
Definition node.cc:125
bNodeType NodeTypeUndefined
Definition node.cc:126
void register_node_zone_type(const bNodeZoneType &zone_type)
void node_type_base_custom(bNodeType &ntype, StringRefNull idname, StringRefNull name, StringRefNull enum_name, short nclass)
Definition node.cc:5129
void register_node_type_group_output()
void register_node_type_group_input()
void register_node_type_frame()
void register_node_type_reroute()
void register_node_tree_type_cmp()
void register_node_tree_type_geo()
static void register_zone_types()
static bool node_undefined_poll(const blender::bke::bNodeType *, const bNodeTree *, const char **)
static void register_undefined_types()
void register_nodes()
void register_standard_node_socket_types()
int16_t type_legacy
void * storage
Defines a node type.
Definition BKE_node.hh:238
#define N_(msgid)