Particle system parenting
authorJanne Karhu <jhkarh@gmail.com>
Sun, 21 Jun 2009 11:09:16 +0000 (11:09 +0000)
committerJanne Karhu <jhkarh@gmail.com>
Sun, 21 Jun 2009 11:09:16 +0000 (11:09 +0000)
* Allows moving, rotating & scaling of particle simulations.
* Setting in particle render options.
* Changes viewed & rendered particles from global space to parent space.
* Doesn't effect simulations at all.

release/ui/buttons_particle.py
source/blender/editors/space_view3d/drawobject.c
source/blender/makesdna/DNA_particle_types.h
source/blender/makesrna/intern/rna_particle.c
source/blender/render/intern/source/convertblender.c

index 3970f7069200379a0f3b6decb6c914ea11efe246..e03db78b7e44c44dda959c135e4ec74e7e8ee977 100644 (file)
@@ -288,7 +288,9 @@ class PARTICLE_PT_render(ParticleButtonsPanel):
                psys = context.particle_system
                part = psys.settings
                
-               layout.itemR(part, "material")
+               row = layout.row()
+               row.itemR(part, "material")
+               row.itemR(psys, "parent");
                
                split = layout.split()
                        
index a67e8c8a1c32c9d039bc7bdc350f4da7778840f0..42da6775d5fc837d5e9e63e1737e439290ce17f9 100644 (file)
@@ -3239,6 +3239,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
                        if(draw_as!=PART_DRAW_PATH){
                                state.time=cfra;
                                if(psys_get_particle_state(scene,ob,psys,a,&state,0)){
+                                       if(psys->parent)
+                                               Mat4MulVecfl(psys->parent->obmat, state.co);
+
                                        /* create actiual particle data */
                                        switch(draw_as){
                                                case PART_DRAW_DOT:
index 6805082d094e3c1a9a7bc2279b74fdf9df3b9b40..b10f35b909169439bd6fcaa5b0cdf3468db72eb3 100644 (file)
@@ -192,6 +192,7 @@ typedef struct ParticleSystem{                              /* note, make sure all (runtime) are NULL's in
        struct Object *target_ob;
        struct Object *keyed_ob;
        struct Object *lattice;
+       struct Object *parent;                                  /* particles from global space -> parent space */
 
        struct ListBase effectors, reactevents; /* runtime */
        
index 2c4c75e45ebfe2a2278531f5247005f3d4965f37..c48c1006588618945c611fee18bdb1798ce82aec 100644 (file)
@@ -1715,6 +1715,14 @@ static void rna_def_particle_system(BlenderRNA *brna)
        RNA_def_property_pointer_sdna(prop, NULL, "pointcache");
        RNA_def_property_struct_type(prop, "PointCache");
        RNA_def_property_ui_text(prop, "Point Cache", "");
+
+       /* offset ob */
+       prop= RNA_def_property(srna, "parent", PROP_POINTER, PROP_NONE);
+       RNA_def_property_pointer_sdna(prop, NULL, "parent");
+       RNA_def_property_flag(prop, PROP_EDITABLE);
+       RNA_def_property_ui_text(prop, "Parent", "Use this object's coordinate system instead of global coordinate system.");
+       RNA_def_property_update(prop, NC_OBJECT|ND_PARTICLE, "rna_Particle_redo");
+
 }
 
 void RNA_def_particle(BlenderRNA *brna)
index 98e5819c0d360495bd2489f54932f802987c4f3b..8423b5d271c39051c56c61fd3eaecebb507a800e 100644 (file)
@@ -1886,6 +1886,9 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                        if(psys_get_particle_state(re->scene,ob,psys,a,&state,0)==0)
                                continue;
 
+                       if(psys->parent)
+                               Mat4MulVecfl(psys->parent->obmat, state.co);
+
                        VECCOPY(loc,state.co);
                        if(part->ren_as!=PART_DRAW_BB)
                                MTC_Mat4MulVecfl(re->viewmat,loc);