[Bf-blender-cvs] [c08dac000ff] blender2.8: Collection: Name collection based on parent's name
Dalai Felinto
noreply at git.blender.org
Fri Dec 22 14:41:19 CET 2017
Commit: c08dac000ff3ca3597c82740c724f63f024ab542
Author: Dalai Felinto
Date: Fri Dec 22 11:11:04 2017 -0200
Branches: blender2.8
https://developer.blender.org/rBc08dac000ff3ca3597c82740c724f63f024ab542
Collection: Name collection based on parent's name
So they are:
House
-> House 1
-> House 2
-> ...
The exception is when the parent collection is the master collection. In this case we get:
Master Collection
-> Collection 1
-> Collection 2
-> ...
This is part of "T53495: View layer and collection editing - Design Task"
===================================================================
M source/blender/blenkernel/intern/collection.c
M source/blender/blenkernel/intern/group.c
M source/blender/blenloader/intern/versioning_280.c
===================================================================
diff --git a/source/blender/blenkernel/intern/collection.c b/source/blender/blenkernel/intern/collection.c
index 8d69563f5ff..f8934184928 100644
--- a/source/blender/blenkernel/intern/collection.c
+++ b/source/blender/blenkernel/intern/collection.c
@@ -69,24 +69,35 @@ static SceneCollection *collection_master_from_id(const ID *owner_id)
* 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
*/
-SceneCollection *BKE_collection_add(ID *owner_id, SceneCollection *sc_parent, const int type, const char *name)
+SceneCollection *BKE_collection_add(ID *owner_id, SceneCollection *sc_parent, const int type, const char *name_custom)
{
SceneCollection *sc_master = collection_master_from_id(owner_id);
SceneCollection *sc = MEM_callocN(sizeof(SceneCollection), "New Collection");
sc->type = type;
-
- if (!name) {
- name = DATA_("New Collection");
- }
+ const char *name = name_custom;
if (!sc_parent) {
sc_parent = sc_master;
}
+ if (!name) {
+ if (sc_parent == sc_master) {
+ name = BLI_sprintfN("Collection %d", BLI_listbase_count(&sc_master->scene_collections) + 1);
+ }
+ else {
+ name = BLI_sprintfN("%s %d", sc_parent->name, BLI_listbase_count(&sc_parent->scene_collections) + 1);
+ }
+ }
+
BKE_collection_rename((Scene *)owner_id, sc, name);
BLI_addtail(&sc_parent->scene_collections, sc);
BKE_layer_sync_new_scene_collection(owner_id, sc_parent, sc);
+
+ if (name != name_custom) {
+ MEM_freeN((char *)name);
+ }
+
return sc;
}
diff --git a/source/blender/blenkernel/intern/group.c b/source/blender/blenkernel/intern/group.c
index 5b55433c1b9..8295fafba56 100644
--- a/source/blender/blenkernel/intern/group.c
+++ b/source/blender/blenkernel/intern/group.c
@@ -88,10 +88,7 @@ void BKE_group_init(Group *group)
BKE_collection_unlink(group->view_layer, group->view_layer->layer_collections.first);
/* Create and link a new default collection. */
- SceneCollection *defaut_collection = BKE_collection_add(&group->id,
- NULL,
- COLLECTION_TYPE_GROUP_INTERNAL,
- "Default Collection");
+ SceneCollection *defaut_collection = BKE_collection_add(&group->id, NULL, COLLECTION_TYPE_GROUP_INTERNAL, NULL);
BKE_collection_link(group->view_layer, defaut_collection);
}
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index ba5beb7993d..b864c75c90f 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -482,11 +482,6 @@ void do_versions_after_linking_280(Main *main)
base->lay = base->object->lay;
}
- /* Fallback name if only one layer was found in the original file */
- if (BLI_listbase_is_single(&sc_master->scene_collections)) {
- BKE_collection_rename(scene, sc_master->scene_collections.first, "Default Collection");
- }
-
/* remove bases once and for all */
for (Base *base = scene->base.first; base; base = base->next) {
id_us_min(&base->object->id);
More information about the Bf-blender-cvs
mailing list