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.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 100cbf2dd45..24f97c00afb 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -44,6 +44,9 @@
#include "MEM_guardedalloc.h"
+bool collection_remlink(SceneCollection *, SceneCollection *);
+bool collection_insert_after(SceneCollection *, SceneCollection *, SceneCollection *);
+
/**
* Add a collection to a collection ListBase and syncronize all render layers
* The ListBase is NULL when the collection is to be added to the master collection
@@ -95,7 +98,7 @@ static void collection_free(SceneCollection *sc)
* Unlink the collection recursively
* return true if unlinked
*/
-static bool collection_remlink(SceneCollection *sc_parent, SceneCollection *sc_gone)
+bool collection_remlink(SceneCollection *sc_parent, SceneCollection *sc_gone)
{
for (SceneCollection *sc = sc_parent->scene_collections.first; sc; sc = sc->next)
{
@@ -174,9 +177,35 @@ bool BKE_collection_remove(Scene *scene, SceneCollection *sc)
}
/**
+ * Lookup the parent listbase of \a sc_insert_after and insert \a sc_insert after it.
+ * \param sc_after: If this is NULL, \a sc_insert will be inserted as first collection in \a parent.
+ */
+bool collection_insert_after(
+ SceneCollection *parent, SceneCollection *sc_insert, SceneCollection *sc_after)
+{
+ if (sc_after == NULL) {
+ BLI_addhead(&parent->scene_collections, sc_insert);
+ return true;
+ }
+
+ for (SceneCollection *sc = parent->scene_collections.first; sc; sc = sc->next) {
+ if (sc == sc_after) {
+ BLI_insertlinkafter(&parent->scene_collections, sc_after, sc_insert);
+ return true;
+ }
+
+ if (collection_insert_after(sc, sc_insert, sc_after)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+/**
* Returns the master collection
*/
-SceneCollection *BKE_collection_master(Scene *scene)
+SceneCollection *BKE_collection_master(const Scene *scene)
{
return scene->collection;
}