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.
This commit is contained in:
Jacques Lucke
2021-03-09 21:20:33 +01:00
parent 7d827d0e9e
commit 90520026e9
2 changed files with 10 additions and 4 deletions

View File

@@ -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. */

View File

@@ -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);
}
}
}