Bugfix #4051
authorTon Roosendaal <ton@blender.org>
Sun, 2 Apr 2006 11:48:22 +0000 (11:48 +0000)
committerTon Roosendaal <ton@blender.org>
Sun, 2 Apr 2006 11:48:22 +0000 (11:48 +0000)
- particle duplicators should not include parent animation (error in
  duplicator recode of last december)
- added exception for 'died' particles to keep correct orientation

Also in this commit:

- added comment in code to explain why vertexnormals in mesh are equal to
  vertex location when no faces exist
- cleanup of BKE_object.h for functions that don't need export.

source/blender/blenkernel/BKE_object.h
source/blender/blenkernel/intern/DerivedMesh.c
source/blender/blenkernel/intern/anim.c
source/blender/blenkernel/intern/object.c
source/blender/src/editmesh.c
source/blender/src/editmesh_lib.c

index d0f70907e5ca5e028804ea212897f99990e14ff3..0ed4119ac59a20ba9e1b3c55793e5b504bd8f566 100644 (file)
@@ -75,20 +75,18 @@ void expand_local_object(struct Object *ob);
 void make_local_object(struct Object *ob);
 void set_mblur_offs(float blur);
 void disable_speed_curve(int val);
+
 float bsystem_time(struct Object *ob, struct Object *par, float cfra, float ofs);
 void object_to_mat3(struct Object *ob, float mat[][3]);
 void object_to_mat4(struct Object *ob, float mat[][4]);
-void ob_parcurve(struct Object *ob, struct Object *par, float mat[][4]);
-void ob_parlimb(struct Object *ob, struct Object *par, float mat[][4]);
-void ob_parbone(struct Object *ob, struct Object *par, float mat[][4]);        /* __NLA */
-void give_parvert(struct Object *par, int nr, float *vec);
-void ob_parvert3(struct Object *ob, struct Object *par, float mat[][4]);
+
 void set_no_parent_ipo(int val);
-void set_dtime(int dtime);
+
 void disable_where_script(short on);
 int during_script(void);
 void disable_where_scriptlink(short on);
 int during_scriptlink(void);
+
 void where_is_object_time(struct Object *ob, float ctime);
 void where_is_object(struct Object *ob);
 void where_is_object_simul(struct Object *ob);
index 1eb94967900730cba9f9d665e3a1b2310aaf5082..1052007846fcf81ed9ed26c71dc9ce480e5ee536 100644 (file)
@@ -956,7 +956,7 @@ static DerivedMesh *getEditMeshDerivedMesh(EditMesh *em, float (*vertexCos)[3])
 
                for(i=0, eve= em->verts.first; eve; i++, eve=eve->next) {
                        float *no = emdm->vertexNos[i];
-
+                       /* following Mesh convention; we use vertex coordinate itself for normal in this case */
                        if (Normalise(no)==0.0) {
                                VECCOPY(no, vertexCos[i]);
                                Normalise(no);
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);
index bcc87ad9bed592397fd08137f3a62c94d4310139..6022c9eae192cfc7b57e665879d0037f3b81ecf7 100644 (file)
@@ -1095,7 +1095,7 @@ void object_to_mat4(Object *ob, float mat[][4])
 
 int enable_cu_speed= 1;
 
-void ob_parcurve(Object *ob, Object *par, float mat[][4])
+static void ob_parcurve(Object *ob, Object *par, float mat[][4])
 {
        Curve *cu;
        float q[4], vec[4], dir[3], *quat, x1, ctime;
@@ -1165,7 +1165,7 @@ void ob_parcurve(Object *ob, Object *par, float mat[][4])
        }
 }
 
-void ob_parbone(Object *ob, Object *par, float mat[][4])
+static void ob_parbone(Object *ob, Object *par, float mat[][4])
 {      
        bPoseChannel *pchan;
        bArmature *arm;
@@ -1194,7 +1194,7 @@ void ob_parbone(Object *ob, Object *par, float mat[][4])
        VecAddf(mat[3], mat[3], vec);
 }
 
-void give_parvert(Object *par, int nr, float *vec)
+static void give_parvert(Object *par, int nr, float *vec)
 {
        EditMesh *em = G.editMesh;
        EditVert *eve;
@@ -1273,7 +1273,7 @@ void give_parvert(Object *par, int nr, float *vec)
        else return;
 }
 
-void ob_parvert3(Object *ob, Object *par, float mat[][4])
+static void ob_parvert3(Object *ob, Object *par, float mat[][4])
 {
        float cmat[3][3], v1[3], v2[3], v3[3], q[4];
 
@@ -1307,12 +1307,6 @@ void set_no_parent_ipo(int val)
        no_parent_ipo= val;
 }
 
-static float timefac= 1.0;             /* 50 Hz, dtime:2 */
-void set_dtime(int dtime)
-{
-       timefac= ((float)(dtime-1))/2.0f;
-}
-
 static int during_script_flag=0;
 void disable_where_script(short on)
 {
@@ -1392,7 +1386,7 @@ void where_is_object_time(Object *ob, float ctime)
                if(ob->partype & PARSLOW) {
                        // include framerate
 
-                       fac1= (float)(timefac/(1.0+ fabs(ob->sf)));
+                       fac1= (1.0f/(1.0f+ fabs(ob->sf)));
                        if(fac1>=1.0) return;
                        fac2= 1.0f-fac1;
                        
index f5b9be06bd76cbfeb02a1190d295ca194149b04e..b3c89690bb12d05dea8d6f6af9ba8c0d8b64736b 100644 (file)
@@ -1631,7 +1631,7 @@ static void *editMesh_to_undoMesh(void)
        EditFaceC *efac=NULL;
        EditSelectionC *esec=NULL;
        TFace *tface= NULL;
-       int i, a;
+       int a;
        
        um= MEM_callocN(sizeof(UndoMesh), "undomesh");
        
index cb8e34af532a5704d1d2c8c2d820a5da3bf0014d..88852052eaac375524302c8857c05eefab8e6231 100644 (file)
@@ -1651,6 +1651,7 @@ void recalc_editnormals(void)
                VecAddf(efa->v3->no, efa->v3->no, efa->n);
        }
 
+       /* following Mesh convention; we use vertex coordinate itself for normal in this case */
        for(eve= em->verts.first; eve; eve=eve->next) {
                if (Normalise(eve->no)==0.0) {
                        VECCOPY(eve->no, eve->co);