svn merge ^/trunk/blender -r40644:40720
[blender-staging.git] / source / blender / modifiers / intern / MOD_explode.c
index 7b86731b5bbb9f9328c51de48366ba477f2ce6fe..59461d18f8f138b85244fcc86cd58dcda16ec655 100644 (file)
@@ -543,7 +543,8 @@ static void remap_uvs_23(DerivedMesh *dm, DerivedMesh *split, int numlayer, int
        }
 }
 
-static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm){
+static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
+{
        DerivedMesh *splitdm;
        MFace *mf=NULL,*df1=NULL;
        MFace *mface=dm->getTessFaceArray(dm);
@@ -557,7 +558,9 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm){
        int *vertpa = MEM_callocN(sizeof(int)*totvert,"explode_vertpa2");
        int *facepa = emd->facepa;
        int *fs, totesplit=0,totfsplit=0,curdupface=0;
-       int i,j,v1,v2,v3,v4,esplit, v[4], uv[4];
+       int i,j,v1,v2,v3,v4,esplit,
+           v[4]  = {0, 0, 0, 0}, /* To quite gcc barking... */
+           uv[4] = {0, 0, 0, 0}; /* To quite gcc barking... */
        int numlayer;
 
        edgehash= BLI_edgehash_new();
@@ -779,14 +782,14 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
 {
        DerivedMesh *explode, *dm=to_explode;
        MFace *mf= NULL, *mface;
-       ParticleSettings *part=psmd->psys->part;
+       /* ParticleSettings *part=psmd->psys->part; */ /* UNUSED */
        ParticleSimulationData sim= {NULL};
        ParticleData *pa=NULL, *pars=psmd->psys->particles;
-       ParticleKey state;
+       ParticleKey state, birth;
        EdgeHash *vertpahash;
        EdgeHashIterator *ehi;
        float *vertco= NULL, imat[4][4];
-       float loc0[3], nor[3];
+       float rot[4];
        float cfra;
        /* float timestep; */
        int *facepa=emd->facepa;
@@ -817,7 +820,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
        for (i=0; i<totface; i++) {
                /* do mindex + totvert to ensure the vertex index to be the first
                 * with BLI_edgehashIterator_getKey */
-               if(facepa[i]==totpart || cfra <= (pars+facepa[i])->time)
+               if(facepa[i]==totpart || cfra < (pars+facepa[i])->time)
                        mindex = totvert+totpart;
                else 
                        mindex = totvert+facepa[i];
@@ -871,26 +874,26 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
                        /* get particle */
                        pa= pars+i;
 
-                       /* get particle state */
-                       psys_particle_on_emitter(psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,loc0,nor,NULL,NULL,NULL,NULL);
-                       mul_m4_v3(ob->obmat,loc0);
+                       psys_get_birth_coordinates(&sim, pa, &birth, 0, 0);
 
                        state.time=cfra;
                        psys_get_particle_state(&sim, i, &state, 1);
 
                        vertco=CDDM_get_vert(explode,v)->co;
-                       
                        mul_m4_v3(ob->obmat,vertco);
 
-                       VECSUB(vertco,vertco,loc0);
+                       sub_v3_v3(vertco, birth.co);
 
                        /* apply rotation, size & location */
-                       mul_qt_v3(state.rot,vertco);
+                       sub_qt_qtqt(rot, state.rot, birth.rot);
+                       mul_qt_v3(rot, vertco);
+
                        if(emd->flag & eExplodeFlag_PaSize)
                                mul_v3_fl(vertco,pa->size);
-                       VECADD(vertco,vertco,state.co);
 
-                       mul_m4_v3(imat,vertco);
+                       add_v3_v3(vertco, state.co);
+
+                       mul_m4_v3(imat, vertco);
                }
        }
        BLI_edgehashIterator_free(ehi);
@@ -914,7 +917,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
                
                orig_v4 = source.v4;
 
-               if(facepa[i]!=totpart && cfra <= pa->time)
+               if(facepa[i]!=totpart && cfra < pa->time)
                        mindex = totvert+totpart;
                else 
                        mindex = totvert+facepa[i];
@@ -1041,4 +1044,5 @@ ModifierTypeInfo modifierType_Explode = {
        /* dependsOnNormals */  NULL,
        /* foreachObjectLink */ NULL,
        /* foreachIDLink */     NULL,
+       /* foreachTexLink */    NULL,
 };