Blender V5.3
object_bake_simulation.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <sstream>
10
11#include "BLI_fileops.hh"
12#include "BLI_listbase.hh"
13#include "BLI_path_utils.hh"
14#include "BLI_string.hh"
15#include "BLI_vector.hh"
16
17#include "BLT_translation.hh"
18
19#include "WM_api.hh"
20#include "WM_types.hh"
21
22#include "ED_object.hh"
23#include "ED_screen.hh"
24
25#include "DNA_array_utils.hh"
26#include "DNA_modifier_types.h"
28
31#include "BKE_context.hh"
32#include "BKE_global.hh"
33#include "BKE_lib_id.hh"
34#include "BKE_library.hh"
35#include "BKE_main.hh"
36#include "BKE_modifier.hh"
38#include "BKE_node_runtime.hh"
39#include "BKE_packedFile.hh"
40#include "BKE_path_templates.hh"
41#include "BKE_report.hh"
42#include "BKE_scene.hh"
43
44#include "RNA_access.hh"
45#include "RNA_define.hh"
46
47#include "DEG_depsgraph.hh"
48
49#include "MOD_nodes.hh"
50
51#include "object_intern.hh"
52
53#include "UI_interface.hh"
55
56namespace blender {
57
58namespace bake = bke::bake;
59
61
63{
65 return false;
66 }
67 return true;
68}
69
79
80static void simulate_to_frame_startjob(void *customdata, wmJobWorkerStatus *worker_status)
81{
82 SimulateToFrameJob &job = *static_cast<SimulateToFrameJob *>(customdata);
83 G.is_rendering = true;
84 G.is_break = false;
85 WM_locked_interface_set(job.wm, true);
86
87 Vector<Object *> objects_to_calc;
88 for (Object *object : job.objects) {
89 if (!BKE_id_is_editable(job.bmain, &object->id)) {
90 continue;
91 }
92 for (ModifierData &md : object->modifiers) {
93 if (md.type != eModifierType_Nodes) {
94 continue;
95 }
96 NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(&md);
97 if (!nmd->runtime->cache) {
98 continue;
99 }
100 for (auto item : nmd->runtime->cache->simulation_cache_by_id.items()) {
101 if (item.value->cache_status != bake::CacheStatus::Baked) {
102 item.value->reset();
103 }
104 }
105 }
106 objects_to_calc.append(object);
107 }
108
109 worker_status->progress = 0.0f;
110 worker_status->do_update = true;
111
112 const float frame_step_size = 1.0f;
113 const float progress_per_frame = 1.0f /
114 (float(job.end_frame - job.start_frame + 1) / frame_step_size);
115 const int old_frame = job.scene->r.cfra;
116
117 for (float frame_f = job.start_frame; frame_f <= job.end_frame; frame_f += frame_step_size) {
118 const SubFrame frame{frame_f};
119
120 if (G.is_break || worker_status->stop) {
121 break;
122 }
123
124 job.scene->r.cfra = frame.frame();
125 job.scene->r.subframe = frame.subframe();
126
128
129 worker_status->progress += progress_per_frame;
130 worker_status->do_update = true;
131 }
132
133 job.scene->r.cfra = old_frame;
135
136 worker_status->progress = 1.0f;
137 worker_status->do_update = true;
138}
139
140static void simulate_to_frame_endjob(void *customdata)
141{
142 SimulateToFrameJob &job = *static_cast<SimulateToFrameJob *>(customdata);
143 WM_locked_interface_set(job.wm, false);
144 G.is_rendering = false;
146}
147
149 wmOperator *op,
150 const wmEvent * /*event*/)
151{
153 Scene *scene = CTX_data_scene(C);
154 Depsgraph *depsgraph = CTX_data_depsgraph_pointer(C);
155 Main *bmain = CTX_data_main(C);
156
157 SimulateToFrameJob *job = MEM_new<SimulateToFrameJob>(__func__);
158 job->wm = wm;
159 job->bmain = bmain;
160 job->depsgraph = depsgraph;
161 job->scene = scene;
162 job->start_frame = scene->r.sfra;
163 job->end_frame = scene->r.cfra;
164
165 if (RNA_boolean_get(op->ptr, "selected")) {
166 CTX_DATA_BEGIN (C, Object *, object, selected_objects) {
167 job->objects.append(object);
168 }
170 }
171 else {
172 if (Object *object = CTX_data_active_object(C)) {
173 job->objects.append(object);
174 }
175 }
176
177 wmJob *wm_job = WM_jobs_get(wm,
180 "Calculating simulation...",
183
185 wm_job, job, [](void *job) { MEM_delete(static_cast<SimulateToFrameJob *>(job)); });
188 wm_job, simulate_to_frame_startjob, nullptr, nullptr, simulate_to_frame_endjob);
189
193}
194
206
208{
210 return false;
211 }
213 const bool use_frame_cache = ob->flag & OB_FLAG_USE_SIMULATION_CACHE;
214 if (!use_frame_cache) {
215 CTX_wm_operator_poll_msg_set(C, "Cache has to be enabled");
216 return false;
217 }
218 return true;
219}
220
226
228 std::optional<bake::BakePath> path;
231 std::unique_ptr<bake::BlobWriteSharing> blob_sharing;
232};
233
243
244static void try_delete_bake(
245 Main *bmain, Object &object, NodesModifierData &nmd, const int bake_id, ReportList *reports);
246static void reset_old_bake_cache(NodeBakeRequest &request);
247
249{
250 for (NodeBakeRequest &request : job.bake_requests) {
251 request.nmd->runtime->cache->requested_bakes.add(request.bake_id);
252 /* Using #DEG_id_tag_update would tag this as user-modified which is not the case here and has
253 * the issue that it invalidates simulation caches. */
255 job.depsgraph, &request.object->id, ID_RECALC_GEOMETRY);
256 }
257}
258
260{
261 for (NodeBakeRequest &request : job.bake_requests) {
262 request.nmd->runtime->cache->requested_bakes.clear();
263 }
264}
265
266static void bake_geometry_nodes_startjob(void *customdata, wmJobWorkerStatus *worker_status)
267{
268 BakeGeometryNodesJob &job = *static_cast<BakeGeometryNodesJob *>(customdata);
269 G.is_rendering = true;
270 G.is_break = false;
271
272 int global_bake_start_frame = INT32_MAX;
273 int global_bake_end_frame = INT32_MIN;
274
275 for (NodeBakeRequest &request : job.bake_requests) {
276 global_bake_start_frame = std::min(global_bake_start_frame, request.frame_start);
277 global_bake_end_frame = std::max(global_bake_end_frame, request.frame_end);
278 }
279
280 worker_status->progress = 0.0f;
281 worker_status->do_update = true;
282
283 const int frames_to_bake = global_bake_end_frame - global_bake_start_frame + 1;
284
285 const float frame_step_size = 1.0f;
286 const float progress_per_frame = frame_step_size / frames_to_bake;
287 const int old_frame = job.scene->r.cfra;
288
289 struct MemoryBakeFile {
290 std::string name;
291 std::string data;
292 };
293
294 struct PackedBake {
295 Vector<MemoryBakeFile> meta_files;
296 Vector<MemoryBakeFile> blob_files;
297 };
298
299 Map<NodeBakeRequest *, PackedBake> packed_data_by_bake;
301
302 for (float frame_f = global_bake_start_frame; frame_f <= global_bake_end_frame;
303 frame_f += frame_step_size)
304 {
305 const SubFrame frame{frame_f};
306
307 if (G.is_break || worker_status->stop) {
308 break;
309 }
310
311 job.scene->r.cfra = frame.frame();
312 job.scene->r.subframe = frame.subframe();
313
315
317
319
320 const std::string frame_file_name = bake::frame_to_file_name(frame);
321
322 for (NodeBakeRequest &request : job.bake_requests) {
323 NodesModifierData &nmd = *request.nmd;
324 bake::ModifierCache &modifier_cache = *nmd.runtime->cache;
325 const bake::NodeBakeCache *bake_cache = modifier_cache.get_node_bake_cache(request.bake_id);
326 if (bake_cache == nullptr) {
327 continue;
328 }
329 if (bake_cache->frames.is_empty()) {
330 continue;
331 }
332 const bake::FrameCache &frame_cache = *bake_cache->frames.last();
333 if (frame_cache.frame != frame) {
334 continue;
335 }
336
337 int64_t &written_size = size_by_bake.lookup_or_add(&request, 0);
338
339 if (request.path.has_value()) {
340 char meta_path[FILE_MAX];
341 BLI_path_join(meta_path,
342 sizeof(meta_path),
343 request.path->meta_dir.c_str(),
344 (frame_file_name + ".json").c_str());
346 bake::DiskBlobWriter blob_writer{request.path->blobs_dir, frame_file_name};
347 fstream meta_file{meta_path, std::ios::out};
348 bake::serialize_bake(frame_cache.values, blob_writer, *request.blob_sharing, meta_file);
349 written_size += blob_writer.written_size();
350 written_size += meta_file.tellp();
351 }
352 else {
353 PackedBake &packed_data = packed_data_by_bake.lookup_or_add_default(&request);
354
355 bake::MemoryBlobWriter blob_writer{frame_file_name};
356 std::ostringstream meta_file{std::ios::binary};
357 bake::serialize_bake(frame_cache.values, blob_writer, *request.blob_sharing, meta_file);
358
359 packed_data.meta_files.append({frame_file_name + ".json", meta_file.str()});
361 blob_writer.get_stream_by_name();
362 for (auto &&item : blob_stream_by_name.items()) {
363 std::string data = item.value.stream->str();
364 if (data.empty()) {
365 continue;
366 }
367 if (data.size() > PACKED_FILE_MAX_SIZE) {
368 job.error_message = TIP_("A file is too large to be packed (>2GB).");
369 return;
370 }
371 packed_data.blob_files.append({item.key, std::move(data)});
372 }
373 written_size += blob_writer.written_size();
374 written_size += meta_file.tellp();
375 }
376 }
377
378 worker_status->progress += progress_per_frame;
379 worker_status->do_update = true;
380 }
381
382 /* Update bake sizes. */
383 for (NodeBakeRequest &request : job.bake_requests) {
384 NodesModifierBake *bake = request.nmd->find_bake(request.bake_id);
385 bake->bake_size = size_by_bake.lookup_default(&request, 0);
386 }
387
388 /* Store gathered data as packed data. */
389 for (NodeBakeRequest &request : job.bake_requests) {
390 NodesModifierBake *bake = request.nmd->find_bake(request.bake_id);
391
392 PackedBake *packed_data = packed_data_by_bake.lookup_ptr(&request);
393 if (!packed_data) {
394 continue;
395 }
396
397 NodesModifierPackedBake *packed_bake = MEM_new<NodesModifierPackedBake>(__func__);
398
399 packed_bake->meta_files_num = packed_data->meta_files.size();
400 packed_bake->blob_files_num = packed_data->blob_files.size();
401
402 packed_bake->meta_files = MEM_new_array<NodesModifierBakeFile>(packed_bake->meta_files_num,
403 __func__);
404 packed_bake->blob_files = MEM_new_array<NodesModifierBakeFile>(packed_bake->blob_files_num,
405 __func__);
406
407 auto transfer_to_bake = [&](NodesModifierBakeFile *bake_files,
408 MemoryBakeFile *memory_bake_files,
409 const int num) {
410 for (const int i : IndexRange(num)) {
411 NodesModifierBakeFile &bake_file = bake_files[i];
412 MemoryBakeFile &memory = memory_bake_files[i];
413 bake_file.name = BLI_strdup_null(memory.name.c_str());
414 const int64_t data_size = memory.data.size();
415 if (data_size == 0) {
416 continue;
417 }
418 const auto *sharing_info = new ImplicitSharedValue<std::string>(std::move(memory.data));
419 const void *data = sharing_info->data.data();
420 bake_file.packed_file = BKE_packedfile_new_from_memory(data, data_size, sharing_info);
421 }
422 };
423
424 transfer_to_bake(
425 packed_bake->meta_files, packed_data->meta_files.data(), packed_bake->meta_files_num);
426 transfer_to_bake(
427 packed_bake->blob_files, packed_data->blob_files.data(), packed_bake->blob_files_num);
428
429 /* Should have been freed before. */
430 BLI_assert(bake->packed == nullptr);
431 bake->packed = packed_bake;
432 }
433
434 /* Tag simulations as being baked. */
435 for (NodeBakeRequest &request : job.bake_requests) {
436 if (request.node_type != GEO_NODE_SIMULATION_OUTPUT) {
437 continue;
438 }
439 NodesModifierData &nmd = *request.nmd;
440 if (bake::SimulationNodeCache *node_cache = nmd.runtime->cache->get_simulation_node_cache(
441 request.bake_id))
442 {
443 if (!node_cache->bake.frames.is_empty()) {
444 /* Tag the caches as being baked so that they are not changed anymore. */
445 node_cache->cache_status = bake::CacheStatus::Baked;
446 }
447 }
449 }
450
451 job.scene->r.cfra = old_frame;
453
454 worker_status->progress = 1.0f;
455 worker_status->do_update = true;
456}
457
458static void bake_geometry_nodes_endjob(void *customdata)
459{
460 BakeGeometryNodesJob &job = *static_cast<BakeGeometryNodesJob *>(customdata);
461 WM_locked_interface_set(job.wm, false);
462 G.is_rendering = false;
466
467 if (!job.error_message.empty()) {
468 for (NodeBakeRequest &request : job.bake_requests) {
469 reset_old_bake_cache(request);
470 try_delete_bake(job.bmain, *request.object, *request.nmd, request.bake_id, job.op->reports);
471 }
472 BKE_report(job.op->reports, RPT_ERROR, job.error_message.c_str());
473 }
474}
475
477{
479 &bake.data_blocks_num,
480 &bake.active_data_block,
481 [](NodesModifierDataBlock *data_block) {
482 nodes_modifier_data_block_destruct(data_block, true);
483 });
484}
485
487{
488 switch (request.node_type) {
490 if (bake::SimulationNodeCache *node_cache =
491 request.nmd->runtime->cache->get_simulation_node_cache(request.bake_id))
492 {
493 node_cache->reset();
494 }
495 break;
496 }
497 case GEO_NODE_BAKE: {
498 if (bake::BakeNodeCache *node_cache = request.nmd->runtime->cache->get_bake_node_cache(
499 request.bake_id))
500 {
501 node_cache->reset();
502 }
503 break;
504 }
505 }
506}
507
508static void try_delete_bake(
509 Main *bmain, Object &object, NodesModifierData &nmd, const int bake_id, ReportList *reports)
510{
511 if (!nmd.runtime->cache) {
512 return;
513 }
514 bake::ModifierCache &modifier_cache = *nmd.runtime->cache;
515 std::lock_guard lock{modifier_cache.mutex};
516 if (auto *node_cache = modifier_cache.simulation_cache_by_id.lookup_ptr(bake_id)) {
517 (*node_cache)->reset();
518 }
519 else if (auto *node_cache = modifier_cache.bake_cache_by_id.lookup_ptr(bake_id)) {
520 (*node_cache)->reset();
521 }
522 NodesModifierBake *bake = nmd.find_bake(bake_id);
523 if (!bake) {
524 return;
525 }
527
528 if (bake->packed) {
530 bake->packed = nullptr;
531 }
532
533 const std::optional<bake::BakePath> bake_path = bake::get_node_bake_path(
534 *bmain, object, nmd, bake_id);
535 if (!bake_path) {
536 return;
537 }
538 const char *meta_dir = bake_path->meta_dir.c_str();
539 if (BLI_exists(meta_dir)) {
540 if (BLI_delete(meta_dir, true, true)) {
541 BKE_reportf(reports, RPT_ERROR, "Failed to remove metadata directory %s", meta_dir);
542 }
543 }
544 const char *blobs_dir = bake_path->blobs_dir.c_str();
545 if (BLI_exists(blobs_dir)) {
546 if (BLI_delete(blobs_dir, true, true)) {
547 BKE_reportf(reports, RPT_ERROR, "Failed to remove blobs directory %s", blobs_dir);
548 }
549 }
550 if (bake_path->bake_dir.has_value()) {
551 const char *zone_bake_dir = bake_path->bake_dir->c_str();
552 /* Try to delete zone bake directory if it is empty. */
553 BLI_delete(zone_bake_dir, true, false);
554 }
555 if (const std::optional<std::string> modifier_bake_dir = bake::get_modifier_bake_path(
556 *bmain, object, nmd))
557 {
558 /* Try to delete modifier bake directory if it is empty. */
559 BLI_delete(modifier_bake_dir->c_str(), true, false);
560 }
561}
562
573
576 wmOperator *op,
577 const BakeRequestsMode mode)
578{
579 Main *bmain = CTX_data_main(C);
580 for (NodeBakeRequest &request : requests) {
581 reset_old_bake_cache(request);
582 if (NodesModifierBake *bake = request.nmd->find_bake(request.bake_id)) {
584 }
585 try_delete_bake(bmain, *request.object, *request.nmd, request.bake_id, op->reports);
586 }
587
588 BakeGeometryNodesJob *job = MEM_new<BakeGeometryNodesJob>(__func__);
589 job->wm = CTX_wm_manager(C);
590 job->bmain = CTX_data_main(C);
592 job->scene = CTX_data_scene(C);
593 job->bake_requests = std::move(requests);
594 job->op = op;
595 WM_locked_interface_set(job->wm, true);
596
597 if (mode == BakeRequestsMode::Sync) {
598 wmJobWorkerStatus worker_status{};
599 bake_geometry_nodes_startjob(job, &worker_status);
601 MEM_delete(job);
602 return OPERATOR_FINISHED;
603 }
604
605 wmJob *wm_job = WM_jobs_get(job->wm,
607 job->scene,
608 "Baking nodes...",
611
613 wm_job, job, [](void *job) { MEM_delete(static_cast<BakeGeometryNodesJob *>(job)); });
617
621}
622
624 Scene &scene,
625 const Span<Object *> objects)
626{
628 for (Object *object : objects) {
629 if (!BKE_id_is_editable(&bmain, &object->id)) {
630 continue;
631 }
632 for (ModifierData &md : object->modifiers) {
633 if (md.type != eModifierType_Nodes) {
634 continue;
635 }
637 continue;
638 }
639 NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(&md);
640 if (!nmd->node_group || ID_MISSING(nmd->node_group)) {
641 continue;
642 }
643 if (!nmd->runtime->cache) {
644 continue;
645 }
646 for (const bNestedNodeRef &nested_node_ref : nmd->node_group->nested_node_refs_span()) {
647 const int id = nested_node_ref.id;
648 const bNode *node = nmd->node_group->find_nested_node(id);
649 if (node->type_legacy != GEO_NODE_SIMULATION_OUTPUT) {
650 continue;
651 }
652 NodeBakeRequest request;
653 request.object = object;
654 request.nmd = nmd;
655 request.bake_id = id;
656 request.node_type = node->type_legacy;
657 request.blob_sharing = std::make_unique<bake::BlobWriteSharing>();
659 request.path = bake::get_node_bake_path(bmain, *object, *nmd, id);
660 }
661 std::optional<IndexRange> frame_range = bake::get_node_bake_frame_range(
662 scene, *object, *nmd, id);
663 if (!frame_range) {
664 continue;
665 }
666 request.frame_start = frame_range->first();
667 request.frame_end = frame_range->last();
668
669 requests.append(std::move(request));
670 }
671 }
672 }
673 return requests;
674}
675
677{
678 Scene *scene = CTX_data_scene(C);
679 Main *bmain = CTX_data_main(C);
680
681 Vector<Object *> objects;
682 if (RNA_boolean_get(op->ptr, "selected")) {
683 CTX_DATA_BEGIN (C, Object *, object, selected_objects) {
684 objects.append(object);
685 }
687 }
688 else {
689 if (Object *object = CTX_data_active_object(C)) {
690 objects.append(object);
691 }
692 }
693
694 return collect_simulations_to_bake(*bmain, *scene, objects);
695}
696
702
705 {
706 /* Normalize the paths so we can compare them. */
707 DynamicStackBuffer<256> norm_buf(s.size() + 1, 8);
708 memcpy(norm_buf.buffer(), s.data(), s.size() + 1);
709 char *norm = static_cast<char *>(norm_buf.buffer());
710
712
713 /* Strip ending slash. */
715
717 return get_default_hash(norm);
718 }
719};
720
722 bool operator()(const StringRef a, const StringRef b) const
723 {
724 return BLI_path_cmp_normalized(a.data(), b.data()) == 0;
725 }
726};
727
728static bool bake_directory_has_data(const StringRefNull absolute_bake_dir)
729{
730 char meta_dir[FILE_MAX];
731 BLI_path_join(meta_dir, sizeof(meta_dir), absolute_bake_dir.c_str(), "meta");
732 char blobs_dir[FILE_MAX];
733 BLI_path_join(blobs_dir, sizeof(blobs_dir), absolute_bake_dir.c_str(), "blobs");
734
735 if (!BLI_is_dir(meta_dir) || !BLI_is_dir(blobs_dir)) {
736 return false;
737 }
738
739 return true;
740}
741
743{
745 return true;
746 }
747 for (const NodesModifierBake &bake : Span{nmd.bakes, nmd.bakes_num}) {
748 if (bake.bake_target == NODES_MODIFIER_BAKE_TARGET_DISK) {
749 return true;
750 }
751 }
752 return false;
753}
754
756 Object &object,
758 wmOperator *op)
759{
760 const bool bake_directory_set = !StringRef(nmd.bake_directory).is_empty();
761 if (bake_directory_set) {
762 return;
763 }
764 if (!may_have_disk_bake(nmd)) {
765 return;
766 }
767
768 Main *bmain = CTX_data_main(C);
769
771 RPT_INFO,
772 "Bake directory of object %s, modifier %s is empty, setting default path",
773 object.id.name + 2,
774 nmd.modifier.name);
775
778 .c_str());
779}
780
782 wmOperator *op,
783 const Span<Object *> objects)
784{
785 Main *bmain = CTX_data_main(C);
786
787 for (Object *object : objects) {
788 if (!BKE_id_is_editable(bmain, &object->id)) {
789 continue;
790 }
791
792 for (ModifierData &md : object->modifiers) {
793 if (md.type != eModifierType_Nodes) {
794 continue;
795 }
796 NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(&md);
798 }
799 }
800}
801
802/* Map for counting path references. */
803using PathUsersMap = Map<std::string,
804 int,
805 default_inline_buffer_capacity(sizeof(std::string)),
809
811{
812 Main *bmain = CTX_data_main(C);
813
814 PathUsersMap path_users;
815 for (const Object *object : objects) {
816 for (const ModifierData &md : object->modifiers) {
817 if (md.type != eModifierType_Nodes) {
818 continue;
819 }
820 const NodesModifierData *nmd = reinterpret_cast<const NodesModifierData *>(&md);
821
822 /* If bakes have a custom directory, report that instead of the modifier data directory. */
823 bool all_bakes_have_custom_dir = true;
824 for (NodesModifierBake &bake : MutableSpan{nmd->bakes, nmd->bakes_num}) {
825 auto bake_path = bke::bake::get_node_bake_path(*bmain, *object, *nmd, bake.id);
826 if (!bake_path || !bake_path.value().bake_dir ||
827 bake_path.value().bake_dir.value().empty())
828 {
829 all_bakes_have_custom_dir = false;
830 continue;
831 }
832 path_users.add_or_modify(
833 bake_path.value().bake_dir.value(),
834 [](int *value) { *value = 1; },
835 [](int *value) { ++(*value); });
836 }
837
838 /* If all bakes have a custom directory, we're done. */
839 if (all_bakes_have_custom_dir) {
840 continue;
841 }
842
843 const std::optional<std::string> modifier_bake_dir = bake::get_modifier_bake_path(
844 *bmain, *object, *nmd);
845 if (!modifier_bake_dir) {
846 continue;
847 }
848
849 path_users.add_or_modify(
850 *modifier_bake_dir, [](int *value) { *value = 1; }, [](int *value) { ++(*value); });
851 }
852 }
853
854 return path_users;
855}
856
858 wmOperator *op,
859 const wmEvent * /*event*/)
860{
861 Vector<Object *> objects;
862 if (RNA_boolean_get(op->ptr, "selected")) {
863 CTX_DATA_BEGIN (C, Object *, object, selected_objects) {
864 objects.append(object);
865 }
867 }
868 else {
869 if (Object *object = CTX_data_active_object(C)) {
870 objects.append(object);
871 }
872 }
873
874 /* Set empty paths to default if necessary. */
875 bake_simulation_validate_paths(C, op, objects);
876
877 PathUsersMap path_users = bake_simulation_get_path_users(C, objects);
878 bool has_path_conflict = false;
879 bool has_existing_bake_data = false;
880 for (const auto &item : path_users.items()) {
881 /* Check if multiple caches are writing to the same bake directory. */
882 if (item.value > 1) {
884 RPT_ERROR,
885 "Path conflict: %d caches set to path %s",
886 item.value,
887 item.key.data());
888 has_path_conflict = true;
889 }
890
891 /* Check if path exists and contains bake data already. */
892 if (bake_directory_has_data(item.key.data())) {
893 has_existing_bake_data = true;
894 }
895 }
896
897 if (has_path_conflict) {
899 return OPERATOR_CANCELLED;
900 }
901 if (has_existing_bake_data) {
903 op,
904 IFACE_("Overwrite existing bake data?"),
905 nullptr,
906 IFACE_("Bake"),
908 false);
909 }
911 return start_bake_job(C, std::move(requests), op, BakeRequestsMode::Async);
912}
913
924
926{
927 Main *bmain = CTX_data_main(C);
928
929 Vector<Object *> objects;
930 if (RNA_boolean_get(op->ptr, "selected")) {
931 CTX_DATA_BEGIN (C, Object *, object, selected_objects) {
932 objects.append(object);
933 }
935 }
936 else {
937 if (Object *object = CTX_data_active_object(C)) {
938 objects.append(object);
939 }
940 }
941
942 if (objects.is_empty()) {
943 return OPERATOR_CANCELLED;
944 }
945
946 for (Object *object : objects) {
947 for (ModifierData &md : object->modifiers) {
948 if (md.type == eModifierType_Nodes) {
949 NodesModifierData *nmd = reinterpret_cast<NodesModifierData *>(&md);
950 for (const NodesModifierBake &bake : Span(nmd->bakes, nmd->bakes_num)) {
951 try_delete_bake(bmain, *object, *nmd, bake.id, op->reports);
952 }
953 }
954 }
955
957 }
958
960
961 return OPERATOR_FINISHED;
962}
963
965{
966 Main *bmain = CTX_data_main(C);
967 Scene *scene = CTX_data_scene(C);
968 Object *object = reinterpret_cast<Object *>(
970 if (object == nullptr) {
971 return {};
972 }
973 std::string modifier_name = RNA_string_get(op->ptr, "modifier_name");
974 ModifierData *md = BKE_modifiers_findby_name(object, modifier_name.c_str());
975 if (md == nullptr) {
976 return {};
977 }
978 NodesModifierData &nmd = *reinterpret_cast<NodesModifierData *>(md);
979 if (!nmd.node_group || ID_MISSING(nmd.node_group)) {
980 return {};
981 }
983 BKE_report(op->reports, RPT_ERROR, "Modifier containing the node is disabled");
984 return {};
985 }
986
988
989 const int bake_id = RNA_int_get(op->ptr, "bake_id");
990 const bNode *node = nmd.node_group->find_nested_node(bake_id);
991 if (node == nullptr) {
992 return {};
993 }
994 if (!ELEM(node->type_legacy, GEO_NODE_SIMULATION_OUTPUT, GEO_NODE_BAKE)) {
995 return {};
996 }
997
998 NodeBakeRequest request;
999 request.object = object;
1000 request.nmd = &nmd;
1001 request.bake_id = bake_id;
1002 request.node_type = node->type_legacy;
1003 request.blob_sharing = std::make_unique<bake::BlobWriteSharing>();
1004
1005 const NodesModifierBake *bake = nmd.find_bake(bake_id);
1006 if (!bake) {
1007 return {};
1008 }
1009 if (bake::get_node_bake_target(*object, nmd, bake_id) == NODES_MODIFIER_BAKE_TARGET_DISK) {
1010 request.path = bake::get_node_bake_path(*bmain, *object, nmd, bake_id);
1011 if (!request.path) {
1012 BKE_report(op->reports,
1013 RPT_INFO,
1014 "Cannot determine bake location on disk. Falling back to packed bake.");
1015 }
1016 }
1017
1018 if (node->type_legacy == GEO_NODE_BAKE && bake->bake_mode == NODES_MODIFIER_BAKE_MODE_STILL) {
1019 const int current_frame = scene->r.cfra;
1020 request.frame_start = current_frame;
1021 request.frame_end = current_frame;
1022 /* Delete old bake because otherwise this wouldn't be a still frame bake. This is not done for
1023 * other bakes to avoid loosing data when starting a bake. */
1024 try_delete_bake(bmain, *object, nmd, bake_id, op->reports);
1025 }
1026 else {
1027 const std::optional<IndexRange> frame_range = bake::get_node_bake_frame_range(
1028 *scene, *object, nmd, bake_id);
1029 if (!frame_range.has_value()) {
1030 return {};
1031 }
1032 if (frame_range->is_empty()) {
1033 return {};
1034 }
1035 request.frame_start = frame_range->first();
1036 request.frame_end = frame_range->last();
1037 }
1038
1039 Vector<NodeBakeRequest> requests;
1040 requests.append(std::move(request));
1041 return requests;
1042}
1043
1045 wmOperator *op,
1046 const wmEvent * /*event*/)
1047{
1049 if (requests.is_empty()) {
1050 return OPERATOR_CANCELLED;
1051 }
1052 return start_bake_job(C, std::move(requests), op, BakeRequestsMode::Async);
1053}
1054
1056{
1058 if (requests.is_empty()) {
1059 return OPERATOR_CANCELLED;
1060 }
1061 return start_bake_job(C, std::move(requests), op, BakeRequestsMode::Sync);
1062}
1063
1074
1076{
1077 Main *bmain = CTX_data_main(C);
1078 Object *object = reinterpret_cast<Object *>(
1080 if (object == nullptr) {
1081 return OPERATOR_CANCELLED;
1082 }
1083 std::string modifier_name = RNA_string_get(op->ptr, "modifier_name");
1084 ModifierData *md = BKE_modifiers_findby_name(object, modifier_name.c_str());
1085 if (md == nullptr) {
1086 return OPERATOR_CANCELLED;
1087 }
1088 NodesModifierData &nmd = *reinterpret_cast<NodesModifierData *>(md);
1089 const int bake_id = RNA_int_get(op->ptr, "bake_id");
1090
1091 try_delete_bake(bmain, *object, nmd, bake_id, op->reports);
1092
1095 WM_main_add_notifier(NC_NODE, nullptr);
1096 return OPERATOR_FINISHED;
1097}
1098
1100{
1101 Main *bmain = CTX_data_main(C);
1102 Object *object = reinterpret_cast<Object *>(
1104 if (object == nullptr) {
1105 return OPERATOR_CANCELLED;
1106 }
1107 std::string modifier_name = RNA_string_get(op->ptr, "modifier_name");
1108 ModifierData *md = BKE_modifiers_findby_name(object, modifier_name.c_str());
1109 if (md == nullptr) {
1110 return OPERATOR_CANCELLED;
1111 }
1112 NodesModifierData &nmd = *reinterpret_cast<NodesModifierData *>(md);
1113 const int bake_id = RNA_int_get(op->ptr, "bake_id");
1114
1115 const std::optional<bake::BakePath> bake_path = bake::get_node_bake_path(
1116 *bmain, *object, nmd, bake_id);
1117 if (!bake_path) {
1118 return OPERATOR_CANCELLED;
1119 }
1120 NodesModifierBake *bake = nmd.find_bake(bake_id);
1121 if (!bake) {
1122 return OPERATOR_CANCELLED;
1123 }
1124
1125 bake::pack_geometry_nodes_bake(*bmain, op->reports, *object, nmd, *bake);
1126
1128 WM_main_add_notifier(NC_NODE, nullptr);
1129 return OPERATOR_FINISHED;
1130}
1131
1133 wmOperator *op,
1134 const wmEvent * /*event*/)
1135{
1136 ui::PopupMenu *pup = ui::popup_menu_begin(C, IFACE_("Unpack"), ICON_NONE);
1137 ui::Layout &layout = *popup_menu_layout(pup);
1138
1140 layout.op_enum(op->type->idname,
1141 "method",
1142 static_cast<IDProperty *>(op->ptr->data),
1144 UI_ITEM_NONE);
1145
1146 popup_menu_end(C, pup);
1147
1148 return OPERATOR_INTERFACE;
1149}
1150
1152{
1153 Main *bmain = CTX_data_main(C);
1154 Object *object = reinterpret_cast<Object *>(
1156 if (object == nullptr) {
1157 return OPERATOR_CANCELLED;
1158 }
1159 std::string modifier_name = RNA_string_get(op->ptr, "modifier_name");
1160 ModifierData *md = BKE_modifiers_findby_name(object, modifier_name.c_str());
1161 if (md == nullptr) {
1162 return OPERATOR_CANCELLED;
1163 }
1164 NodesModifierData &nmd = *reinterpret_cast<NodesModifierData *>(md);
1165 const int bake_id = RNA_int_get(op->ptr, "bake_id");
1166 NodesModifierBake *bake = nmd.find_bake(bake_id);
1167 if (!bake) {
1168 return OPERATOR_CANCELLED;
1169 }
1170
1171 const ePF_FileStatus method = ePF_FileStatus(RNA_enum_get(op->ptr, "method"));
1172
1174 *bmain, op->reports, *object, nmd, *bake, method);
1175 if (result != bake::UnpackGeometryNodesBakeResult::Success) {
1176 return OPERATOR_CANCELLED;
1177 }
1178
1180 WM_main_add_notifier(NC_NODE, nullptr);
1181 return OPERATOR_FINISHED;
1182}
1183
1185{
1186 ot->name = "Calculate Simulation to Frame";
1187 ot->description =
1188 "Calculate simulations in geometry nodes modifiers from the start to current frame";
1189 ot->idname = __func__;
1190
1194
1196 "selected",
1197 false,
1198 "Selected",
1199 "Calculate all selected objects instead of just the active object");
1200}
1201
1203{
1204 ot->name = "Bake Simulation";
1205 ot->description = "Bake simulations in geometry nodes modifiers";
1206 ot->idname = __func__;
1207
1212
1213 RNA_def_boolean(ot->srna, "selected", false, "Selected", "Bake cache on all selected objects");
1214}
1215
1217{
1218 ot->name = "Delete Cached Simulation";
1219 ot->description = "Delete cached/baked simulations in geometry nodes modifiers";
1220 ot->idname = __func__;
1221
1224
1225 RNA_def_boolean(ot->srna, "selected", false, "Selected", "Delete cache on all selected objects");
1226}
1227
1229{
1231
1232 RNA_def_string(ot->srna,
1233 "modifier_name",
1234 nullptr,
1235 0,
1236 "Modifier Name",
1237 "Name of the modifier that contains the node");
1239 ot->srna, "bake_id", 0, 0, INT32_MAX, "Bake ID", "Nested node id of the node", 0, INT32_MAX);
1240}
1241
1243{
1244 ot->name = "Bake Geometry Node";
1245 ot->description = "Bake a single bake node or simulation";
1246 ot->idname = "OBJECT_OT_geometry_node_bake_single";
1247
1252
1254}
1255
1257{
1258 ot->name = "Delete Geometry Node Bake";
1259 ot->description = "Delete baked data of a single bake node or simulation";
1260 ot->idname = "OBJECT_OT_geometry_node_bake_delete_single";
1261
1264
1266}
1267
1269{
1270 ot->name = "Pack Geometry Node Bake";
1271 ot->description = "Pack baked data from disk into the .blend file";
1272 ot->idname = "OBJECT_OT_geometry_node_bake_pack_single";
1273
1276
1278}
1279
1281{
1282 ot->name = "Unpack Geometry Node Bake";
1283 ot->description = "Unpack baked data from the .blend file to disk";
1284 ot->idname = "OBJECT_OT_geometry_node_bake_unpack_single";
1285
1289
1291
1292 static const EnumPropertyItem method_items[] = {
1293 {PF_USE_LOCAL,
1294 "USE_LOCAL",
1295 0,
1296 "Use bake from current directory (create when necessary)",
1297 ""},
1299 "WRITE_LOCAL",
1300 0,
1301 "Write bake to current directory (overwrite existing bake)",
1302 ""},
1304 "USE_ORIGINAL",
1305 0,
1306 "Use bake in original location (create when necessary)",
1307 ""},
1309 "WRITE_ORIGINAL",
1310 0,
1311 "Write bake to original location (overwrite existing file)",
1312 ""},
1313 {0, nullptr, 0, nullptr, nullptr},
1314 };
1315
1316 RNA_def_enum(ot->srna, "method", method_items, PF_USE_LOCAL, "Method", "How to unpack");
1317}
1318
1319} // namespace ed::object::bake_simulation
1320
1321} // namespace blender
#define CTX_DATA_BEGIN(C, Type, instance, member)
#define CTX_DATA_END
#define GEO_NODE_SIMULATION_OUTPUT
#define GEO_NODE_BAKE
Functions and classes for evaluating template expressions in filepaths.
#define INT32_MAX
#define INT32_MIN
File and directory operations.
#define FILE_MAX
#define BLI_path_join(...)
#define TIP_(msgid)
#define IFACE_(msgid)
#define ID_MISSING(_id)
Definition DNA_ID.h:695
#define C
Definition RandGen.cpp:29
#define UI_ITEM_NONE
#define NC_NODE
Definition WM_types.hh:407
#define ND_DISPLAY
Definition WM_types.hh:534
#define ND_MODIFIER
Definition WM_types.hh:503
#define ND_SPACE_VIEW3D
Definition WM_types.hh:571
#define NC_OBJECT
Definition WM_types.hh:392
#define NS_VIEW3D_SHADING
Definition WM_types.hh:627
#define NC_SPACE
Definition WM_types.hh:405
volatile int lock
#define ELEM(...)
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
Definition btVector3.h:263
constexpr IndexRange()=default
const Value * lookup_ptr(const Key &key) const
Definition BLI_map.hh:508
Value & lookup_or_add_default(const Key &key)
Definition BLI_map.hh:639
Value lookup_default(const Key &key, const Value &default_value) const
Definition BLI_map.hh:570
auto add_or_modify(const Key &key, const CreateValueF &create_value, const ModifyValueF &modify_value) -> decltype(create_value(nullptr))
Definition BLI_map.hh:481
ItemIterator items() const &
Definition BLI_map.hh:902
Value & lookup_or_add(const Key &key, const Value &value)
Definition BLI_map.hh:588
constexpr Span()=default
constexpr const char * c_str() const
constexpr StringRef()
void append(const T &value)
bool is_empty() const
const Map< std::string, OutputStream > & get_stream_by_name() const
constexpr int64_t size() const
constexpr const char * data() const
std::optional< NodesModifierBakeTarget > get_node_bake_target(const Object &object, const NodesModifierData &nmd, int node_id)
std::string get_default_modifier_bake_directory(const Main &bmain, const Object &object, const NodesModifierData &nmd)
std::optional< BakePath > get_node_bake_path(const Main &bmain, const Object &object, const NodesModifierData &nmd, int node_id)
std::optional< IndexRange > get_node_bake_frame_range(const Scene &scene, const Object &object, const NodesModifierData &nmd, int node_id)
UnpackGeometryNodesBakeResult unpack_geometry_nodes_bake(Main &bmain, ReportList *reports, Object &object, NodesModifierData &nmd, NodesModifierBake &bake, ePF_FileStatus how)
void serialize_bake(const BakeValues &bake_values, BlobWriter &blob_writer, BlobWriteSharing &blob_sharing, std::ostream &r_stream)
PackGeometryNodesBakeResult pack_geometry_nodes_bake(Main &bmain, ReportList *reports, Object &object, NodesModifierData &nmd, NodesModifierBake &bake)
std::string frame_to_file_name(const SubFrame &frame)
std::optional< std::string > get_modifier_bake_path(const Main &bmain, const Object &object, const NodesModifierData &nmd)
void clear(T **items, int *items_num, int *active_index, void(*destruct_item)(T *))
void OBJECT_OT_simulation_nodes_cache_bake(wmOperatorType *ot)
static wmOperatorStatus bake_single_node_exec(bContext *C, wmOperator *op)
static void bake_geometry_nodes_startjob(void *customdata, wmJobWorkerStatus *worker_status)
static void clear_requested_bakes_in_modifier_cache(BakeGeometryNodesJob &job)
static void bake_geometry_nodes_endjob(void *customdata)
static void simulate_to_frame_endjob(void *customdata)
static void bake_simulation_validate_paths(bContext *C, wmOperator *op, const Span< Object * > objects)
static wmOperatorStatus unpack_single_bake_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus unpack_single_bake_exec(bContext *C, wmOperator *op)
static wmOperatorStatus bake_simulation_modal(bContext *C, wmOperator *, const wmEvent *)
static void simulate_to_frame_startjob(void *customdata, wmJobWorkerStatus *worker_status)
void OBJECT_OT_geometry_node_bake_delete_single(wmOperatorType *ot)
static wmOperatorStatus simulate_to_frame_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus bake_simulation_invoke(bContext *C, wmOperator *op, const wmEvent *)
static wmOperatorStatus simulate_to_frame_modal(bContext *C, wmOperator *, const wmEvent *)
void OBJECT_OT_geometry_node_bake_unpack_single(wmOperatorType *ot)
static void single_bake_operator_props(wmOperatorType *ot)
void OBJECT_OT_geometry_node_bake_pack_single(wmOperatorType *ot)
static void initialize_modifier_bake_directory_if_necessary(bContext *C, Object &object, NodesModifierData &nmd, wmOperator *op)
static wmOperatorStatus delete_baked_simulation_exec(bContext *C, wmOperator *op)
static Vector< NodeBakeRequest > bake_simulation_gather_requests(bContext *C, wmOperator *op)
static wmOperatorStatus bake_single_node_modal(bContext *C, wmOperator *, const wmEvent *)
static PathUsersMap bake_simulation_get_path_users(bContext *C, const Span< Object * > objects)
static wmOperatorStatus bake_simulation_exec(bContext *C, wmOperator *op)
static bool may_have_disk_bake(const NodesModifierData &nmd)
void OBJECT_OT_geometry_node_bake_single(wmOperatorType *ot)
static wmOperatorStatus pack_single_bake_exec(bContext *C, wmOperator *op)
static wmOperatorStatus delete_single_bake_exec(bContext *C, wmOperator *op)
static Vector< NodeBakeRequest > collect_simulations_to_bake(Main &bmain, Scene &scene, const Span< Object * > objects)
static wmOperatorStatus bake_single_node_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void request_bakes_in_modifier_cache(BakeGeometryNodesJob &job)
void OBJECT_OT_simulation_nodes_cache_calculate_to_frame(wmOperatorType *ot)
static void reset_old_bake_cache(NodeBakeRequest &request)
static bool bake_directory_has_data(const StringRefNull absolute_bake_dir)
Map< std::string, int, default_inline_buffer_capacity(sizeof(std::string)), DefaultProbingStrategy, PathStringHash, PathStringEquality > PathUsersMap
static Vector< NodeBakeRequest > bake_single_node_gather_bake_request(bContext *C, wmOperator *op)
static wmOperatorStatus start_bake_job(bContext *C, Vector< NodeBakeRequest > requests, wmOperator *op, const BakeRequestsMode mode)
static void try_delete_bake(Main *bmain, Object &object, NodesModifierData &nmd, const int bake_id, ReportList *reports)
void OBJECT_OT_simulation_nodes_cache_delete(wmOperatorType *ot)
static void clear_data_block_references(NodesModifierBake &bake)
Object * context_active_object(const bContext *C)
PopupMenu * popup_menu_begin(bContext *C, const char *title, int icon) ATTR_NONNULL()
void popup_menu_reports(bContext *C, ReportList *reports) ATTR_NONNULL()
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void DEG_time_tag_update(Main *bmain)
void BKE_scene_graph_update_for_newframe(Depsgraph *depsgraph)
Definition scene.cc:2953
unsigned __int64 uint64_t
Definition BKE_text.h:91
ModifierData * BKE_modifiers_findby_name(const Object *ob, const char *name)
__int64 int64_t
Definition BKE_text.h:90
int RNA_enum_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
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:407
void WM_operator_properties_id_lookup(wmOperatorType *ot, const bool add_name_prop)
ID * WM_operator_properties_id_lookup_from_name_or_session_uid(Main *bmain, PointerRNA *ptr, const ID_Type type)
Depsgraph * CTX_data_depsgraph_pointer(const bContext *C)
bool BLI_exists(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:404
@ OB_FLAG_USE_SIMULATION_CACHE
@ WM_JOB_TYPE_BAKE_GEOMETRY_NODES
Definition WM_api.hh:2050
@ WM_JOB_TYPE_CALCULATE_SIMULATION_NODES
Definition WM_api.hh:2049
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
int RNA_int_get(PointerRNA *ptr, const char *name)
wmWindow * CTX_wm_window(const bContext *C)
void WM_jobs_customdata_set(wmJob *wm_job, void *customdata, void(*free)(void *customdata))
Definition wm_jobs.cc:377
@ WM_JOB_PROGRESS
Definition WM_api.hh:1997
void BLI_path_slash_native(char *path) ATTR_NONNULL(1)
void WM_jobs_start(wmWindowManager *wm, wmJob *wm_job)
Definition wm_jobs.cc:498
Global G
Definition blender.cc:57
void WM_locked_interface_set(wmWindowManager *wm, bool lock)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
void BLI_path_slash_rstrip(char *path) ATTR_NONNULL(1)
std::string BKE_path_template_escape(StringRef text)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
BMesh const char void * data
bool WM_jobs_has_running(const wmWindowManager *window_manager, const void *owner, const eWM_JobType type, const eWM_JobFlag exclude_flags)
Definition wm_jobs.cc:809
int BLI_path_cmp_normalized(const char *p1, const char *p2) ATTR_NONNULL(1
@ NODES_MODIFIER_BAKE_MODE_STILL
wmWindowManager * CTX_wm_manager(const bContext *C)
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
int BLI_path_normalize(char *path) ATTR_NONNULL(1)
ATTR_WARN_UNUSED_RESULT const size_t num
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
wmOperatorStatus WM_operator_confirm_ex(bContext *C, wmOperator *op, const char *title, const char *message, const char *confirm_text, ui::AlertIcon icon, bool cancel_default)
bool ED_operator_object_active_editable(bContext *C)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void DEG_id_tag_update_for_side_effect_request(Depsgraph *depsgraph, ID *id, unsigned int flags)
bool BLI_is_dir(const char *path) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition storage.cc:457
@ NODES_MODIFIER_BAKE_TARGET_DISK
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
constexpr int64_t default_inline_buffer_capacity(size_t element_size)
void BKE_reportf(ReportList *reports, eReportType type, const char *format,...) ATTR_PRINTF_FORMAT(3
Definition report.cc:191
Main * CTX_data_main(const bContext *C)
char * BLI_strdup(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC
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:228
PythonProbingStrategy<> DefaultProbingStrategy
constexpr int64_t PACKED_FILE_MAX_SIZE
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
Scene * CTX_data_scene(const bContext *C)
char * BLI_strdup_null(const char *str) ATTR_WARN_UNUSED_RESULT ATTR_MALLOC
void nodes_modifier_packed_bake_free(NodesModifierPackedBake *packed_bake)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
bool BKE_id_is_editable(const Main *bmain, const ID *id)
Definition lib_id.cc:2782
PackedFile * BKE_packedfile_new_from_memory(const void *mem, int memlen, const ImplicitSharingInfo *sharing_info=nullptr)
bool BKE_modifier_is_enabled(const Scene *scene, ModifierData *md, int required_mode)
Object * CTX_data_active_object(const bContext *C)
constexpr uint64_t get_default_hash(const T &v, const Args &...args)
Definition BLI_hash.hh:252
void WM_jobs_timer(wmJob *wm_job, double time_step, uint note, uint endnote, void(*timer_step)(void *))
Definition wm_jobs.cc:393
bool BLI_file_ensure_parent_dir_exists(const char *filepath) ATTR_NONNULL(1)
Definition fileops_c.cc:454
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
NodesModifierBakeTarget bake_target
NodesModifierRuntime * runtime
std::shared_ptr< bke::bake::ModifierCache > cache
Definition MOD_nodes.hh:64
struct RenderData r
float subframe() const
Map< int, std::unique_ptr< SimulationNodeCache > > simulation_cache_by_id
Map< int, std::unique_ptr< BakeNodeCache > > bake_cache_by_id
NodeBakeCache * get_node_bake_cache(const int id)
Vector< std::unique_ptr< FrameCache > > frames
std::unique_ptr< bake::BlobWriteSharing > blob_sharing
bool operator()(const StringRef a, const StringRef b) const
void operator_context_set(wm::OpCallContext opcontext)
void op_enum(StringRefNull opname, StringRefNull propname, IDProperty *properties, wm::OpCallContext context, eUI_Item_Flag flag, const int active=-1)
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
wmOperatorStatus(*) modal(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1157
struct ReportList * reports
struct wmOperatorType * type