diff options
-rw-r--r-- | source/blender/nodes/NOD_derived_node_tree.hh | 3 | ||||
-rw-r--r-- | source/blender/nodes/intern/derived_node_tree.cc | 11 |
2 files changed, 10 insertions, 4 deletions
diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh index f1dbb2caf29..3529336baf6 100644 --- a/source/blender/nodes/NOD_derived_node_tree.hh +++ b/source/blender/nodes/NOD_derived_node_tree.hh @@ -132,7 +132,8 @@ class DInputSocket : public DSocket { DOutputSocket get_corresponding_group_node_output() const; Vector<DOutputSocket, 4> get_corresponding_group_input_sockets() const; - void foreach_origin_socket(FunctionRef<void(DSocket)> callback) const; + void foreach_origin_socket(FunctionRef<void(DSocket)> callback, + const bool follow_only_first_incoming_link = false) const; }; /* A (nullable) reference to an output socket and the context it is in. */ diff --git a/source/blender/nodes/intern/derived_node_tree.cc b/source/blender/nodes/intern/derived_node_tree.cc index c5f267470fd..36c64b00f47 100644 --- a/source/blender/nodes/intern/derived_node_tree.cc +++ b/source/blender/nodes/intern/derived_node_tree.cc @@ -168,10 +168,15 @@ DInputSocket DOutputSocket::get_active_corresponding_group_output_socket() const /* Call the given callback for every "real" origin socket. "Real" means that reroutes, muted nodes * and node groups are handled by this function. Origin sockets are ones where a node gets its * inputs from. */ -void DInputSocket::foreach_origin_socket(FunctionRef<void(DSocket)> callback) const +void DInputSocket::foreach_origin_socket(FunctionRef<void(DSocket)> callback, + const bool follow_only_first_incoming_link) const { BLI_assert(*this); - for (const OutputSocketRef *linked_socket : socket_ref_->as_input().linked_sockets()) { + Span<const OutputSocketRef *> linked_sockets_to_check = socket_ref_->as_input().linked_sockets(); + if (follow_only_first_incoming_link) { + linked_sockets_to_check = linked_sockets_to_check.take_front(1); + } + for (const OutputSocketRef *linked_socket : linked_sockets_to_check) { const NodeRef &linked_node = linked_socket->node(); DOutputSocket linked_dsocket{context_, linked_socket}; @@ -180,7 +185,7 @@ void DInputSocket::foreach_origin_socket(FunctionRef<void(DSocket)> callback) co for (const InternalLinkRef *internal_link : linked_node.internal_links()) { if (&internal_link->to() == linked_socket) { DInputSocket input_of_muted_node{context_, &internal_link->from()}; - input_of_muted_node.foreach_origin_socket(callback); + input_of_muted_node.foreach_origin_socket(callback, true); } } } |