Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzymon Ulatowski <szulat>2020-04-09 20:33:57 +0300
committerBrecht Van Lommel <brecht@blender.org>2020-04-09 22:46:22 +0300
commitf3433fcd3bf87c9405fb05c96fde036eb658e8aa (patch)
tree48dc84c573a7ca00c1c408312ce5e87b060aacb3 /source/blender/blenkernel
parent07bb7206c202fdea3645b01887e9eeba3d2e6ae3 (diff)
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
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_layer.h1
-rw-r--r--source/blender/blenkernel/intern/layer.c43
2 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 7059675ec7d..7a0252e6813 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -137,6 +137,7 @@ void BKE_layer_collection_set_visible(struct ViewLayer *view_layer,
struct LayerCollection *lc,
const bool visible,
const bool hierarchy);
+void BKE_layer_collection_set_flag(struct LayerCollection *lc, const int flag, const bool value);
/* evaluation */
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index d8f0bda8c22..f6e80d66ad1 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1359,6 +1359,49 @@ void BKE_layer_collection_set_visible(ViewLayer *view_layer,
}
}
+/**
+ * Set layer collection hide/exclude/indirect flag on a layer collection.
+ * recursively.
+ */
+static void layer_collection_flag_recursive_set(LayerCollection *lc,
+ const int flag,
+ const bool value,
+ const bool restore_flag)
+{
+ if (flag == LAYER_COLLECTION_EXCLUDE) {
+ /* For exclude flag, we remember the state the children had before
+ * excluding and restoring it when enabling the parent collection again. */
+ if (value) {
+ if (restore_flag) {
+ SET_FLAG_FROM_TEST(
+ lc->flag, (lc->flag & LAYER_COLLECTION_EXCLUDE), LAYER_COLLECTION_PREVIOUSLY_EXCLUDED);
+ }
+ else {
+ lc->flag &= ~LAYER_COLLECTION_PREVIOUSLY_EXCLUDED;
+ }
+
+ lc->flag |= flag;
+ }
+ else {
+ if (!(lc->flag & LAYER_COLLECTION_PREVIOUSLY_EXCLUDED)) {
+ lc->flag &= ~flag;
+ }
+ }
+ }
+ else {
+ SET_FLAG_FROM_TEST(lc->flag, value, flag);
+ }
+
+ LISTBASE_FOREACH (LayerCollection *, nlc, &lc->layer_collections) {
+ layer_collection_flag_recursive_set(nlc, flag, value, true);
+ }
+}
+
+void BKE_layer_collection_set_flag(LayerCollection *lc, const int flag, const bool value)
+{
+ layer_collection_flag_recursive_set(lc, flag, value, false);
+}
+
/* ---------------------------------------------------------------------- */
static LayerCollection *find_layer_collection_by_scene_collection(LayerCollection *lc,