Outliner visibility: Respect original viewport enable/disable state
authorDalai Felinto <dfelinto@gmail.com>
Wed, 6 Feb 2019 16:52:40 +0000 (16:52 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Wed, 6 Feb 2019 17:06:16 +0000 (17:06 +0000)
Note: We still change it to the collection we are directly isolating/making
visible and its parents (in the case of isolating). But no longer its children.

Feedback and discussion on D4011. The motivation is that if we don't keep those
locked the disable state becomes useless.

source/blender/blenkernel/intern/layer.c

index 6d4c2072ce2ed477835defc95a08b3cfc9988be7..441f74e5d5fc92b91671665de1045ce9a8cbe4cc 100644 (file)
@@ -1009,6 +1009,9 @@ static bool layer_collection_collection_flag_unset_recursive(LayerCollection *lc
  * Make sure to show all the direct parents and all children of the layer collection as well.
  * When extending we simply show the collections and its direct family.
  *
+ * If the collection or any of its parents is disabled, make it enabled.
+ * Don't change the children disable state though.
+ *
  * Return whether depsgraph needs update.
  */
 bool BKE_layer_collection_isolate(Scene *scene, ViewLayer *view_layer, LayerCollection *lc, bool extend)
@@ -1016,6 +1019,11 @@ bool BKE_layer_collection_isolate(Scene *scene, ViewLayer *view_layer, LayerColl
        bool depsgraph_need_update = false;
        LayerCollection *lc_master = view_layer->layer_collections.first;
 
+       if (lc->collection->flag & COLLECTION_RESTRICT_VIEW) {
+               lc->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
+               depsgraph_need_update = true;
+       }
+
        if (!extend) {
                /* Hide all collections . */
                for (LayerCollection *lc_iter = lc_master->layer_collections.first; lc_iter; lc_iter = lc_iter->next) {
@@ -1033,8 +1041,11 @@ bool BKE_layer_collection_isolate(Scene *scene, ViewLayer *view_layer, LayerColl
        }
 
        while (lc_parent != lc) {
-               depsgraph_need_update |= (lc_parent->collection->flag & COLLECTION_RESTRICT_VIEW) != 0;
-               lc_parent->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
+               if (lc_parent->collection->flag & COLLECTION_RESTRICT_VIEW) {
+                       lc_parent->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
+                       depsgraph_need_update = true;
+               }
+
                lc_parent->flag &= ~LAYER_COLLECTION_RESTRICT_VIEW;
 
                for (LayerCollection *lc_iter = lc_parent->layer_collections.first; lc_iter; lc_iter = lc_iter->next) {
@@ -1045,9 +1056,8 @@ bool BKE_layer_collection_isolate(Scene *scene, ViewLayer *view_layer, LayerColl
                }
        }
 
-       /* Make all the children visible. */
+       /* Make all the children visible, but respect their disable state. */
        layer_collection_flag_unset_recursive(lc, LAYER_COLLECTION_RESTRICT_VIEW);
-       depsgraph_need_update |= layer_collection_collection_flag_unset_recursive(lc, COLLECTION_RESTRICT_VIEW);
 
        BKE_layer_collection_activate(view_layer, lc);
 
@@ -1081,16 +1091,21 @@ static void layer_collection_bases_hide_recursive(ViewLayer *view_layer, LayerCo
 
 /**
  * Hide/show all the elements of a collection.
- * Enable a disable collection if needs be.
+ * Don't change the collection children enable/disable state, but it may change it for the collection itself.
  *
  * Return true if depsgraph needs update.
  */
 bool BKE_layer_collection_set_visible(ViewLayer *view_layer, LayerCollection *lc, const bool visible, const bool hierarchy)
 {
        bool depsgraph_changed = false;
+
+       if (visible && ((lc->collection->flag & COLLECTION_RESTRICT_VIEW) != 0)) {
+               lc->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
+               depsgraph_changed = true;
+       }
+
        if (hierarchy) {
                if (visible) {
-                       depsgraph_changed |= layer_collection_collection_flag_unset_recursive(lc, COLLECTION_RESTRICT_VIEW);
                        layer_collection_flag_unset_recursive(lc, LAYER_COLLECTION_RESTRICT_VIEW);
                        layer_collection_bases_show_recursive(view_layer, lc);
                }
@@ -1101,9 +1116,7 @@ bool BKE_layer_collection_set_visible(ViewLayer *view_layer, LayerCollection *lc
        }
        else {
                if (visible) {
-                       depsgraph_changed |= (lc->collection->flag & COLLECTION_RESTRICT_VIEW) != 0;
                        lc->flag &= ~LAYER_COLLECTION_RESTRICT_VIEW;
-                       lc->collection->flag &= ~COLLECTION_RESTRICT_VIEW;
                }
                else {
                        lc->flag |= LAYER_COLLECTION_RESTRICT_VIEW;