Changeset View
Changeset View
Standalone View
Standalone View
source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
| Show First 20 Lines • Show All 300 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /* Similar to BKE_scene_copy() but does not require main and assumes pointer | /* Similar to BKE_scene_copy() but does not require main and assumes pointer | ||||
| * is already allocated. */ | * is already allocated. */ | ||||
| bool scene_copy_inplace_no_main(const Scene *scene, Scene *new_scene) | bool scene_copy_inplace_no_main(const Scene *scene, Scene *new_scene) | ||||
| { | { | ||||
| const ID *id_for_copy = &scene->id; | const ID *id_for_copy = &scene->id; | ||||
| if (G.debug & G_DEBUG_DEPSGRAPH_UUID) { | |||||
| BKE_sequencer_check_uuids_unique_and_report(scene); | |||||
| } | |||||
| #ifdef NESTED_ID_NASTY_WORKAROUND | #ifdef NESTED_ID_NASTY_WORKAROUND | ||||
| NestedIDHackTempStorage id_hack_storage; | NestedIDHackTempStorage id_hack_storage; | ||||
| id_for_copy = nested_id_hack_get_discarded_pointers(&id_hack_storage, &scene->id); | id_for_copy = nested_id_hack_get_discarded_pointers(&id_hack_storage, &scene->id); | ||||
| #endif | #endif | ||||
| bool result = BKE_id_copy_ex( | bool result = BKE_id_copy_ex( | ||||
| nullptr, id_for_copy, (ID **)&new_scene, LIB_ID_COPY_LOCALIZE | LIB_ID_CREATE_NO_ALLOCATE); | nullptr, id_for_copy, (ID **)&new_scene, LIB_ID_COPY_LOCALIZE | LIB_ID_CREATE_NO_ALLOCATE); | ||||
| ▲ Show 20 Lines • Show All 154 Lines • ▼ Show 20 Lines | void scene_setup_view_layers_after_remap(const Depsgraph *depsgraph, | ||||
| ViewLayer *view_layer_eval = reinterpret_cast<ViewLayer *>(scene_cow->view_layers.first); | 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_update_orig_base_pointers(view_layer_orig, view_layer_eval); | ||||
| view_layer_remove_disabled_bases(depsgraph, view_layer_eval); | view_layer_remove_disabled_bases(depsgraph, view_layer_eval); | ||||
| /* TODO(sergey): Remove objects from collections as well. | /* TODO(sergey): Remove objects from collections as well. | ||||
| * Not a HUGE deal for now, nobody is looking into those CURRENTLY. | * Not a HUGE deal for now, nobody is looking into those CURRENTLY. | ||||
| * Still not an excuse to have those. */ | * Still not an excuse to have those. */ | ||||
| } | } | ||||
| void update_sequence_orig_pointers(const ListBase *sequences_orig, ListBase *sequences_cow) | |||||
| { | |||||
| Sequence *sequence_orig = reinterpret_cast<Sequence *>(sequences_orig->first); | |||||
| Sequence *sequence_cow = reinterpret_cast<Sequence *>(sequences_cow->first); | |||||
| while (sequence_orig != nullptr) { | |||||
| update_sequence_orig_pointers(&sequence_orig->seqbase, &sequence_cow->seqbase); | |||||
| sequence_cow->orig_sequence = sequence_orig; | |||||
| sequence_cow = sequence_cow->next; | |||||
| sequence_orig = sequence_orig->next; | |||||
| } | |||||
| } | |||||
| void update_scene_orig_pointers(const Scene *scene_orig, Scene *scene_cow) | |||||
| { | |||||
| if (scene_orig->ed != nullptr) { | |||||
| update_sequence_orig_pointers(&scene_orig->ed->seqbase, &scene_cow->ed->seqbase); | |||||
| } | |||||
| } | |||||
| /* Check whether given ID is expanded or still a shallow copy. */ | /* Check whether given ID is expanded or still a shallow copy. */ | ||||
| inline bool check_datablock_expanded(const ID *id_cow) | inline bool check_datablock_expanded(const ID *id_cow) | ||||
| { | { | ||||
| return (id_cow->name[0] != '\0'); | return (id_cow->name[0] != '\0'); | ||||
| } | } | ||||
| /* Callback for BKE_library_foreach_ID_link which remaps original ID pointer | /* Callback for BKE_library_foreach_ID_link which remaps original ID pointer | ||||
| * with the one created by CoW system. */ | * with the one created by CoW system. */ | ||||
| ▲ Show 20 Lines • Show All 296 Lines • ▼ Show 20 Lines | case ID_OB: { | ||||
| break; | break; | ||||
| } | } | ||||
| case ID_SCE: { | case ID_SCE: { | ||||
| Scene *scene_cow = (Scene *)id_cow; | Scene *scene_cow = (Scene *)id_cow; | ||||
| const Scene *scene_orig = (const Scene *)id_orig; | const Scene *scene_orig = (const Scene *)id_orig; | ||||
| scene_cow->toolsettings = scene_orig->toolsettings; | scene_cow->toolsettings = scene_orig->toolsettings; | ||||
| scene_cow->eevee.light_cache_data = scene_orig->eevee.light_cache_data; | scene_cow->eevee.light_cache_data = scene_orig->eevee.light_cache_data; | ||||
| scene_setup_view_layers_after_remap(depsgraph, id_node, reinterpret_cast<Scene *>(id_cow)); | scene_setup_view_layers_after_remap(depsgraph, id_node, reinterpret_cast<Scene *>(id_cow)); | ||||
| update_scene_orig_pointers(scene_orig, scene_cow); | |||||
| break; | break; | ||||
| } | } | ||||
| default: | default: | ||||
| break; | break; | ||||
| } | } | ||||
| update_edit_mode_pointers(depsgraph, id_orig, id_cow); | update_edit_mode_pointers(depsgraph, id_orig, id_cow); | ||||
| BKE_animsys_update_driver_array(id_cow); | BKE_animsys_update_driver_array(id_cow); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 311 Lines • Show Last 20 Lines | |||||