From 8d3e57f338234995c30ae702fff62ed6229f762e Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 22 Dec 2021 16:57:07 +0100 Subject: Fix T93799: Outliner: Remaping objects could result in duplicates in a collection. Fix is similar to how CollectionObject with NULL object pointers are handled. Using one of the 'free' pad bytes in Object_Runtime struct instead of a gset (or other external way to detect object duplicates), as this is several times faster. NOTE: This makes remapping slightly slower again (adds 10 extra seconds to file case in T94059). General improvements of remapping time complexity, especially when remapping a lot of IDs at once, is a separate topic currently investigated in D13615. --- source/blender/blenkernel/BKE_collection.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/blenkernel/BKE_collection.h') diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h index 46c1fe0d33d..7dfda7b5121 100644 --- a/source/blender/blenkernel/BKE_collection.h +++ b/source/blender/blenkernel/BKE_collection.h @@ -163,7 +163,21 @@ bool BKE_scene_collections_object_remove(struct Main *bmain, struct Scene *scene, struct Object *object, const bool free_us); + +/** + * Check all collections in \a bmain (including embedded ones in scenes) for CollectionObject with + * NULL object pointer, and remove them. + */ void BKE_collections_object_remove_nulls(struct Main *bmain); + +/** + * Check all collections in \a bmain (including embedded ones in scenes) for duplicate + * CollectionObject with a same object pointer within a same object, and remove them. + * + * NOTE: Always keeps the first of the detected duplicates. + */ +void BKE_collections_object_remove_duplicates(struct Main *bmain); + /** * Remove all NULL children from parent collections of changed \a collection. * This is used for library remapping, where these pointers have been set to NULL. -- cgit v1.2.3