[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30140] branches/particles-2010: Added a new modifier "NodeTree", which will be used to couple ParticleSets to a node tree.

Lukas Toenne lukas.toenne at googlemail.com
Fri Jul 9 08:59:49 CEST 2010


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

Log Message:
-----------
Added a new modifier "NodeTree", which will be used to couple ParticleSets to a node tree.
It creates a new node tree of the NTREE_SIMULATION type. The tree execution can then be started from the modifier update function (like current particles do their update too).
Two issues:
* The modifier is a singleton atm. This is because the node tree must be gettable from the object ID on select (modifiers have no "select" themselves), so must be unique. Ideally there could be multiple node trees to simulate at different parts in the modifier stack, but this is disabled until a solution is found.
* The modifier creates its own node tree, just like materials, etc. do. It could be a nice feature to have them link dynamically to node trees in the library, but this is safer for now.

Modified Paths:
--------------
    branches/particles-2010/release/scripts/ui/properties_data_modifier.py
    branches/particles-2010/source/blender/editors/space_buttons/buttons_context.c
    branches/particles-2010/source/blender/editors/space_node/node_edit.c
    branches/particles-2010/source/blender/makesdna/DNA_modifier_types.h
    branches/particles-2010/source/blender/makesrna/RNA_access.h
    branches/particles-2010/source/blender/makesrna/intern/makesrna.c
    branches/particles-2010/source/blender/makesrna/intern/rna_internal.h
    branches/particles-2010/source/blender/makesrna/intern/rna_modifier.c
    branches/particles-2010/source/blender/modifiers/MOD_modifiertypes.h
    branches/particles-2010/source/blender/modifiers/intern/MOD_util.c

Added Paths:
-----------
    branches/particles-2010/source/blender/makesrna/intern/rna_particleset.c
    branches/particles-2010/source/blender/modifiers/intern/MOD_nodetree.c

Modified: branches/particles-2010/release/scripts/ui/properties_data_modifier.py
===================================================================
--- branches/particles-2010/release/scripts/ui/properties_data_modifier.py	2010-07-09 06:23:01 UTC (rev 30139)
+++ branches/particles-2010/release/scripts/ui/properties_data_modifier.py	2010-07-09 06:59:48 UTC (rev 30140)
@@ -460,6 +460,12 @@
             row.operator("object.multires_external_save", text="Save External...")
             row.label()
 
+    def NODETREE(self, layout, ob, md, wide_ui):
+        split = layout.split()
+
+        if wide_ui:
+            col = split.column()
+
     def PARTICLE_INSTANCE(self, layout, ob, md, wide_ui):
         layout.prop(md, "object")
         layout.prop(md, "particle_system_number", text="Particle System")

Modified: branches/particles-2010/source/blender/editors/space_buttons/buttons_context.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_buttons/buttons_context.c	2010-07-09 06:23:01 UTC (rev 30139)
+++ branches/particles-2010/source/blender/editors/space_buttons/buttons_context.c	2010-07-09 06:59:48 UTC (rev 30140)
@@ -180,6 +180,7 @@
 	else if(RNA_struct_is_a(ptr->type, &RNA_Armature) && (type == -1 || type == OB_ARMATURE)) return 1;
 	else if(RNA_struct_is_a(ptr->type, &RNA_MetaBall) && (type == -1 || type == OB_MBALL)) return 1;
 	else if(RNA_struct_is_a(ptr->type, &RNA_Lattice) && (type == -1 || type == OB_LATTICE)) return 1;
+	else if(RNA_struct_is_a(ptr->type, &RNA_ParticleSet) && (type == -1 || type == OB_PSET)) return 1;
 	else if(RNA_struct_is_a(ptr->type, &RNA_Camera) && (type == -1 || type == OB_CAMERA)) return 1;
 	else if(RNA_struct_is_a(ptr->type, &RNA_Lamp) && (type == -1 || type == OB_LAMP)) return 1;
 	/* try to get an object in the path, no pinning supported here */
@@ -205,7 +206,7 @@
 	if(buttons_context_path_object(path)) {
 		ob= path->ptr[path->len-1].data;
 
-		if(ob && ELEM5(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE))
+		if(ob && ELEM6(ob->type, OB_MESH, OB_CURVE, OB_FONT, OB_SURF, OB_LATTICE, OB_PSET))
 			return 1;
 	}
 

Modified: branches/particles-2010/source/blender/editors/space_node/node_edit.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_edit.c	2010-07-09 06:23:01 UTC (rev 30139)
+++ branches/particles-2010/source/blender/editors/space_node/node_edit.c	2010-07-09 06:59:48 UTC (rev 30140)
@@ -49,6 +49,7 @@
 #include "BKE_main.h"
 #include "BKE_node.h"
 #include "BKE_material.h"
+#include "BKE_modifier.h"
 #include "BKE_paint.h"
 #include "BKE_particleset.h"
 #include "BKE_texture.h"
@@ -377,11 +378,11 @@
 		*ntree= ((Tex*)id)->nodetree;
 		if(treetype) *treetype= NTREE_TEXTURE;
 	}
-	else if(idtype == ID_PA) {
-		#if 0
-		*ntree= ((ParticleSettings*)id)->nodetree;
+	else if(idtype == ID_OB) {
+		NodeTreeModifierData *smd= (NodeTreeModifierData*)modifiers_findByType((Object*)id, eModifierType_NodeTree);
+		if (smd)
+			*ntree= smd->nodetree;
 		if(treetype) *treetype= NTREE_SIMULATION;
-		#endif
 	}
 
 	/* find editable group */
@@ -462,16 +463,8 @@
 		}
 	}
 	else if(snode->treetype==NTREE_SIMULATION) {
-		#if 0
-		/* TODO psys should be stored in the context (needed for data link resolution, etc) - phonybone */
-		if(ob) {
-			ParticleSystem *psys= psys_get_current(ob);
-			if(psys) {
-				snode->from= &ob->id;
-				snode->id= &psys->part->id;
-			}
-		}
-		#endif
+		snode->from= &ob->id;
+		snode->id= &ob->id;
 	}
 
 	if(snode->id)

Modified: branches/particles-2010/source/blender/makesdna/DNA_modifier_types.h
===================================================================
--- branches/particles-2010/source/blender/makesdna/DNA_modifier_types.h	2010-07-09 06:23:01 UTC (rev 30139)
+++ branches/particles-2010/source/blender/makesdna/DNA_modifier_types.h	2010-07-09 06:59:48 UTC (rev 30140)
@@ -66,6 +66,7 @@
 	eModifierType_ShapeKey,
 	eModifierType_Solidify,
 	eModifierType_Screw,
+	eModifierType_NodeTree,
 	NUM_MODIFIER_TYPES
 } ModifierType;
 
@@ -722,5 +723,12 @@
 #define MOD_SCREW_OBJECT_OFFSET	(1<<2)
 // #define MOD_SCREW_OBJECT_ANGLE	(1<<4)
 
+struct bNodeTree;
 
+typedef struct NodeTreeModifierData {
+	ModifierData modifier;
+	
+	struct bNodeTree *nodetree;
+} NodeTreeModifierData;
+
 #endif

Modified: branches/particles-2010/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/particles-2010/source/blender/makesrna/RNA_access.h	2010-07-09 06:23:01 UTC (rev 30139)
+++ branches/particles-2010/source/blender/makesrna/RNA_access.h	2010-07-09 06:59:48 UTC (rev 30140)
@@ -351,6 +351,7 @@
 extern StructRNA RNA_ParticleHairKey;
 extern StructRNA RNA_ParticleInstanceModifier;
 extern StructRNA RNA_ParticleKey;
+extern StructRNA RNA_ParticleSet;
 extern StructRNA RNA_ParticleSettings;
 extern StructRNA RNA_SPHFluidSettings;
 extern StructRNA RNA_ParticleSystem;

Modified: branches/particles-2010/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/makesrna.c	2010-07-09 06:23:01 UTC (rev 30139)
+++ branches/particles-2010/source/blender/makesrna/intern/makesrna.c	2010-07-09 06:59:48 UTC (rev 30140)
@@ -2267,6 +2267,7 @@
 	{"rna_object_force.c", NULL, RNA_def_object_force},
 	{"rna_packedfile.c", NULL, RNA_def_packedfile},
 	{"rna_particle.c", NULL, RNA_def_particle},
+	{"rna_particleset.c", NULL, RNA_def_particleset}, 
 	{"rna_pose.c", "rna_pose_api.c", RNA_def_pose},
 	{"rna_property.c", NULL, RNA_def_gameproperty},
 	{"rna_render.c", NULL, RNA_def_render},

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_internal.h
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_internal.h	2010-07-09 06:23:01 UTC (rev 30139)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_internal.h	2010-07-09 06:59:48 UTC (rev 30140)
@@ -153,6 +153,7 @@
 void RNA_def_object_force(struct BlenderRNA *brna);
 void RNA_def_packedfile(struct BlenderRNA *brna);
 void RNA_def_particle(struct BlenderRNA *brna);
+void RNA_def_particleset(struct BlenderRNA *brna);
 void RNA_def_pose(struct BlenderRNA *brna);
 void RNA_def_render(struct BlenderRNA *brna);
 void RNA_def_rna(struct BlenderRNA *brna);

Modified: branches/particles-2010/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_modifier.c	2010-07-09 06:23:01 UTC (rev 30139)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_modifier.c	2010-07-09 06:59:48 UTC (rev 30140)
@@ -78,7 +78,8 @@
 	{eModifierType_Collision, "COLLISION", ICON_MOD_PHYSICS, "Collision", ""},
 	{eModifierType_Explode, "EXPLODE", ICON_MOD_EXPLODE, "Explode", ""},
 	{eModifierType_Fluidsim, "FLUID_SIMULATION", ICON_MOD_FLUIDSIM, "Fluid Simulation", ""},
-	{eModifierType_ParticleInstance, "PARTICLE_INSTANCE", ICON_MOD_PARTICLES, "Particle Instance", ""},
+	{eModifierType_NodeTree, "NODETREE", ICON_MOD_FLUIDSIM, "Node Tree", ""},
+	{eModifierType_ParticleInstance, "PARTICLE_INSTANCE", ICON_NODETREE, "Particle Instance", ""},
 	{eModifierType_ParticleSystem, "PARTICLE_SYSTEM", ICON_MOD_PARTICLES, "Particle System", ""},
 	{eModifierType_Smoke, "SMOKE", ICON_MOD_SMOKE, "Smoke", ""},
 	{eModifierType_Softbody, "SOFT_BODY", ICON_MOD_SOFT, "Soft Body", ""},
@@ -2206,6 +2207,17 @@
 	RNA_def_property_update(prop, 0, "rna_Modifier_update");*/
 }
 
+static void rna_def_modifier_nodetree(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	srna= RNA_def_struct(brna, "NodeTreeModifier", "Modifier");
+	RNA_def_struct_ui_text(srna, "Node Tree Modifier", "Simulate with Node Tree");
+	RNA_def_struct_sdna(srna, "NodeTreeModifierData");
+	RNA_def_struct_ui_icon(srna, ICON_NODETREE);
+}
+
 void RNA_def_modifier(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -2296,6 +2308,7 @@
 	rna_def_modifier_smoke(brna);
 	rna_def_modifier_solidify(brna);
 	rna_def_modifier_screw(brna);
+	rna_def_modifier_nodetree(brna);
 }
 
 #endif

Added: branches/particles-2010/source/blender/makesrna/intern/rna_particleset.c
===================================================================
--- branches/particles-2010/source/blender/makesrna/intern/rna_particleset.c	                        (rev 0)
+++ branches/particles-2010/source/blender/makesrna/intern/rna_particleset.c	2010-07-09 06:59:48 UTC (rev 30140)
@@ -0,0 +1,69 @@
+/**
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s):
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "RNA_define.h"
+
+#include "rna_internal.h"
+
+#include "DNA_modifier_types.h"
+#include "DNA_particleset_types.h"
+#include "DNA_object_types.h"
+#include "DNA_scene_types.h"
+
+#include "WM_types.h"
+#include "WM_api.h"
+
+#ifdef RNA_RUNTIME
+
+#include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_modifier.h"
+#include "BKE_particleset.h"
+#include "BKE_pointcache.h"
+
+#include "BLI_math.h"
+#include "BLI_listbase.h"
+
+
+
+#else
+
+static void rna_def_particleset(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	srna = RNA_def_struct(brna, "ParticleSet", NULL);
+	RNA_def_struct_sdna(srna, "ParticleSet");
+	RNA_def_struct_ui_text(srna, "Particle Set", "");
+}
+
+void RNA_def_particleset(BlenderRNA *brna)
+{
+	rna_def_particleset(brna);
+}
+
+#endif
+

Modified: branches/particles-2010/source/blender/modifiers/MOD_modifiertypes.h

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list