[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [49730] trunk/blender/source/blender/nodes /intern/node_util.c: Fix for the default internal connect function for nodes (used in muting, detaching, etc.).
Lukas Toenne
lukas.toenne at googlemail.com
Thu Aug 9 13:45:54 CEST 2012
Revision: 49730
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=49730
Author: lukastoenne
Date: 2012-08-09 11:45:54 +0000 (Thu, 09 Aug 2012)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/nodes/intern/node_util.c
Modified: trunk/blender/source/blender/nodes/intern/node_util.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/node_util.c 2012-08-09 09:36:53 UTC (rev 49729)
+++ trunk/blender/source/blender/nodes/intern/node_util.c 2012-08-09 11:45:54 UTC (rev 49730)
@@ -29,6 +29,7 @@
* \ingroup nodes
*/
+#include <limits.h>
#include "DNA_action_types.h"
#include "DNA_node_types.h"
@@ -116,42 +117,58 @@
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) {
- fromsock = link->tosock;
- ++num_links_in;
- if (!fromsock_first)
- fromsock_first = fromsock;
- break;
+ 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;
+ }
+ toindex = INT_MAX;
+ tosock = NULL;
for (link=ntree->links.first; link; link=link->next) {
if (link->fromnode == node && link->fromsock->type == datatype) {
- tosock = link->fromsock;
- ++num_links_out;
- if (!tosock_first)
- tosock_first = tosock;
-
- if (fromsock) {
- bNodeLink *ilink = MEM_callocN(sizeof(bNodeLink), "internal node link");
- ilink->fromnode = node;
- ilink->fromsock = fromsock;
- ilink->tonode = node;
- ilink->tosock = tosock;
- /* internal link is always valid */
- ilink->flag |= NODE_LINK_VALID;
- BLI_addtail(&ret, ilink);
-
- ++num_reconnect;
+ 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;
+
+ if (fromsock) {
+ bNodeLink *ilink = MEM_callocN(sizeof(bNodeLink), "internal node link");
+ ilink->fromnode = node;
+ ilink->fromsock = fromsock;
+ ilink->tonode = node;
+ ilink->tosock = tosock;
+ /* internal link is always valid */
+ ilink->flag |= NODE_LINK_VALID;
+ BLI_addtail(&ret, ilink);
+
+ ++num_reconnect;
+ }
+ }
}
/* if there is one input and one output link, but no reconnections by type,
More information about the Bf-blender-cvs
mailing list