Merge branch 'master' into blender2.8
[blender.git] / source / blender / editors / physics / dynamicpaint_ops.c
index 92f4ef8..f45ee05 100644 (file)
@@ -4,7 +4,7 @@
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. 
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -42,7 +42,6 @@
 #include "BKE_context.h"
 #include "BKE_deform.h"
 #include "BKE_object_deform.h"
-#include "BKE_depsgraph.h"
 #include "BKE_dynamicpaint.h"
 #include "BKE_global.h"
 #include "BKE_main.h"
@@ -50,6 +49,9 @@
 #include "BKE_report.h"
 #include "BKE_screen.h"
 
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+
 #include "ED_mesh.h"
 #include "ED_screen.h"
 #include "ED_object.h"
@@ -100,7 +102,7 @@ void DPAINT_OT_surface_slot_add(wmOperatorType *ot)
        ot->name = "Add Surface Slot";
        ot->idname = "DPAINT_OT_surface_slot_add";
        ot->description = "Add a new Dynamic Paint surface slot";
-       
+
        /* api callbacks */
        ot->exec = surface_slot_add_exec;
        ot->poll = ED_operator_object_active_editable;
@@ -135,7 +137,7 @@ static int surface_slot_remove_exec(bContext *C, wmOperator *UNUSED(op))
        }
 
        dynamicPaint_resetPreview(canvas);
-       DAG_id_tag_update(&obj_ctx->id, OB_RECALC_DATA);
+       DEG_id_tag_update(&obj_ctx->id, OB_RECALC_DATA);
        WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, obj_ctx);
 
        return OPERATOR_FINISHED;
@@ -148,7 +150,7 @@ void DPAINT_OT_surface_slot_remove(wmOperatorType *ot)
        ot->name = "Remove Surface Slot";
        ot->idname = "DPAINT_OT_surface_slot_remove";
        ot->description = "Remove the selected surface slot";
-       
+
        /* api callbacks */
        ot->exec = surface_slot_remove_exec;
        ot->poll = ED_operator_object_active_editable;
@@ -179,10 +181,10 @@ static int type_toggle_exec(bContext *C, wmOperator *op)
                if (!dynamicPaint_createType(pmd, type, scene))
                        return OPERATOR_CANCELLED;
        }
-       
+
        /* update dependency */
-       DAG_id_tag_update(&cObject->id, OB_RECALC_DATA);
-       DAG_relations_tag_update(CTX_data_main(C));
+       DEG_id_tag_update(&cObject->id, OB_RECALC_DATA);
+       DEG_relations_tag_update(CTX_data_main(C));
        WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, cObject);
 
        return OPERATOR_FINISHED;
@@ -196,14 +198,14 @@ void DPAINT_OT_type_toggle(wmOperatorType *ot)
        ot->name = "Toggle Type Active";
        ot->idname = "DPAINT_OT_type_toggle";
        ot->description = "Toggle whether given type is active or not";
-       
+
        /* api callbacks */
        ot->exec = type_toggle_exec;
        ot->poll = ED_operator_object_active_editable;
-       
+
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-       
+
        /* properties */
        prop = RNA_def_enum(ot->srna, "type", rna_enum_prop_dynamicpaint_type_items, MOD_DYNAMICPAINT_TYPE_CANVAS, "Type", "");
        ot->prop = prop;
@@ -223,7 +225,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
        if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
                int exists = dynamicPaint_outputLayerExists(surface, ob, output);
                const char *name;
-               
+
                if (output == 0)
                        name = surface->output_name;
                else
@@ -233,7 +235,7 @@ static int output_toggle_exec(bContext *C, wmOperator *op)
                if (surface->type == MOD_DPAINT_SURFACE_T_PAINT) {
                        if (!exists)
                                ED_mesh_color_add(ob->data, name, true);
-                       else 
+                       else
                                ED_mesh_color_remove_named(ob->data, name);
                }
                /* Vertex Weight Layer */
@@ -263,14 +265,14 @@ void DPAINT_OT_output_toggle(wmOperatorType *ot)
        ot->name = "Toggle Output Layer";
        ot->idname = "DPAINT_OT_output_toggle";
        ot->description = "Add or remove Dynamic Paint output data layer";
-       
+
        /* api callbacks */
        ot->exec = output_toggle_exec;
        ot->poll = ED_operator_object_active_editable;
-       
+
        /* flags */
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
-       
+
        /* properties */
        ot->prop = RNA_def_enum(ot->srna, "output", prop_output_toggle_types, 0, "Output Toggle", "");
 }
@@ -286,6 +288,7 @@ typedef struct DynamicPaintBakeJob {
 
        struct Main *bmain;
        Scene *scene;
+       Depsgraph *depsgraph;
        Object *ob;
 
        DynamicPaintSurface *surface;
@@ -357,7 +360,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
        frame = surface->start_frame;
        orig_frame = scene->r.cfra;
        scene->r.cfra = (int)frame;
-       ED_update_for_newframe(job->bmain, scene, 1);
+       ED_update_for_newframe(job->bmain, job->depsgraph);
 
        /* Init surface */
        if (!dynamicPaint_createUVSurface(scene, surface, job->progress, job->do_update)) {
@@ -383,8 +386,8 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job)
 
                /* calculate a frame */
                scene->r.cfra = (int)frame;
-               ED_update_for_newframe(job->bmain, scene, 1);
-               if (!dynamicPaint_calculateFrame(job->bmain->eval_ctx, surface, scene, cObject, frame)) {
+               ED_update_for_newframe(job->bmain, job->depsgraph);
+               if (!dynamicPaint_calculateFrame(surface, job->depsgraph, scene, cObject, frame)) {
                        job->success = 0;
                        return;
                }
@@ -479,6 +482,7 @@ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op)
        DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob");
        job->bmain = CTX_data_main(C);
        job->scene = scene;
+       job->depsgraph = CTX_data_depsgraph(C);
        job->ob = ob;
        job->canvas = canvas;
        job->surface = surface;
@@ -505,7 +509,7 @@ void DPAINT_OT_bake(wmOperatorType *ot)
        ot->name = "Dynamic Paint Bake";
        ot->description = "Bake dynamic paint image sequence surface";
        ot->idname = "DPAINT_OT_bake";
-       
+
        /* api callbacks */
        ot->exec = dynamicpaint_bake_exec;
        ot->poll = ED_operator_object_active_editable;