Blender V4.3
physics_fluid.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#include <cmath>
10#include <cstdlib>
11#include <cstring>
12#include <sys/stat.h>
13
14#include "MEM_guardedalloc.h"
15
16/* types */
17#include "DNA_action_types.h"
18#include "DNA_object_types.h"
19
20#include "BLI_blenlib.h"
21#include "BLI_path_utils.hh"
22#include "BLI_time.h"
23#include "BLI_utildefines.h"
24
25#include "BLT_translation.hh"
26
27#include "BKE_context.hh"
28#include "BKE_fluid.h"
29#include "BKE_global.hh"
30#include "BKE_main.hh"
31#include "BKE_modifier.hh"
32#include "BKE_report.hh"
33#include "BKE_screen.hh"
34
35#include "DEG_depsgraph.hh"
36
37#include "ED_object.hh"
38#include "ED_screen.hh"
39
40#include "WM_api.hh"
41#include "WM_types.hh"
42
43#include "physics_intern.hh" /* own include */
44
45#include "DNA_fluid_types.h"
46#include "DNA_scene_types.h"
47
48#define FLUID_JOB_BAKE_ALL "FLUID_OT_bake_all"
49#define FLUID_JOB_BAKE_DATA "FLUID_OT_bake_data"
50#define FLUID_JOB_BAKE_NOISE "FLUID_OT_bake_noise"
51#define FLUID_JOB_BAKE_MESH "FLUID_OT_bake_mesh"
52#define FLUID_JOB_BAKE_PARTICLES "FLUID_OT_bake_particles"
53#define FLUID_JOB_BAKE_GUIDES "FLUID_OT_bake_guides"
54#define FLUID_JOB_FREE_ALL "FLUID_OT_free_all"
55#define FLUID_JOB_FREE_DATA "FLUID_OT_free_data"
56#define FLUID_JOB_FREE_NOISE "FLUID_OT_free_noise"
57#define FLUID_JOB_FREE_MESH "FLUID_OT_free_mesh"
58#define FLUID_JOB_FREE_PARTICLES "FLUID_OT_free_particles"
59#define FLUID_JOB_FREE_GUIDES "FLUID_OT_free_guides"
60#define FLUID_JOB_BAKE_PAUSE "FLUID_OT_pause_bake"
61
62struct FluidJob {
63 /* from wmJob */
64 void *owner;
65 bool *stop, *do_update;
66 float *progress;
67 const char *type;
68 const char *name;
69
72 Depsgraph *depsgraph;
74
76
78 double start;
79
81};
82
83static inline bool fluid_is_bake_all(FluidJob *job)
84{
85 return STREQ(job->type, FLUID_JOB_BAKE_ALL);
86}
87static inline bool fluid_is_bake_data(FluidJob *job)
88{
89 return STREQ(job->type, FLUID_JOB_BAKE_DATA);
90}
91static inline bool fluid_is_bake_noise(FluidJob *job)
92{
93 return STREQ(job->type, FLUID_JOB_BAKE_NOISE);
94}
95static inline bool fluid_is_bake_mesh(FluidJob *job)
96{
97 return STREQ(job->type, FLUID_JOB_BAKE_MESH);
98}
99static inline bool fluid_is_bake_particle(FluidJob *job)
100{
101 return STREQ(job->type, FLUID_JOB_BAKE_PARTICLES);
102}
103static inline bool fluid_is_bake_guiding(FluidJob *job)
104{
105 return STREQ(job->type, FLUID_JOB_BAKE_GUIDES);
106}
107static inline bool fluid_is_free_all(FluidJob *job)
108{
109 return STREQ(job->type, FLUID_JOB_FREE_ALL);
110}
111static inline bool fluid_is_free_data(FluidJob *job)
112{
113 return STREQ(job->type, FLUID_JOB_FREE_DATA);
114}
115static inline bool fluid_is_free_noise(FluidJob *job)
116{
117 return STREQ(job->type, FLUID_JOB_FREE_NOISE);
118}
119static inline bool fluid_is_free_mesh(FluidJob *job)
120{
121 return STREQ(job->type, FLUID_JOB_FREE_MESH);
122}
123static inline bool fluid_is_free_particles(FluidJob *job)
124{
125 return STREQ(job->type, FLUID_JOB_FREE_PARTICLES);
126}
127static inline bool fluid_is_free_guiding(FluidJob *job)
128{
129 return STREQ(job->type, FLUID_JOB_FREE_GUIDES);
130}
131
132static bool fluid_initjob(
133 bContext *C, FluidJob *job, wmOperator *op, char *error_msg, int error_size)
134{
135 FluidModifierData *fmd = nullptr;
138
140 if (!fmd) {
141 BLI_strncpy(error_msg, N_("Bake failed: no Fluid modifier found"), error_size);
142 return false;
143 }
144 fds = fmd->domain;
145 if (!fds) {
146 BLI_strncpy(error_msg, N_("Bake failed: invalid domain"), error_size);
147 return false;
148 }
149
150 job->bmain = CTX_data_main(C);
151 job->scene = CTX_data_scene(C);
153 job->ob = ob;
154 job->fmd = fmd;
155 job->type = op->type->idname;
156 job->name = op->type->name;
157
158 return true;
159}
160
161static bool fluid_validatepaths(FluidJob *job, ReportList *reports)
162{
163 FluidDomainSettings *fds = job->fmd->domain;
164 char temp_dir[FILE_MAX];
165 temp_dir[0] = '\0';
166 bool is_relative = false;
167
168 const char *relbase = BKE_modifier_path_relbase(job->bmain, job->ob);
169
170 /* We do not accept empty paths, they can end in random places silently, see #51176. */
171 if (fds->cache_directory[0] == '\0') {
172 char cache_name[64];
173 BKE_fluid_cache_new_name_for_current_session(sizeof(cache_name), cache_name);
174 BKE_modifier_path_init(fds->cache_directory, sizeof(fds->cache_directory), cache_name);
175 BKE_reportf(reports,
177 "Fluid: Empty cache path, reset to default '%s'",
178 fds->cache_directory);
179 }
180
181 BLI_strncpy(temp_dir, fds->cache_directory, FILE_MAXDIR);
182 is_relative = BLI_path_abs(temp_dir, relbase);
183
184 /* Ensure whole path exists */
185 const bool dir_exists = BLI_dir_create_recursive(temp_dir);
186
187 /* We change path to some presumably valid default value, but do not allow bake process to
188 * continue, this gives user chance to set manually another path. */
189 if (!dir_exists) {
190 char cache_name[64];
191 BKE_fluid_cache_new_name_for_current_session(sizeof(cache_name), cache_name);
192 BKE_modifier_path_init(fds->cache_directory, sizeof(fds->cache_directory), cache_name);
193
194 BKE_reportf(reports,
195 RPT_ERROR,
196 "Fluid: Could not create cache directory '%s', reset to default '%s'",
197 temp_dir,
198 fds->cache_directory);
199
200 /* Ensure whole path exists and is writable. */
201 if (!BLI_dir_create_recursive(temp_dir)) {
202 BKE_reportf(reports,
203 RPT_ERROR,
204 "Fluid: Could not use default cache directory '%s', "
205 "please define a valid cache path manually",
206 temp_dir);
207 return false;
208 }
209 /* Copy final dir back into domain settings */
210 BLI_strncpy(fds->cache_directory, temp_dir, FILE_MAXDIR);
211
212 return false;
213 }
214
215 /* Change path back to is original state (ie relative or absolute). */
216 if (is_relative) {
217 BLI_path_rel(temp_dir, relbase);
218 }
219
220 /* Copy final dir back into domain settings */
221 BLI_strncpy(fds->cache_directory, temp_dir, FILE_MAXDIR);
222 return true;
223}
224
225static void fluid_bake_free(void *customdata)
226{
227 FluidJob *job = static_cast<FluidJob *>(customdata);
228 MEM_freeN(job);
229}
230
232{
233 FluidDomainSettings *fds = job->fmd->domain;
234 Scene *scene = job->scene;
235 int frame = 1, orig_frame;
236 int frames;
237 int *pause_frame = nullptr;
238 bool is_first_frame;
239
240 frames = fds->cache_frame_end - fds->cache_frame_start + 1;
241
242 if (frames <= 0) {
243 STRNCPY(fds->error, N_("No frames to bake"));
244 return;
245 }
246
247 /* Show progress bar. */
248 if (job->do_update) {
249 *(job->do_update) = true;
250 }
251
252 /* Get current pause frame (pointer) - depending on bake type. */
253 pause_frame = job->pause_frame;
254
255 /* Set frame to start point (depending on current pause frame value). */
256 is_first_frame = ((*pause_frame) == 0);
257 frame = is_first_frame ? fds->cache_frame_start : (*pause_frame);
258
259 /* Save orig frame and update scene frame. */
260 orig_frame = scene->r.cfra;
261 scene->r.cfra = frame;
262
263 /* Loop through selected frames. */
264 for (; frame <= fds->cache_frame_end; frame++) {
265 const float progress = (frame - fds->cache_frame_start) / float(frames);
266
267 /* Keep track of pause frame - needed to init future loop. */
268 (*pause_frame) = frame;
269
270 /* If user requested stop, quit baking. */
271 if (G.is_break) {
272 job->success = 0;
273 return;
274 }
275
276 /* Update progress bar. */
277 if (job->do_update) {
278 *(job->do_update) = true;
279 }
280 if (job->progress) {
281 *(job->progress) = progress;
282 }
283
284 scene->r.cfra = frame;
285
286 /* Update animation system. */
288
289 /* If user requested stop, quit baking. */
290 if (G.is_break) {
291 job->success = 0;
292 return;
293 }
294 }
295
296 /* Restore frame position that we were on before bake. */
297 scene->r.cfra = orig_frame;
298}
299
300static void fluid_bake_endjob(void *customdata)
301{
302 FluidJob *job = static_cast<FluidJob *>(customdata);
303 FluidDomainSettings *fds = job->fmd->domain;
304
305 if (fluid_is_bake_noise(job) || fluid_is_bake_all(job)) {
306 fds->cache_flag &= ~FLUID_DOMAIN_BAKING_NOISE;
308 fds->cache_flag &= ~FLUID_DOMAIN_OUTDATED_NOISE;
309 }
310 if (fluid_is_bake_mesh(job) || fluid_is_bake_all(job)) {
311 fds->cache_flag &= ~FLUID_DOMAIN_BAKING_MESH;
313 fds->cache_flag &= ~FLUID_DOMAIN_OUTDATED_MESH;
314 }
315 if (fluid_is_bake_particle(job) || fluid_is_bake_all(job)) {
316 fds->cache_flag &= ~FLUID_DOMAIN_BAKING_PARTICLES;
318 fds->cache_flag &= ~FLUID_DOMAIN_OUTDATED_PARTICLES;
319 }
320 if (fluid_is_bake_guiding(job) || fluid_is_bake_all(job)) {
321 fds->cache_flag &= ~FLUID_DOMAIN_BAKING_GUIDE;
323 fds->cache_flag &= ~FLUID_DOMAIN_OUTDATED_GUIDE;
324 }
325 if (fluid_is_bake_data(job) || fluid_is_bake_all(job)) {
326 fds->cache_flag &= ~FLUID_DOMAIN_BAKING_DATA;
328 fds->cache_flag &= ~FLUID_DOMAIN_OUTDATED_DATA;
329 }
331
332 G.is_rendering = false;
334 WM_set_locked_interface(static_cast<wmWindowManager *>(G_MAIN->wm.first), false);
335
336 /* Bake was successful:
337 * Report for ended bake and how long it took. */
338 if (job->success) {
339 /* Show bake info. */
341 RPT_INFO, "Fluid: %s complete! (%.2f)", job->name, BLI_time_now_seconds() - job->start);
342 }
343 else {
344 if (fds->error[0] != '\0') {
345 WM_reportf(RPT_ERROR, "Fluid: %s failed: %s", job->name, fds->error);
346 }
347 else { /* User canceled the bake. */
348 WM_reportf(RPT_WARNING, "Fluid: %s canceled!", job->name);
349 }
350 }
351}
352
353static void fluid_bake_startjob(void *customdata, wmJobWorkerStatus *worker_status)
354{
355 FluidJob *job = static_cast<FluidJob *>(customdata);
356 FluidDomainSettings *fds = job->fmd->domain;
357
358 char temp_dir[FILE_MAX];
359 const char *relbase = BKE_modifier_path_relbase_from_global(job->ob);
360
361 job->stop = &worker_status->stop;
362 job->do_update = &worker_status->do_update;
363 job->progress = &worker_status->progress;
365 job->success = 1;
366
367 G.is_break = false;
368 G.is_rendering = true;
370
371 if (fluid_is_bake_noise(job) || fluid_is_bake_all(job)) {
372 BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_NOISE);
373 BLI_path_abs(temp_dir, relbase);
374 BLI_dir_create_recursive(temp_dir); /* Create 'noise' subdir if it does not exist already */
378 }
379 if (fluid_is_bake_mesh(job) || fluid_is_bake_all(job)) {
380 BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_MESH);
381 BLI_path_abs(temp_dir, relbase);
382 BLI_dir_create_recursive(temp_dir); /* Create 'mesh' subdir if it does not exist already */
386 }
387 if (fluid_is_bake_particle(job) || fluid_is_bake_all(job)) {
388 BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_PARTICLES);
389 BLI_path_abs(temp_dir, relbase);
390
391 /* Create 'particles' subdir if it does not exist already */
392 BLI_dir_create_recursive(temp_dir);
393
397 }
398 if (fluid_is_bake_guiding(job) || fluid_is_bake_all(job)) {
399 BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_GUIDE);
400 BLI_path_abs(temp_dir, relbase);
401 BLI_dir_create_recursive(temp_dir); /* Create 'guiding' subdir if it does not exist already */
405 }
406 if (fluid_is_bake_data(job) || fluid_is_bake_all(job)) {
407 BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_CONFIG);
408 BLI_path_abs(temp_dir, relbase);
409 BLI_dir_create_recursive(temp_dir); /* Create 'config' subdir if it does not exist already */
410
411 BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_DATA);
412 BLI_path_abs(temp_dir, relbase);
413 BLI_dir_create_recursive(temp_dir); /* Create 'data' subdir if it does not exist already */
417
419 BLI_path_join(temp_dir, sizeof(temp_dir), fds->cache_directory, FLUID_DOMAIN_DIR_SCRIPT);
420 BLI_path_abs(temp_dir, relbase);
421 BLI_dir_create_recursive(temp_dir); /* Create 'script' subdir if it does not exist already */
422 }
423 }
425
427
428 worker_status->do_update = true;
429 worker_status->stop = false;
430}
431
432static void fluid_free_endjob(void *customdata)
433{
434 FluidJob *job = static_cast<FluidJob *>(customdata);
435 FluidDomainSettings *fds = job->fmd->domain;
436
437 G.is_rendering = false;
439 WM_set_locked_interface(static_cast<wmWindowManager *>(G_MAIN->wm.first), false);
440
441 /* Reflect the now empty cache in the viewport too. */
443
444 /* Free was successful:
445 * Report for ended free job and how long it took */
446 if (job->success) {
447 /* Show free job info */
449 RPT_INFO, "Fluid: %s complete! (%.2f)", job->name, BLI_time_now_seconds() - job->start);
450 }
451 else {
452 if (fds->error[0] != '\0') {
453 WM_reportf(RPT_ERROR, "Fluid: %s failed: %s", job->name, fds->error);
454 }
455 else { /* User canceled the free job */
456 WM_reportf(RPT_WARNING, "Fluid: %s canceled!", job->name);
457 }
458 }
459}
460
461static void fluid_free_startjob(void *customdata, wmJobWorkerStatus *worker_status)
462{
463 FluidJob *job = static_cast<FluidJob *>(customdata);
464 FluidDomainSettings *fds = job->fmd->domain;
465
466 job->stop = &worker_status->stop;
467 job->do_update = &worker_status->do_update;
468 job->progress = &worker_status->progress;
470 job->success = 1;
471
472 G.is_break = false;
473 G.is_rendering = true;
475
476 int cache_map = 0;
477
478 if (fluid_is_free_data(job) || fluid_is_free_all(job)) {
481 }
482 if (fluid_is_free_noise(job) || fluid_is_free_all(job)) {
483 cache_map |= FLUID_DOMAIN_OUTDATED_NOISE;
484 }
485 if (fluid_is_free_mesh(job) || fluid_is_free_all(job)) {
486 cache_map |= FLUID_DOMAIN_OUTDATED_MESH;
487 }
490 }
491 if (fluid_is_free_guiding(job) || fluid_is_free_all(job)) {
495 }
496#ifdef WITH_FLUID
497 BKE_fluid_cache_free(fds, job->ob, cache_map);
498#else
499 UNUSED_VARS(fds);
500 UNUSED_VARS(cache_map);
501#endif
502
503 worker_status->do_update = true;
504 worker_status->stop = false;
505
506 /* Update scene so that viewport shows freed up scene */
508}
509
510/***************************** Operators ******************************/
511
513{
514 FluidJob *job = static_cast<FluidJob *>(MEM_mallocN(sizeof(FluidJob), "FluidJob"));
515 char error_msg[256] = "\0";
516
517 if (!fluid_initjob(C, job, op, error_msg, sizeof(error_msg))) {
518 if (error_msg[0]) {
519 BKE_report(op->reports, RPT_ERROR, error_msg);
520 }
521 fluid_bake_free(job);
522 return OPERATOR_CANCELLED;
523 }
524 if (!fluid_validatepaths(job, op->reports)) {
525 fluid_bake_free(job);
526 return OPERATOR_CANCELLED;
527 }
529
530 wmJobWorkerStatus worker_status = {};
531 fluid_bake_startjob(job, &worker_status);
533 fluid_bake_free(job);
534
535 return OPERATOR_FINISHED;
536}
537
538static int fluid_bake_invoke(bContext *C, wmOperator *op, const wmEvent * /*_event*/)
539{
540 Scene *scene = CTX_data_scene(C);
541 FluidJob *job = static_cast<FluidJob *>(MEM_mallocN(sizeof(FluidJob), "FluidJob"));
542 char error_msg[256] = "\0";
543
544 if (!fluid_initjob(C, job, op, error_msg, sizeof(error_msg))) {
545 if (error_msg[0]) {
546 BKE_report(op->reports, RPT_ERROR, error_msg);
547 }
548 fluid_bake_free(job);
549 return OPERATOR_CANCELLED;
550 }
551
552 if (!fluid_validatepaths(job, op->reports)) {
553 fluid_bake_free(job);
554 return OPERATOR_CANCELLED;
555 }
556
557 /* Clear existing banners so that the upcoming progress bar from this job has more room. */
559
560 wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
561 CTX_wm_window(C),
562 scene,
563 "Fluid Bake",
566
569 WM_jobs_callbacks(wm_job, fluid_bake_startjob, nullptr, nullptr, fluid_bake_endjob);
570
572
573 WM_jobs_start(CTX_wm_manager(C), wm_job);
575
577}
578
579static int fluid_bake_modal(bContext *C, wmOperator * /*op*/, const wmEvent *event)
580{
581 /* no running blender, remove handler and pass through */
584 }
585
586 switch (event->type) {
587 case EVT_ESCKEY:
589 }
591}
592
594{
595 FluidModifierData *fmd = nullptr;
598 Scene *scene = CTX_data_scene(C);
599
600 /*
601 * Get modifier data
602 */
604 if (!fmd) {
605 BKE_report(op->reports, RPT_ERROR, "Bake free failed: no Fluid modifier found");
606 return OPERATOR_CANCELLED;
607 }
608 fds = fmd->domain;
609 if (!fds) {
610 BKE_report(op->reports, RPT_ERROR, "Bake free failed: invalid domain");
611 return OPERATOR_CANCELLED;
612 }
613
614 /* Cannot free data if other bakes currently working */
617 {
618 BKE_report(op->reports, RPT_ERROR, "Bake free failed: pending bake jobs found");
619 return OPERATOR_CANCELLED;
620 }
621
622 FluidJob *job = static_cast<FluidJob *>(MEM_mallocN(sizeof(FluidJob), "FluidJob"));
623 job->bmain = CTX_data_main(C);
624 job->scene = scene;
626 job->ob = ob;
627 job->fmd = fmd;
628 job->type = op->type->idname;
629 job->name = op->type->name;
630
631 if (!fluid_validatepaths(job, op->reports)) {
632 fluid_bake_free(job);
633 return OPERATOR_CANCELLED;
634 }
635
636 /* Clear existing banners so that the upcoming progress bar from this job has more room. */
638
639 wmJob *wm_job = WM_jobs_get(CTX_wm_manager(C),
640 CTX_wm_window(C),
641 scene,
642 "Fluid Free",
645
648 WM_jobs_callbacks(wm_job, fluid_free_startjob, nullptr, nullptr, fluid_free_endjob);
649
651
652 /* Free Fluid Geometry */
653 WM_jobs_start(CTX_wm_manager(C), wm_job);
654
655 return OPERATOR_FINISHED;
656}
657
659{
660 FluidModifierData *fmd = nullptr;
663
664 /*
665 * Get modifier data
666 */
668 if (!fmd) {
669 BKE_report(op->reports, RPT_ERROR, "Bake free failed: no Fluid modifier found");
670 return OPERATOR_CANCELLED;
671 }
672 fds = fmd->domain;
673 if (!fds) {
674 BKE_report(op->reports, RPT_ERROR, "Bake free failed: invalid domain");
675 return OPERATOR_CANCELLED;
676 }
677
678 G.is_break = true;
679
680 return OPERATOR_FINISHED;
681}
682
684{
685 /* identifiers */
686 ot->name = "Bake All";
687 ot->description = "Bake Entire Fluid Simulation";
689
690 /* api callbacks */
695}
696
698{
699 /* identifiers */
700 ot->name = "Free All";
701 ot->description = "Free Entire Fluid Simulation";
703
704 /* api callbacks */
707}
708
710{
711 /* identifiers */
712 ot->name = "Bake Data";
713 ot->description = "Bake Fluid Data";
715
716 /* api callbacks */
721}
722
724{
725 /* identifiers */
726 ot->name = "Free Data";
727 ot->description = "Free Fluid Data";
729
730 /* api callbacks */
733}
734
736{
737 /* identifiers */
738 ot->name = "Bake Noise";
739 ot->description = "Bake Fluid Noise";
741
742 /* api callbacks */
747}
748
750{
751 /* identifiers */
752 ot->name = "Free Noise";
753 ot->description = "Free Fluid Noise";
755
756 /* api callbacks */
759}
760
762{
763 /* identifiers */
764 ot->name = "Bake Mesh";
765 ot->description = "Bake Fluid Mesh";
767
768 /* api callbacks */
773}
774
776{
777 /* identifiers */
778 ot->name = "Free Mesh";
779 ot->description = "Free Fluid Mesh";
781
782 /* api callbacks */
785}
786
788{
789 /* identifiers */
790 ot->name = "Bake Particles";
791 ot->description = "Bake Fluid Particles";
793
794 /* api callbacks */
799}
800
802{
803 /* identifiers */
804 ot->name = "Free Particles";
805 ot->description = "Free Fluid Particles";
807
808 /* api callbacks */
811}
812
814{
815 /* identifiers */
816 ot->name = "Bake Guides";
817 ot->description = "Bake Fluid Guiding";
819
820 /* api callbacks */
825}
826
828{
829 /* identifiers */
830 ot->name = "Free Guides";
831 ot->description = "Free Fluid Guiding";
833
834 /* api callbacks */
837}
838
840{
841 /* identifiers */
842 ot->name = "Pause Bake";
843 ot->description = "Pause Bake";
845
846 /* api callbacks */
849}
wmWindow * CTX_wm_window(const bContext *C)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
void BKE_fluid_cache_new_name_for_current_session(int maxlen, char *r_name)
Definition fluid.cc:5105
void BKE_fluid_cache_free(struct FluidDomainSettings *fds, struct Object *ob, int cache_map)
#define G_MAIN
void BKE_modifier_path_init(char *path, int path_maxncpy, const char *name)
ModifierData * BKE_modifiers_findby_type(const Object *ob, ModifierType type)
const char * BKE_modifier_path_relbase_from_global(Object *ob)
const char * BKE_modifier_path_relbase(Main *bmain, Object *ob)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:125
void BKE_spacedata_draw_locks(bool set)
Definition screen.cc:405
bool BLI_dir_create_recursive(const char *dirname) ATTR_NONNULL()
Definition fileops_c.cc:391
bool BLI_path_abs(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1
#define FILE_MAX
#define BLI_path_join(...)
bool void BLI_path_rel(char path[FILE_MAX], const char *basepath) ATTR_NONNULL(1)
#define FILE_MAXDIR
#define STRNCPY(dst, src)
Definition BLI_string.h:593
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, size_t dst_maxncpy) ATTR_NONNULL(1
Platform independent time functions.
double BLI_time_now_seconds(void)
Definition time.c:65
#define UNUSED_VARS(...)
#define STREQ(a, b)
void DEG_id_tag_update(ID *id, unsigned int flags)
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1041
#define FLUID_DOMAIN_DIR_DATA
#define FLUID_DOMAIN_DIR_PARTICLES
#define FLUID_DOMAIN_DIR_MESH
#define FLUID_DOMAIN_DIR_GUIDE
#define FLUID_DOMAIN_DIR_SCRIPT
@ FLUID_DOMAIN_BAKED_DATA
@ FLUID_DOMAIN_OUTDATED_GUIDE
@ FLUID_DOMAIN_OUTDATED_PARTICLES
@ FLUID_DOMAIN_BAKING_MESH
@ FLUID_DOMAIN_BAKING_NOISE
@ FLUID_DOMAIN_BAKING_GUIDE
@ FLUID_DOMAIN_OUTDATED_NOISE
@ FLUID_DOMAIN_BAKED_NOISE
@ FLUID_DOMAIN_BAKED_MESH
@ FLUID_DOMAIN_OUTDATED_MESH
@ FLUID_DOMAIN_BAKING_DATA
@ FLUID_DOMAIN_BAKED_GUIDE
@ FLUID_DOMAIN_BAKED_PARTICLES
@ FLUID_DOMAIN_OUTDATED_DATA
@ FLUID_DOMAIN_BAKING_PARTICLES
#define FLUID_DOMAIN_DIR_CONFIG
@ FLUID_DOMAIN_EXPORT_MANTA_SCRIPT
#define FLUID_DOMAIN_DIR_NOISE
@ eModifierType_Fluid
Object is a sort of wrapper for general info.
@ OPERATOR_RUNNING_MODAL
@ OPERATOR_PASS_THROUGH
bool ED_operator_object_active_editable(bContext *C)
void ED_update_for_newframe(Main *bmain, Depsgraph *depsgraph)
Read Guarded memory(de)allocation.
@ WM_JOB_TYPE_OBJECT_SIM_FLUID
Definition WM_api.hh:1583
@ WM_JOB_PROGRESS
Definition WM_api.hh:1566
#define ND_MODIFIER
Definition WM_types.hh:429
#define NC_OBJECT
Definition WM_types.hh:346
void *(* MEM_mallocN)(size_t len, const char *str)
Definition mallocn.cc:44
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
#define G(x, y, z)
Object * context_active_object(const bContext *C)
#define FLUID_JOB_FREE_DATA
#define FLUID_JOB_BAKE_GUIDES
static int fluid_bake_exec(bContext *C, wmOperator *op)
#define FLUID_JOB_BAKE_ALL
void FLUID_OT_free_mesh(wmOperatorType *ot)
static void fluid_bake_endjob(void *customdata)
static bool fluid_is_bake_guiding(FluidJob *job)
static bool fluid_is_bake_particle(FluidJob *job)
static bool fluid_is_free_data(FluidJob *job)
static bool fluid_is_bake_noise(FluidJob *job)
static bool fluid_validatepaths(FluidJob *job, ReportList *reports)
#define FLUID_JOB_FREE_MESH
void FLUID_OT_free_particles(wmOperatorType *ot)
#define FLUID_JOB_FREE_ALL
void FLUID_OT_free_all(wmOperatorType *ot)
void FLUID_OT_bake_guides(wmOperatorType *ot)
static void fluid_free_startjob(void *customdata, wmJobWorkerStatus *worker_status)
static int fluid_pause_exec(bContext *C, wmOperator *op)
static int fluid_bake_modal(bContext *C, wmOperator *, const wmEvent *event)
static bool fluid_is_free_mesh(FluidJob *job)
void FLUID_OT_free_guides(wmOperatorType *ot)
#define FLUID_JOB_BAKE_PAUSE
void FLUID_OT_bake_particles(wmOperatorType *ot)
static bool fluid_initjob(bContext *C, FluidJob *job, wmOperator *op, char *error_msg, int error_size)
static void fluid_free_endjob(void *customdata)
static bool fluid_is_free_guiding(FluidJob *job)
static bool fluid_is_bake_all(FluidJob *job)
static void fluid_bake_free(void *customdata)
#define FLUID_JOB_BAKE_NOISE
#define FLUID_JOB_FREE_PARTICLES
void FLUID_OT_bake_all(wmOperatorType *ot)
#define FLUID_JOB_BAKE_PARTICLES
static bool fluid_is_bake_mesh(FluidJob *job)
static void fluid_bake_startjob(void *customdata, wmJobWorkerStatus *worker_status)
static bool fluid_is_free_all(FluidJob *job)
static bool fluid_is_free_noise(FluidJob *job)
static bool fluid_is_free_particles(FluidJob *job)
#define FLUID_JOB_FREE_NOISE
void FLUID_OT_bake_data(wmOperatorType *ot)
static bool fluid_is_bake_data(FluidJob *job)
void FLUID_OT_free_noise(wmOperatorType *ot)
#define FLUID_JOB_FREE_GUIDES
static int fluid_free_exec(bContext *C, wmOperator *op)
#define FLUID_JOB_BAKE_DATA
static int fluid_bake_invoke(bContext *C, wmOperator *op, const wmEvent *)
void FLUID_OT_pause_bake(wmOperatorType *ot)
void FLUID_OT_bake_noise(wmOperatorType *ot)
void FLUID_OT_free_data(wmOperatorType *ot)
#define FLUID_JOB_BAKE_MESH
static void fluid_bake_sequence(FluidJob *job)
void FLUID_OT_bake_mesh(wmOperatorType *ot)
int * pause_frame
bool * stop
const char * name
FluidModifierData * fmd
Main * bmain
Object * ob
Depsgraph * depsgraph
const char * type
double start
float * progress
bool * do_update
void * owner
Scene * scene
struct FluidDomainSettings * domain
short type
Definition WM_types.hh:722
const char * name
Definition WM_types.hh:990
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1042
const char * idname
Definition WM_types.hh:992
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1036
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1022
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1006
const char * description
Definition WM_types.hh:996
struct ReportList * reports
struct wmOperatorType * type
#define N_(msgid)
void WM_report_banners_cancel(Main *bmain)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_reportf(eReportType type, const char *format,...)
void WM_set_locked_interface(wmWindowManager *wm, bool lock)
@ EVT_ESCKEY
wmOperatorType * ot
Definition wm_files.cc:4125
void WM_jobs_timer(wmJob *wm_job, double time_step, uint note, uint endnote)
Definition wm_jobs.cc:352
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition wm_jobs.cc:455
wmJob * WM_jobs_get(wmWindowManager *wm, wmWindow *win, const void *owner, const char *name, const eWM_JobFlag flag, const eWM_JobType job_type)
Definition wm_jobs.cc:189
void WM_jobs_callbacks(wmJob *wm_job, wm_jobs_start_callback startjob, void(*initjob)(void *), void(*update)(void *), void(*endjob)(void *))
Definition wm_jobs.cc:364
bool WM_jobs_test(const wmWindowManager *wm, const void *owner, int job_type)
Definition wm_jobs.cc:223
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *customdata))
Definition wm_jobs.cc:336