Merge branch 'master' into blender2.8
[blender.git] / source / blender / modifiers / intern / MOD_dynamicpaint.c
index 9a497acbde118a2c90b9f9e2ecbb3eed35b84521..f951c96116d38cc0dbd45ec469afe16b62955289 100644 (file)
 
 #include "BKE_cdderivedmesh.h"
 #include "BKE_dynamicpaint.h"
+#include "BKE_layer.h"
 #include "BKE_library.h"
 #include "BKE_library_query.h"
 #include "BKE_modifier.h"
 
-#include "depsgraph_private.h"
+#include "DEG_depsgraph.h"
+
 #include "DEG_depsgraph_build.h"
 
 #include "MOD_modifiertypes.h"
@@ -66,9 +68,6 @@ static void copyData(const ModifierData *md, ModifierData *target)
                        id_us_plus((ID *)surface->init_texture);
                }
        }
-       if (tpmd->brush) {
-               id_us_plus((ID *)tpmd->brush->mat);
-       }
 }
 
 static void freeData(ModifierData *md)
@@ -89,7 +88,7 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
                        if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ || 
                            surface->init_color_type == MOD_DPAINT_INITIAL_TEXTURE)
                        {
-                               dataMask |= CD_MASK_MLOOPUV | CD_MASK_MTEXPOLY;
+                               dataMask |= CD_MASK_MLOOPUV;
                        }
                        /* mcol */
                        if (surface->type == MOD_DPAINT_SURFACE_T_PAINT ||
@@ -103,24 +102,17 @@ static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
                        }
                }
        }
-
-       if (pmd->brush) {
-               if (pmd->brush->flags & MOD_DPAINT_USE_MATERIAL) {
-                       dataMask |= CD_MASK_MLOOPUV | CD_MASK_MTEXPOLY;
-               }
-       }
        return dataMask;
 }
 
-static DerivedMesh *applyModifier(ModifierData *md, Object *ob, 
-                                  DerivedMesh *dm,
-                                  ModifierApplyFlag flag)
+static DerivedMesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx,
+                                  DerivedMesh *dm)
 {
        DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md;
 
        /* dont apply dynamic paint on orco dm stack */
-       if (!(flag & MOD_APPLY_ORCO)) {
-               return dynamicPaint_Modifier_do(pmd, md->scene, ob, dm);
+       if (!(ctx->flag & MOD_APPLY_ORCO)) {
+               return dynamicPaint_Modifier_do(pmd, ctx->depsgraph, md->scene, ctx->object, dm);
        }
        return dm;
 }
@@ -130,27 +122,6 @@ static bool is_brush_cb(Object *UNUSED(ob), ModifierData *pmd)
        return ((DynamicPaintModifierData *)pmd)->brush != NULL;
 }
 
-static void updateDepgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
-{
-       DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md;
-
-       /* add relation from canvases to all brush objects */
-       if (pmd && pmd->canvas) {
-#ifdef WITH_LEGACY_DEPSGRAPH
-               for (DynamicPaintSurface *surface = pmd->canvas->surfaces.first; surface; surface = surface->next) {
-                       if (surface->effect & MOD_DPAINT_EFFECT_DO_DRIP) {
-                               dag_add_forcefield_relations(ctx->forest, ctx->scene, ctx->object, ctx->obNode, surface->effector_weights, true, 0, "Dynamic Paint Field");
-                       }
-
-                       /* Actual code uses custom loop over group/scene without layer checks in dynamicPaint_doStep */
-                       dag_add_collision_relations(ctx->forest, ctx->scene, ctx->object, ctx->obNode, surface->brush_group, -1, eModifierType_DynamicPaint, is_brush_cb, false, "Dynamic Paint Brush");
-               }
-#else
-       (void)ctx;
-#endif
-       }
-}
-
 static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
 {
        DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)md;
@@ -162,7 +133,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte
                        }
 
                        /* Actual code uses custom loop over group/scene without layer checks in dynamicPaint_doStep */
-                       DEG_add_collision_relations(ctx->node, ctx->scene, ctx->object, surface->brush_group, -1, eModifierType_DynamicPaint, is_brush_cb, false, "Dynamic Paint Brush");
+                       DEG_add_collision_relations(ctx->node, ctx->scene, ctx->object, surface->brush_group,  eModifierType_DynamicPaint, is_brush_cb, false, "Dynamic Paint Brush");
                }
        }
 }
@@ -188,9 +159,6 @@ static void foreachIDLink(ModifierData *md, Object *ob,
                        }
                }
        }
-       if (pmd->brush) {
-               walk(userData, ob, (ID **)&pmd->brush->mat, IDWALK_CB_USER);
-       }
 }
 
 static void foreachTexLink(ModifierData *UNUSED(md), Object *UNUSED(ob),
@@ -211,17 +179,25 @@ ModifierTypeInfo modifierType_DynamicPaint = {
                                eModifierTypeFlag_UsesPreview,
 
        /* 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 */    updateDepgraph,
        /* updateDepsgraph */   updateDepsgraph,
        /* dependsOnTime */     dependsOnTime,
        /* dependsOnNormals */  NULL,