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:
authorSergey Sharybin <sergey.vfx@gmail.com>2017-06-14 17:56:21 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2017-06-14 17:59:52 +0300
commitdbca1afefa700f25198761624cdb9f1fd21095d2 (patch)
treea8f0ae0c23c7d62f426aa5096962d0020b6cac6f /source/blender/blenkernel/intern/collection.c
parentc59abb4c9a371e709c4904ce87d74c5c6c8a0792 (diff)
Add an option to free scene without doing id-counters
This is similar to some other datablocks. Mainly applies to collections, so freeing scene does not involve changing any non-directly owned data. There are two main usecases foreseen for the future: - Less CPU ticks on bmain free, where everything is freed anyway and there is no need to preserve id counters. - Easier freeing of temporary data, including data which is used by depsgraph's copy-on-write mechanism. Neither of those are currently implemented, but will be shortly.
Diffstat (limited to 'source/blender/blenkernel/intern/collection.c')
-rw-r--r--source/blender/blenkernel/intern/collection.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 507ae1a4e70..3bf3a5ce5a4 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -75,20 +75,22 @@ SceneCollection *BKE_collection_add(Scene *scene, SceneCollection *sc_parent, co
/**
* Free the collection items recursively
*/
-static void collection_free(SceneCollection *sc)
+static void collection_free(SceneCollection *sc, const bool do_id_user)
{
- for (LinkData *link = sc->objects.first; link; link = link->next) {
- id_us_min(link->data);
+ if (do_id_user) {
+ for (LinkData *link = sc->objects.first; link; link = link->next) {
+ id_us_min(link->data);
+ }
+ for (LinkData *link = sc->filter_objects.first; link; link = link->next) {
+ id_us_min(link->data);
+ }
}
- BLI_freelistN(&sc->objects);
- for (LinkData *link = sc->filter_objects.first; link; link = link->next) {
- id_us_min(link->data);
- }
+ BLI_freelistN(&sc->objects);
BLI_freelistN(&sc->filter_objects);
for (SceneCollection *nsc = sc->scene_collections.first; nsc; nsc = nsc->next) {
- collection_free(nsc);
+ collection_free(nsc, do_id_user);
}
BLI_freelistN(&sc->scene_collections);
}
@@ -160,7 +162,7 @@ bool BKE_collection_remove(Scene *scene, SceneCollection *sc)
}
/* clear the collection items */
- collection_free(sc);
+ collection_free(sc, true);
/* check all layers that use this collection and clear them */
for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) {
@@ -218,9 +220,9 @@ void BKE_collection_rename(const Scene *scene, SceneCollection *sc, const char *
* Free (or release) any data used by the master collection (does not free the master collection itself).
* Used only to clear the entire scene data since it's not doing re-syncing of the LayerCollection tree
*/
-void BKE_collection_master_free(Scene *scene)
+void BKE_collection_master_free(Scene *scene, const bool do_id_user)
{
- collection_free(BKE_collection_master(scene));
+ collection_free(BKE_collection_master(scene), do_id_user);
}
static void collection_object_add(const Scene *scene, SceneCollection *sc, Object *ob)