From 90520026e9cedfd080c649ae0d954a0d68e1c51a Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Tue, 9 Mar 2021 21:20:33 +0100 Subject: Fix: only follow first input of multi-input-socket when muted Otherwise muting a Join Geometry node has no effect, when there are multiple Join Geometry nodes in a row. --- source/blender/nodes/NOD_derived_node_tree.hh | 3 ++- source/blender/nodes/intern/derived_node_tree.cc | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'source/blender') 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 get_corresponding_group_input_sockets() const; - void foreach_origin_socket(FunctionRef callback) const; + void foreach_origin_socket(FunctionRef 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 callback) const +void DInputSocket::foreach_origin_socket(FunctionRef callback, + const bool follow_only_first_incoming_link) const { BLI_assert(*this); - for (const OutputSocketRef *linked_socket : socket_ref_->as_input().linked_sockets()) { + Span 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 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); } } } -- cgit v1.2.3