Fix #108336: Treat node sockets with muted links as linked

Prevent make links operator from creating links to sockets that are
already linked to a muted link.

The `SOCK_IS_LINKED` flag is used to check if there already is a link
connecting to the socket but when the link is muted, the flag wasn't set
leading to issues in parts of the code that used the flag to check
for any type of connected link.
This commit now also sets `SOCK_IS_LINKED` when links are muted and
adds an additional check in places where different behavior is expected
for muted links.

Pull Request: https://projects.blender.org/blender/blender/pulls/108375
This commit is contained in:
Leon Schittek
2023-06-03 12:34:58 +02:00
committed by Leon Schittek
parent cc9c720aae
commit 2ce5fc4a3e
3 changed files with 6 additions and 10 deletions

View File

@@ -527,13 +527,8 @@ class NodeTreeMainUpdater {
{
tree.ensure_topology_cache();
for (bNodeSocket *socket : tree.all_sockets()) {
socket->flag &= ~SOCK_IS_LINKED;
for (const bNodeLink *link : socket->directly_linked_links()) {
if (!link->is_muted()) {
socket->flag |= SOCK_IS_LINKED;
break;
}
}
const bool socket_is_linked = !socket->directly_linked_links().is_empty();
SET_FLAG_FROM_TEST(socket->flag, socket_is_linked, SOCK_IS_LINKED);
}
}

View File

@@ -1295,8 +1295,9 @@ static void std_node_socket_draw(
return;
}
if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_IS_LINKED) ||
(sock->flag & SOCK_HIDE_VALUE)) {
if ((sock->in_out == SOCK_OUT) || (sock->flag & SOCK_HIDE_VALUE) ||
((sock->flag & SOCK_IS_LINKED) && !(sock->link->is_muted())))
{
node_socket_button_label(C, layout, ptr, node_ptr, text);
return;
}

View File

@@ -1098,7 +1098,7 @@ void node_set_hidden_sockets(SpaceNode *snode, bNode *node, int set)
}
}
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
if (nodeCountSocketLinks(snode->edittree, sock) == 0) {
if ((sock->flag & SOCK_IS_LINKED) == 0) {
sock->flag |= SOCK_HIDDEN;
}
}