[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31638] branches/particles-2010/source/ blender: Moved update call of data nodes types to the string set function, to allow it to check validity (when implemented) and cancel if the type is not usable.

Lukas Toenne lukas.toenne at googlemail.com
Sun Aug 29 08:07:04 CEST 2010


Revision: 31638
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31638
Author:   lukastoenne
Date:     2010-08-29 08:07:04 +0200 (Sun, 29 Aug 2010)

Log Message:
-----------
Moved update call of data nodes types to the string set function, to allow it to check validity (when implemented) and cancel if the type is not usable.
Added call of NodeTagUpdated to the generic rna update function for nodes, so the customized update functions for tree/nodes can be used when node options or socket defaults change.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/BKE_node.h
    branches/particles-2010/source/blender/editors/space_node/node_draw.c
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c
    branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-08-29 04:48:00 UTC (rev 31637)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-08-29 06:07:04 UTC (rev 31638)
@@ -52,6 +52,7 @@
 struct ListBase;
 struct Main;
 struct MTex;
+struct StructRNA;
 struct PointerRNA;
 struct PropertyRNA;
 struct rctf;
@@ -556,7 +557,7 @@
 /* API */
 void ntreeSimulationExecTree(struct SimulationContext *sim);
 
-void sim_node_update_datatype(struct bNodeTree *ntree, struct bNode *node);
+void sim_datanode_set_type(struct bNodeTree *ntree, struct bNode *node, struct StructRNA *type);
 struct StructRNA *sim_node_get_datatype(struct bNode *node);
 void sim_node_add_rna_socket(struct bNode *node, struct PropertyRNA *prop);
 int sim_node_convert_rna_property(struct PropertyRNA *prop);

Modified: branches/particles-2010/source/blender/editors/space_node/node_draw.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_draw.c	2010-08-29 04:48:00 UTC (rev 31637)
+++ branches/particles-2010/source/blender/editors/space_node/node_draw.c	2010-08-29 06:07:04 UTC (rev 31638)
@@ -96,6 +96,8 @@
 		WM_main_add_notifier(NC_TEXTURE|ND_NODES, id);
 	}
 	else if(treetype==NTREE_SIMULATION) {
+		NodeTagChanged(edittree, node);
+		
 		DAG_id_flush_update(id, 0);
 		WM_main_add_notifier(NC_OBJECT|ND_NODES, id);
 	}

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c	2010-08-29 04:48:00 UTC (rev 31637)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c	2010-08-29 06:07:04 UTC (rev 31638)
@@ -312,7 +312,8 @@
 	rna_Node_update(bmain, scene, ptr);
 }
 
-static void rna_Node_simdata_update_type(Main *bmain, Scene *scene, PointerRNA *ptr)
+#if 0
+static void rna_Node_simdata_update_typename(Main *bmain, Scene *scene, PointerRNA *ptr)
 {
 	bNodeTree *ntree= (bNodeTree*)ptr->id.data;
 	bNode *node= (bNode*)ptr->data;
@@ -321,6 +322,7 @@
 	
 	node_update(bmain, scene, ntree, node);
 }
+#endif
 
 static EnumPropertyItem *renderresult_layers_add_enum(RenderLayer *rl)
 {
@@ -449,14 +451,12 @@
 
 static void rna_Node_simdata_typename_set(PointerRNA *ptr, const char *value)
 {
-	bNode *node= (bNode*)ptr->data;
-	SimNodeData *stor= (SimNodeData*)node->storage;
 	BlenderRNA *brna= &BLENDER_RNA;
 	StructRNA *type;
 	
 	for (type = brna->structs.first; type; type = type->cont.next) {
 		if (strcmp(type->identifier, value)==0) {
-			stor->type = type;
+			sim_datanode_set_type((bNodeTree*)ptr->id.data, (bNode*)ptr->data, type);
 			break;
 		}
 	}
@@ -2195,7 +2195,7 @@
 	prop = RNA_def_property(srna, "typename", PROP_STRING, PROP_NONE);
 	RNA_def_property_string_funcs(prop, "rna_Node_simdata_typename_get", "rna_Node_simdata_typename_length", "rna_Node_simdata_typename_set");
 	RNA_def_property_ui_text(prop, "Type", "RNA struct name of the data node");
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_simdata_update_type");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 }
 
 static void def_sim_setdata(StructRNA *srna)
@@ -2205,7 +2205,7 @@
 	prop = RNA_def_property(srna, "typename", PROP_STRING, PROP_NONE);
 	RNA_def_property_string_funcs(prop, "rna_Node_simdata_typename_get", "rna_Node_simdata_typename_length", "rna_Node_simdata_typename_set");
 	RNA_def_property_ui_text(prop, "Type", "RNA struct name of the data node");
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_simdata_update_type");
+	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 }
 
 /* -------------------------------------------------------------------------- */

Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c	2010-08-29 04:48:00 UTC (rev 31637)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c	2010-08-29 06:07:04 UTC (rev 31638)
@@ -48,6 +48,11 @@
 	simdata->type = NULL;
 }
 
+static void update(bNodeTree *ntree, bNode *node)
+{
+//	SimNodeData *simdata= (SimNodeData*)node->storage;
+}
+
 static int exec(SimNodeThreadContext *ctx, SimNodeJob *job)
 {
 	SimNodeDataStream istream[1];
@@ -75,7 +80,7 @@
 	/* id              */	NULL,
 	/* pynode, pydict  */	NULL, NULL,
 	/* gpufunc         */	NULL,
-	/* updatefunc      */	NULL,
+	/* updatefunc      */	update,
 	/* sim_exec        */	exec,
 	/* sim_opexec      */	NULL
 };

Modified: branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c	2010-08-29 04:48:00 UTC (rev 31637)
+++ branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c	2010-08-29 06:07:04 UTC (rev 31638)
@@ -1212,13 +1212,15 @@
 	ntreeEndExecTree(sim->ntmd->nodetree);
 }
 
-void sim_node_update_datatype(bNodeTree *ntree, bNode *node)
+void sim_datanode_set_type(bNodeTree *ntree, bNode *node, struct StructRNA *type)
 {
 	bNodeSocket *sock, *next;
-	StructRNA *type= ((SimNodeData*)node->storage)->type;
+	SimNodeData* data= (SimNodeData*)node->storage;
 	
+	/* TODO check type validity */
+	data->type = type;
+	
 	/* check existing property sockets for compatibility and remove if necessary */
-	
 	switch (node->type) {
 	case SIM_NODE_GETDATA:
 		/* first socket is data path, do not remove! */





More information about the Bf-blender-cvs mailing list