[Bf-blender-cvs] [542bff5e940] temp-nodes-group-declarations: Declarations for group input and output nodes

Hans Goudey noreply at git.blender.org
Fri Dec 16 00:18:39 CET 2022


Commit: 542bff5e9409330747fa69f4da8b0bbffef8b470
Author: Hans Goudey
Date:   Thu Dec 15 16:44:08 2022 -0600
Branches: temp-nodes-group-declarations
https://developer.blender.org/rB542bff5e9409330747fa69f4da8b0bbffef8b470

Declarations for group input and output nodes

===================================================================

M	source/blender/blenkernel/intern/node_tree_update.cc
M	source/blender/nodes/NOD_node_declaration.hh
M	source/blender/nodes/intern/node_common.cc

===================================================================

diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc
index 3cec5e4a5fe..c818259c086 100644
--- a/source/blender/blenkernel/intern/node_tree_update.cc
+++ b/source/blender/blenkernel/intern/node_tree_update.cc
@@ -540,6 +540,9 @@ class NodeTreeMainUpdater {
       nodeDeclarationEnsure(&ntree, node);
       if (this->should_update_individual_node(ntree, *node)) {
         bNodeType &ntype = *node->typeinfo;
+        if (ntype.group_update_func) {
+          ntype.group_update_func(&ntree, node);
+        }
         if (ntype.updatefunc) {
           ntype.updatefunc(&ntree, node);
         }
@@ -549,9 +552,6 @@ class NodeTreeMainUpdater {
           }
           build_node_declaration_dynamic(ntree, *node, *node->runtime->declaration);
         }
-        if (ntype.group_update_func) {
-          ntype.group_update_func(&ntree, node);
-        }
       }
       if (ELEM(node->type, NODE_GROUP_INPUT, NODE_GROUP_OUTPUT)) {
         group_inout_nodes.append(node);
diff --git a/source/blender/nodes/NOD_node_declaration.hh b/source/blender/nodes/NOD_node_declaration.hh
index 4b7f09f8ed5..9c0f9c5bab2 100644
--- a/source/blender/nodes/NOD_node_declaration.hh
+++ b/source/blender/nodes/NOD_node_declaration.hh
@@ -308,7 +308,7 @@ class SocketDeclarationBuilder : public BaseSocketDeclarationBuilder {
 using SocketDeclarationPtr = std::unique_ptr<SocketDeclaration>;
 
 class NodeDeclaration {
- private:
+ public:
   Vector<SocketDeclarationPtr> inputs_;
   Vector<SocketDeclarationPtr> outputs_;
 
diff --git a/source/blender/nodes/intern/node_common.cc b/source/blender/nodes/intern/node_common.cc
index 6484aa28a24..8d36ca6c0b0 100644
--- a/source/blender/nodes/intern/node_common.cc
+++ b/source/blender/nodes/intern/node_common.cc
@@ -231,13 +231,6 @@ bool node_group_declare_dynamic_fn(const bNodeTree & /*node_tree*/,
     outputs.append(declataion_for_interface_socket(*output));
   }
 
-  if (!ID_IS_LINKED(node.id)) {
-    /* TODO: The if statement is a fun possibility, but maybe not worth it right now? */
-    std::make_unique<decl::Extend>();
-    b.add_input<decl::Extend>("__extend__");
-    b.add_output<decl::Extend>("__extend__");
-  }
-
   return true;
 }
 
@@ -434,6 +427,45 @@ bNodeSocket *node_group_input_find_socket(bNode *node, const char *identifier)
   return nullptr;
 }
 
+namespace blender::nodes {
+
+static SocketDeclarationPtr extend_declaration(const eNodeSocketInOut in_out)
+{
+  std::unique_ptr<decl::Extend> decl = std::make_unique<decl::Extend>();
+  decl->name_ = "";
+  decl->identifier_ = "__extend__";
+  decl->in_out_ = in_out;
+  return decl;
+}
+
+static bool group_input_declare_dynamic_fn(const bNodeTree &node_tree,
+                                           const bNode &node,
+                                           NodeDeclaration &r_declaration)
+{
+  LISTBASE_FOREACH (const bNodeSocket *, input, &node_tree.inputs) {
+    r_declaration.outputs_.append(declataion_for_interface_socket(*input));
+    r_declaration.outputs_.last()->in_out_ = SOCK_OUT;
+  }
+  if (!ID_IS_LINKED(&node_tree.id)) {
+    r_declaration.outputs_.append(extend_declaration(SOCK_OUT));
+  }
+}
+
+static bool group_output_declare_dynamic_fn(const bNodeTree &node_tree,
+                                            const bNode &node,
+                                            NodeDeclaration &r_declaration)
+{
+  LISTBASE_FOREACH (const bNodeSocket *, input, &node_tree.inputs) {
+    r_declaration.inputs_.append(declataion_for_interface_socket(*input));
+    r_declaration.inputs_.last()->in_out_ = SOCK_OUT;
+  }
+  if (!ID_IS_LINKED(&node_tree.id)) {
+    r_declaration.inputs_.append(extend_declaration(SOCK_OUT));
+  }
+}
+
+}  // namespace blender::nodes
+
 void register_node_type_group_input()
 {
   /* used for all tree types, needs dynamic allocation */
@@ -443,7 +475,7 @@ void register_node_type_group_input()
   node_type_base(ntype, NODE_GROUP_INPUT, "Group Input", NODE_CLASS_INTERFACE);
   node_type_size(ntype, 140, 80, 400);
   /* TODO: Update declaration when linking to the extension sockets. */
-  // ntype->declare_dynamic =
+  ntype->declare_dynamic = blender::nodes::group_input_declare_dynamic_fn;
 
   nodeRegisterType(ntype);
 }



More information about the Bf-blender-cvs mailing list