diff options
Diffstat (limited to 'source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc')
-rw-r--r-- | source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc index bd713058cce..86786a968a3 100644 --- a/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc +++ b/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc @@ -368,12 +368,7 @@ void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, const int base_enabled_flag = (depsgraph->mode == DAG_EVAL_VIEWPORT) ? BASE_ENABLED_VIEWPORT : BASE_ENABLED_RENDER; ListBase enabled_bases = {NULL, NULL}; - for (Base *base = reinterpret_cast<Base *>(view_layer->object_bases.first), - *base_next; - base != NULL; - base = base_next) - { - base_next = base->next; + LISTBASE_FOREACH_MUTABLE (Base *, base, &view_layer->object_bases) { const bool is_object_enabled = (base->flag & base_enabled_flag); if (is_object_enabled) { BLI_addtail(&enabled_bases, base); @@ -388,12 +383,26 @@ void view_layer_remove_disabled_bases(const Depsgraph *depsgraph, view_layer->object_bases = enabled_bases; } -void scene_cleanup_view_layers(const Depsgraph *depsgraph, Scene *scene_cow) +void view_layer_update_orig_base_pointers(ViewLayer *view_layer_orig, + ViewLayer *view_layer_eval) +{ + Base *base_orig = + reinterpret_cast<Base *>(view_layer_orig->object_bases.first); + LISTBASE_FOREACH (Base *, base_eval, &view_layer_eval->object_bases) { + base_eval->base_orig = base_orig; + base_orig = base_orig->next; + } +} + +void scene_setup_view_layers_after_copy(const Depsgraph *depsgraph, + Scene *scene_cow) { scene_remove_unused_view_layers(depsgraph, scene_cow); - view_layer_remove_disabled_bases( - depsgraph, - reinterpret_cast<ViewLayer *>(scene_cow->view_layers.first)); + ViewLayer *view_layer_orig = depsgraph->view_layer; + ViewLayer *view_layer_eval = + reinterpret_cast<ViewLayer *>(scene_cow->view_layers.first); + view_layer_update_orig_base_pointers(view_layer_orig, view_layer_eval); + view_layer_remove_disabled_bases(depsgraph, view_layer_eval); /* TODO(sergey): Remove objects from collections as well. * Not a HUGE deal for now, nobody is looking into those CURRENTLY. * Still not an excuse to have those. */ @@ -720,7 +729,7 @@ ID *deg_expand_copy_on_write_datablock(const Depsgraph *depsgraph, { done = scene_copy_inplace_no_main((Scene *)id_orig, (Scene *)id_cow); if (done) { - scene_cleanup_view_layers(depsgraph, (Scene *)id_cow); + scene_setup_view_layers_after_copy(depsgraph, (Scene *)id_cow); } break; } |