diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-01-30 16:14:52 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-01-30 16:15:07 +0300 |
commit | dce8ef49ffb7c2e38455da8195b9cacba8b0424a (patch) | |
tree | e7d48946cef09d1cb94643d28f8b535419ea1518 | |
parent | c1742b88a4cf58e474b3dfe9d01921105b8c8b6e (diff) |
Layers: allow anonymous collection, and set active collection when linking it
-rw-r--r-- | source/blender/blenkernel/intern/collection.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/layer.c | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c index c7ff70e4047..f374ebd1e53 100644 --- a/source/blender/blenkernel/intern/collection.c +++ b/source/blender/blenkernel/intern/collection.c @@ -50,8 +50,16 @@ */ SceneCollection *BKE_collection_add(Scene *scene, SceneCollection *sc_parent, const char *name) { - SceneCollection *sc = MEM_callocN(sizeof(SceneCollection), "New Collection"); SceneCollection *sc_master = BKE_collection_master(scene); + SceneCollection *sc = MEM_callocN(sizeof(SceneCollection), "New Collection"); + + if (!name) { + name = DATA_("New Collection"); + } + + if (!sc_parent) { + sc_parent = sc_master; + } BLI_strncpy(sc->name, name, sizeof(sc->name)); BLI_uniquename(&sc_master->scene_collections, sc, DATA_("Collection"), '.', offsetof(SceneCollection, name), sizeof(sc->name)); diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index bb013b4aa46..39b00531222 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -30,6 +30,7 @@ #include "BLI_string_utils.h" #include "BLT_translation.h" +#include "BKE_layer.h" #include "BKE_collection.h" #include "BKE_layer.h" #include "BKE_main.h" @@ -395,6 +396,7 @@ int BKE_layer_collection_findindex(SceneLayer *sl, LayerCollection *lc) LayerCollection *BKE_collection_link(SceneLayer *sl, SceneCollection *sc) { LayerCollection *lc = layer_collection_add(sl, &sl->layer_collections, sc); + sl->active_collection = BKE_layer_collection_findindex(sl, lc); return lc; } |