merge with/from trunk at r35190
[blender.git] / source / blender / modifiers / intern / MOD_explode.c
index aea6997c5d541748f8bf6402a3ae43efca56c4f2..04687958efdd8efb69b55c633f1bc75f0acf3595 100644 (file)
@@ -110,8 +110,8 @@ static void createFacepa(ExplodeModifierData *emd,
        int i,p,v1,v2,v3,v4=0;
 
        mvert = dm->getVertArray(dm);
-       mface = dm->getFaceArray(dm);
-       totface= dm->getNumFaces(dm);
+       mface = dm->getTessFaceArray(dm);
+       totface= dm->getNumTessFaces(dm);
        totvert= dm->getNumVerts(dm);
        totpart= psmd->psys->totpart;
 
@@ -200,7 +200,7 @@ const short add_faces[24] = {
 
 MFace *get_dface(DerivedMesh *dm, DerivedMesh *split, int cur, int i, MFace *mf)
 {
-       MFace *df = CDDM_get_face(split, cur);
+       MFace *df = CDDM_get_tessface(split, cur);
        DM_copy_face_data(dm, split, i, cur, 1);
        *df = *mf;
        return df;
@@ -547,12 +547,12 @@ static void remap_uvs_23(DerivedMesh *dm, DerivedMesh *split, int numlayer, int
 static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm){
        DerivedMesh *splitdm;
        MFace *mf=NULL,*df1=NULL;
-       MFace *mface=dm->getFaceArray(dm);
+       MFace *mface=dm->getTessFaceArray(dm);
        MVert *dupve, *mv;
        EdgeHash *edgehash;
        EdgeHashIterator *ehi;
        int totvert=dm->getNumVerts(dm);
-       int totface=dm->getNumFaces(dm);
+       int totface=dm->getNumTessFaces(dm);
 
        int *facesplit = MEM_callocN(sizeof(int)*totface,"explode_facesplit");
        int *vertpa = MEM_callocN(sizeof(int)*totvert,"explode_vertpa2");
@@ -628,7 +628,7 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm){
        for(i=0,fs=facesplit; i<totface; i++,fs++)
                totfsplit += add_faces[*fs];
        
-       splitdm= CDDM_from_template(dm, totesplit, 0, totface+totfsplit);
+       splitdm= CDDM_from_template(dm, totesplit, 0, totface+totfsplit, 0, 0);
        numlayer = CustomData_number_of_layers(&splitdm->faceData, CD_MTFACE);
 
        /* copy new faces & verts (is it really this painful with custom data??) */
@@ -670,7 +670,7 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm){
        curdupface=0;//=totface;
        //curdupin=totesplit;
        for(i=0,fs=facesplit; i<totface; i++,fs++){
-               mf = dm->getFaceData(dm, i, CD_MFACE);
+               mf = dm->getTessFaceData(dm, i, CD_MFACE);
 
                switch(*fs) {
                case 3:
@@ -760,7 +760,7 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm){
        }
 
        for(i=0; i<curdupface; i++) {
-               mf = CDDM_get_face(splitdm, i);
+               mf = CDDM_get_tessface(splitdm, i);
                test_index_face(mf, &splitdm->faceData, i, (mf->flag & ME_FACE_SEL ? 4 : 3));
        }
 
@@ -768,8 +768,11 @@ static DerivedMesh * cutEdges(ExplodeModifierData *emd, DerivedMesh *dm){
        MEM_freeN(facesplit);
        MEM_freeN(vertpa);
 
-       return splitdm;
+       dm = CDDM_copy(splitdm, 1); /*builds ngon faces from tess (mface) faces*/
+       splitdm->needsFree = 1;
+       splitdm->release(splitdm);
 
+       return dm;
 }
 static DerivedMesh * explodeMesh(ExplodeModifierData *emd, 
                ParticleSystemModifierData *psmd, Scene *scene, Object *ob, 
@@ -792,9 +795,9 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
        int i, j, v, mindex=0;
        MTFace *mtface = NULL, *mtf;
 
-       totface= dm->getNumFaces(dm);
+       totface= dm->getNumTessFaces(dm);
        totvert= dm->getNumVerts(dm);
-       mface= dm->getFaceArray(dm);
+       mface= dm->getTessFaceArray(dm);
        totpart= psmd->psys->totpart;
 
        sim.scene= scene;
@@ -839,7 +842,7 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
        BLI_edgehashIterator_free(ehi);
 
        /* the final duplicated vertices */
-       explode= CDDM_from_template(dm, totdup, 0,totface);
+       explode= CDDM_from_template(dm, totdup, 0,totface, 0, 0);
        mtface = CustomData_get_layer_named(&explode->faceData, CD_MTFACE, emd->uvname);
        /*dupvert= CDDM_get_verts(explode);*/
 
@@ -907,8 +910,8 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
                        if(pa->alive==PARS_DEAD && (emd->flag&eExplodeFlag_Dead)==0) continue;
                }
 
-               dm->getFace(dm,i,&source);
-               mf=CDDM_get_face(explode,i);
+               dm->getTessFace(dm,i,&source);
+               mf=CDDM_get_tessface(explode,i);
                
                orig_v4 = source.v4;
 
@@ -954,6 +957,10 @@ static DerivedMesh * explodeMesh(ExplodeModifierData *emd,
                psmd->psys->lattice= NULL;
        }
 
+       dm = CDDM_copy(explode, 1); /*builds ngon faces from tess (mface) faces*/
+       explode->needsFree = 1;
+       explode->release(explode);
+
        return explode;
 }
 
@@ -988,7 +995,7 @@ static DerivedMesh * applyModifier(ModifierData *md, Object *ob,
                if(emd->facepa==0
                                 || psmd->flag&eParticleSystemFlag_Pars
                                 || emd->flag&eExplodeFlag_CalcFaces
-                                || MEM_allocN_len(emd->facepa)/sizeof(int) != dm->getNumFaces(dm))
+                                || MEM_allocN_len(emd->facepa)/sizeof(int) != dm->getNumTessFaces(dm))
                {
                        if(psmd->flag & eParticleSystemFlag_Pars)
                                psmd->flag &= ~eParticleSystemFlag_Pars;