Merge branch 'master' into blender2.8
[blender.git] / source / blender / modifiers / intern / MOD_explode.c
index 2d4a4a89f718ad6dd1c28143dfb9f08ef1a51125..4167d60a4097cd4548f524b78f202fe1a0b5cfe4 100644 (file)
@@ -147,7 +147,7 @@ static void createFacepa(ExplodeModifierData *emd,
        /* make tree of emitter locations */
        tree = BLI_kdtree_new(totpart);
        for (p = 0, pa = psys->particles; p < totpart; p++, pa++) {
-               psys_particle_on_emitter(psmd, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, NULL, NULL, NULL, NULL, NULL);
+               psys_particle_on_emitter(psmd, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, NULL, NULL, NULL, NULL);
                BLI_kdtree_insert(tree, p, co);
        }
        BLI_kdtree_balance(tree);
@@ -785,9 +785,10 @@ static DerivedMesh *cutEdges(ExplodeModifierData *emd, DerivedMesh *dm)
 
        return splitdm;
 }
-static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
-                                ParticleSystemModifierData *psmd, Scene *scene, Object *ob,
-                                DerivedMesh *to_explode)
+static DerivedMesh *explodeMesh(
+        ExplodeModifierData *emd,
+        ParticleSystemModifierData *psmd, const ModifierEvalContext *ctx, Scene *scene,
+        DerivedMesh *to_explode)
 {
        DerivedMesh *explode, *dm = to_explode;
        MFace *mf = NULL, *mface;
@@ -812,8 +813,9 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
        mface = dm->getTessFaceArray(dm);
        totpart = psmd->psys->totpart;
 
+       sim.depsgraph = ctx->depsgraph;
        sim.scene = scene;
-       sim.ob = ob;
+       sim.ob = ctx->object;
        sim.psys = psmd->psys;
        sim.psmd = psmd;
 
@@ -868,7 +870,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
        /*dupvert = CDDM_get_verts(explode);*/
 
        /* getting back to object space */
-       invert_m4_m4(imat, ob->obmat);
+       invert_m4_m4(imat, ctx->object->obmat);
 
        psmd->psys->lattice_deform_data = psys_create_lattice_deform_data(&sim);
 
@@ -899,7 +901,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
                        psys_get_particle_state(&sim, ed_v2, &state, 1);
 
                        vertco = CDDM_get_vert(explode, v)->co;
-                       mul_m4_v3(ob->obmat, vertco);
+                       mul_m4_v3(ctx->object->obmat, vertco);
 
                        sub_v3_v3(vertco, birth.co);
 
@@ -993,13 +995,12 @@ static ParticleSystemModifierData *findPrecedingParticlesystem(Object *ob, Modif
        }
        return psmd;
 }
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
-                                  DerivedMesh *derivedData,
-                                  ModifierApplyFlag UNUSED(flag))
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+                                  DerivedMesh *derivedData)
 {
        DerivedMesh *dm = derivedData;
        ExplodeModifierData *emd = (ExplodeModifierData *) md;
-       ParticleSystemModifierData *psmd = findPrecedingParticlesystem(ob, md);
+       ParticleSystemModifierData *psmd = findPrecedingParticlesystem(ctx->object, md);
 
        if (psmd) {
                ParticleSystem *psys = psmd->psys;
@@ -1028,7 +1029,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                if (emd->flag & eExplodeFlag_EdgeCut) {
                        int *facepa = emd->facepa;
                        DerivedMesh *splitdm = cutEdges(emd, dm);
-                       DerivedMesh *explode = explodeMesh(emd, psmd, md->scene, ob, splitdm);
+                       DerivedMesh *explode = explodeMesh(emd, psmd, ctx, md->scene, splitdm);
 
                        MEM_freeN(emd->facepa);
                        emd->facepa = facepa;
@@ -1036,7 +1037,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
                        return explode;
                }
                else
-                       return explodeMesh(emd, psmd, md->scene, ob, derivedData);
+                       return explodeMesh(emd, psmd, ctx, md->scene, derivedData);
        }
        return derivedData;
 }
@@ -1049,17 +1050,25 @@ ModifierTypeInfo modifierType_Explode = {
        /* type */              eModifierTypeType_Constructive,
        /* flags */             eModifierTypeFlag_AcceptsMesh,
        /* copyData */          copyData,
+
+       /* deformVerts_DM */    NULL,
+       /* deformMatrices_DM */ NULL,
+       /* deformVertsEM_DM */  NULL,
+       /* deformMatricesEM_DM*/NULL,
+       /* applyModifier_DM */  applyModifier,
+       /* applyModifierEM_DM */NULL,
+
        /* deformVerts */       NULL,
        /* deformMatrices */    NULL,
        /* deformVertsEM */     NULL,
        /* deformMatricesEM */  NULL,
-       /* applyModifier */     applyModifier,
+       /* applyModifier */     NULL,
        /* applyModifierEM */   NULL,
+
        /* initData */          initData,
        /* requiredDataMask */  requiredDataMask,
        /* freeData */          freeData,
        /* isDisabled */        NULL,
-       /* updateDepgraph */    NULL,
        /* updateDepsgraph */   NULL,
        /* dependsOnTime */     dependsOnTime,
        /* dependsOnNormals */  NULL,