diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2017-12-01 16:24:21 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2017-12-01 19:15:54 +0300 |
commit | be9e469ead227aee8d4c29b98a125cf599c5c8bb (patch) | |
tree | 381ee3e58a94495a923c575bb8185899d84ab4bc /source/blender/blenloader/intern/versioning_280.c | |
parent | e8c15e0ed15f8369d0d0f706b4953fb64e357902 (diff) |
Groups and collection: initial integration
Since we are ditching layers from Blender (2.8) we need a replacement to
control groups visibility. This commit introduces collections as the building
blocks for groups, allowing users to control visibility as well as overrides
for groups.
Features
========
* Groups now have collections
This way you can change the visibility of a collection inside a group, and add
overrides which are part of the group and are prioritized over other overrides.
* Outliner
Groups can inspect their collections, change visibility, and add/remove members.
To change an override of a group collection, you need to select an instance of
the group, and then you can choose "group" in the collection properties editor
to edit this group active collection instead of the view layer one.
* Dupli groups overrides
We can now have multiple instances of the same group with an original "override"
and different overrides depending on the collection the instanced object is part
of.
Technical
=========
* Layers
We use the same api for groups and scene as much as possible.
Reviewers: sergey (depsgraph), mont29 (read/write and user count)
Differential Revision: https://developer.blender.org/D2892
Diffstat (limited to 'source/blender/blenloader/intern/versioning_280.c')
-rw-r--r-- | source/blender/blenloader/intern/versioning_280.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 3b5e248f58b..8f2295781bf 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -39,6 +39,7 @@ #include "DNA_object_types.h" #include "DNA_camera_types.h" #include "DNA_gpu_types.h" +#include "DNA_group_types.h" #include "DNA_lamp_types.h" #include "DNA_layer_types.h" #include "DNA_material_types.h" @@ -52,6 +53,7 @@ #include "BKE_collection.h" #include "BKE_customdata.h" #include "BKE_freestyle.h" +#include "BKE_group.h" #include "BKE_idprop.h" #include "BKE_layer.h" #include "BKE_main.h" @@ -171,7 +173,7 @@ void do_versions_after_linking_280(Main *main) for (Scene *scene = main->scene.first; scene; scene = scene->id.next) { /* since we don't have access to FileData we check the (always valid) first render layer instead */ if (scene->view_layers.first == NULL) { - SceneCollection *sc_master = BKE_collection_master(scene); + SceneCollection *sc_master = BKE_collection_master(&scene->id); BLI_strncpy(sc_master->name, "Master Collection", sizeof(sc_master->name)); struct DoVersionSceneCollections { @@ -242,7 +244,7 @@ void do_versions_after_linking_280(Main *main) layer + 1, collections[DO_VERSION_COLLECTION_VISIBLE].suffix); collections[DO_VERSION_COLLECTION_VISIBLE].collections[layer] = - BKE_collection_add(scene, sc_master, name); + BKE_collection_add(&scene->id, sc_master, COLLECTION_TYPE_NONE, name); collections[DO_VERSION_COLLECTION_VISIBLE].created |= (1 << layer); } @@ -254,12 +256,16 @@ void do_versions_after_linking_280(Main *main) "Collection %d%s", layer + 1, collections[collection_index].suffix); - collections[collection_index].collections[layer] = BKE_collection_add(scene, sc_parent, name); + collections[collection_index].collections[layer] = BKE_collection_add( + &scene->id, + sc_parent, + COLLECTION_TYPE_NONE, + name); collections[collection_index].created |= (1 << layer); } } - BKE_collection_object_add(scene, collections[collection_index].collections[layer], base->object); + BKE_collection_object_add(&scene->id, collections[collection_index].collections[layer], base->object); } if (base->flag & SELECT) { @@ -542,6 +548,43 @@ void do_versions_after_linking_280(Main *main) BLI_freelistN(&scene->r.layers); } } + + { + /* Since we don't have access to FileData we check the (always valid) master collection of the group. */ + for (Group *group = main->group.first; group; group = group->id.next) { + if (group->collection == NULL) { + BKE_group_init(group); + SceneCollection *sc = GROUP_MASTER_COLLECTION(group); + SceneCollection *sc_hidden = NULL; + + for (GroupObject *go = group->gobject.first; go; go = go->next) { + if (go->ob->lay & group->layer){ + BKE_collection_object_add(&group->id, sc, go->ob); + } + else { + if (sc_hidden == NULL) { + sc_hidden = BKE_collection_add(&group->id, sc, COLLECTION_TYPE_GROUP_INTERNAL, "Hidden"); + } + BKE_collection_object_add(&group->id, sc_hidden, go->ob); + } + } + + if (sc_hidden != NULL) { + LayerCollection *layer_collection_master, *layer_collection_hidden; + + layer_collection_master = group->view_layer->layer_collections.first; + layer_collection_hidden = layer_collection_master->layer_collections.first; + + layer_collection_hidden->flag &= ~COLLECTION_VISIBLE; + } + } + + GroupObject *go; + while ((go = BLI_pophead(&group->gobject))) { + MEM_freeN(go); + } + } + } } static void do_version_layer_collections_idproperties(ListBase *lb) |