[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13274] branches/pynodes/source/blender/ nodes/intern/SHD_nodes/SHD_dynamic.c: Small update to support loading dynamic nodes from .blend files.

Willian Padovani Germano wpgermano at gmail.com
Thu Jan 17 18:45:20 CET 2008


Revision: 13274
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13274
Author:   ianwill
Date:     2008-01-17 18:45:20 +0100 (Thu, 17 Jan 2008)

Log Message:
-----------
Small update to support loading dynamic nodes from .blend files. Still missing: preserve links (instead of deleting them) when dynamic nodes are updated (via the update button); more testing.

Modified Paths:
--------------
    branches/pynodes/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c

Modified: branches/pynodes/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
===================================================================
--- branches/pynodes/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c	2008-01-17 17:15:44 UTC (rev 13273)
+++ branches/pynodes/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c	2008-01-17 17:45:20 UTC (rev 13274)
@@ -189,9 +189,11 @@
 	 * ERROR
 	 */
 
-	/* NEW, but not linked to a script, nothing to do here */
-	if (!node->id)
+	/* NEW, but not linked to a script: link default (empty) typeinfo */
+	if (!node->id) {
+		node->typeinfo = node_dynamic_find_typeinfo(&node_all_shaders, NULL);
 		return;
+	}
 
 	/* READY, no need to be here */
 	if (BTST(node->custom1, NODE_DYNAMIC_READY))
@@ -225,7 +227,7 @@
 	node->storage = nsd;
 	
 	/* NEW, but the user already linked it to a script */
-	if (BTST(node->custom1, NODE_DYNAMIC_NEW)) {
+	if (BTST2(node->custom1, NODE_DYNAMIC_NEW, NODE_DYNAMIC_LOADED)) {
 		/* check if there's already a bNodeType linked to this script */
 		/* (XXX hardcoded for shader nodes for now) */
 		ntype = node_dynamic_find_typeinfo(&node_all_shaders, node->id);
@@ -268,9 +270,8 @@
 
 	node->custom2 = 0;
 
-	/* XXX testing if type can be < NODE_DYNAMIC_MENU ? */
-	if (type < NODE_DYNAMIC_MENU)
-		printf("\nTYPE < NODE_DYNAMIC_MENU: %d\n", type);
+	/* note: type can be < NODE_DYNAMIC_MENU:
+	 * it is 0 for loaded empty pynodes */
 
 	if (type >= NODE_DYNAMIC_MENU) {
 		node->custom1 = 0;
@@ -284,8 +285,7 @@
 		node->id = node->typeinfo->id;
 	}
 
-	if (node->id)
-		node_dynamic_setup(node);
+	node_dynamic_setup(node);
 }
 
 static void node_dynamic_copy(bNode *orig_node, bNode *new_node)
@@ -332,7 +332,6 @@
 		return;
 	}
 
-	/* XXX NODE_DYNAMIC_UPDATED: unused? remove? */
 	if(BTST2(node->custom1, NODE_DYNAMIC_READY, NODE_DYNAMIC_UPDATED)) {
 		if(BTST(node->custom1,NODE_DYNAMIC_UPDATED)) {
 			node->custom1= BCLR(node->custom1,NODE_DYNAMIC_UPDATED);





More information about the Bf-blender-cvs mailing list