Merge branch 'master' into blender2.8
[blender.git] / source / blender / modifiers / intern / MOD_wave.c
index 49dd4718c9c95e1fc206219684104e67a9d4210e..f558d3fc5bdca70f2b7ac81d7b802ac685aef5f2 100644 (file)
 #include "BKE_scene.h"
 #include "BKE_texture.h"
 
-#include "depsgraph_private.h"
-
 #include "MEM_guardedalloc.h"
 #include "RE_shader_ext.h"
 
 #include "MOD_modifiertypes.h"
 #include "MOD_util.h"
 
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
+
 static void initData(ModifierData *md)
 {
        WaveModifierData *wmd = (WaveModifierData *) md; // whadya know, moved here from Iraq
@@ -109,25 +110,6 @@ static void foreachTexLink(ModifierData *md, Object *ob,
        walk(userData, ob, md, "texture");
 }
 
-static void updateDepgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
-{
-       WaveModifierData *wmd = (WaveModifierData *) md;
-
-       if (wmd->objectcenter) {
-               DagNode *curNode = dag_get_node(ctx->forest, wmd->objectcenter);
-
-               dag_add_relation(ctx->forest, curNode, ctx->obNode, DAG_RL_OB_DATA,
-                                "Wave Modifier");
-       }
-
-       if (wmd->map_object) {
-               DagNode *curNode = dag_get_node(ctx->forest, wmd->map_object);
-
-               dag_add_relation(ctx->forest, curNode, ctx->obNode, DAG_RL_OB_DATA,
-                                "Wave Modifer");
-       }
-}
-
 static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
 {
        WaveModifierData *wmd = (WaveModifierData *)md;
@@ -156,15 +138,16 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
        return dataMask;
 }
 
-static void waveModifier_do(WaveModifierData *md, 
-                            Scene *scene, Object *ob, DerivedMesh *dm,
+static void waveModifier_do(WaveModifierData *md,
+                            Depsgraph *depsgraph,
+                            Object *ob, DerivedMesh *dm,
                             float (*vertexCos)[3], int numVerts)
 {
        WaveModifierData *wmd = (WaveModifierData *) md;
        MVert *mvert = NULL;
        MDeformVert *dvert;
        int defgrp_index;
-       float ctime = BKE_scene_frame_get(scene);
+       float ctime = DEG_get_ctime(depsgraph);
        float minfac = (float)(1.0 / exp(wmd->width * wmd->narrow * wmd->width * wmd->narrow));
        float lifefac = wmd->height;
        float (*tex_co)[3] = NULL;
@@ -309,39 +292,39 @@ static void waveModifier_do(WaveModifierData *md,
        if (wmd->texture) MEM_freeN(tex_co);
 }
 
-static void deformVerts(ModifierData *md, Object *ob,
+static void deformVerts(ModifierData *md, const ModifierEvalContext *ctx,
                         DerivedMesh *derivedData,
                         float (*vertexCos)[3],
-                        int numVerts,
-                        ModifierApplyFlag UNUSED(flag))
+                        int numVerts)
 {
        DerivedMesh *dm = derivedData;
        WaveModifierData *wmd = (WaveModifierData *)md;
 
        if (wmd->flag & MOD_WAVE_NORM)
-               dm = get_cddm(ob, NULL, dm, vertexCos, false);
+               dm = get_cddm(ctx->object, NULL, dm, vertexCos, false);
        else if (wmd->texture || wmd->defgrp_name[0])
-               dm = get_dm(ob, NULL, dm, NULL, false, false);
+               dm = get_dm(ctx->object, NULL, dm, NULL, false, false);
 
-       waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts);
+       waveModifier_do(wmd, ctx->depsgraph, ctx->object, dm, vertexCos, numVerts);
 
        if (dm != derivedData)
                dm->release(dm);
 }
 
 static void deformVertsEM(
-        ModifierData *md, Object *ob, struct BMEditMesh *editData,
+        ModifierData *md, const ModifierEvalContext *ctx,
+        struct BMEditMesh *editData,
         DerivedMesh *derivedData, float (*vertexCos)[3], int numVerts)
 {
        DerivedMesh *dm = derivedData;
        WaveModifierData *wmd = (WaveModifierData *)md;
 
        if (wmd->flag & MOD_WAVE_NORM)
-               dm = get_cddm(ob, editData, dm, vertexCos, false);
+               dm = get_cddm(ctx->object, editData, dm, vertexCos, false);
        else if (wmd->texture || wmd->defgrp_name[0])
-               dm = get_dm(ob, editData, dm, NULL, false, false);
+               dm = get_dm(ctx->object, editData, dm, NULL, false, false);
 
-       waveModifier_do(wmd, md->scene, ob, dm, vertexCos, numVerts);
+       waveModifier_do(wmd, ctx->depsgraph, ctx->object, dm, vertexCos, numVerts);
 
        if (dm != derivedData)
                dm->release(dm);
@@ -356,18 +339,27 @@ ModifierTypeInfo modifierType_Wave = {
        /* flags */             eModifierTypeFlag_AcceptsCVs |
                                eModifierTypeFlag_AcceptsLattice |
                                eModifierTypeFlag_SupportsEditmode,
+
        /* copyData */          modifier_copyData_generic,
-       /* deformVerts */       deformVerts,
+
+       /* deformVerts_DM */    deformVerts,
+       /* deformMatrices_DM */ NULL,
+       /* deformVertsEM_DM */  deformVertsEM,
+       /* deformMatricesEM_DM*/NULL,
+       /* applyModifier_DM */  NULL,
+       /* applyModifierEM_DM */NULL,
+
+       /* deformVerts */       NULL,
        /* deformMatrices */    NULL,
-       /* deformVertsEM */     deformVertsEM,
+       /* deformVertsEM */     NULL,
        /* deformMatricesEM */  NULL,
        /* applyModifier */     NULL,
        /* applyModifierEM */   NULL,
+
        /* initData */          initData,
        /* requiredDataMask */  requiredDataMask,
        /* freeData */          NULL,
        /* isDisabled */        NULL,
-       /* updateDepgraph */    updateDepgraph,
        /* updateDepsgraph */   updateDepsgraph,
        /* dependsOnTime */     dependsOnTime,
        /* dependsOnNormals */  NULL,