Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/dynamicpaint_ops.c
| Show First 20 Lines • Show All 282 Lines • ▼ Show 20 Lines | |||||
| typedef struct DynamicPaintBakeJob { | typedef struct DynamicPaintBakeJob { | ||||
| /* from wmJob */ | /* from wmJob */ | ||||
| void *owner; | void *owner; | ||||
| short *stop, *do_update; | short *stop, *do_update; | ||||
| float *progress; | float *progress; | ||||
| struct Main *bmain; | struct Main *bmain; | ||||
| Scene *scene; | Scene *scene; | ||||
| SceneLayer *scene_layer; | ViewLayer *view_layer; | ||||
| Depsgraph *depsgraph; | Depsgraph *depsgraph; | ||||
| Object *ob; | Object *ob; | ||||
| DynamicPaintSurface *surface; | DynamicPaintSurface *surface; | ||||
| DynamicPaintCanvasSettings *canvas; | DynamicPaintCanvasSettings *canvas; | ||||
| EvaluationContext *eval_ctx; | EvaluationContext *eval_ctx; | ||||
| ▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) | ||||
| /* Show progress bar. */ | /* Show progress bar. */ | ||||
| *(job->do_update) = true; | *(job->do_update) = true; | ||||
| /* Set frame to start point (also inits modifier data) */ | /* Set frame to start point (also inits modifier data) */ | ||||
| frame = surface->start_frame; | frame = surface->start_frame; | ||||
| orig_frame = scene->r.cfra; | orig_frame = scene->r.cfra; | ||||
| scene->r.cfra = (int)frame; | scene->r.cfra = (int)frame; | ||||
| ED_update_for_newframe(job->bmain, scene, job->scene_layer, job->depsgraph); | ED_update_for_newframe(job->bmain, scene, job->view_layer, job->depsgraph); | ||||
| /* Init surface */ | /* Init surface */ | ||||
| if (!dynamicPaint_createUVSurface(scene, surface, job->progress, job->do_update)) { | if (!dynamicPaint_createUVSurface(scene, surface, job->progress, job->do_update)) { | ||||
| job->success = 0; | job->success = 0; | ||||
| return; | return; | ||||
| } | } | ||||
| /* Loop through selected frames */ | /* Loop through selected frames */ | ||||
| Show All 9 Lines | for (frame = surface->start_frame; frame <= surface->end_frame; frame++) { | ||||
| } | } | ||||
| /* Update progress bar */ | /* Update progress bar */ | ||||
| *(job->do_update) = true; | *(job->do_update) = true; | ||||
| *(job->progress) = progress; | *(job->progress) = progress; | ||||
| /* calculate a frame */ | /* calculate a frame */ | ||||
| scene->r.cfra = (int)frame; | scene->r.cfra = (int)frame; | ||||
| ED_update_for_newframe(job->bmain, scene, job->scene_layer, job->depsgraph); | ED_update_for_newframe(job->bmain, scene, job->view_layer, job->depsgraph); | ||||
| if (!dynamicPaint_calculateFrame(surface, job->eval_ctx, scene, cObject, frame)) { | if (!dynamicPaint_calculateFrame(surface, job->eval_ctx, scene, cObject, frame)) { | ||||
| job->success = 0; | job->success = 0; | ||||
| return; | return; | ||||
| } | } | ||||
| /* | /* | ||||
| * Save output images | * Save output images | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
| * Bake Dynamic Paint image sequence surface | * Bake Dynamic Paint image sequence surface | ||||
| */ | */ | ||||
| static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) | static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) | ||||
| { | { | ||||
| DynamicPaintModifierData *pmd = NULL; | DynamicPaintModifierData *pmd = NULL; | ||||
| DynamicPaintCanvasSettings *canvas; | DynamicPaintCanvasSettings *canvas; | ||||
| Object *ob = ED_object_context(C); | Object *ob = ED_object_context(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| SceneLayer *sl = CTX_data_scene_layer(C); | ViewLayer *sl = CTX_data_view_layer(C); | ||||
| EvaluationContext *eval_ctx = MEM_mallocN(sizeof(*eval_ctx), "EvaluationContext"); | EvaluationContext *eval_ctx = MEM_mallocN(sizeof(*eval_ctx), "EvaluationContext"); | ||||
| CTX_data_eval_ctx(C, eval_ctx); | CTX_data_eval_ctx(C, eval_ctx); | ||||
| DynamicPaintSurface *surface; | DynamicPaintSurface *surface; | ||||
| /* | /* | ||||
| * Get modifier data | * Get modifier data | ||||
| Show All 14 Lines | static int dynamicpaint_bake_exec(struct bContext *C, struct wmOperator *op) | ||||
| /* Set state to baking and init surface */ | /* Set state to baking and init surface */ | ||||
| canvas->error[0] = '\0'; | canvas->error[0] = '\0'; | ||||
| canvas->flags |= MOD_DPAINT_BAKING; | canvas->flags |= MOD_DPAINT_BAKING; | ||||
| DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob"); | DynamicPaintBakeJob *job = MEM_mallocN(sizeof(DynamicPaintBakeJob), "DynamicPaintBakeJob"); | ||||
| job->bmain = CTX_data_main(C); | job->bmain = CTX_data_main(C); | ||||
| job->scene = scene; | job->scene = scene; | ||||
| job->scene_layer = sl; | job->view_layer = sl; | ||||
| job->depsgraph = CTX_data_depsgraph(C); | job->depsgraph = CTX_data_depsgraph(C); | ||||
| job->ob = ob; | job->ob = ob; | ||||
| job->canvas = canvas; | job->canvas = canvas; | ||||
| job->surface = surface; | job->surface = surface; | ||||
| job->eval_ctx = eval_ctx; | job->eval_ctx = eval_ctx; | ||||
| wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, | wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, | ||||
| "Dynamic Paint Bake", WM_JOB_PROGRESS, | "Dynamic Paint Bake", WM_JOB_PROGRESS, | ||||
| Show All 25 Lines | |||||