[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13356] branches/pynodes/source/blender: Small addition: pressing any pynode's "update" button will make all pynodes that share the related script be updated, too .

Willian Padovani Germano wpgermano at gmail.com
Tue Jan 22 20:55:51 CET 2008


Revision: 13356
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13356
Author:   ianwill
Date:     2008-01-22 20:55:51 +0100 (Tue, 22 Jan 2008)

Log Message:
-----------
Small addition: pressing any pynode's "update" button will make all pynodes that share the related script be updated, too.

Modified Paths:
--------------
    branches/pynodes/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c
    branches/pynodes/source/blender/src/drawnode.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-22 19:46:47 UTC (rev 13355)
+++ branches/pynodes/source/blender/nodes/intern/SHD_nodes/SHD_dynamic.c	2008-01-22 19:55:51 UTC (rev 13356)
@@ -117,17 +117,14 @@
 	BLI_freelistN(&node->outputs);
 }
 
-/* XXX for now we just remove the socket links */
+/* For now we just remove the socket links. It's the safest
+ * route, since an update in the script may change completely the
+ * inputs and outputs. Trying to recreate the node links would be
+ * nicer for pynode authors, though. */
 static void node_dynamic_update_socket_links(bNode *node)
 {
 	Material *ma;
-/*
-	for (ma = G.main->mat.first; ma; ma = ma->id.next) {
-		if (ma->nodetree) {
-			bNode *node;
-		}
-	}
-	*/
+
 	ma = give_current_material(OBACT, OBACT->actcol);
 	if (ma && ma->nodetree)
 		nodeVerifyType(ma->nodetree, node);
@@ -159,7 +156,6 @@
 {
 	node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_LOADED);
 	node->custom1 = BCLR(node->custom1, NODE_DYNAMIC_ADDEXIST);
-	//node->custom1 = BSET(node->custom1, NODE_DYNAMIC_NEW);
 	node->custom1 = BSET(node->custom1, NODE_DYNAMIC_ERROR);
 
 	node_dynamic_free_typeinfo_sockets(node);
@@ -182,11 +178,12 @@
 	bNodeType *ntype = NULL;
 
 	/* Possible cases:
-	 * READY
 	 * NEW
 	 * ADDEXIST
 	 * LOADED
+	 * REPARSE
 	 * ERROR
+	 * READY
 	 */
 
 	/* NEW, but not linked to a script: link default (empty) typeinfo */
@@ -303,15 +300,6 @@
 		Py_INCREF((PyObject *)(nsd->dict));
 }
 
-/* When a pynode is updated (REPARSE) we also update all other
- * pynodes that use the same script (same typeinfo) or not?
- * still undecided, gotta test well first */
-/*static void node_dynamic_update_script_links(ID *id)
-{
-	return;
-}
-*/
-
 static void node_dynamic_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) {
 	BPy_Node *mynode = NULL;
 	NodeScriptDict *nsd = NULL;
@@ -393,7 +381,8 @@
 	if (!pyresult) {
 		node_dynamic_pyerror_print(node);
 		node_dynamic_disable(node);
-		/* invalid typeinfo, get rid of it and link to default (empty) one */
+		/* invalid typeinfo:
+		 * get rid of it and link to default (empty) one */
 		node_dynamic_free_typeinfo(node);
 		node->typeinfo = node_dynamic_find_typeinfo(&node_all_shaders, NULL);
 		return;

Modified: branches/pynodes/source/blender/src/drawnode.c
===================================================================
--- branches/pynodes/source/blender/src/drawnode.c	2008-01-22 19:46:47 UTC (rev 13355)
+++ branches/pynodes/source/blender/src/drawnode.c	2008-01-22 19:55:51 UTC (rev 13356)
@@ -432,27 +432,30 @@
 
 static void node_dynamic_update_cb(void *ntree_v, void *node_v)
 {
+	Material *ma;
 	bNode *node= (bNode *)node_v;
-	/*bNodeTree *ntree= (bNodeTree *)ntree_v;*/
-	int error = 0;
+	ID *id= node->id;
+	int error= 0;
 
-	if (BTST(node->custom1, NODE_DYNAMIC_ERROR)) error = 1;
+	if (BTST(node->custom1, NODE_DYNAMIC_ERROR)) error= 1;
 
-	node->custom1= 0;
-	node->custom1= BSET(node->custom1, NODE_DYNAMIC_REPARSE);
+	/* Users only have to press the "update" button in one pynode
+	 * and we also update all others sharing the same script */
+	for (ma= G.main->mat.first; ma; ma= ma->id.next) {
+		if (ma->nodetree) {
+			bNode *nd;
+			for (nd= ma->nodetree->nodes.first; nd; nd= nd->next) {
+				if ((nd->type == NODE_DYNAMIC) && (nd->id == id)) {
+					nd->custom1= 0;
+					nd->custom1= BSET(nd->custom1, NODE_DYNAMIC_REPARSE);
+					nd->menunr= 0;
+					if (error)
+						nd->custom1= BSET(nd->custom1, NODE_DYNAMIC_ERROR);
+				}
+			}
+		}
+	}
 
-	if (error)
-		node->custom1= BSET(node->custom1, NODE_DYNAMIC_ERROR);
-
-	/*nodeDynamicParse(node);
-	if(node->custom1== SH_NODE_DYNAMIC_CREATED)
-		nodeAddSockets(node, node->typeinfo);
-	else if(node->custom1== SH_NODE_DYNAMIC_UPDATED)
-		printf("we should update node with new typeinfo\n");*/
-
-	/*node->custom1= SH_NODE_DYNAMIC_READY;*/
-	node->menunr= 0;
-
 	allqueue(REDRAWBUTSSHADING, 0);
 	allqueue(REDRAWNODE, 0);
 }





More information about the Bf-blender-cvs mailing list