[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32960] branches/particles-2010/source/ blender: Implemented "Index" node to give sub-trees a unique number in the current context.

Lukas Toenne lukas.toenne at googlemail.com
Tue Nov 9 09:54:16 CET 2010


Revision: 32960
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32960
Author:   lukastoenne
Date:     2010-11-09 09:54:16 +0100 (Tue, 09 Nov 2010)

Log Message:
-----------
Implemented "Index" node to give sub-trees a unique number in the current context. For data sets this is the index of the element in the array (so in fact a simple list of running numbers), for singleton objects this number is the context key (i.e. the array index in the data path).

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/BKE_node.h
    branches/particles-2010/source/blender/blenkernel/intern/node.c
    branches/particles-2010/source/blender/blenloader/intern/writefile.c
    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/nodes/CMakeLists.txt
    branches/particles-2010/source/blender/nodes/SIM_node.h
    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_set_data.c
    branches/particles-2010/source/blender/nodes/intern/SIM_nodetree.c

Added Paths:
-----------
    branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_index.c

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-11-09 07:49:15 UTC (rev 32959)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-11-09 08:54:16 UTC (rev 32960)
@@ -554,7 +554,7 @@
 #define SIM_NODE_FOR				605
 #define SIM_NODE_WHILE				606
 #define SIM_NODE_FILTER				607
-#define SIM_NODE_FOR_GROUP			608
+#define SIM_NODE_FORGROUP			608
 
 /* scalar math */
 #define SIM_NODE_ADD				650
@@ -585,14 +585,17 @@
 /* data input/output */
 #define SIM_NODE_GETDATA			750
 #define SIM_NODE_SETDATA			751
-#define SIM_NODE_TIMESTEP			760
-#define SIM_NODE_ADDPARTICLE		765
-#define SIM_NODE_RANDOM				768
-#define SIM_NODE_PARTICLEDYNAMICS	769
-#define SIM_NODE_ADDPARTICLEFORCE	770
+#define SIM_NODE_INDEX				752
+#define SIM_NODE_TIMESTEP			753
+#define SIM_NODE_RANDOM				754
 
+/* particles */
+#define SIM_NODE_ADDPARTICLE		800
+#define SIM_NODE_PARTICLEDYNAMICS	801
+#define SIM_NODE_ADDPARTICLEFORCE	802
+
 /* TO BE REMOVED: debugging stuff, testing, etc. */
-#define SIM_NODE_DEBUGPRINT			801
+#define SIM_NODE_DEBUGPRINT			900
 
 /* API */
 void ntreeSimulationCompileProgram(struct bNodeTree *ntree, int force);
@@ -603,16 +606,12 @@
 /* XXX having these here is ugly, should be in nodes directory */
 void sim_getdata_add_property_socket(struct bNode *node, const char *name);
 void sim_getdata_foreach_property(struct bNode *node, void *items, const char *str, int (*cb)(void *items, const char *str, const char *name, const char *identifier, int icon));
-const char *sim_getdata_path_get(struct bNode *node);
-void sim_getdata_path_set(struct bNodeTree *ntree, struct bNode *node, const char *path);
 struct StructRNA *sim_getdata_type_get(struct bNode *node);
 void sim_getdata_type_set(struct bNodeTree *ntree, struct bNode *node, struct StructRNA *type);
 void sim_getdata_property_types(struct bNodeSocket *sock, int **types, int *num_types);
 
 void sim_setdata_add_property_socket(struct bNode *node, const char *name);
 void sim_setdata_foreach_property(struct bNode *node, void *items, const char *str, int (*cb)(void *items, const char *str, const char *name, const char *identifier, int icon));
-const char *sim_setdata_path_get(struct bNode *node);
-void sim_setdata_path_set(struct bNodeTree *ntree, struct bNode *node, const char *path);
 struct StructRNA *sim_setdata_type_get(struct bNode *node);
 void sim_setdata_type_set(struct bNodeTree *ntree, struct bNode *node, struct StructRNA *type);
 void sim_setdata_property_types(struct bNodeSocket *sock, int **types, int *num_types);

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-11-09 07:49:15 UTC (rev 32959)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-11-09 08:54:16 UTC (rev 32960)
@@ -2555,6 +2555,7 @@
 
 	nodeRegisterSimGetData(ntypelist);
 	nodeRegisterSimSetData(ntypelist);
+	nodeRegisterSimIndex(ntypelist);
 	nodeRegisterSimTimeStep(ntypelist);
 	nodeRegisterSimRandom(ntypelist);
 	nodeRegisterSimDebugPrint(ntypelist);

Modified: branches/particles-2010/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/particles-2010/source/blender/blenloader/intern/writefile.c	2010-11-09 07:49:15 UTC (rev 32959)
+++ branches/particles-2010/source/blender/blenloader/intern/writefile.c	2010-11-09 08:54:16 UTC (rev 32960)
@@ -499,6 +499,8 @@
 			else if(ntree->type==NTREE_SIMULATION) {
 				if(node->type==SIM_NODE_GETDATA || node->type==SIM_NODE_SETDATA)
 					write_sim_data_node(wd, node->storage);
+				else
+					writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);
 			}
 			else
 				writestruct(wd, DATA, node->typeinfo->storagename, 1, node->storage);

Modified: branches/particles-2010/source/blender/editors/space_node/drawnode.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/drawnode.c	2010-11-09 07:49:15 UTC (rev 32959)
+++ branches/particles-2010/source/blender/editors/space_node/drawnode.c	2010-11-09 08:54:16 UTC (rev 32960)
@@ -1282,6 +1282,14 @@
 	}
 }
 
+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);
+}
+
 static void node_simulation_buts_getdata(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
 	uiLayout *col;
@@ -1496,6 +1504,16 @@
 	}
 }
 
+static void node_simulation_buts_index(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_buts_while(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
 	uiLayout *col;
@@ -1508,6 +1526,9 @@
 static void node_simulation_set_butfunc(bNodeType *ntype)
 {
 	switch(ntype->type) {
+	case SIM_NODE_FORGROUP:
+		ntype->uifunc = node_simulation_buts_forgroup;
+		break;
 	case SIM_NODE_GETDATA:
 		ntype->uifunc = node_simulation_buts_getdata;
 		ntype->buttonfunc = node_simulation_detailbuts_getdata;
@@ -1516,6 +1537,9 @@
 		ntype->uifunc = node_simulation_buts_setdata;
 		ntype->buttonfunc = node_simulation_detailbuts_setdata;
 		break;
+	case SIM_NODE_INDEX:
+		ntype->uifunc = node_simulation_buts_index;
+		break;
 	case SIM_NODE_WHILE:
 		ntype->uifunc = node_simulation_buts_while;
 		break;

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c	2010-11-09 07:49:15 UTC (rev 32959)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c	2010-11-09 08:54:16 UTC (rev 32960)
@@ -469,21 +469,23 @@
 	return item;
 }
 
-static void rna_Node_getdata_path_get(PointerRNA *ptr, char *value)
+
+static void rna_Node_data_path_get(PointerRNA *ptr, char *value)
 {
-	strcpy(value, sim_getdata_path_get((bNode*)ptr->data));
+	strcpy(value, ((SimDataNode*)((bNode*)ptr->data)->storage)->path);
 }
 
-static int rna_Node_getdata_path_length(PointerRNA *ptr)
+static int rna_Node_data_path_length(PointerRNA *ptr)
 {
-	return strlen(sim_getdata_path_get((bNode*)ptr->data));
+	return strlen(((SimDataNode*)((bNode*)ptr->data)->storage)->path);
 }
 
-static void rna_Node_getdata_path_set(PointerRNA *ptr, const char *value)
+static void rna_Node_data_path_set(PointerRNA *ptr, const char *value)
 {
-	sim_getdata_path_set((bNodeTree*)ptr->id.data, (bNode*)ptr->data, value);
+	strcpy(((SimDataNode*)((bNode*)ptr->data)->storage)->path, value);
 }
 
+
 static void rna_Node_getdata_typename_get(PointerRNA *ptr, char *value)
 {
 	StructRNA *type= sim_getdata_type_get((bNode*)ptr->data);
@@ -507,22 +509,7 @@
 	sim_getdata_type_set((bNodeTree*)ptr->id.data, (bNode*)ptr->data, RNA_find_struct(value));
 }
 
-static void rna_Node_setdata_path_get(PointerRNA *ptr, char *value)
-{
-	strcpy(value, sim_setdata_path_get((bNode*)ptr->data));
-}
 
-static int rna_Node_setdata_path_length(PointerRNA *ptr)
-{
-	return strlen(sim_setdata_path_get((bNode*)ptr->data));
-}
-
-static void rna_Node_setdata_path_set(PointerRNA *ptr, const char *value)
-{
-	sim_setdata_path_set((bNodeTree*)ptr->id.data, (bNode*)ptr->data, value);
-}
-
-
 static void rna_Node_setdata_typename_get(PointerRNA *ptr, char *value)
 {
 	StructRNA *type= sim_setdata_type_get((bNode*)ptr->data);
@@ -2257,12 +2244,22 @@
 
 /* -- Simulation Nodes ---------------------------------------------------------- */
 
+static void def_sim_forgroup(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_getdata_path_get", "rna_Node_getdata_path_length", "rna_Node_getdata_path_set");
+	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");
 
@@ -2276,7 +2273,7 @@
 	PropertyRNA *prop;
 
 	prop = RNA_def_property(srna, "path", PROP_STRING, PROP_NONE);
-	RNA_def_property_string_funcs(prop, "rna_Node_setdata_path_get", "rna_Node_setdata_path_length", "rna_Node_setdata_path_set");
+	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");
 
@@ -2285,6 +2282,16 @@
 	RNA_def_property_ui_text(prop, "Type", "RNA struct name of the data node");
 }
 
+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 void def_sim_while(StructRNA *srna)
 {
 	PropertyRNA *prop;

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h	2010-11-09 07:49:15 UTC (rev 32959)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h	2010-11-09 08:54:16 UTC (rev 32960)
@@ -140,7 +140,7 @@
 DefNode( SimulationNode, SIM_NODE_FOR,            0,                      "FOR",            For,              "For",               ""              )

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list