[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32686] branches/particles-2010/source/ blender: Brought back the explicit data node StructRNA type.

Lukas Toenne lukas.toenne at googlemail.com
Sun Oct 24 17:26:43 CEST 2010


Revision: 32686
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32686
Author:   lukastoenne
Date:     2010-10-24 17:26:43 +0200 (Sun, 24 Oct 2010)

Log Message:
-----------
Brought back the explicit data node StructRNA type. This is necessary because data paths are only fully known in rare cases, so selecting existing properties would not work and all properties would have to be entered manually.

Modified Paths:
--------------
    branches/particles-2010/source/blender/blenkernel/BKE_node.h
    branches/particles-2010/source/blender/blenkernel/BKE_particleset.h
    branches/particles-2010/source/blender/blenkernel/intern/particleset.c
    branches/particles-2010/source/blender/blenloader/intern/readfile.c
    branches/particles-2010/source/blender/blenloader/intern/writefile.c
    branches/particles-2010/source/blender/editors/particleset/particleset_edit.c
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h
    branches/particles-2010/source/blender/makesdna/DNA_particleset_types.h
    branches/particles-2010/source/blender/makesrna/intern/rna_particleset.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/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-10-24 13:05:09 UTC (rev 32685)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-10-24 15:26:43 UTC (rev 32686)
@@ -116,8 +116,6 @@
 
 	/* called when the node is updated (e.g. linked) in the editor. */
 	void (*updatefunc)(struct bNodeTree *ntree, struct bNode *node);
-	/* called to (partially) determine self-context at build time */
-	void (*updatecontextfunc)(struct SimDataContext *ctx);
 
 	char socketstoragename[64];		/* socket storage struct name for DNA */
 	void (*initsocketfunc)(struct bNodeSocket *sock);
@@ -595,11 +593,15 @@
 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));
 void sim_getdata_path_set(struct bNodeTree *ntree, struct bNode *node, const char *path);
 const char *sim_getdata_path_get(struct bNode *node);
+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_setdata_add_property_socket(struct bNode *node, const char *prop);
 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));
 void sim_setdata_path_set(struct bNodeTree *ntree, struct bNode *node, const char *path);
 const char *sim_setdata_path_get(struct bNode *node);
+struct StructRNA *sim_setdata_type_get(struct bNode *node);
+void sim_setdata_type_set(struct bNodeTree *ntree, struct bNode *node, struct StructRNA *type);
 
 /**/
 

Modified: branches/particles-2010/source/blender/blenkernel/BKE_particleset.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_particleset.h	2010-10-24 13:05:09 UTC (rev 32685)
+++ branches/particles-2010/source/blender/blenkernel/BKE_particleset.h	2010-10-24 15:26:43 UTC (rev 32686)
@@ -36,7 +36,7 @@
 void pset_calc_modifiers(struct Scene *scene, struct Object *ob);
 
 /* attribute management */
-extern struct ParticlePropertyInfo pset_std_properties[];
+extern struct ParticlePropertyInfo pset_common_properties[];
 
 struct ParticlePropertyInfo *pset_find_particle_property(struct ParticleSet *pset, const char *name);
 

Modified: branches/particles-2010/source/blender/blenkernel/intern/particleset.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/particleset.c	2010-10-24 13:05:09 UTC (rev 32685)
+++ branches/particles-2010/source/blender/blenkernel/intern/particleset.c	2010-10-24 15:26:43 UTC (rev 32686)
@@ -43,28 +43,29 @@
 #include "BKE_particleset.h"
 #include "BKE_utildefines.h"
 
-ParticlePropertyInfo particle_std_properties[] = {
+ParticlePropertyInfo pset_common_properties[] = {
 //	   Name,          data type,        flags
-	{ "Position",     PPTYPE_VECTOR,    PARPROP_DEFAULT|PARPROP_PROTECTED    },
-	{ "Velocity",     PPTYPE_VECTOR,    PARPROP_DEFAULT|PARPROP_PROTECTED    },
-	{ "Force",        PPTYPE_VECTOR,    PARPROP_PROTECTED,                   },
-	{ "Mass",         PPTYPE_FLOAT,     0                                    },
-	{ "Init",         PPTYPE_BOOL,      0                                    },
-	{ "Custom",       PPTYPE_CUSTOM,    0                                    },
+	{ "Position",     PARPROP_VECTOR,    PARPROP_DEFAULT|PARPROP_PROTECTED    },
+	{ "Velocity",     PARPROP_VECTOR,    PARPROP_DEFAULT|PARPROP_PROTECTED    },
+	{ "Force",        PARPROP_VECTOR,    PARPROP_PROTECTED,                   },
+	{ "Mass",         PARPROP_FLOAT,     0                                    },
+	{ "Init",         PARPROP_BOOL,      0                                    },
 	/* last line marks the array end */
 	{ "" }
 };
 
-static int get_proptype_size(int type)
+static size_t get_proptype_size(int type)
 {
-	switch (type) {
-	case PPTYPE_FLOAT:	return sizeof(float); break;
-	case PPTYPE_INT:	return sizeof(int); break;
-	case PPTYPE_BOOL:	return sizeof(char); break;
-	case PPTYPE_VECTOR:	return 3*sizeof(float); break;
-	case PPTYPE_RGBA:	return 4*sizeof(float); break;
-	}
-	return 0;
+	static const size_t parpropsize[NUM_PARPROP_TYPES] = {
+		/* PARPROP_FLOAT */		sizeof(float),
+		/* PARPROP_INT */		sizeof(int),
+		/* PARPROP_BOOL */		sizeof(char),
+		/* PARPROP_VECTOR */	3*sizeof(float),
+		/* PARPROP_RGBA */		4*sizeof(float),
+		/* PARPROP_QUAT */		4*sizeof(float),
+		/* PARPROP_MATRIX */	16*sizeof(float)
+	};
+	return parpropsize[type];
 }
 
 /* modifier update function */
@@ -182,7 +183,7 @@
 	if (propinfo)
 		return propinfo;
 	
-	for (propinfo=particle_std_properties; strcmp(propinfo->name, name) != 0; ++propinfo)
+	for (propinfo=pset_common_properties; strcmp(propinfo->name, name) != 0; ++propinfo)
 		if (propinfo->name[0] == '\0')
 			return NULL;
 	
@@ -290,7 +291,7 @@
 static void pset_add_default_properties(ParticleSet *pset)
 {
 	ParticlePropertyInfo *propinfo;
-	for (propinfo=particle_std_properties; propinfo->name[0] != '\0'; ++propinfo) {
+	for (propinfo=pset_common_properties; propinfo->name[0] != '\0'; ++propinfo) {
 		if ((propinfo->flag & PARPROP_DEFAULT) != 0) {
 			pset_property_add(pset, propinfo->name);
 		}

Modified: branches/particles-2010/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/particles-2010/source/blender/blenloader/intern/readfile.c	2010-10-24 13:05:09 UTC (rev 32685)
+++ branches/particles-2010/source/blender/blenloader/intern/readfile.c	2010-10-24 15:26:43 UTC (rev 32686)
@@ -2064,8 +2064,19 @@
 	}
 }
 
-extern StructRNA RNA_SimulationNodeGetData;
-extern StructRNA RNA_SimulationNodeSetData;
+static void direct_link_sim_data_node(FileData *fd, bNodeTree *ntree, bNode *node)
+{
+	SimDataNode *data= (SimDataNode*)node->storage;
+
+	/* restore the identifier string */
+	data->save_type = newdataadr(fd, (void*)data->save_type);
+	data->type = RNA_find_struct(data->save_type);
+	if (data->save_type) {
+		MEM_freeN((void*)data->save_type);
+		data->save_type = NULL;
+	}
+}
+
 /* ntree itself has been read! */
 static void direct_link_nodetree(FileData *fd, bNodeTree *ntree)
 {
@@ -2110,6 +2121,10 @@
 			else if( ntree->type==NTREE_TEXTURE && (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) ) {
 				direct_link_curvemapping(fd, node->storage);
 			}
+			else if( ntree->type==NTREE_SIMULATION ) {
+				if( node->type==SIM_NODE_GETDATA || node->type==SIM_NODE_SETDATA )
+					direct_link_sim_data_node(fd, ntree, node);
+			}
 		}
 	}
 	link_list(fd, &ntree->links);

Modified: branches/particles-2010/source/blender/blenloader/intern/writefile.c
===================================================================
--- branches/particles-2010/source/blender/blenloader/intern/writefile.c	2010-10-24 13:05:09 UTC (rev 32685)
+++ branches/particles-2010/source/blender/blenloader/intern/writefile.c	2010-10-24 15:26:43 UTC (rev 32686)
@@ -446,6 +446,16 @@
 		writestruct(wd, DATA, "CurveMapPoint", cumap->cm[a].totpoint, cumap->cm[a].curve);
 }
 
+static void write_sim_data_node(WriteData *wd, SimDataNode *data)
+{
+	writestruct(wd, DATA, "SimDataNode", 1, data);
+	if (data->type) {
+		/* save identifier string, to allow restoring the StructRNA pointer */
+		data->save_type= RNA_struct_identifier(data->type);
+		writedata(wd, DATA, strlen(data->save_type)+1, (void*)data->save_type);
+	}
+}
+
 /* this is only direct data, tree itself should have been written */
 static void write_nodetree(WriteData *wd, bNodeTree *ntree)
 {
@@ -486,6 +496,10 @@
 				write_curvemapping(wd, node->storage);
 			else if(ntree->type==NTREE_TEXTURE && (node->type==TEX_NODE_CURVE_RGB || node->type==TEX_NODE_CURVE_TIME) )
 				write_curvemapping(wd, node->storage);
+			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);
 		}

Modified: branches/particles-2010/source/blender/editors/particleset/particleset_edit.c
===================================================================
--- branches/particles-2010/source/blender/editors/particleset/particleset_edit.c	2010-10-24 13:05:09 UTC (rev 32685)
+++ branches/particles-2010/source/blender/editors/particleset/particleset_edit.c	2010-10-24 15:26:43 UTC (rev 32686)
@@ -148,7 +148,7 @@
 }
 
 /* ================= property_add ================= */
-static EnumPropertyItem particle_std_properties_items[] = {
+static EnumPropertyItem pset_common_properties_items[] = {
 { 0, "PLACEHOLDER",          0, "Placeholder",          ""},
 {0, NULL, 0, NULL, NULL}};
 
@@ -162,7 +162,7 @@
 		return OPERATOR_CANCELLED;
 	pset = (ParticleSet*)ob->data;
 
-	if (!pset_property_add(pset, particle_std_properties[type].name));
+	if (!pset_property_add(pset, pset_common_properties[type].name));
 		return OPERATOR_CANCELLED;
 
 	WM_event_add_notifier(C, NC_OBJECT|ND_DATA, ob);
@@ -181,7 +181,7 @@
 //	if(!ob)
 //		return NULL;
 	
-	for (a=0, propinfo=particle_std_properties; propinfo->name[0] != '\0'; ++a, ++propinfo) {
+	for (a=0, propinfo=pset_common_properties; propinfo->name[0] != '\0'; ++a, ++propinfo) {
 		tmp.identifier = propinfo->name;
 		tmp.name= propinfo->name;
 		tmp.value = a;
@@ -213,7 +213,7 @@
 	ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 	
 	/* properties */
-	prop= RNA_def_enum(ot->srna, "type", particle_std_properties_items, 0, "Type", "");
+	prop= RNA_def_enum(ot->srna, "type", pset_common_properties_items, 0, "Type", "");
 	RNA_def_enum_funcs(prop, property_add_itemf);
 	ot->prop= prop;
 }

Modified: branches/particles-2010/source/blender/makesdna/DNA_node_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_node_types.h	2010-10-24 13:05:09 UTC (rev 32685)
+++ branches/particles-2010/source/blender/makesdna/DNA_node_types.h	2010-10-24 15:26:43 UTC (rev 32686)
@@ -177,8 +177,6 @@
 	struct uiBlock *block;	/* runtime during drawing */
 	
 	struct bNodeType *typeinfo;	/* lookup of callbacks and defaults */
-	

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list