Fix T97002: Preserve multi socket link order

Preserve multi socket link order when copying nodes or adding a new
group input sockets by linking directly to multi inputs from the group
input node's extension socket.

This is done by also copying the `multi_input_socket_index` when
the new links are created by copying existing or temporary links.

Reviewed By: Hans Goudey

Differential Revision: http://developer.blender.org/D14535
This commit is contained in:
Leon Schittek
2022-04-18 22:28:03 +02:00
parent 314b27850c
commit 03d39a04a3
2 changed files with 9 additions and 1 deletions

View File

@@ -1306,6 +1306,11 @@ static int node_duplicate_exec(bContext *C, wmOperator *op)
newlink->flag = link->flag;
newlink->tonode = node_map.lookup(link->tonode);
newlink->tosock = socket_map.lookup(link->tosock);
if (link->tosock->flag & SOCK_MULTI_INPUT) {
newlink->multi_input_socket_index = link->multi_input_socket_index;
}
if (link->fromnode && (link->fromnode->flag & NODE_SELECT)) {
newlink->fromnode = node_map.lookup(link->fromnode);
newlink->fromsock = socket_map.lookup(link->fromsock);

View File

@@ -476,7 +476,10 @@ void node_group_input_update(bNodeTree *ntree, bNode *node)
/* redirect links from the extension socket */
for (link = (bNodeLink *)tmplinks.first; link; link = link->next) {
nodeAddLink(ntree, node, newsock, link->tonode, link->tosock);
bNodeLink *newlink = nodeAddLink(ntree, node, newsock, link->tonode, link->tosock);
if (newlink->tosock->flag & SOCK_MULTI_INPUT) {
newlink->multi_input_socket_index = link->multi_input_socket_index;
}
}
}