[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19771] trunk/blender/source/blender: bugfix #18287

Ton Roosendaal ton at blender.org
Fri Apr 17 12:38:10 CEST 2009


Revision: 19771
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19771
Author:   ton
Date:     2009-04-17 12:38:10 +0200 (Fri, 17 Apr 2009)

Log Message:
-----------
bugfix #18287

Texture nodes hang when nodes have a cyclic case.

Added a (temp?) provision to tag node->need_exec zero for cyclic
nodes, and added check for this in texture nodes. 
There was also a bug in 'tag changed' for texture nodes, which not
only tagged, but also called the tree exec (should not happen!).

In general the texture exec needs recode; it doesn't use the stacks
as provided per node, but recurses itself to previous nodes, giving
problems like this. Node execs should only do their own bizz, the
node system handles dependency and eval order nicely already.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/node.c
    trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_texture.c
    trunk/blender/source/blender/nodes/intern/TEX_util.c

Modified: trunk/blender/source/blender/blenkernel/intern/node.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/node.c	2009-04-17 10:34:09 UTC (rev 19770)
+++ trunk/blender/source/blender/blenkernel/intern/node.c	2009-04-17 10:38:10 UTC (rev 19771)
@@ -1644,7 +1644,8 @@
 		might be different for editor or for "real" use... */
 }
 
-/* should be callback! */
+/* Should be callback! */
+/* Do not call execs here */
 void NodeTagChanged(bNodeTree *ntree, bNode *node)
 {
 	if(ntree->type==NTREE_COMPOSIT) {
@@ -1664,8 +1665,6 @@
 		}
 		node->need_exec= 1;
 	}
-	else if(ntree->type == NTREE_TEXTURE)
-		ntreeTexUpdatePreviews(ntree);
 }
 
 void NodeTagIDChanged(bNodeTree *ntree, ID *id)
@@ -2067,6 +2066,11 @@
 		/* tag used outputs, so we know when we can skip operations */
 		for(node= ntree->nodes.first; node; node= node->next) {
 			bNodeSocket *sock;
+			
+			/* composite has own need_exec tag handling */
+			if(ntree->type!=NTREE_COMPOSIT)
+				node->need_exec= 1;
+
 			for(sock= node->inputs.first; sock; sock= sock->next) {
 				if(sock->link) {
 					ns= ntree->stack + sock->link->fromsock->stack_index;
@@ -2075,9 +2079,22 @@
 				}
 				else
 					sock->ns.sockettype= sock->type;
+				
+				if(sock->link) {
+					bNodeLink *link= sock->link;
+					/* this is the test for a cyclic case */
+					if(link->fromnode && link->tonode) {
+						if(link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF);
+						else {
+							node->need_exec= 0;
+						}
+					}
+				}
 			}
+			
 			if(node->type==NODE_GROUP && node->id)
 				group_tag_used_outputs(node, ntree->stack);
+			
 		}
 		
 		if(ntree->type==NTREE_COMPOSIT)
@@ -2160,14 +2177,16 @@
 	}
 	
 	for(node= ntree->nodes.first; node; node= node->next) {
-		if(node->typeinfo->execfunc) {
-			node_get_stack(node, stack, nsin, nsout);
-			node->typeinfo->execfunc(callerdata, node, nsin, nsout);
+		if(node->need_exec) {
+			if(node->typeinfo->execfunc) {
+				node_get_stack(node, stack, nsin, nsout);
+				node->typeinfo->execfunc(callerdata, node, nsin, nsout);
+			}
+			else if(node->type==NODE_GROUP && node->id) {
+				node_get_stack(node, stack, nsin, nsout);
+				node_group_execute(stack, callerdata, node, nsin, nsout); 
+			}
 		}
-		else if(node->type==NODE_GROUP && node->id) {
-			node_get_stack(node, stack, nsin, nsout);
-			node_group_execute(stack, callerdata, node, nsin, nsout); 
-		}
 	}
 
 	if(nts)

Modified: trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_texture.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_texture.c	2009-04-17 10:34:09 UTC (rev 19770)
+++ trunk/blender/source/blender/nodes/intern/TEX_nodes/TEX_texture.c	2009-04-17 10:38:10 UTC (rev 19771)
@@ -47,7 +47,7 @@
 	
 	Tex *nodetex = (Tex *)node->id;
 	
-	if(node->custom2) {
+	if(node->custom2 || node->need_exec==0) {
 		/* this node refers to its own texture tree! */
 		QUATCOPY(
 			out,

Modified: trunk/blender/source/blender/nodes/intern/TEX_util.c
===================================================================
--- trunk/blender/source/blender/nodes/intern/TEX_util.c	2009-04-17 10:34:09 UTC (rev 19770)
+++ trunk/blender/source/blender/nodes/intern/TEX_util.c	2009-04-17 10:38:10 UTC (rev 19771)
@@ -34,6 +34,12 @@
 	obtain a colour value from this, a node further up the chain reads
 	the TexDelegate* from its input stack, and uses tex_call_delegate to
 	retrieve the colour from the delegate.
+ 
+    comments: (ton)
+    
+    This system needs recode, a node system should rely on the stack, and 
+	callbacks for nodes only should evaluate own node, not recursively go
+    over other previous ones.
 */
 
 #include <assert.h>
@@ -43,7 +49,8 @@
 
 void tex_call_delegate(TexDelegate *dg, float *out, float *coord, short thread)
 {
-	dg->fn(out, coord, dg->node, dg->in, thread);
+	if(dg->node->need_exec)
+		dg->fn(out, coord, dg->node, dg->in, thread);
 }
 
 void tex_input(float *out, int sz, bNodeStack *in, float *coord, short thread)





More information about the Bf-blender-cvs mailing list