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:
authorDalai Felinto <dalai@blender.org>2020-03-06 17:17:47 +0300
committerDalai Felinto <dalai@blender.org>2020-03-06 17:27:50 +0300
commit17f08cff6a12a1ba2ff336cac13ffc8d4b1e845e (patch)
tree95136c47ebfac37374e9e69cdef6fc49e0daad00 /source/blender
parent69d4aec55f9c5bc64c58e43edefc6687fcb9d08b (diff)
Cleanup: Collection: Move to IDTypeInfo, and remove unused BKE API.
Note: we still need BKE_collection_free since we call it from scene.c.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_collection.h5
-rw-r--r--source/blender/blenkernel/BKE_idtype.h2
-rw-r--r--source/blender/blenkernel/intern/collection.c130
-rw-r--r--source/blender/blenkernel/intern/idtype.c2
-rw-r--r--source/blender/blenkernel/intern/lib_id.c6
-rw-r--r--source/blender/blenkernel/intern/lib_id_delete.c2
6 files changed, 80 insertions, 67 deletions
diff --git a/source/blender/blenkernel/BKE_collection.h b/source/blender/blenkernel/BKE_collection.h
index 9fdea820499..a314008f715 100644
--- a/source/blender/blenkernel/BKE_collection.h
+++ b/source/blender/blenkernel/BKE_collection.h
@@ -56,11 +56,6 @@ bool BKE_collection_delete(struct Main *bmain, struct Collection *collection, bo
struct Collection *BKE_collection_copy(struct Main *bmain,
struct Collection *parent,
struct Collection *collection);
-void BKE_collection_copy_data(struct Main *bmain,
- struct Collection *collection_dst,
- const struct Collection *collection_src,
- const int flag);
-void BKE_collection_make_local(struct Main *bmain, struct Collection *collection, const int flags);
struct Collection *BKE_collection_duplicate(struct Main *bmain,
struct Collection *parent,
diff --git a/source/blender/blenkernel/BKE_idtype.h b/source/blender/blenkernel/BKE_idtype.h
index 356e059057e..8d7267061ac 100644
--- a/source/blender/blenkernel/BKE_idtype.h
+++ b/source/blender/blenkernel/BKE_idtype.h
@@ -144,7 +144,7 @@ extern IDTypeInfo IDType_ID_SCR;
// extern IDTypeInfo IDType_ID_TXT;
// extern IDTypeInfo IDType_ID_SPK;
// extern IDTypeInfo IDType_ID_SO;
-// extern IDTypeInfo IDType_ID_GR;
+extern IDTypeInfo IDType_ID_GR;
// extern IDTypeInfo IDType_ID_AR;
// extern IDTypeInfo IDType_ID_AC;
extern IDTypeInfo IDType_ID_NT;
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 2699121b63e..5c4636db728 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -30,6 +30,7 @@
#include "BKE_collection.h"
#include "BKE_icons.h"
+#include "BKE_idtype.h"
#include "BKE_idprop.h"
#include "BKE_layer.h"
#include "BKE_lib_id.h"
@@ -70,6 +71,79 @@ static CollectionParent *collection_find_parent(Collection *child, Collection *c
static bool collection_find_child_recursive(Collection *parent, Collection *collection);
+/****************************** Collection Datablock ************************/
+
+/**
+ * Only copy internal data of Collection ID from source
+ * to already allocated/initialized destination.
+ * You probably never want to use that directly,
+ * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
+ *
+ * WARNING! This function will not handle ID user count!
+ *
+ * \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
+ */
+static void collection_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const int flag)
+{
+ Collection *collection_dst = (Collection *)id_dst;
+ const Collection *collection_src = (const Collection *)id_src;
+
+ 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);
+ }
+ else {
+ collection_dst->preview = NULL;
+ }
+
+ collection_dst->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
+ BLI_listbase_clear(&collection_dst->object_cache);
+
+ BLI_listbase_clear(&collection_dst->gobject);
+ BLI_listbase_clear(&collection_dst->children);
+ BLI_listbase_clear(&collection_dst->parents);
+
+ for (CollectionChild *child = collection_src->children.first; child; child = child->next) {
+ collection_child_add(collection_dst, child->collection, flag, false);
+ }
+ for (CollectionObject *cob = collection_src->gobject.first; cob; cob = cob->next) {
+ collection_object_add(bmain, collection_dst, cob->ob, flag, false);
+ }
+}
+
+static void collection_free_data(ID *id)
+{
+ Collection *collection = (Collection *)id;
+
+ /* No animdata here. */
+ BKE_previewimg_free(&collection->preview);
+
+ BLI_freelistN(&collection->gobject);
+ BLI_freelistN(&collection->children);
+ BLI_freelistN(&collection->parents);
+
+ BKE_collection_object_cache_free(collection);
+}
+
+IDTypeInfo IDType_ID_GR = {
+ .id_code = ID_GR,
+ .id_filter = FILTER_ID_GR,
+ .main_listbase_index = INDEX_ID_GR,
+ .struct_size = sizeof(Collection),
+ .name = "Collection",
+ .name_plural = "collections",
+ .translation_context = BLT_I18NCONTEXT_ID_COLLECTION,
+ .flags = 0,
+
+ .init_data = NULL,
+ .copy_data = collection_copy_data,
+ .free_data = collection_free_data,
+ .make_local = NULL,
+};
+
/***************************** Add Collection *******************************/
/* Add new collection, without view layer syncing. */
@@ -117,14 +191,7 @@ Collection *BKE_collection_add(Main *bmain, Collection *collection_parent, const
/** Free (or release) any data used by this collection (does not free the collection itself). */
void BKE_collection_free(Collection *collection)
{
- /* No animdata here. */
- BKE_previewimg_free(&collection->preview);
-
- BLI_freelistN(&collection->gobject);
- BLI_freelistN(&collection->children);
- BLI_freelistN(&collection->parents);
-
- BKE_collection_object_cache_free(collection);
+ collection_free_data(&collection->id);
}
/**
@@ -187,48 +254,6 @@ bool BKE_collection_delete(Main *bmain, Collection *collection, bool hierarchy)
}
/***************************** Collection Copy *******************************/
-
-/**
- * Only copy internal data of Collection ID from source
- * to already allocated/initialized destination.
- * You probably never want to use that directly,
- * use #BKE_id_copy or #BKE_id_copy_ex for typical needs.
- *
- * WARNING! This function will not handle ID user count!
- *
- * \param flag: Copying options (see BKE_lib_id.h's LIB_ID_COPY_... flags for more).
- */
-void BKE_collection_copy_data(Main *bmain,
- Collection *collection_dst,
- 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);
- }
- else {
- collection_dst->preview = NULL;
- }
-
- collection_dst->flag &= ~COLLECTION_HAS_OBJECT_CACHE;
- BLI_listbase_clear(&collection_dst->object_cache);
-
- BLI_listbase_clear(&collection_dst->gobject);
- BLI_listbase_clear(&collection_dst->children);
- BLI_listbase_clear(&collection_dst->parents);
-
- for (CollectionChild *child = collection_src->children.first; child; child = child->next) {
- collection_child_add(collection_dst, child->collection, flag, false);
- }
- for (CollectionObject *cob = collection_src->gobject.first; cob; cob = cob->next) {
- collection_object_add(bmain, collection_dst, cob->ob, flag, false);
- }
-}
-
static Collection *collection_duplicate_recursive(Main *bmain,
Collection *parent,
Collection *collection_old,
@@ -369,11 +394,6 @@ Collection *BKE_collection_duplicate(Main *bmain,
return collection_new;
}
-void BKE_collection_make_local(Main *bmain, Collection *collection, const int flags)
-{
- BKE_lib_id_make_local_generic(bmain, &collection->id, flags);
-}
-
/********************************* Naming *******************************/
/**
diff --git a/source/blender/blenkernel/intern/idtype.c b/source/blender/blenkernel/intern/idtype.c
index 9de431a7f13..c224c8586fa 100644
--- a/source/blender/blenkernel/intern/idtype.c
+++ b/source/blender/blenkernel/intern/idtype.c
@@ -71,7 +71,7 @@ static void id_type_init(void)
// INIT_TYPE(ID_TXT);
// INIT_TYPE(ID_SPK);
// INIT_TYPE(ID_SO);
- // INIT_TYPE(ID_GR);
+ INIT_TYPE(ID_GR);
// INIT_TYPE(ID_AR);
// INIT_TYPE(ID_AC);
INIT_TYPE(ID_NT);
diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c
index 954f1d51b6f..a0de72deb99 100644
--- a/source/blender/blenkernel/intern/lib_id.c
+++ b/source/blender/blenkernel/intern/lib_id.c
@@ -540,9 +540,7 @@ bool BKE_lib_id_make_local(Main *bmain, ID *id, const bool test, const int flags
}
return true;
case ID_GR:
- if (!test) {
- BKE_collection_make_local(bmain, (Collection *)id, flags);
- }
+ BLI_assert(0);
return true;
case ID_AR:
if (!test) {
@@ -762,7 +760,7 @@ bool BKE_id_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int flag)
BKE_text_copy_data(bmain, (Text *)*r_newid, (Text *)id, flag);
break;
case ID_GR:
- BKE_collection_copy_data(bmain, (Collection *)*r_newid, (Collection *)id, flag);
+ BLI_assert(0);
break;
case ID_AR:
BKE_armature_copy_data(bmain, (bArmature *)*r_newid, (bArmature *)id, flag);
diff --git a/source/blender/blenkernel/intern/lib_id_delete.c b/source/blender/blenkernel/intern/lib_id_delete.c
index a790207cebb..7a0cc749cbd 100644
--- a/source/blender/blenkernel/intern/lib_id_delete.c
+++ b/source/blender/blenkernel/intern/lib_id_delete.c
@@ -200,7 +200,7 @@ void BKE_libblock_free_datablock(ID *id, const int UNUSED(flag))
BKE_sound_free((bSound *)id);
break;
case ID_GR:
- BKE_collection_free((Collection *)id);
+ BLI_assert(0);
break;
case ID_AR:
BKE_armature_free((bArmature *)id);