Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r--source/blender/blenkernel/intern/collection.c35
1 files changed, 13 insertions, 22 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 2031576190e..f2098cc2430 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -203,6 +203,9 @@ void BKE_collection_copy_data(Main *bmain,
const Collection *collection_src,
const int flag)
{
+ BLI_assert(((collection_src->flag & COLLECTION_IS_MASTER) != 0) ==
+ ((collection_src->id.flag & LIB_PRIVATE_DATA) != 0));
+
/* Do not copy collection's preview (same behavior as for objects). */
if ((flag & LIB_ID_COPY_NO_PREVIEW) == 0 && false) { /* XXX TODO temp hack */
BKE_previewimg_id_copy(&collection_dst->id, &collection_src->id);
@@ -338,8 +341,9 @@ Collection *BKE_collection_duplicate(Main *bmain,
const bool do_obdata)
{
/* It's not allowed to copy the master collection. */
+ BLI_assert((collection->id.flag & LIB_PRIVATE_DATA) == 0);
+ BLI_assert((collection->flag & COLLECTION_IS_MASTER) == 0);
if (collection->flag & COLLECTION_IS_MASTER) {
- BLI_assert("!Master collection can't be duplicated");
return NULL;
}
@@ -365,15 +369,6 @@ Collection *BKE_collection_duplicate(Main *bmain,
return collection_new;
}
-Collection *BKE_collection_copy_master(Main *bmain, Collection *collection, const int flag)
-{
- BLI_assert(collection->flag & COLLECTION_IS_MASTER);
-
- Collection *collection_dst = MEM_dupallocN(collection);
- BKE_collection_copy_data(bmain, collection_dst, collection, flag);
- return collection_dst;
-}
-
void BKE_collection_make_local(Main *bmain, Collection *collection, const bool lib_local)
{
BKE_id_make_local_generic(bmain, &collection->id, true, lib_local);
@@ -499,15 +494,11 @@ Collection *BKE_collection_master_add()
/* Not an actual datablock, but owned by scene. */
Collection *master_collection = MEM_callocN(sizeof(Collection), "Master Collection");
STRNCPY(master_collection->id.name, "GRMaster Collection");
+ master_collection->id.flag |= LIB_PRIVATE_DATA;
master_collection->flag |= COLLECTION_IS_MASTER;
return master_collection;
}
-Collection *BKE_collection_master(const Scene *scene)
-{
- return scene->master_collection;
-}
-
Scene *BKE_collection_master_scene_search(const Main *bmain, const Collection *master_collection)
{
BLI_assert((master_collection->flag & COLLECTION_IS_MASTER) != 0);
@@ -584,7 +575,7 @@ bool BKE_collection_has_object_recursive(Collection *collection, Object *ob)
static Collection *collection_next_find(Main *bmain, Scene *scene, Collection *collection)
{
- if (scene && collection == BKE_collection_master(scene)) {
+ if (scene && collection == scene->master_collection) {
return bmain->collections.first;
}
else {
@@ -601,7 +592,7 @@ Collection *BKE_collection_object_find(Main *bmain,
collection = collection_next_find(bmain, scene, collection);
}
else if (scene) {
- collection = BKE_collection_master(scene);
+ collection = scene->master_collection;
}
else {
collection = bmain->collections.first;
@@ -743,7 +734,7 @@ void BKE_collection_object_add_from(Main *bmain, Scene *scene, Object *ob_src, O
if (!is_instantiated) {
/* In case we could not find any non-linked collections in which instantiate our ob_dst,
* fallback to scene's master collection... */
- collection_object_add(bmain, BKE_collection_master(scene), ob_dst, 0, true);
+ collection_object_add(bmain, scene->master_collection, ob_dst, 0, true);
}
BKE_main_collection_sync(bmain);
@@ -885,7 +876,7 @@ void BKE_collections_child_remove_nulls(Main *bmain, Collection *collection)
collection_null_children_remove(collection);
}
for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- collection_null_children_remove(BKE_collection_master(scene));
+ collection_null_children_remove(scene->master_collection);
}
for (collection = bmain->collections.first; collection != NULL;
@@ -893,7 +884,7 @@ void BKE_collections_child_remove_nulls(Main *bmain, Collection *collection)
collection_missing_parents_remove(collection);
}
for (Scene *scene = bmain->scenes.first; scene != NULL; scene = scene->id.next) {
- collection_missing_parents_remove(BKE_collection_master(scene));
+ collection_missing_parents_remove(scene->master_collection);
}
}
else {
@@ -1169,7 +1160,7 @@ static Collection *collection_from_index_recursive(Collection *collection,
Collection *BKE_collection_from_index(Scene *scene, const int index)
{
int index_current = 0;
- Collection *master_collection = BKE_collection_master(scene);
+ Collection *master_collection = scene->master_collection;
return collection_from_index_recursive(master_collection, index, &index_current);
}
@@ -1363,7 +1354,7 @@ static void scene_collections_array(Scene *scene, Collection ***collections_arra
return;
}
- collection = BKE_collection_master(scene);
+ collection = scene->master_collection;
BLI_assert(collection != NULL);
scene_collection_callback(collection, scene_collections_count, tot);