Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/physics/physics_fluid.c
| Show First 20 Lines • Show All 328 Lines • ▼ Show 20 Lines | for (fobj = fobjects->first; fobj; fobj = fobj->next) { | ||||
| if (fobj->VertexCache) { | if (fobj->VertexCache) { | ||||
| MEM_freeN(fobj->VertexCache); | MEM_freeN(fobj->VertexCache); | ||||
| fobj->VertexCache = NULL; | fobj->VertexCache = NULL; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void fluid_init_all_channels(bContext *C, | static void fluid_init_all_channels(bContext *C, | ||||
| Depsgraph *depsgraph, | |||||
| Object *UNUSED(fsDomain), | Object *UNUSED(fsDomain), | ||||
| FluidsimSettings *domainSettings, | FluidsimSettings *domainSettings, | ||||
| FluidAnimChannels *channels, | FluidAnimChannels *channels, | ||||
| ListBase *fobjects) | ListBase *fobjects) | ||||
| { | { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | |||||
| Base *base; | Base *base; | ||||
brecht: Make the depsgraph a parameter to this function and ensure evaluated at the start of the… | |||||
| int i; | int i; | ||||
| int length = channels->length; | int length = channels->length; | ||||
| float eval_time; | float eval_time; | ||||
| /* init time values (assuming that time moves at a constant speed; may be overridden later) */ | /* init time values (assuming that time moves at a constant speed; may be overridden later) */ | ||||
| init_time(domainSettings, channels); | init_time(domainSettings, channels); | ||||
| /* allocate domain animation channels */ | /* allocate domain animation channels */ | ||||
| ▲ Show 20 Lines • Show All 155 Lines • ▼ Show 20 Lines | for (fobj = fobjects->first; fobj; fobj = fobj->next) { | ||||
| if (fluid_is_animated_mesh(fluidmd->fss)) { | if (fluid_is_animated_mesh(fluidmd->fss)) { | ||||
| set_vertex_channel(depsgraph, fobj->VertexCache, timeAtFrame, scene, fobj, i); | set_vertex_channel(depsgraph, fobj->VertexCache, timeAtFrame, scene, fobj, i); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void export_fluid_objects(const bContext *C, ListBase *fobjects, Scene *scene, int length) | static void export_fluid_objects(Depsgraph *depsgraph, | ||||
| ListBase *fobjects, | |||||
| Scene *scene, | |||||
| int length) | |||||
| { | { | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | |||||
| FluidObject *fobj; | FluidObject *fobj; | ||||
Done Inline ActionsSame comment. brecht: Same comment. | |||||
| for (fobj = fobjects->first; fobj; fobj = fobj->next) { | for (fobj = fobjects->first; fobj; fobj = fobj->next) { | ||||
| Object *ob = fobj->object; | Object *ob = fobj->object; | ||||
| FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType( | FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType( | ||||
| ob, eModifierType_Fluidsim); | ob, eModifierType_Fluidsim); | ||||
| int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd); | int modifierIndex = BLI_findindex(&ob->modifiers, fluidmd); | ||||
| float *verts = NULL; | float *verts = NULL; | ||||
| ▲ Show 20 Lines • Show All 388 Lines • ▼ Show 20 Lines | static void fluidsim_delete_until_lastframe(FluidsimSettings *fss, const char *relbase) | ||||
| return; | return; | ||||
| } | } | ||||
| static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, short do_job) | static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, short do_job) | ||||
| { | { | ||||
| Main *bmain = CTX_data_main(C); | Main *bmain = CTX_data_main(C); | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(C); | ViewLayer *view_layer = CTX_data_view_layer(C); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | ||||
| int i; | int i; | ||||
| FluidsimSettings *domainSettings; | FluidsimSettings *domainSettings; | ||||
| char debugStrBuffer[256]; | char debugStrBuffer[256]; | ||||
| int gridlevels = 0; | int gridlevels = 0; | ||||
| const char *relbase = modifier_path_relbase(bmain, fsDomain); | const char *relbase = modifier_path_relbase(bmain, fsDomain); | ||||
| const char *strEnvName = "BLENDER_ELBEEMDEBUG"; // from blendercall.cpp | const char *strEnvName = "BLENDER_ELBEEMDEBUG"; // from blendercall.cpp | ||||
| ▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, short do_job) | ||||
| /* DG TODO: why using endframe and not "noFrames" here? | /* DG TODO: why using endframe and not "noFrames" here? | ||||
| * because "noFrames" is buggy too? (not using sfra) */ | * because "noFrames" is buggy too? (not using sfra) */ | ||||
| channels->length = scene->r.efra; | channels->length = scene->r.efra; | ||||
| channels->aniFrameTime = (double)((double)domainSettings->animEnd - | channels->aniFrameTime = (double)((double)domainSettings->animEnd - | ||||
| (double)domainSettings->animStart) / | (double)domainSettings->animStart) / | ||||
| (double)noFrames; | (double)noFrames; | ||||
| /* ******** initialize and allocate animation channels ******** */ | /* ******** initialize and allocate animation channels ******** */ | ||||
| fluid_init_all_channels(C, fsDomain, domainSettings, channels, fobjects); | fluid_init_all_channels(C, depsgraph, fsDomain, domainSettings, channels, fobjects); | ||||
| /* reset to original current frame */ | /* reset to original current frame */ | ||||
| scene->r.cfra = origFrame; | scene->r.cfra = origFrame; | ||||
| ED_update_for_newframe(CTX_data_main(C), depsgraph); | ED_update_for_newframe(CTX_data_main(C), CTX_data_depsgraph_pointer(C)); | ||||
| /* ******** init domain object's matrix ******** */ | /* ******** init domain object's matrix ******** */ | ||||
| copy_m4_m4(domainMat, fsDomain->obmat); | copy_m4_m4(domainMat, fsDomain->obmat); | ||||
| if (!invert_m4_m4(invDomMat, domainMat)) { | if (!invert_m4_m4(invDomMat, domainMat)) { | ||||
| BLI_snprintf( | BLI_snprintf( | ||||
| debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::error - Invalid obj matrix?\n"); | debugStrBuffer, sizeof(debugStrBuffer), "fluidsimBake::error - Invalid obj matrix?\n"); | ||||
| elbeemDebugOut(debugStrBuffer); | elbeemDebugOut(debugStrBuffer); | ||||
| BKE_report(reports, RPT_ERROR, "Invalid object matrix"); | BKE_report(reports, RPT_ERROR, "Invalid object matrix"); | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | // init blender domain transform matrix | ||||
| } | } | ||||
| } | } | ||||
| /* ******** init solver with settings ******** */ | /* ******** init solver with settings ******** */ | ||||
| elbeemInit(); | elbeemInit(); | ||||
| elbeemAddDomain(fsset); | elbeemAddDomain(fsset); | ||||
| /* ******** export all fluid objects to elbeem ******** */ | /* ******** export all fluid objects to elbeem ******** */ | ||||
| export_fluid_objects(C, fobjects, scene, channels->length); | export_fluid_objects(depsgraph, fobjects, scene, channels->length); | ||||
| /* custom data for fluid bake job */ | /* custom data for fluid bake job */ | ||||
| fb->settings = fsset; | fb->settings = fsset; | ||||
| if (do_job) { | if (do_job) { | ||||
| wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), | wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C), | ||||
| CTX_wm_window(C), | CTX_wm_window(C), | ||||
| scene, | scene, | ||||
| ▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines | |||||
Make the depsgraph a parameter to this function and ensure evaluated at the start of the operator, it's not obvious what happens between this and when it starts executing the operator.