Fix for the default internal connect function for nodes (used in muting, detaching, etc.). This is supposed to look for the first input/output of every socket type, but was actually taking the first matching link from the link list, regardless of the linked socket's position.
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
* \ingroup nodes
|
||||
*/
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
#include "DNA_action_types.h"
|
||||
#include "DNA_node_types.h"
|
||||
@@ -116,24 +117,41 @@ ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node)
|
||||
return ret;
|
||||
|
||||
for (datatype=0; datatype < NUM_SOCKET_TYPES; ++datatype) {
|
||||
bNodeSocket *fromsock=NULL, *tosock=NULL;
|
||||
bNodeSocket *fromsock, *tosock;
|
||||
int fromindex, toindex;
|
||||
bNodeLink *link;
|
||||
|
||||
/* Connect the first input of each type with outputs of the same type. */
|
||||
|
||||
fromindex = INT_MAX;
|
||||
fromsock = NULL;
|
||||
for (link=ntree->links.first; link; link=link->next) {
|
||||
if (link->tonode == node && link->tosock->type == datatype) {
|
||||
int index = BLI_findindex(&node->inputs, link->tosock);
|
||||
if (index < fromindex) {
|
||||
fromindex = index;
|
||||
fromsock = link->tosock;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fromsock) {
|
||||
++num_links_in;
|
||||
if (!fromsock_first)
|
||||
fromsock_first = fromsock;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
toindex = INT_MAX;
|
||||
tosock = NULL;
|
||||
for (link=ntree->links.first; link; link=link->next) {
|
||||
if (link->fromnode == node && link->fromsock->type == datatype) {
|
||||
int index = BLI_findindex(&node->outputs, link->fromsock);
|
||||
if (index < toindex) {
|
||||
toindex = index;
|
||||
tosock = link->fromsock;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (tosock) {
|
||||
++num_links_out;
|
||||
if (!tosock_first)
|
||||
tosock_first = tosock;
|
||||
@@ -152,7 +170,6 @@ ListBase node_internal_connect_default(bNodeTree *ntree, bNode *node)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if there is one input and one output link, but no reconnections by type,
|
||||
* simply connect those two sockets.
|
||||
|
||||
Reference in New Issue
Block a user