[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30146] branches/particles-2010/source/ blender: Implemented basic time stepping by the node tree modifier.

Lukas Toenne lukas.toenne at googlemail.com
Fri Jul 9 11:27:24 CEST 2010


Revision: 30146
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30146
Author:   lukastoenne
Date:     2010-07-09 11:27:24 +0200 (Fri, 09 Jul 2010)

Log Message:
-----------
Implemented basic time stepping by the node tree modifier.
It prepares a context struct that collects basic simulation info.
Added two simple nodes:
* Debug print is a simple print node for debugging output. More sophisticated debugging nodes can be added later.
* Time step input. This includes frame, time and deltas for both.

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/node.c
    branches/particles-2010/source/blender/blenkernel/intern/object.c
    branches/particles-2010/source/blender/blenkernel/intern/particleset.c
    branches/particles-2010/source/blender/makesdna/DNA_node_types.h
    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/SIM_node.h
    branches/particles-2010/source/blender/nodes/intern/SIM_util.c
    branches/particles-2010/source/blender/nodes/intern/SIM_util.h
    branches/particles-2010/source/blender/nodes/intern/node_tree_simulation.c

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

Modified: branches/particles-2010/source/blender/blenkernel/BKE_node.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-07-09 08:56:25 UTC (rev 30145)
+++ branches/particles-2010/source/blender/blenkernel/BKE_node.h	2010-07-09 09:27:24 UTC (rev 30146)
@@ -54,8 +54,7 @@
 struct GPUMaterial;
 struct GPUNode;
 struct GPUNodeStack;
-struct ParticleSimulationData;
-struct ParticleSystem;
+struct SimulationContext;
 struct PointerRNA;
 struct bContext;
 
@@ -460,24 +459,20 @@
 char* ntreeTexOutputMenu(struct bNodeTree *ntree);
 
 
-/* ************** PARTICLE NODES *************** */
+/* ************** SIMULATION NODES *************** */
 
 /* note: types are needed to restore callbacks, don't change values */
 /* range 1 - 100 is reserved for common nodes */
 /* using toolbox, we add node groups by assuming the values below don't exceed NODE_GROUP_MENU for now */
 
-#define PAR_NODE_PROGRAM	601
-#define PAR_NODE_NEWTONIAN	602
-#define PAR_NODE_INPUT		603
-#define PAR_NODE_EMITTER	604
-#define PAR_NODE_OBJECT		605
+#define SIM_NODE_TIMESTEP	601
 
-/* the type definitions array */
-extern struct ListBase node_all_particles;
+#define SIM_NODE_DEBUGPRINT	699
 
 /* API */
-void ntreeParticlesExecTree(struct ParticleSimulationData *sim, float cfra, float dfra, int thread);
+void ntreeSimulationExecTree(struct SimulationContext *sim, int thread);
 
+
 /**/
 
 void init_nodesystem(void);

Modified: branches/particles-2010/source/blender/blenkernel/BKE_particleset.h
===================================================================
--- branches/particles-2010/source/blender/blenkernel/BKE_particleset.h	2010-07-09 08:56:25 UTC (rev 30145)
+++ branches/particles-2010/source/blender/blenkernel/BKE_particleset.h	2010-07-09 09:27:24 UTC (rev 30146)
@@ -32,6 +32,9 @@
 
 struct ParticleSet;
 
+/* modifiers */
+void pset_calc_modifiers(struct Scene *scene, struct Object *ob);
+
 /* attribute management */
 int pset_get_particle_size(struct ParticleSet *pset);
 

Modified: branches/particles-2010/source/blender/blenkernel/intern/node.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-07-09 08:56:25 UTC (rev 30145)
+++ branches/particles-2010/source/blender/blenkernel/intern/node.c	2010-07-09 09:27:24 UTC (rev 30146)
@@ -2827,13 +2827,10 @@
 	nodeRegisterType(ntypelist, &tex_node_proc_distnoise);
 }
 
-static void registerParticleNodes(ListBase *ntypelist)
+static void registerSimulationNodes(ListBase *ntypelist)
 {
-//	nodeRegisterType(ntypelist, &par_node_input);
-//	nodeRegisterType(ntypelist, &par_node_newtonian);
-//	nodeRegisterType(ntypelist, &par_node_program);
-//	nodeRegisterType(ntypelist, &par_node_emitter);
-//	nodeRegisterType(ntypelist, &par_node_object);
+	nodeRegisterType(ntypelist, &sim_node_timestep);
+	nodeRegisterType(ntypelist, &sim_node_debugprint);
 }
 
 static void remove_dynamic_typeinfos(ListBase *list)
@@ -2874,7 +2871,7 @@
 	registerCompositNodes(&ntreeGetTypeInfo(NTREE_COMPOSIT)->node_types);
 	registerShaderNodes(&ntreeGetTypeInfo(NTREE_SHADER)->node_types);
 	registerTextureNodes(&ntreeGetTypeInfo(NTREE_TEXTURE)->node_types);
-	registerParticleNodes(&ntreeGetTypeInfo(NTREE_SIMULATION)->node_types);
+	registerSimulationNodes(&ntreeGetTypeInfo(NTREE_SIMULATION)->node_types);
 }
 
 void free_nodesystem(void) 

Modified: branches/particles-2010/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/object.c	2010-07-09 08:56:25 UTC (rev 30145)
+++ branches/particles-2010/source/blender/blenkernel/intern/object.c	2010-07-09 09:27:24 UTC (rev 30146)
@@ -2536,6 +2536,9 @@
 			else if(ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
 				makeDispListCurveTypes(scene, ob, 0);
 			}
+			else if(ob->type==OB_PSET) {
+				pset_calc_modifiers(scene, ob);
+			}
 			else if(ELEM(ob->type, OB_CAMERA, OB_LAMP)) {
 				/* evaluate drivers */
 				BKE_animsys_evaluate_animdata(data_id, adt, ctime, ADT_RECALC_DRIVERS);

Modified: branches/particles-2010/source/blender/blenkernel/intern/particleset.c
===================================================================
--- branches/particles-2010/source/blender/blenkernel/intern/particleset.c	2010-07-09 08:56:25 UTC (rev 30145)
+++ branches/particles-2010/source/blender/blenkernel/intern/particleset.c	2010-07-09 09:27:24 UTC (rev 30146)
@@ -25,20 +25,67 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
 #include "DNA_particleset_types.h"
+#include "DNA_scene_types.h"
 
 #include "MEM_guardedalloc.h"
 
 #include "BLI_math.h"
 
 #include "BKE_animsys.h"
+#include "BKE_displist.h"
 #include "BKE_global.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_modifier.h"
 #include "BKE_particleset.h"
 #include "BKE_utildefines.h"
 
+/* modifier update function */
+void pset_calc_modifiers(Scene *scene, Object *ob)
+{
+	ParticleSet *pset= ob->data;
+	ModifierData *md = modifiers_getVirtualModifierList(ob);
+//	float (*vertexCos)[3] = NULL;
+//	int numVerts;
+//	int editmode = (pset->editlatt!=NULL);
+	int editmode = 0;
+
+	freedisplist(&ob->disp);
+
+	for (; md; md=md->next) {
+		ModifierTypeInfo *mti = modifierType_getInfo(md->type);
+
+		md->scene= scene;
+		
+		if (!(md->mode&eModifierMode_Realtime)) continue;
+		if (editmode && !(md->mode&eModifierMode_Editmode)) continue;
+		if (mti->isDisabled && mti->isDisabled(md, 0)) continue;
+		if (mti->type!=eModifierTypeType_OnlyDeform) continue;
+
+//		if (!vertexCos) vertexCos = lattice_getVertexCos(ob, &numVerts);
+//		mti->deformVerts(md, ob, NULL, vertexCos, numVerts, 0, 0);
+		mti->deformVerts(md, ob, NULL, NULL, 0, 0, 0);
+	}
+
+	#if 0
+	/* always displist to make this work like derivedmesh */
+	if (!vertexCos) vertexCos = lattice_getVertexCos(ob, &numVerts);
+	
+	{
+		DispList *dl = MEM_callocN(sizeof(*dl), "lt_dl");
+		dl->type = DL_VERTS;
+		dl->parts = 1;
+		dl->nr = numVerts;
+		dl->verts = (float*) vertexCos;
+		
+		BLI_addtail(&ob->disp, dl);
+	}
+	#endif
+}
+
 /* attribute management */
 /* TODO */
 

Modified: branches/particles-2010/source/blender/makesdna/DNA_node_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_node_types.h	2010-07-09 08:56:25 UTC (rev 30145)
+++ branches/particles-2010/source/blender/makesdna/DNA_node_types.h	2010-07-09 09:27:24 UTC (rev 30146)
@@ -334,6 +334,19 @@
 	char name[32];
 } TexNodeOutput;
 
+
+struct ParticleSet;
+struct NodeTreeModifierData;
+
+typedef struct SimulationContext {
+	struct ParticleSet *pset;
+	struct NodeTreeModifierData *ntmd;
+	
+	float cfra, dfra;
+	float time, dtime;
+} SimulationContext;
+
+
 typedef struct ParticleOperatorContext {
 	struct ParticleSimulationData *sim;
 	float cfra, dfra;

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c	2010-07-09 08:56:25 UTC (rev 30145)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_nodetree.c	2010-07-09 09:27:24 UTC (rev 30146)
@@ -465,7 +465,7 @@
 	Category_ShaderNode,
 	Category_CompositorNode,
 	Category_TextureNode,
-	Category_ParticleNode
+	Category_SimulationNode
 };
 
 typedef struct NodeInfo
@@ -2051,33 +2051,8 @@
 	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
 }
 
-/* -- Particle Nodes ---------------------------------------------------------- */
+/* -- Simulation Nodes ---------------------------------------------------------- */
 
-static void def_par_emitter(StructRNA *srna)
-{
-	PropertyRNA *prop;
-
-	RNA_def_struct_sdna_from(srna, "ParticleNodeEmitter", "storage");
-	
-	prop = RNA_def_property(srna, "emitter_index", PROP_INT, PROP_NONE);
-	RNA_def_property_int_sdna(prop, NULL, "emitter_index");
-	RNA_def_property_range(prop, -1, 1000000);
-	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-}
-
-static void def_par_object(StructRNA *srna)
-{
-	PropertyRNA *prop;
-
-	prop = RNA_def_property(srna, "object", PROP_POINTER, PROP_NONE);
-	RNA_def_property_pointer_sdna(prop, NULL, "id");
-	RNA_def_property_struct_type(prop, "Object");
-	RNA_def_property_flag(prop, PROP_EDITABLE);
-	RNA_def_property_ui_text(prop, "Object", "");
-	RNA_def_property_update(prop, NC_NODE|NA_EDITED, "rna_Node_update");
-}
-
 /* -------------------------------------------------------------------------- */
 
 static EnumPropertyItem shader_node_type_items[MaxNodes];
@@ -2134,21 +2109,21 @@
 	RNA_def_property_ui_text(prop, "Type", "");
 }
 
-static EnumPropertyItem particle_node_type_items[MaxNodes];
-static void rna_def_particle_node(BlenderRNA *brna)
+static EnumPropertyItem simulation_node_type_items[MaxNodes];
+static void rna_def_simulation_node(BlenderRNA *brna)
 {
 	StructRNA *srna;
 	PropertyRNA *prop;
 	
-	alloc_node_type_items(particle_node_type_items, Category_ParticleNode);
+	alloc_node_type_items(simulation_node_type_items, Category_SimulationNode);
 	
-	srna = RNA_def_struct(brna, "ParticleNode", "Node");
-	RNA_def_struct_ui_text(srna, "Particle Node", "");
+	srna = RNA_def_struct(brna, "SimulationNode", "Node");
+	RNA_def_struct_ui_text(srna, "Simulation Node", "");
 	RNA_def_struct_sdna(srna, "bNode");
 
 	prop = RNA_def_property(srna, "type", PROP_ENUM, PROP_NONE);
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
-	RNA_def_property_enum_items(prop, particle_node_type_items);
+	RNA_def_property_enum_items(prop, simulation_node_type_items);
 	RNA_def_property_ui_text(prop, "Type", "");
 }
 
@@ -2321,7 +2296,7 @@
 	rna_def_shader_node(brna);
 	rna_def_compositor_node(brna);
 	rna_def_texture_node(brna);
-	rna_def_particle_node(brna);
+	rna_def_simulation_node(brna);
 		
 	#define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \
 		define_specific_node(brna, ID, DefFunc);

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_nodetree_types.h	2010-07-09 08:56:25 UTC (rev 30145)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list