From f3433fcd3bf87c9405fb05c96fde036eb658e8aa Mon Sep 17 00:00:00 2001 From: Szymon Ulatowski Date: Thu, 9 Apr 2020 19:33:57 +0200 Subject: Collections: preserve exclude flag of child collections when unexcluding Excluding a collection also changes the exclude setting on all child collections so that it is possible to selectively enable some children without the parent being enabled. This change makes it so that if you unexclude the parent, the exclude setting of children are restored again instead of being permanently lost. Original patch by Szymon with modifications by Brecht. Differential Revision: https://developer.blender.org/D7016 --- .../editors/space_outliner/outliner_collections.c | 27 ++-------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'source/blender/editors/space_outliner') diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c index 5a0ed954909..4b6241d45ee 100644 --- a/source/blender/editors/space_outliner/outliner_collections.c +++ b/source/blender/editors/space_outliner/outliner_collections.c @@ -845,20 +845,6 @@ static bool collections_indirect_only_clear_poll(bContext *C) return collections_view_layer_poll(C, true, LAYER_COLLECTION_INDIRECT_ONLY); } -static void layer_collection_flag_recursive_set(LayerCollection *lc, int flag) -{ - LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) { - if (lc->flag & flag) { - nlc->flag |= flag; - } - else { - nlc->flag &= ~flag; - } - - layer_collection_flag_recursive_set(nlc, flag); - } -} - static int collection_view_layer_exec(bContext *C, wmOperator *op) { Main *bmain = CTX_data_main(C); @@ -883,15 +869,7 @@ static int collection_view_layer_exec(bContext *C, wmOperator *op) GSetIterator collections_to_edit_iter; GSET_ITER (collections_to_edit_iter, data.collections_to_edit) { LayerCollection *lc = BLI_gsetIterator_getKey(&collections_to_edit_iter); - - if (clear) { - lc->flag &= ~flag; - } - else { - lc->flag |= flag; - } - - layer_collection_flag_recursive_set(lc, flag); + BKE_layer_collection_set_flag(lc, flag, !clear); } BLI_gset_free(data.collections_to_edit, NULL); @@ -1468,8 +1446,7 @@ static int outliner_unhide_all_exec(bContext *C, wmOperator *UNUSED(op)) /* Unhide all the collections. */ LayerCollection *lc_master = view_layer->layer_collections.first; LISTBASE_FOREACH (LayerCollection *, lc_iter, &lc_master->layer_collections) { - lc_iter->flag &= ~LAYER_COLLECTION_HIDE; - layer_collection_flag_recursive_set(lc_iter, LAYER_COLLECTION_HIDE); + BKE_layer_collection_set_flag(lc_iter, LAYER_COLLECTION_HIDE, false); } /* Unhide all objects. */ -- cgit v1.2.3