[Bf-blender-cvs] [4aa0105aacc] temp-derived-node-tree-refactor: move function to xxx socket

Jacques Lucke noreply at git.blender.org
Thu Mar 4 16:16:59 CET 2021


Commit: 4aa0105aacc99517457088f4b6732908dfdc7531
Author: Jacques Lucke
Date:   Thu Mar 4 15:51:42 2021 +0100
Branches: temp-derived-node-tree-refactor
https://developer.blender.org/rB4aa0105aacc99517457088f4b6732908dfdc7531

move function to xxx socket

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

M	source/blender/modifiers/intern/MOD_nodes.cc
M	source/blender/nodes/NOD_XXX_node_tree.hh
M	source/blender/nodes/intern/xxx_node_tree.cc

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

diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc
index a762bde41de..14323b5a18d 100644
--- a/source/blender/modifiers/intern/MOD_nodes.cc
+++ b/source/blender/modifiers/intern/MOD_nodes.cc
@@ -506,8 +506,8 @@ class GeometryNodesEvaluator {
   {
     /* For all sockets that are linked with the from_socket push the value to their node. */
     Vector<XXXInputSocket> to_sockets_all;
-    this->foreach_input_to_forward_to(
-        from_socket, [&](XXXInputSocket to_socket) { to_sockets_all.append(to_socket); });
+    from_socket.foreach_target_socket(
+        [&](XXXInputSocket to_socket) { to_sockets_all.append(to_socket); });
 
     const CPPType &from_type = *value_to_forward.type();
     Vector<XXXInputSocket> to_sockets_same_type;
@@ -560,32 +560,6 @@ class GeometryNodesEvaluator {
     }
   }
 
-  void foreach_input_to_forward_to(XXXOutputSocket from_socket,
-                                   FunctionRef<void(XXXInputSocket)> callback) const
-  {
-    for (const InputSocketRef *linked_socket : from_socket->linked_sockets()) {
-      const NodeRef &linked_node = linked_socket->node();
-      XXXInputSocket linked_xxx_socket{from_socket.context, linked_socket};
-      if (linked_node.is_group_output_node()) {
-        if (from_socket.context->is_root()) {
-          callback(linked_xxx_socket);
-        }
-        else {
-          XXXOutputSocket socket_in_parent_group =
-              linked_xxx_socket.get_corresponding_group_node_output();
-          this->foreach_input_to_forward_to(socket_in_parent_group, callback);
-        }
-      }
-      else if (linked_node.is_group_node()) {
-        XXXOutputSocket socket_in_group = linked_xxx_socket.get_corresponding_group_input_socket();
-        this->foreach_input_to_forward_to(socket_in_group, callback);
-      }
-      else {
-        callback(linked_xxx_socket);
-      }
-    }
-  }
-
   void add_value_to_input_socket(const std::pair<XXXInputSocket, XXXOutputSocket> key,
                                  GMutablePointer value)
   {
diff --git a/source/blender/nodes/NOD_XXX_node_tree.hh b/source/blender/nodes/NOD_XXX_node_tree.hh
index 10a0c28a568..422deb9ea87 100644
--- a/source/blender/nodes/NOD_XXX_node_tree.hh
+++ b/source/blender/nodes/NOD_XXX_node_tree.hh
@@ -122,6 +122,8 @@ struct XXXOutputSocket {
 
   XXXInputSocket get_corresponding_group_node_input() const;
   XXXInputSocket get_corresponding_group_output_socket() const;
+
+  void foreach_target_socket(FunctionRef<void(XXXInputSocket)> callback) const;
 };
 
 class XXXNodeTree {
diff --git a/source/blender/nodes/intern/xxx_node_tree.cc b/source/blender/nodes/intern/xxx_node_tree.cc
index 4d62c78557a..089a4597f16 100644
--- a/source/blender/nodes/intern/xxx_node_tree.cc
+++ b/source/blender/nodes/intern/xxx_node_tree.cc
@@ -187,4 +187,29 @@ void XXXInputSocket::foreach_origin_socket(FunctionRef<void(XXXSocket)> callback
   }
 }
 
+void XXXOutputSocket::foreach_target_socket(FunctionRef<void(XXXInputSocket)> callback) const
+{
+  for (const InputSocketRef *linked_socket : socket_ref->linked_sockets()) {
+    const NodeRef &linked_node = linked_socket->node();
+    XXXInputSocket linked_xxx_socket{context, linked_socket};
+    if (linked_node.is_group_output_node()) {
+      if (context->is_root()) {
+        callback(linked_xxx_socket);
+      }
+      else {
+        XXXOutputSocket socket_in_parent_group =
+            linked_xxx_socket.get_corresponding_group_node_output();
+        socket_in_parent_group.foreach_target_socket(callback);
+      }
+    }
+    else if (linked_node.is_group_node()) {
+      XXXOutputSocket socket_in_group = linked_xxx_socket.get_corresponding_group_input_socket();
+      socket_in_group.foreach_target_socket(callback);
+    }
+    else {
+      callback(linked_xxx_socket);
+    }
+  }
+}
+
 }  // namespace blender::nodes



More information about the Bf-blender-cvs mailing list