[Bf-blender-cvs] [2c435cf249c] master: Cleanup: get rid of `BKE_collection_copy`.

Bastien Montagne noreply at git.blender.org
Tue Jun 16 17:40:36 CEST 2020


Commit: 2c435cf249cc01550c04e284eda3eb3cf6cf223e
Author: Bastien Montagne
Date:   Tue Jun 16 15:18:55 2020 +0200
Branches: master
https://developer.blender.org/rB2c435cf249cc01550c04e284eda3eb3cf6cf223e

Cleanup: get rid of `BKE_collection_copy`.

We want to get rid of those for all ID types ultimately, but that one
was only used in one place, being the only one calling
`BKE_collection_duplicate` without hierarchical duplicate and parent
collection pointer, effectively using the full power of the complex deep
duplication code for a mere `BKE_id_copy` call...

This will allow for further cleanup in duplicate code.

===================================================================

M	source/blender/blenkernel/BKE_collection.h
M	source/blender/blenkernel/intern/collection.c
M	source/blender/editors/object/object_relations.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index f4b56aa152f..f34bcfaf48f 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -57,10 +57,6 @@ void BKE_collection_add_from_object(struct Main *bmain,
 void BKE_collection_free(struct Collection *collection);
 bool BKE_collection_delete(struct Main *bmain, struct Collection *collection, bool hierarchy);
 
-struct Collection *BKE_collection_copy(struct Main *bmain,
-                                       struct Collection *parent,
-                                       struct Collection *collection);
-
 struct Collection *BKE_collection_duplicate(struct Main *bmain,
                                             struct Collection *parent,
                                             struct Collection *collection,
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 6f63da18a22..e1c58bad9d3 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -420,17 +420,6 @@ static Collection *collection_duplicate_recursive(Main *bmain,
   return collection_new;
 }
 
-/**
- * Makes a standard (aka shallow) ID copy of a Collection.
- *
- * Add a new collection in the same level as the old one, link any nested collections
- * and finally link the objects to the new collection (as opposed to copying them).
- */
-Collection *BKE_collection_copy(Main *bmain, Collection *parent, Collection *collection)
-{
-  return BKE_collection_duplicate(bmain, parent, collection, false, false, false);
-}
-
 /**
  * Make either a shallow copy, or deeper duplicate of given collection.
  *
diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c
index fd2fcb11635..4a05658fc00 100644
--- a/source/blender/editors/object/object_relations.c
+++ b/source/blender/editors/object/object_relations.c
@@ -1771,7 +1771,10 @@ static Collection *single_object_users_collection(Main *bmain,
   /* Generate new copies for objects in given collection and all its children,
    * and optionally also copy collections themselves. */
   if (copy_collections && !is_master_collection) {
-    collection = ID_NEW_SET(collection, BKE_collection_copy(bmain, NULL, collection));
+    Collection *collection_new;
+    BKE_id_copy(bmain, &collection->id, (ID **)&collection_new);
+    id_us_min(&collection_new->id);
+    collection = ID_NEW_SET(collection, collection_new);
   }
 
   /* We do not remap to new objects here, this is done in separate step. */



More information about the Bf-blender-cvs mailing list