Bugfix #4051
[blender.git] / source / blender / blenkernel / intern / anim.c
index e7000838f7dd68af878056251b27de8321e3107a..3f7c28e09447cd7a2b06ff06f2c3a7b5941d3ac3 100644 (file)
@@ -471,6 +471,10 @@ static void particle_duplilist(ListBase *lb, Scene *sce, Object *par, PartEff *p
                                        /* temp copy, to have ipos etc to work OK */
                                        copyob= *ob;
                                        
+                                       /* don't want parent animation to apply on past object positions */
+                                       if(!(paf->flag & PAF_STATIC))
+                                               ob->parent= NULL;
+                                       
                                        for(a=0, pa= paf->keys, counter=0; a<paf->totpart; a++, pa+=paf->totkey, counter++) {
                                                
                                                if(paf->flag & PAF_STATIC) {
@@ -516,14 +520,21 @@ static void particle_duplilist(ListBase *lb, Scene *sce, Object *par, PartEff *p
 
                                                        //if(ctime < pa->time+pa->lifetime) {
 
-                                                       /* to give ipos in object correct offset */
+                                                       /* to give ipos in object correct offset, ob->parent is NULLed */
                                                        where_is_object_time(ob, ctime-pa->time);
                                                        
                                                        where_is_particle(paf, pa, ctime, vec);
                                                        if(paf->stype==PAF_VECT) {
-                                                               where_is_particle(paf, pa, ctime+1.0f, vec1);
                                                                
-                                                               VecSubf(vec1, vec1, vec);
+                                                               /* if particle died, we use previous position */
+                                                               if(ctime > pa->time+pa->lifetime) {
+                                                                       where_is_particle(paf, pa, pa->time+pa->lifetime-1.0f, vec1);
+                                                                       VecSubf(vec1, vec, vec1);
+                                                               }
+                                                               else {
+                                                                       where_is_particle(paf, pa, ctime+1.0f, vec1);
+                                                                       VecSubf(vec1, vec1, vec);
+                                                               }
                                                                q2= vectoquat(vec1, ob->trackflag, ob->upflag);
                                        
                                                                QuatToMat3(q2, mat);