From 37570a73170e6cddc32ed0523b626bf0857cf068 Mon Sep 17 00:00:00 2001 From: Fabian Schempp Date: Thu, 13 May 2021 23:05:38 +0200 Subject: Fix T87360 Multi input links aren't placed correctly when created with python link->multi_input_socket_index, which is used to calculate the links position on the multi-input socket, was not set. Now it is set to the sockets current link count. Review: Jacques Lucke (JacquesLucke) Differential Revision: https://developer.blender.org/D11082 --- source/blender/blenkernel/intern/node.cc | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'source') diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 02195e0d60f..cf5f7163c17 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -2172,6 +2172,17 @@ bNodeTree *ntreeCopyTree_ex_new_pointers(const bNodeTree *ntree, return new_ntree; } +static int node_count_links(const bNodeTree *ntree, const bNodeSocket *socket) +{ + int count = 0; + LISTBASE_FOREACH (bNodeLink *, link, &ntree->links) { + if (ELEM(socket, link->fromsock, link->tosock)) { + count++; + } + } + return count; +} + /* also used via rna api, so we check for proper input output direction */ bNodeLink *nodeAddLink( bNodeTree *ntree, bNode *fromnode, bNodeSocket *fromsock, bNode *tonode, bNodeSocket *tosock) @@ -2208,6 +2219,10 @@ bNodeLink *nodeAddLink( ntree->update |= NTREE_UPDATE_LINKS; } + if(link->tosock->flag & SOCK_MULTI_INPUT){ + link->multi_input_socket_index = node_count_links(ntree,link->tosock) - 1; + } + return link; } -- cgit v1.2.3