[Bf-blender-cvs] [dce8ef49ff] render-layers: Layers: allow anonymous collection, and set active collection when linking it

Dalai Felinto noreply at git.blender.org
Mon Jan 30 18:26:27 CET 2017


Commit: dce8ef49ffb7c2e38455da8195b9cacba8b0424a
Author: Dalai Felinto
Date:   Mon Jan 30 14:14:52 2017 +0100
Branches: render-layers
https://developer.blender.org/rBdce8ef49ffb7c2e38455da8195b9cacba8b0424a

Layers: allow anonymous collection, and set active collection when linking it

===================================================================

M	source/blender/blenkernel/intern/collection.c
M	source/blender/blenkernel/intern/layer.c

===================================================================

diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index c7ff70e404..f374ebd1e5 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 bb013b4aa4..39b0053122 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;
 }




More information about the Bf-blender-cvs mailing list