Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/physics/physics_fluid.c')
-rw-r--r--source/blender/editors/physics/physics_fluid.c50
1 files changed, 35 insertions, 15 deletions
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 11796d01620..918adcac138 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -844,7 +844,7 @@ static void fluidsim_delete_until_lastframe(FluidsimSettings *fss)
return;
}
-static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
+static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, short do_job)
{
Scene *scene= CTX_data_scene(C);
int i;
@@ -871,12 +871,10 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
ListBase *fobjects = MEM_callocN(sizeof(ListBase), "fluid objects");
FluidsimModifierData *fluidmd = NULL;
Mesh *mesh = NULL;
-
- wmJob *steve;
+
FluidBakeJob *fb;
elbeemSimulationSettings *fsset= MEM_callocN(sizeof(elbeemSimulationSettings), "Fluid sim settings");
-
- steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS);
+
fb= MEM_callocN(sizeof(FluidBakeJob), "fluid bake job");
if(getenv(strEnvName)) {
@@ -1083,12 +1081,25 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
/* custom data for fluid bake job */
fb->settings = fsset;
- /* setup job */
- WM_jobs_customdata(steve, fb, fluidbake_free);
- WM_jobs_timer(steve, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME);
- WM_jobs_callbacks(steve, fluidbake_startjob, NULL, NULL, fluidbake_endjob);
-
- WM_jobs_start(CTX_wm_manager(C), steve);
+ if(do_job) {
+ wmJob *steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene, "Fluid Simulation", WM_JOB_PROGRESS);
+
+ /* setup job */
+ WM_jobs_customdata(steve, fb, fluidbake_free);
+ WM_jobs_timer(steve, 0.1, NC_SCENE|ND_FRAME, NC_SCENE|ND_FRAME);
+ WM_jobs_callbacks(steve, fluidbake_startjob, NULL, NULL, fluidbake_endjob);
+
+ WM_jobs_start(CTX_wm_manager(C), steve);
+ }
+ else {
+ short dummy_stop, dummy_do_update;
+ float dummy_progress;
+
+ /* blocking, use with exec() */
+ fluidbake_startjob((void *)fb, &dummy_stop, &dummy_do_update, &dummy_progress);
+ fluidbake_endjob((void *)fb);
+ fluidbake_free((void *)fb);
+ }
/* ******** free stored animation data ******** */
fluidbake_free_data(channels, fobjects, NULL, NULL);
@@ -1121,7 +1132,7 @@ FluidsimSettings* fluidsimSettingsCopy(FluidsimSettings *UNUSED(fss))
}
/* only compile dummy functions */
-static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object *UNUSED(ob))
+static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object *UNUSED(ob), short UNUSED(do_job))
{
return 0;
}
@@ -1130,13 +1141,21 @@ static int fluidsimBake(bContext *UNUSED(C), ReportList *UNUSED(reports), Object
/***************************** Operators ******************************/
-static int fluid_bake_exec(bContext *C, wmOperator *op)
+static int fluid_bake_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event))
{
/* only one bake job at a time */
if(WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C)))
- return 0;
+ return OPERATOR_CANCELLED;
- if(!fluidsimBake(C, op->reports, CTX_data_active_object(C)))
+ if(!fluidsimBake(C, op->reports, CTX_data_active_object(C), TRUE))
+ return OPERATOR_CANCELLED;
+
+ return OPERATOR_FINISHED;
+}
+
+static int fluid_bake_exec(bContext *C, wmOperator *op)
+{
+ if(!fluidsimBake(C, op->reports, CTX_data_active_object(C), FALSE))
return OPERATOR_CANCELLED;
return OPERATOR_FINISHED;
@@ -1150,6 +1169,7 @@ void FLUID_OT_bake(wmOperatorType *ot)
ot->idname= "FLUID_OT_bake";
/* api callbacks */
+ ot->invoke= fluid_bake_invoke;
ot->exec= fluid_bake_exec;
ot->poll= ED_operator_object_active_editable;
}