Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/collection.c
| Show First 20 Lines • Show All 1,683 Lines • ▼ Show 20 Lines | if (relative_child) { | ||||
| BLI_insertlinkbefore(&to_parent->children, relative_child, child); | BLI_insertlinkbefore(&to_parent->children, relative_child, child); | ||||
| } | } | ||||
| BKE_collection_object_cache_free(to_parent); | BKE_collection_object_cache_free(to_parent); | ||||
| } | } | ||||
| } | } | ||||
| /* Make sure we store the flag of the layer collections before we remove and re-create them. | /* Make sure we store the flag of the layer collections before we remove and re-create them. | ||||
| * Otherwise they will get lost and everything will be copied from the new parent collection. */ | * Otherwise they will get lost and everything will be copied from the new parent collection. | ||||
| * Don't use flag syncing when moving a collection to a different scene, as it no longer exists | |||||
| * in the same view layers anyway. */ | |||||
mont29: Would be nice to have a comment explaining why this is needed. | |||||
| const bool do_flag_sync = BKE_scene_find_from_collection(bmain, to_parent) == | |||||
| BKE_scene_find_from_collection(bmain, collection); | |||||
| ListBase layer_flags; | ListBase layer_flags; | ||||
| if (do_flag_sync) { | |||||
| layer_collection_flags_store(bmain, collection, &layer_flags); | layer_collection_flags_store(bmain, collection, &layer_flags); | ||||
| } | |||||
| /* Create and remove layer collections. */ | /* Create and remove layer collections. */ | ||||
| BKE_main_collection_sync(bmain); | BKE_main_collection_sync(bmain); | ||||
| /* Restore the original layer collection flags. */ | /* Restore the original layer collection flags. */ | ||||
| if (do_flag_sync) { | |||||
| layer_collection_flags_restore(&layer_flags, collection); | layer_collection_flags_restore(&layer_flags, collection); | ||||
| } | |||||
| /* We need to sync it again to pass the correct flags to the collections objects. */ | /* We need to sync it again to pass the correct flags to the collections objects. */ | ||||
| BKE_main_collection_sync(bmain); | BKE_main_collection_sync(bmain); | ||||
| return true; | return true; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 191 Lines • Show Last 20 Lines | |||||
Would be nice to have a comment explaining why this is needed.