[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [51584] trunk/blender/source/blender/nodes /intern: Fix #32835, Reroute node on shading nodes connection gives wrong renders.

Lukas Toenne lukas.toenne at googlemail.com
Wed Oct 24 14:57:48 CEST 2012


Revision: 51584
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=51584
Author:   lukastoenne
Date:     2012-10-24 12:57:48 +0000 (Wed, 24 Oct 2012)
Log Message:
-----------
Fix #32835, Reroute node on shading nodes connection gives wrong renders.

Problem here is that muted nodes and reroute nodes are supposed to be removed from the execution node tree during the localize function. However, this is function is apparently only used during preview renders and must be considered a hack (is there anything that is not a hack in BI?)

Now the mute/reroute check happens in the node tree exec functions still used by BI and the legacy compositor and texture nodes. It uses the same internal_connect function from nodes to assign input stack indices directly to outputs (which also avoids overhead). Localize function also still does this. Cycles/Tile should also implement muting/reroute in their intermediate node layers by using this function, then it could be removed from localize too.

Modified Paths:
--------------
    trunk/blender/source/blender/nodes/intern/node_exec.c
    trunk/blender/source/blender/nodes/intern/node_exec.h

Modified: trunk/blender/source/blender/nodes/intern/node_exec.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/node_exec.c	2012-10-24 11:53:48 UTC (rev 51583)
+++ trunk/blender/source/blender/nodes/intern/node_exec.c	2012-10-24 12:57:48 UTC (rev 51584)
@@ -69,7 +69,7 @@
 	}
 }
 
-void node_init_input_index(bNodeSocket *sock, int *index)
+static void node_init_input_index(bNodeSocket *sock, int *index)
 {
 	if (sock->link && sock->link->fromsock) {
 		sock->stack_index = sock->link->fromsock->stack_index;
@@ -79,9 +79,24 @@
 	}
 }
 
-void node_init_output_index(bNodeSocket *sock, int *index)
+static void node_init_output_index(bNodeSocket *sock, int *index, ListBase *internal_links)
 {
-	sock->stack_index = (*index)++;
+	if (internal_links) {
+		bNodeLink *link;
+		/* copy the stack index from internally connected input to skip the node */
+		for (link = internal_links->first; link; link = link->next) {
+			if (link->tosock == sock) {
+				sock->stack_index = link->fromsock->stack_index;
+				break;
+			}
+		}
+		/* if not internally connected, assign a new stack index anyway to avoid bad stack access */
+		if (!link)
+			sock->stack_index = (*index)++;
+	}
+	else {
+		sock->stack_index = (*index)++;
+	}
 }
 
 /* basic preparation of socket stacks */
@@ -133,7 +148,7 @@
 	bNodeExec *nodeexec;
 	bNodeSocket *sock, *gsock;
 	bNodeStack *ns;
-	int index= 0;
+	int index;
 	bNode **nodelist;
 	int totnodes, n;
 	
@@ -148,10 +163,11 @@
 	/* backpointer to node tree */
 	exec->nodetree = ntree;
 	
+	/* set stack indices */
+	index = 0;
 	/* group inputs essentially work as outputs */
 	for (gsock=ntree->inputs.first; gsock; gsock = gsock->next)
-		node_init_output_index(gsock, &index);
-	/* set stack indexes */
+		node_init_output_index(gsock, &index, NULL);
 	for (n=0; n < totnodes; ++n) {
 		node = nodelist[n];
 		
@@ -160,8 +176,21 @@
 		/* init node socket stack indexes */
 		for (sock=node->inputs.first; sock; sock=sock->next)
 			node_init_input_index(sock, &index);
-		for (sock=node->outputs.first; sock; sock=sock->next)
-			node_init_output_index(sock, &index);
+		
+		if ((node->flag & NODE_MUTED || node->type == NODE_REROUTE)
+			&& node->typeinfo->internal_connect) {
+			
+			ListBase internal_links = node->typeinfo->internal_connect(ntree, node);
+			
+			for (sock=node->outputs.first; sock; sock=sock->next)
+				node_init_output_index(sock, &index, &internal_links);
+			
+			BLI_freelistN(&internal_links);
+		}
+		else {
+			for (sock=node->outputs.first; sock; sock=sock->next)
+				node_init_output_index(sock, &index, NULL);
+		}
 	}
 	/* group outputs essentially work as inputs */
 	for (gsock=ntree->outputs.first; gsock; gsock = gsock->next)

Modified: trunk/blender/source/blender/nodes/intern/node_exec.h
===================================================================
--- trunk/blender/source/blender/nodes/intern/node_exec.h	2012-10-24 11:53:48 UTC (rev 51583)
+++ trunk/blender/source/blender/nodes/intern/node_exec.h	2012-10-24 12:57:48 UTC (rev 51584)
@@ -73,8 +73,6 @@
 
 struct bNodeStack *node_get_socket_stack(struct bNodeStack *stack, struct bNodeSocket *sock);
 void node_get_stack(struct bNode *node, struct bNodeStack *stack, struct bNodeStack **in, struct bNodeStack **out);
-void node_init_input_index(struct bNodeSocket *sock, int *index);
-void node_init_output_index(struct bNodeSocket *sock, int *index);
 
 struct bNodeTreeExec *ntree_exec_begin(struct bNodeTree *ntree);
 void ntree_exec_end(struct bNodeTreeExec *exec);




More information about the Bf-blender-cvs mailing list