[Bf-blender-cvs] [19491e5fc09] master: Nodes: extract function that builds the node declaration
Jacques Lucke
noreply at git.blender.org
Sun Dec 11 19:14:29 CET 2022
Commit: 19491e5fc090b5f33b08b4b225466026fddf6b6b
Author: Jacques Lucke
Date: Sun Dec 11 19:12:09 2022 +0100
Branches: master
https://developer.blender.org/rB19491e5fc090b5f33b08b4b225466026fddf6b6b
Nodes: extract function that builds the node declaration
This also makes it easier to add some post processing on top of
the node-defined declaration.
===================================================================
M source/blender/blenkernel/intern/node.cc
M source/blender/editors/space_node/node_templates.cc
M source/blender/nodes/NOD_node_declaration.hh
M source/blender/nodes/intern/node_declaration.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc
index da215c9003a..f195be3c0e6 100644
--- a/source/blender/blenkernel/intern/node.cc
+++ b/source/blender/blenkernel/intern/node.cc
@@ -1373,8 +1373,7 @@ void nodeRegisterType(bNodeType *nt)
if (nt->declare && !nt->declaration_is_dynamic) {
if (nt->fixed_declaration == nullptr) {
nt->fixed_declaration = new blender::nodes::NodeDeclaration();
- blender::nodes::NodeDeclarationBuilder builder{*nt->fixed_declaration};
- nt->declare(builder);
+ blender::nodes::build_node_declaration(*nt, *nt->fixed_declaration);
}
}
@@ -3607,8 +3606,7 @@ bool nodeDeclarationEnsureOnOutdatedNode(bNodeTree * /*ntree*/, bNode *node)
}
if (node->typeinfo->declaration_is_dynamic) {
node->runtime->declaration = new blender::nodes::NodeDeclaration();
- blender::nodes::NodeDeclarationBuilder builder{*node->runtime->declaration};
- node->typeinfo->declare(builder);
+ blender::nodes::build_node_declaration(*node->typeinfo, *node->runtime->declaration);
}
else {
/* Declaration should have been created in #nodeRegisterType. */
diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc
index 18c6e49c8a2..c16e09f4b2f 100644
--- a/source/blender/editors/space_node/node_templates.cc
+++ b/source/blender/editors/space_node/node_templates.cc
@@ -361,8 +361,7 @@ static Vector<NodeLinkItem> ui_node_link_items(NodeLinkArg *arg,
using namespace blender::nodes;
r_node_decl.emplace(NodeDeclaration());
- NodeDeclarationBuilder node_decl_builder{*r_node_decl};
- arg->node_type->declare(node_decl_builder);
+ blender::nodes::build_node_declaration(*arg->node_type, *r_node_decl);
Span<SocketDeclarationPtr> socket_decls = (in_out == SOCK_IN) ? r_node_decl->inputs() :
r_node_decl->outputs();
int index = 0;
diff --git a/source/blender/nodes/NOD_node_declaration.hh b/source/blender/nodes/NOD_node_declaration.hh
index 13f8af4ddf5..b06f0736917 100644
--- a/source/blender/nodes/NOD_node_declaration.hh
+++ b/source/blender/nodes/NOD_node_declaration.hh
@@ -367,6 +367,8 @@ void index(const bNode &node, void *r_value);
void id_or_index(const bNode &node, void *r_value);
} // namespace implicit_field_inputs
+void build_node_declaration(const bNodeType &typeinfo, NodeDeclaration &r_declaration);
+
/* -------------------------------------------------------------------- */
/** \name #OutputFieldDependency Inline Methods
* \{ */
diff --git a/source/blender/nodes/intern/node_declaration.cc b/source/blender/nodes/intern/node_declaration.cc
index f323d035668..7a6e237a18f 100644
--- a/source/blender/nodes/intern/node_declaration.cc
+++ b/source/blender/nodes/intern/node_declaration.cc
@@ -7,6 +7,12 @@
namespace blender::nodes {
+void build_node_declaration(const bNodeType &typeinfo, NodeDeclaration &r_declaration)
+{
+ NodeDeclarationBuilder node_decl_builder{r_declaration};
+ typeinfo.declare(node_decl_builder);
+}
+
bool NodeDeclaration::matches(const bNode &node) const
{
auto check_sockets = [&](ListBase sockets, Span<SocketDeclarationPtr> socket_decls) {
More information about the Bf-blender-cvs
mailing list