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/editors/space_outliner/outliner_tools.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/editors/space_outliner/outliner_tools.c')
-rw-r--r-- | source/blender/editors/space_outliner/outliner_tools.c | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c index 63e1a527138..203942b3c9b 100644 --- a/source/blender/editors/space_outliner/outliner_tools.c +++ b/source/blender/editors/space_outliner/outliner_tools.c @@ -525,20 +525,21 @@ static void group_linkobs2scene_cb( ViewLayer *view_layer = CTX_data_view_layer(C); SceneCollection *sc = CTX_data_scene_collection(C); Group *group = (Group *)tselem->id; - GroupObject *gob; Base *base; - for (gob = group->gobject.first; gob; gob = gob->next) { - base = BKE_view_layer_base_find(view_layer, gob->ob); + FOREACH_GROUP_OBJECT(group, object) + { + base = BKE_view_layer_base_find(view_layer, object); if (!base) { /* link to scene */ - BKE_collection_object_add(scene, sc, gob->ob); - base = BKE_view_layer_base_find(view_layer, gob->ob); - id_us_plus(&gob->ob->id); + BKE_collection_object_add(&scene->id, sc, object); + base = BKE_view_layer_base_find(view_layer, object); + id_us_plus(&object->id); } base->flag |= BASE_SELECTED; } + FOREACH_GROUP_OBJECT_END } static void group_instance_cb( @@ -820,12 +821,13 @@ static void collection_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tsel bContext *C = (bContext *)Carg; Scene *scene = CTX_data_scene(C); LayerCollection *lc = te->directdata; + ID *id = te->store_elem->id; SceneCollection *sc = lc->scene_collection; if (event == OL_COLLECTION_OP_OBJECTS_ADD) { CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { - BKE_collection_object_add(scene, sc, ob); + BKE_collection_object_add(id, sc, ob); } CTX_DATA_END; @@ -836,7 +838,7 @@ static void collection_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tsel CTX_DATA_BEGIN (C, Object *, ob, selected_objects) { - BKE_collection_object_remove(bmain, scene, sc, ob, true); + BKE_collection_object_remove(bmain, id, sc, ob, true); } CTX_DATA_END; @@ -844,7 +846,13 @@ static void collection_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tsel te->store_elem->flag &= ~TSE_SELECTED; } else if (event == OL_COLLECTION_OP_COLLECTION_NEW) { - BKE_collection_add(scene, sc, NULL); + if (GS(id->name) == ID_GR) { + BKE_collection_add(id, sc, COLLECTION_TYPE_GROUP_INTERNAL, NULL); + } + else { + BLI_assert(GS(id->name) == ID_SCE); + BKE_collection_add(id, sc, COLLECTION_TYPE_NONE, NULL); + } WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); } else if (event == OL_COLLECTION_OP_COLLECTION_UNLINK) { @@ -861,7 +869,7 @@ static void collection_cb(int event, TreeElement *te, TreeStoreElem *UNUSED(tsel } } else if (event == OL_COLLECTION_OP_COLLECTION_DEL) { - if (BKE_collection_remove(scene, sc)) { + if (BKE_collection_remove(id, sc)) { DEG_relations_tag_update(CTX_data_main(C)); WM_event_add_notifier(C, NC_SCENE | ND_LAYER, scene); } @@ -1794,15 +1802,38 @@ void OUTLINER_OT_modifier_operation(wmOperatorType *ot) /* ******************** */ -static EnumPropertyItem prop_collection_op_types[] = { - {OL_COLLECTION_OP_OBJECTS_ADD, "OBJECTS_ADD", ICON_ZOOMIN, "Add Selected", "Add selected objects to collection"}, - {OL_COLLECTION_OP_OBJECTS_REMOVE, "OBJECTS_REMOVE", ICON_X, "Remove Selected", "Remove selected objects from collection"}, - {OL_COLLECTION_OP_COLLECTION_NEW, "COLLECTION_NEW", ICON_NEW, "New Collection", "Add a new nested collection"}, - {OL_COLLECTION_OP_COLLECTION_UNLINK, "COLLECTION_UNLINK", ICON_UNLINKED, "Unlink", "Unlink collection"}, - {OL_COLLECTION_OP_COLLECTION_DEL, "COLLECTION_DEL", ICON_X, "Delete Collection", "Delete the collection"}, - {0, NULL, 0, NULL, NULL} +static EnumPropertyItem prop_collection_op_none_types[] = { + {OL_COLLECTION_OP_OBJECTS_ADD, "OBJECTS_ADD", ICON_ZOOMIN, "Add Selected", "Add selected objects to collection"}, + {OL_COLLECTION_OP_OBJECTS_REMOVE, "OBJECTS_REMOVE", ICON_X, "Remove Selected", "Remove selected objects from collection"}, + {OL_COLLECTION_OP_COLLECTION_NEW, "COLLECTION_NEW", ICON_NEW, "New Collection", "Add a new nested collection"}, + {OL_COLLECTION_OP_COLLECTION_UNLINK, "COLLECTION_UNLINK", ICON_UNLINKED, "Unlink", "Unlink collection"}, + {OL_COLLECTION_OP_COLLECTION_DEL, "COLLECTION_DEL", ICON_X, "Delete Collection", "Delete the collection"}, + {0, NULL, 0, NULL, NULL} }; +static EnumPropertyItem prop_collection_op_group_internal_types[] = { + {OL_COLLECTION_OP_OBJECTS_ADD, "OBJECTS_ADD", ICON_ZOOMIN, "Add Selected", "Add selected objects to collection"}, + {OL_COLLECTION_OP_OBJECTS_REMOVE, "OBJECTS_REMOVE", ICON_X, "Remove Selected", "Remove selected objects from collection"}, + {OL_COLLECTION_OP_COLLECTION_NEW, "COLLECTION_NEW", ICON_NEW, "New Collection", "Add a new nested collection"}, + {OL_COLLECTION_OP_COLLECTION_DEL, "COLLECTION_DEL", ICON_X, "Delete Collection", "Delete the collection"}, + {0, NULL, 0, NULL, NULL} +}; + +static const EnumPropertyItem *outliner_collection_operation_type_itemf( + bContext *C, PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +{ + *r_free = false; + SpaceOops *soops = CTX_wm_space_outliner(C); + + switch (soops->outlinevis) { + case SO_GROUPS: + return prop_collection_op_group_internal_types; + case SO_ACT_LAYER: + return prop_collection_op_none_types; + } + return NULL; +} + static int outliner_collection_operation_exec(bContext *C, wmOperator *op) { SpaceOops *soops = CTX_wm_space_outliner(C); @@ -1823,6 +1854,8 @@ static int outliner_collection_operation_exec(bContext *C, wmOperator *op) void OUTLINER_OT_collection_operation(wmOperatorType *ot) { + PropertyRNA *prop; + /* identifiers */ ot->name = "Outliner Collection Operation"; ot->idname = "OUTLINER_OT_collection_operation"; @@ -1835,7 +1868,10 @@ void OUTLINER_OT_collection_operation(wmOperatorType *ot) ot->flag = 0; - ot->prop = RNA_def_enum(ot->srna, "type", prop_collection_op_types, 0, "Collection Operation", ""); + prop = RNA_def_enum(ot->srna, "type", DummyRNA_NULL_items, 0, "Collection Operation", ""); + RNA_def_enum_funcs(prop, outliner_collection_operation_type_itemf); + RNA_def_property_flag(prop, PROP_ENUM_NO_TRANSLATE); + ot->prop = prop; } /* ******************** */ |