[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32497] branches/particles-2010/source/ blender: Removed the contexttype variable from bNodeSocket.

Lukas Toenne lukas.toenne at googlemail.com
Fri Oct 15 13:30:30 CEST 2010


Revision: 32497
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32497
Author:   lukastoenne
Date:     2010-10-15 13:30:29 +0200 (Fri, 15 Oct 2010)

Log Message:
-----------
Removed the contexttype variable from bNodeSocket. This was intended for at least partially checking matching contexts while building the node tree, but that does not work. To make the artists life a little easier with this, a better feedback and error reporting system should be devised instead, so bad context combinations can be detected when executing the tree.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/intern/node.c
    branches/particles-2010/source/blender/blenloader/intern/readfile.c
    branches/particles-2010/source/blender/blenloader/intern/writefile.c
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h
    branches/particles-2010/source/blender/nodes/intern/simulation/node_tree_simulation.c
    branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_get_data.c
    branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_set_data.c

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-10-15 10:47:22 UTC (rev 32496)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-10-15 11:30:29 UTC (rev 32497)
@@ -160,7 +160,6 @@
 	BLI_strncpy(sock->name, name, NODE_MAXSTR);
 	sock->limit = (is_input ? 1 : 0xFFF);
 	sock->type= type;
-	sock->contexttype = NULL;
 	sock->intern = 1;
 	if (type == SOCK_ANY)
 		sock->flag |= SOCK_ADAPT_TYPE;

Modified: branches/particles-2010/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/particles-2010/source/blender/blenloader/intern/readfile.c	2010-10-15 10:47:22 UTC (rev 32496)
+++ branches/particles-2010/source/blender/blenloader/intern/readfile.c	2010-10-15 11:30:29 UTC (rev 32497)
@@ -2180,23 +2180,11 @@
 		node->lasty= 0;
 		for(sock= node->inputs.first; sock; sock= sock->next) {
 			sock->link= newdataadr(fd, sock->link);
-			sock->contexttype_name= newdataadr(fd, (void*)sock->contexttype_name);
-			sock->contexttype = RNA_find_struct(sock->contexttype_name);
-			if (sock->contexttype_name) {
-				MEM_freeN((void*)sock->contexttype_name);
-				sock->contexttype_name = NULL;
-			}
 			sock->storage= newdataadr(fd, sock->storage);
 			sock->panel= newdataadr(fd, sock->panel);
 		}
 		for(sock= node->outputs.first; sock; sock= sock->next) {
 			sock->ns.data= NULL;
-			sock->contexttype_name= newdataadr(fd, (void*)sock->contexttype_name);
-			sock->contexttype = RNA_find_struct(sock->contexttype_name);
-			if (sock->contexttype_name) {
-				MEM_freeN((void*)sock->contexttype_name);
-				sock->contexttype_name = NULL;
-			}
 			sock->storage= newdataadr(fd, sock->storage);
 			sock->panel= newdataadr(fd, sock->panel);
 		}

Modified: branches/particles-2010/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/particles-2010/source/blender/blenloader/intern/writefile.c	2010-10-15 10:47:22 UTC (rev 32496)
+++ branches/particles-2010/source/blender/blenloader/intern/writefile.c	2010-10-15 11:30:29 UTC (rev 32497)
@@ -494,21 +494,11 @@
 	for(node= ntree->nodes.first; node; node= node->next) {
 		for(sock= node->inputs.first; sock; sock= sock->next) {
 			writestruct(wd, DATA, "bNodeSocket", 1, sock);
-			if (sock->contexttype) {
-				/* save identifier string, to allow restoring the StructRNA pointer */
-				sock->contexttype_name= RNA_struct_identifier(sock->contexttype);
-				writedata(wd, DATA, strlen(sock->contexttype_name)+1, (void*)sock->contexttype_name);
-			}
 			if (sock->storage)
 				writestruct(wd, DATA, node->typeinfo->socketstoragename, 1, sock->storage);
 		}
 		for(sock= node->outputs.first; sock; sock= sock->next) {
 			writestruct(wd, DATA, "bNodeSocket", 1, sock);
-			if (sock->contexttype) {
-				/* save identifier string, to allow restoring the StructRNA pointer */
-				sock->contexttype_name= RNA_struct_identifier(sock->contexttype);
-				writedata(wd, DATA, strlen(sock->contexttype_name)+1, (void*)sock->contexttype_name);
-			}
 			if (sock->storage)
 				writestruct(wd, DATA, node->typeinfo->socketstoragename, 1, sock->storage);
 		}

Modified: branches/particles-2010/source/blender/makesdna/DNA_node_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_node_types.h	2010-10-15 10:47:22 UTC (rev 32496)
+++ branches/particles-2010/source/blender/makesdna/DNA_node_types.h	2010-10-15 11:30:29 UTC (rev 32497)
@@ -102,9 +102,6 @@
 	/* internal data to retrieve relations and groups */
 	int own_index, to_index;	/* group socket identifiers, to find matching pairs after reading files */
 	
-	/* TODO contexttype is deprecated, remove */
-	struct StructRNA *contexttype;	/* data context type (simulation nodes) */
-	const char *contexttype_name;			/* temporary name string, only used during save/load! */
 	int island;					/* used during island calculation, for finding shared socket groups */
 	int pad2;
 	

Modified: branches/particles-2010/source/blender/nodes/intern/simulation/node_tree_simulation.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/simulation/node_tree_simulation.c	2010-10-15 10:47:22 UTC (rev 32496)
+++ branches/particles-2010/source/blender/nodes/intern/simulation/node_tree_simulation.c	2010-10-15 11:30:29 UTC (rev 32497)
@@ -280,93 +280,6 @@
 	}
 }
 
-static void resolve_input_contexts(bNode *node)
-{
-	bNodeSocket *sock;
-	
-	/* first get input contexts from links */
-	for (sock=node->inputs.first; sock; sock=sock->next) {
-		if ((sock->flag & SOCK_ADAPT_CONTEXT)!=0) {
-			/* propagate context along link (fromnode is fully resolved) */
-			if (sock->link && sock->link->fromsock) {
-				sock->contexttype = sock->link->fromsock->contexttype;
-			}
-			else if (sock->intern) {
-				/* socket uses default singleton data */
-				sock->contexttype = NULL;
-			}
-		}
-	}
-
-	if (node->type == NODE_GROUP) {
-		for (sock=node->inputs.first; sock; sock=sock->next)
-			if (sock->tosock && (sock->flag & SOCK_ADAPT_CONTEXT)!=0)
-				sock->tosock->contexttype = sock->contexttype;
-	}
-}
-
-static void resolve_output_contexts(bNode *node)
-{
-	bNodeSocket *sock;
-	
-	if (node->type == NODE_GROUP) {
-		/* internal nodes may be unresolvable and have reset the context, so we copy it back to the inputs */
-		for (sock=node->inputs.first; sock; sock=sock->next)
-			if (sock->tosock && (sock->flag & SOCK_ADAPT_CONTEXT)!=0)
-				sock->contexttype = sock->tosock->contexttype;
-		for (sock=node->outputs.first; sock; sock=sock->next)
-			if (sock->tosock && (sock->flag & SOCK_ADAPT_CONTEXT)!=0)
-				sock->contexttype = sock->tosock->contexttype;
-	}
-	else {
-		StructRNA *res= NULL;
-		for (sock=node->inputs.first; sock; sock=sock->next) {
-			if ((sock->flag & SOCK_ADAPT_CONTEXT)!=0) {
-				if (res == NULL) {
-					if (sock->contexttype != NULL)
-						res = sock->contexttype;
-				}
-				else if (sock->contexttype != NULL) {
-					if (RNA_struct_is_a(sock->contexttype, res)) {
-						res = sock->contexttype;
-					} else {
-						res = NULL;
-					}
-				}
-			}
-		}
-		
-		/* context unresolvable, reset all other inputs too */
-		if (res == NULL) {
-			for (sock=node->inputs.first; sock; sock=sock->next) {
-				if ((sock->flag & SOCK_ADAPT_CONTEXT)!=0) {
-					sock->contexttype = NULL;
-				}
-			}
-		}
-		for (sock=node->outputs.first; sock; sock=sock->next) {
-			if ((sock->flag & SOCK_ADAPT_CONTEXT)!=0) {
-				sock->contexttype = res;
-			}
-		}
-	}
-}
-
-static void resolve_socket_contexts_recursive(bNodeTree *ntree)
-{
-	bNode *node;
-	
-	/* nodes are assumed fully sorted, so context can be propagated from left to right */
-	for (node=ntree->nodes.first; node; node = node->next) {
-		resolve_input_contexts(node);
-		
-		if (node->type == NODE_GROUP && node->id)
-			resolve_socket_contexts_recursive((bNodeTree*)node->id);
-		
-		resolve_output_contexts(node);
-	}
-}
-
 #if 0
 static void ntree_clear_tag_recursive(bNodeTree *ntree)
 {
@@ -1276,12 +1189,11 @@
 	
 	ntreeSolveNodeOrder(ntree);
 
-	/* Note: The resolve functions access lower-level trees.
+	/* Note: The resolve function accesses lower-level trees.
 	 * They have to be recalculated for each tree up in the hierarchy,
 	 * because the result on higher levels may differ from local level result.
 	 */
 	resolve_socket_types(ntree);
-	resolve_socket_contexts_recursive(ntree);
 
 	ntreeValidateLinks(ntree);
 	

Modified: branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_get_data.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_get_data.c	2010-10-15 10:47:22 UTC (rev 32496)
+++ branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_get_data.c	2010-10-15 11:30:29 UTC (rev 32497)
@@ -58,30 +58,20 @@
 	if (type == data->type)
 		return;
 	
-	/* TODO check type validity */
-	data->type = type;
-	
-	/* check existing property sockets for compatibility and remove if necessary */
-	/* TODO this is just a quick and simple way for now: remove all property sockets that do not match exactly */
-	sock=node->outputs.first;
-	/* first socket is data path, do not remove! */
-	sock = sock->next;
-	while (sock) {
-		next = sock->next;
-		if (RNA_struct_is_a(type, sock->contexttype))
-			sock->contexttype = type;
-		else
+	if (!RNA_struct_is_a(type, data->type)) {
+		/* remove property sockets */
+		sock=node->outputs.first;
+		/* first socket is data path, do not remove! */
+		sock = sock->next;
+		while (sock) {
+			next = sock->next;
 			nodeRemoveOutputSocket(ntree, node, sock);
-		sock = next;
+			sock = next;
+		}
 	}
 	
-	/* now set the context type to all remaining property sockets */
-	sock=node->outputs.first;
-	sock = sock->next;
-	while (sock) {
-		sock->contexttype = type;
-		sock = sock->next;
-	}
+	/* TODO check type validity */
+	data->type = type;
 }
 
 int simnode_getdata_property_valid(bNode *node, PropertyRNA *prop)
@@ -101,7 +91,6 @@
 void simnode_getdata_add_rna_socket(bNode *node, PropertyRNA *prop)
 {
 	if (simnode_getdata_property_valid(node, prop)) {
-		NodeRNAData *stor= (NodeRNAData*)node->storage;
 		bNodeSocket *sock;
 		const char *name= RNA_property_ui_name(prop);
 		int type;
@@ -113,7 +102,6 @@
 		sim_rna_socket_set_defaults(prop, sock);
 		/* disable context adaptation and set the context type */
 		sock->flag &= ~SOCK_ADAPT_CONTEXT;
-		sock->contexttype = stor->type;
 		/* associate with the property */
 		((NodeSocketProperty*)sock->storage)->prop = prop;
 	}

Modified: branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_set_data.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_set_data.c	2010-10-15 10:47:22 UTC (rev 32496)
+++ branches/particles-2010/source/blender/nodes/intern/simulation/nodes/SIM_set_data.c	2010-10-15 11:30:29 UTC (rev 32497)
@@ -63,27 +63,17 @@
 	/* TODO check type validity */
 	data->type = type;
 	
-	/* check existing property sockets for compatibility and remove if necessary */

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list