[Bf-blender-cvs] [b05fa123d74] master: Make `BKE_collection_duplicate able to handle master collections.
Bastien Montagne
noreply at git.blender.org
Wed Jun 10 19:45:57 CEST 2020
Commit: b05fa123d741567d0446a1e73cf7e97016cfa7da
Author: Bastien Montagne
Date: Wed Jun 10 18:25:08 2020 +0200
Branches: master
https://developer.blender.org/rBb05fa123d741567d0446a1e73cf7e97016cfa7da
Make `BKE_collection_duplicate able to handle master collections.
Those are then assumed already duplicated, and not touched. However, all
of ther objects and sub-collections can still be processed as with any
other regular collection...
===================================================================
M source/blender/blenkernel/intern/collection.c
===================================================================
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 1388146eeb7..675e86b1584 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -314,9 +314,17 @@ static Collection *collection_duplicate_recursive(Main *bmain,
Collection *collection_new;
bool do_full_process = false;
const int object_dupflag = (do_obdata) ? U.dupflag : 0;
+ const bool is_collection_master = (collection_old->flag & COLLECTION_IS_MASTER) != 0;
const bool is_collection_liboverride = ID_IS_OVERRIDE_LIBRARY(collection_old);
- if (!do_hierarchy || collection_old->id.newid == NULL) {
+ if (is_collection_master) {
+ /* We never duplicate master collections here, but we can still deep-copy their objects and
+ * collections. */
+ BLI_assert(parent == NULL);
+ collection_new = collection_old;
+ do_full_process = true;
+ }
+ else if (!do_hierarchy || collection_old->id.newid == NULL) {
BKE_id_copy(bmain, &collection_old->id, (ID **)&collection_new);
/* Copying add one user by default, need to get rid of that one. */
@@ -378,7 +386,7 @@ static Collection *collection_duplicate_recursive(Main *bmain,
/* We can loop on collection_old's children,
* that list is currently identical the collection_new' children, and won't be changed here. */
- LISTBASE_FOREACH (CollectionChild *, child, &collection_old->children) {
+ LISTBASE_FOREACH_MUTABLE (CollectionChild *, child, &collection_old->children) {
Collection *child_collection_old = child->collection;
collection_duplicate_recursive(
@@ -422,13 +430,6 @@ Collection *BKE_collection_duplicate(Main *bmain,
const bool do_objects,
const bool do_obdata)
{
- /* It's not allowed to copy the master collection. */
- BLI_assert((collection->id.flag & LIB_EMBEDDED_DATA) == 0);
- BLI_assert((collection->flag & COLLECTION_IS_MASTER) == 0);
- if (collection->flag & COLLECTION_IS_MASTER) {
- return NULL;
- }
-
if (do_hierarchy) {
BKE_main_id_tag_all(bmain, LIB_TAG_NEW, false);
BKE_main_id_clear_newpoins(bmain);
More information about the Bf-blender-cvs
mailing list