[Bf-blender-cvs] [497167d3a09] temp-node-tree-pages-prototype: add more sockets to portals

Jacques Lucke noreply at git.blender.org
Thu Mar 18 16:40:56 CET 2021


Commit: 497167d3a091ea669451a797a96d6d2b239925ce
Author: Jacques Lucke
Date:   Thu Mar 18 15:47:35 2021 +0100
Branches: temp-node-tree-pages-prototype
https://developer.blender.org/rB497167d3a091ea669451a797a96d6d2b239925ce

add more sockets to portals

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

M	source/blender/nodes/geometry/nodes/node_geo_portals.cc
M	source/blender/nodes/intern/derived_node_tree.cc

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

diff --git a/source/blender/nodes/geometry/nodes/node_geo_portals.cc b/source/blender/nodes/geometry/nodes/node_geo_portals.cc
index da8b99c845b..54a564ae530 100644
--- a/source/blender/nodes/geometry/nodes/node_geo_portals.cc
+++ b/source/blender/nodes/geometry/nodes/node_geo_portals.cc
@@ -23,13 +23,16 @@
 
 #include "RNA_access.h"
 
-static bNodeSocketTemplate node_portal_in[] = {
-    {SOCK_GEOMETRY, N_("Geometry")},
-    {-1, ""},
-};
-
-static bNodeSocketTemplate node_portal_out[] = {
+static bNodeSocketTemplate node_portal_sockets[] = {
     {SOCK_GEOMETRY, N_("Geometry")},
+    {SOCK_FLOAT, N_("Float"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
+    {SOCK_VECTOR, N_("Vector"), 0.0f, 0.0f, 0.0f, 0.0f, -FLT_MAX, FLT_MAX},
+    {SOCK_RGBA, N_("Color"), 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
+    {SOCK_INT, N_("Integer"), 0, 0, 0, 0, -10000, 10000},
+    {SOCK_BOOLEAN, N_("Boolean")},
+    {SOCK_STRING, N_("String")},
+    {SOCK_OBJECT, N_("Object")},
+    {SOCK_COLLECTION, N_("Collection")},
     {-1, ""},
 };
 
@@ -117,7 +120,7 @@ void register_node_type_portal_in()
   static bNodeType ntype;
 
   geo_node_type_base(&ntype, NODE_PORTAL_IN, "Portal In", NODE_CLASS_LAYOUT, 0);
-  node_type_socket_templates(&ntype, node_portal_in, nullptr);
+  node_type_socket_templates(&ntype, node_portal_sockets, nullptr);
   node_type_init(&ntype, blender::nodes::node_portal_in_init);
   node_type_update(&ntype, blender::nodes::node_portal_in_update);
   node_type_storage(
@@ -131,7 +134,7 @@ void register_node_type_portal_out()
   static bNodeType ntype;
 
   geo_node_type_base(&ntype, NODE_PORTAL_OUT, "Portal Out", NODE_CLASS_LAYOUT, 0);
-  node_type_socket_templates(&ntype, nullptr, node_portal_out);
+  node_type_socket_templates(&ntype, nullptr, node_portal_sockets);
   node_type_init(&ntype, blender::nodes::node_portal_out_init);
   node_type_update(&ntype, blender::nodes::node_portal_out_update);
   node_type_storage(
diff --git a/source/blender/nodes/intern/derived_node_tree.cc b/source/blender/nodes/intern/derived_node_tree.cc
index a44ce89869a..f6866780321 100644
--- a/source/blender/nodes/intern/derived_node_tree.cc
+++ b/source/blender/nodes/intern/derived_node_tree.cc
@@ -195,8 +195,13 @@ void DInputSocket::foreach_origin_socket(FunctionRef<void(DSocket)> callback,
           node_storage->portal_id);
       if (portal_in_nodes.size() == 1) {
         const NodeRef *portal_in_node = portal_in_nodes[0];
-        DInputSocket input_of_portal{context_, &portal_in_node->input(0)};
-        input_of_portal.foreach_origin_socket(callback);
+        DInputSocket input_of_portal{context_, &portal_in_node->input(linked_socket->index())};
+        if (input_of_portal->is_linked()) {
+          input_of_portal.foreach_origin_socket(callback);
+        }
+        else {
+          callback(input_of_portal);
+        }
       }
     }
     else if (linked_node.is_group_input_node()) {
@@ -261,7 +266,7 @@ void DOutputSocket::foreach_target_socket(FunctionRef<void(DInputSocket)> callba
       Span<const NodeRef *> portal_out_nodes = context_->tree().portal_out_nodes_by_id(
           node_storage->portal_id);
       for (const NodeRef *portal_out_node : portal_out_nodes) {
-        DOutputSocket output_of_portal{context_, &portal_out_node->output(0)};
+        DOutputSocket output_of_portal{context_, &portal_out_node->output(linked_socket->index())};
         output_of_portal.foreach_target_socket(callback);
       }
     }



More information about the Bf-blender-cvs mailing list