Nodes: Cut hidden links when creating node groups

Add a check to the creation of node groups to remove hidden links
that are connected to the outside of the node group. This avoids
creating sockets in the group's interface that aren't (visibly)
connected to anything within the node group.

Reviewed By: Jacques Lucke, Hans Goudey

Differential Revision: https://developer.blender.org/D14249
This commit is contained in:
Leon Schittek 2022-03-30 23:07:11 +02:00
parent 2670032038
commit 4edde244da
1 changed files with 12 additions and 0 deletions

View File

@ -841,6 +841,12 @@ static void node_group_make_insert_selected(const bContext &C, bNodeTree &ntree,
nodeRemLink(&ntree, link);
}
else if (toselect && !fromselect) {
/* Remove hidden links to not create unconnected sockets in the interface. */
if (nodeLinkIsHidden(link)){
nodeRemLink(&ntree, link);
continue;
}
bNodeSocket *link_sock;
bNode *link_node;
node_socket_skip_reroutes(&ntree.links, link->tonode, link->tosock, &link_node, &link_sock);
@ -861,6 +867,12 @@ static void node_group_make_insert_selected(const bContext &C, bNodeTree &ntree,
link->tosock = node_group_find_input_socket(gnode, iosock->identifier);
}
else if (fromselect && !toselect) {
/* Remove hidden links to not create unconnected sockets in the interface. */
if (nodeLinkIsHidden(link)){
nodeRemLink(&ntree, link);
continue;
}
/* First check whether the source of this link is already connected to an output.
* If yes, reuse that output instead of duplicating it. */
bool connected = false;