[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [33501] branches/particles-2010/source/ blender: Cleaned up and unified RNA and drawing functions for data nodes, i .e.

Lukas Toenne lukas.toenne at googlemail.com
Mon Dec 6 09:28:32 CET 2010


Revision: 33501
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=33501
Author:   lukastoenne
Date:     2010-12-06 09:28:32 +0100 (Mon, 06 Dec 2010)

Log Message:
-----------
Cleaned up and unified RNA and drawing functions for data nodes, i.e. nodes that use a path string and (optional) StructRNA pointer.
Fixed normal data interpolation in GetMeshData node. This currently uses a hack to be able to retrieve a derived mesh when called from a modifier stack: The mesh_get_derived_mesh function is called, which evaluates the modifier stack a second time, but does not re-enter node tree evaluation. This should be changed, so the tree uses the intermediate derived mesh from the actual first stack evaluation.

Modified Paths:
--------------
    branches/particles-2010/source/blender/editors/space_node/drawnode.c
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
    branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
    branches/particles-2010/source/blender/modifiers/intern/MOD_nodetree.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_add_particle.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_create_mesh_point.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_for_group.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_data.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_get_mesh_data.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_index.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_set_data.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodetree.c
    branches/particles-2010/source/blender/nodes/intern/SIM_util.c
    branches/particles-2010/source/blender/nodes/intern/SIM_util.h

Modified: branches/particles-2010/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/drawnode.c	2010-12-06 07:45:07 UTC (rev 33500)
+++ branches/particles-2010/source/blender/editors/space_node/drawnode.c	2010-12-06 08:28:32 UTC (rev 33501)
@@ -1294,14 +1294,6 @@
 	}
 }
 
-static void node_simulation_buts_forgroup(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
-	uiLayout *col;
-	
-	col= uiLayoutColumn(layout, 0);
-	uiItemR(col, ptr, "path", 0, NULL, 0);
-}
-
 /* Local struct for passing several pointers to the various button functions */
 typedef struct NodeDataArgs {
 	bNodeTree *ntree;
@@ -1458,15 +1450,22 @@
 	uiButSetSearchFunc(but, node_data_add_property_search_cb, &args, node_data_add_property_exec_cb, NULL);
 }
 
-static void node_simulation_buts_getdata(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_simulation_buts_data(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
-	uiLayout *col;
+	bNode *node= (bNode*)ptr->data;
+	SimDataNode *data= (SimDataNode*)node->storage;
+	uiLayout *col, *row;
 	
 	col= uiLayoutColumn(layout, 0);
 	uiLayoutSetContextPointer(col, "node", ptr);
 
 	uiItemR(col, ptr, "path", 0, NULL, 0);
+
+//	row= uiLayoutRow(col, 0);
+//	uiItemL(row, "Type:", 0);
+//	uiItemL(row, RNA_struct_ui_name(data->type), RNA_struct_ui_icon(data->type));
 }
+
 static void node_simulation_detailbuts_getdata(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
 	static NodeDataArgs args;
@@ -1509,15 +1508,6 @@
 	}
 }
 
-static void node_simulation_buts_setdata(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
-	uiLayout *col;
-	
-	col= uiLayoutColumn(layout, 0);
-	uiLayoutSetContextPointer(col, "node", ptr);
-
-	uiItemR(col, ptr, "path", 0, NULL, 0);
-}
 static void node_simulation_detailbuts_setdata(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
 	static NodeDataArgs args;
@@ -1560,13 +1550,14 @@
 	}
 }
 
-static void node_simulation_buts_getmeshdata(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_simulation_buts_getmeshdata(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
 	uiLayout *col;
 	
+	node_simulation_buts_data(layout, C, ptr);
+	
 	col= uiLayoutColumn(layout, 0);
 	uiItemR(col, ptr, "space", 0, NULL, 0);
-	uiItemR(col, ptr, "path", 0, NULL, 0);
 }
 static void node_simulation_detailbuts_getmeshdata(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
@@ -1606,22 +1597,6 @@
 	}
 }
 
-static void node_simulation_buts_createmeshpoint(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
-	uiLayout *col;
-	
-	col= uiLayoutColumn(layout, 0);
-	uiItemR(col, ptr, "path", 0, NULL, 0);
-}
-
-static void node_simulation_buts_index(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
-{
-	uiLayout *col;
-	
-	col= uiLayoutColumn(layout, 0);
-	uiItemR(col, ptr, "path", 0, NULL, 0);
-}
-
 static void node_simulation_buts_random(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
 	uiLayout *col;
@@ -1698,10 +1673,13 @@
 {
 	switch(ntype->type) {
 	case SIM_NODE_FORGROUP:
-		ntype->uifunc = node_simulation_buts_forgroup;
+	case SIM_NODE_INDEX:
+	case SIM_NODE_CREATEMESHPOINT:
+	case SIM_NODE_ADDPARTICLE:
+		ntype->uifunc = node_simulation_buts_data;
 		break;
 	case SIM_NODE_GETDATA:
-		ntype->uifunc = node_simulation_buts_getdata;
+		ntype->uifunc = node_simulation_buts_data;
 		ntype->buttonfunc = node_simulation_detailbuts_getdata;
 		break;
 	case SIM_NODE_GETMESHDATA:
@@ -1709,12 +1687,9 @@
 		ntype->buttonfunc = node_simulation_detailbuts_getmeshdata;
 		break;
 	case SIM_NODE_SETDATA:
-		ntype->uifunc = node_simulation_buts_setdata;
+		ntype->uifunc = node_simulation_buts_data;
 		ntype->buttonfunc = node_simulation_detailbuts_setdata;
 		break;
-	case SIM_NODE_INDEX:
-		ntype->uifunc = node_simulation_buts_index;
-		break;
 	case SIM_NODE_RANDOM:
 		ntype->uifunc = node_simulation_buts_random;
 		break;
@@ -1740,9 +1715,6 @@
 	case SIM_NODE_CURVE:
 		ntype->uifunc = node_simulation_buts_curve;
 		break;
-	case SIM_NODE_CREATEMESHPOINT:
-		ntype->uifunc = node_simulation_buts_createmeshpoint;
-		break;
 		
 	default:
 		ntype->uifunc= NULL;

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c	2010-12-06 07:45:07 UTC (rev 33500)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c	2010-12-06 08:28:32 UTC (rev 33501)
@@ -543,21 +543,6 @@
 	return item;
 }
 
-static void rna_Node_data_path_get(PointerRNA *ptr, char *value)
-{
-	strcpy(value, ((SimDataNode*)((bNode*)ptr->data)->storage)->path);
-}
-
-static int rna_Node_data_path_length(PointerRNA *ptr)
-{
-	return strlen(((SimDataNode*)((bNode*)ptr->data)->storage)->path);
-}
-
-static void rna_Node_data_path_set(PointerRNA *ptr, const char *value)
-{
-	strcpy(((SimDataNode*)((bNode*)ptr->data)->storage)->path, value);
-}
-
 static int node_data_valid_types_skip(CollectionPropertyIterator *iter, void *data)
 {
 	/* XXX could use a special flag or a whitelist to limit the set of RNA types here */
@@ -2459,58 +2444,23 @@
 	{ -1, "", 0, NULL, NULL },
 };
 
-static void def_sim_forgroup(StructRNA *srna)
+static void def_sim_data(StructRNA *srna)
 {
 	PropertyRNA *prop;
 
-	prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
-	RNA_def_property_string_funcs(prop, "rna_Node_data_path_get", "rna_Node_data_path_length", "rna_Node_data_path_set");
-	RNA_def_property_ui_text(prop, "Path", "RNA path of the data node");
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-}
-
-static void def_sim_getdata(StructRNA *srna)
-{
-	PropertyRNA *prop;
-
-	prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
-	RNA_def_property_string_funcs(prop, "rna_Node_data_path_get", "rna_Node_data_path_length", "rna_Node_data_path_set");
-	RNA_def_property_ui_text(prop, "Path", "RNA path of the data node");
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-
 	RNA_def_struct_sdna_from(srna, "SimDataNode", "storage");
-	
-	prop = RNA_def_property(srna, "type", PROP_POINTER, PROP_NONE);
-	RNA_def_property_pointer_sdna(prop, NULL, "type");
-	RNA_def_property_struct_type(prop, "Struct");
-	RNA_def_property_ui_text(prop, "Type", "RNA type of the data node");
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-	
-	prop = RNA_def_property(srna, "valid_types", PROP_COLLECTION, PROP_NONE);
-	RNA_def_property_collection_funcs(prop, "rna_Node_data_valid_types_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end",
-									  "rna_iterator_listbase_get", NULL, "rna_Node_data_valid_types_lookupint", "rna_Node_data_valid_types_lookupstring");
-	RNA_def_property_struct_type(prop, "Struct");
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-	RNA_def_property_ui_text(prop, "Valid Types", "Valid RNA types for the data node");
-}
 
-static void def_sim_setdata(StructRNA *srna)
-{
-	PropertyRNA *prop;
-
 	prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
-	RNA_def_property_string_funcs(prop, "rna_Node_data_path_get", "rna_Node_data_path_length", "rna_Node_data_path_set");
+	RNA_def_property_string_sdna(prop, NULL, "path");
 	RNA_def_property_ui_text(prop, "Path", "RNA path of the data node");
 	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 
-	RNA_def_struct_sdna_from(srna, "SimDataNode", "storage");
-	
 	prop = RNA_def_property(srna, "type", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_sdna(prop, NULL, "type");
 	RNA_def_property_struct_type(prop, "Struct");
 	RNA_def_property_ui_text(prop, "Type", "RNA type of the data node");
 	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-	
+
 	prop = RNA_def_property(srna, "valid_types", PROP_COLLECTION, PROP_NONE);
 	RNA_def_property_collection_funcs(prop, "rna_Node_data_valid_types_begin", "rna_iterator_listbase_next", "rna_iterator_listbase_end",
 									  "rna_iterator_listbase_get", NULL, "rna_Node_data_valid_types_lookupint", "rna_Node_data_valid_types_lookupstring");
@@ -2530,36 +2480,9 @@
 	RNA_def_property_ui_text(prop, "Space", "Transformation space of the mesh data");
 	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 
-	RNA_def_struct_sdna_from(srna, "SimDataNode", "storage");
-
-	prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
-	RNA_def_property_string_sdna(prop, NULL, "path");
-	RNA_def_property_ui_text(prop, "Path", "RNA path of the data node");
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
+	def_sim_data(srna);
 }
 
-static void def_sim_createmeshpoint(StructRNA *srna)
-{
-	PropertyRNA *prop;
-
-	RNA_def_struct_sdna_from(srna, "SimDataNode", "storage");
-
-	prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
-	RNA_def_property_string_sdna(prop, NULL, "path");
-	RNA_def_property_ui_text(prop, "Path", "RNA path of the data node");
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-}
-
-static void def_sim_index(StructRNA *srna)
-{
-	PropertyRNA *prop;
-
-	prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
-	RNA_def_property_string_funcs(prop, "rna_Node_data_path_get", "rna_Node_data_path_length", "rna_Node_data_path_set");
-	RNA_def_property_ui_text(prop, "Path", "RNA path of the data node");
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-}
-
 static EnumPropertyItem sim_random_distribution_items[] = {
 	{ SIM_RANDOM_UNIFORM,		"SIM_RANDOM_UNIFORM",		0,	"Uniform",		""	},
 	{ SIM_RANDOM_GAUSSIAN,		"SIM_RANDOM_GAUSSIAN",		0,	"Gaussian",		""	},

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h	2010-12-06 07:45:07 UTC (rev 33500)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h	2010-12-06 08:28:32 UTC (rev 33501)
@@ -140,7 +140,7 @@
 DefNode( SimulationNode, SIM_NODE_FOR,            0,                      "FOR",            For,              "For",               ""              )
 DefNode( SimulationNode, SIM_NODE_WHILE,          def_sim_while,          "WHILE",          While,            "While",             ""              )

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list