diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-05-02 18:46:08 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2019-05-02 18:46:54 +0300 |
commit | cdf68af12e6348782918c968eb0741d9cd135a6d (patch) | |
tree | 153ec967e76fab22bd1ac55b1ea1bb47d68e4c70 /source/blender | |
parent | 95e052f830807a89f36021b77638a3a5d0c01309 (diff) |
Fix T64072: DynamicPaint: Bake failed: Canvas mesh not updated
Baking is to happen form within an evaluated scene.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/physics/dynamicpaint_ops.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index cb8fe262730..40b7a245f69 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -47,6 +47,7 @@ #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" +#include "DEG_depsgraph_query.h" #include "ED_mesh.h" #include "ED_screen.h" @@ -360,6 +361,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) DynamicPaintSurface *surface = job->surface; Object *cObject = job->ob; DynamicPaintCanvasSettings *canvas = surface->canvas; + Scene *input_scene = DEG_get_input_scene(job->depsgraph); Scene *scene = job->scene; int frame = 1, orig_frame; int frames; @@ -375,8 +377,8 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) /* Set frame to start point (also inits modifier data) */ frame = surface->start_frame; - orig_frame = scene->r.cfra; - scene->r.cfra = (int)frame; + orig_frame = input_scene->r.cfra; + input_scene->r.cfra = (int)frame; ED_update_for_newframe(job->bmain, job->depsgraph); /* Init surface */ @@ -402,7 +404,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) *(job->progress) = progress; /* calculate a frame */ - scene->r.cfra = (int)frame; + input_scene->r.cfra = (int)frame; ED_update_for_newframe(job->bmain, job->depsgraph); if (!dynamicPaint_calculateFrame(surface, job->depsgraph, scene, cObject, frame)) { job->success = 0; @@ -438,7 +440,8 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) } } - scene->r.cfra = orig_frame; + input_scene->r.cfra = orig_frame; + ED_update_for_newframe(job->bmain, job->depsgraph); } static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update, float *progress) @@ -470,25 +473,26 @@ static void dpaint_bake_startjob(void *customdata, short *stop, short *do_update */ static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) { - DynamicPaintModifierData *pmd = NULL; - DynamicPaintCanvasSettings *canvas; - Object *ob = ED_object_context(C); - Scene *scene = CTX_data_scene(C); + Depsgraph *depsgraph = CTX_data_depsgraph(C); + Object *ob_ = ED_object_context(C); + Object *object_eval = DEG_get_evaluated_object(depsgraph, ob_); + Scene *scene_eval = DEG_get_evaluated_scene(depsgraph); DynamicPaintSurface *surface; /* * Get modifier data */ - pmd = (DynamicPaintModifierData *)modifiers_findByType(ob, eModifierType_DynamicPaint); - if (!pmd) { + DynamicPaintModifierData *pmd = (DynamicPaintModifierData *)modifiers_findByType( + object_eval, eModifierType_DynamicPaint); + if (pmd == NULL) { BKE_report(op->reports, RPT_ERROR, "Bake failed: no Dynamic Paint modifier found"); return OPERATOR_CANCELLED; } /* Make sure we're dealing with a canvas */ - canvas = pmd->canvas; - if (!canvas) { + DynamicPaintCanvasSettings *canvas = pmd->canvas; + if (canvas == NULL) { BKE_report(op->reports, RPT_ERROR, "Bake failed: invalid canvas"); return OPERATOR_CANCELLED; } @@ -500,15 +504,15 @@ 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->scene = scene_eval; job->depsgraph = CTX_data_depsgraph(C); - job->ob = ob; + job->ob = object_eval; job->canvas = canvas; job->surface = surface; wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), - scene, + CTX_data_scene(C), "Dynamic Paint Bake", WM_JOB_PROGRESS, WM_JOB_TYPE_DPAINT_BAKE); |