[Bf-blender-cvs] [0812949bbc3] master: Local Collections: Allow users to show hidden collections

Dalai Felinto noreply at git.blender.org
Wed Oct 9 00:16:54 CEST 2019


Commit: 0812949bbc3d7acfd1f20a47087ff973110aa177
Author: Dalai Felinto
Date:   Thu Oct 3 19:22:36 2019 -0300
Branches: master
https://developer.blender.org/rB0812949bbc3d7acfd1f20a47087ff973110aa177

Local Collections: Allow users to show hidden collections

Users now can turn on in a viewport collections that are temporarily
hidden (eye) in the view layer.

Design task: T61327

As for the implementation, I had to decouple the visibility in the
depsgraph from the visibility in the view layer.

Also there is a "bug" that in a way was there before which is some
operators (e.g., writing a text inside of a text object, tab into edit
mode) run regardless of the visibility of the active object. The bug was
present already (with object type visibility restriction) in 2.80 so if
we decide to tackle it, can be done separately (I have a patch for it
though P1132).

Reviewed by: brecht (thank you)

Differential Revision: D5992

===================================================================

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/alembic/intern/abc_exporter.cc
M	source/blender/blenkernel/BKE_layer.h
M	source/blender/blenkernel/intern/layer.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenkernel/intern/object_update.c
M	source/blender/depsgraph/intern/depsgraph_query_iter.cc
M	source/blender/draw/intern/draw_manager.c
M	source/blender/editors/animation/anim_filter.c
M	source/blender/editors/object/object_add.c
M	source/blender/editors/object/object_bake_api.c
M	source/blender/editors/object/object_edit.c
M	source/blender/editors/object/object_select.c
M	source/blender/editors/render/render_internal.c
M	source/blender/editors/render/render_preview.c
M	source/blender/editors/space_outliner/outliner_collections.c
M	source/blender/editors/space_outliner/outliner_select.c
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_draw_legacy.c
M	source/blender/editors/space_view3d/view3d_gizmo_armature.c
M	source/blender/editors/space_view3d/view3d_gizmo_camera.c
M	source/blender/editors/space_view3d/view3d_gizmo_empty.c
M	source/blender/editors/space_view3d/view3d_gizmo_forcefield.c
M	source/blender/editors/space_view3d/view3d_gizmo_light.c
M	source/blender/editors/space_view3d/view3d_view.c
M	source/blender/editors/transform/transform_orientations.c
M	source/blender/editors/transform/transform_snap_object.c
M	source/blender/makesdna/DNA_layer_types.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_layer.c

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index ffb0096d2f3..7d13c9c4112 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5078,9 +5078,6 @@ class VIEW3D_PT_collections(Panel):
             if not use_local_collections:
                 subrow.active = collection.is_visible  # Parent collection runtime visibility
                 subrow.prop(child, "hide_viewport", text="", emboss=False)
-            elif not child.is_visible:
-                subrow.active = False
-                subrow.label(text="", icon='REMOVE')
             else:
                 subrow.active = collection.visible_get() # Parent collection runtime visibility
                 icon = 'HIDE_OFF' if child.visible_get() else 'HIDE_ON'
diff --git a/source/blender/alembic/intern/abc_exporter.cc b/source/blender/alembic/intern/abc_exporter.cc
index 69a376d00b0..a69178281ff 100644
--- a/source/blender/alembic/intern/abc_exporter.cc
+++ b/source/blender/alembic/intern/abc_exporter.cc
@@ -53,6 +53,7 @@ extern "C" {
 #include "BKE_anim.h"
 #include "BKE_global.h"
 #include "BKE_idprop.h"
+#include "BKE_layer.h"
 #include "BKE_main.h"
 #include "BKE_mball.h"
 #include "BKE_modifier.h"
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h
index 535980840c1..d2c869532c8 100644
--- a/source/blender/blenkernel/BKE_layer.h
+++ b/source/blender/blenkernel/BKE_layer.h
@@ -114,11 +114,12 @@ void BKE_base_set_visible(struct Scene *scene,
                           struct ViewLayer *view_layer,
                           struct Base *base,
                           bool extend);
-void BKE_layer_collection_isolate(struct Scene *scene,
-                                  struct ViewLayer *view_layer,
-                                  struct LayerCollection *lc,
-                                  bool extend);
-void BKE_layer_collection_local_isolate(struct ViewLayer *view_layer,
+bool BKE_base_is_visible(const struct View3D *v3d, const struct Base *base);
+void BKE_layer_collection_isolate_global(struct Scene *scene,
+                                         struct ViewLayer *view_layer,
+                                         struct LayerCollection *lc,
+                                         bool extend);
+void BKE_layer_collection_isolate_local(struct ViewLayer *view_layer,
                                         struct View3D *v3d,
                                         struct LayerCollection *lc,
                                         bool extend);
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index 9b18052ef1e..726ca9d705b 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -44,6 +44,7 @@
 #include "DNA_object_types.h"
 #include "DNA_node_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_view3d_types.h"
 #include "DNA_windowmanager_types.h"
 #include "DNA_workspace_types.h"
 
@@ -56,9 +57,10 @@
 #include "MEM_guardedalloc.h"
 
 /* Set of flags which are dependent on a collection settings. */
-static const short g_base_collection_flags = (BASE_VISIBLE | BASE_SELECTABLE |
-                                              BASE_ENABLED_VIEWPORT | BASE_ENABLED_RENDER |
-                                              BASE_HOLDOUT | BASE_INDIRECT_ONLY);
+static const short g_base_collection_flags = (BASE_VISIBLE_DEPSGRAPH | BASE_VISIBLE_VIEWLAYER |
+                                              BASE_SELECTABLE | BASE_ENABLED_VIEWPORT |
+                                              BASE_ENABLED_RENDER | BASE_HOLDOUT |
+                                              BASE_INDIRECT_ONLY);
 
 /* prototype */
 static void object_bases_iterator_next(BLI_Iterator *iter, const int flag);
@@ -735,9 +737,15 @@ static short layer_collection_sync(ViewLayer *view_layer,
       lc->runtime_flag = child_runtime_flag;
     }
 
-    if (((child_restrict & COLLECTION_RESTRICT_VIEWPORT) == 0) &&
+    /* We separate restrict viewport and visible view layer because a layer collection can be
+     * hidden in the view layer yet (locally) visible in a viewport (if it is not restricted).*/
+    if (child_restrict & COLLECTION_RESTRICT_VIEWPORT) {
+      lc->runtime_flag |= LAYER_COLLECTION_RESTRICT_VIEWPORT;
+    }
+
+    if (((lc->runtime_flag & LAYER_COLLECTION_RESTRICT_VIEWPORT) == 0) &&
         ((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0)) {
-      lc->runtime_flag |= LAYER_COLLECTION_VISIBLE;
+      lc->runtime_flag |= LAYER_COLLECTION_VISIBLE_VIEW_LAYER;
     }
 
     /* Sync objects, except if collection was excluded. */
@@ -771,12 +779,12 @@ static short layer_collection_sync(ViewLayer *view_layer,
       }
 
       if ((child_restrict & COLLECTION_RESTRICT_VIEWPORT) == 0) {
-        base->flag_from_collection |= BASE_ENABLED_VIEWPORT;
+        base->flag_from_collection |= (BASE_ENABLED_VIEWPORT | BASE_VISIBLE_DEPSGRAPH);
         if ((child_layer_restrict & LAYER_COLLECTION_HIDE) == 0) {
-          base->flag_from_collection |= BASE_VISIBLE;
-          if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0)) {
-            base->flag_from_collection |= BASE_SELECTABLE;
-          }
+          base->flag_from_collection |= BASE_VISIBLE_VIEWLAYER;
+        }
+        if (((child_restrict & COLLECTION_RESTRICT_SELECT) == 0)) {
+          base->flag_from_collection |= BASE_SELECTABLE;
         }
       }
 
@@ -974,7 +982,7 @@ bool BKE_layer_collection_has_selected_objects(ViewLayer *view_layer, LayerColle
     for (CollectionObject *cob = lc->collection->gobject.first; cob; cob = cob->next) {
       Base *base = BKE_view_layer_base_find(view_layer, cob->ob);
 
-      if (base && (base->flag & BASE_SELECTED) && (base->flag & BASE_VISIBLE)) {
+      if (base && (base->flag & BASE_SELECTED) && (base->flag & BASE_VISIBLE_DEPSGRAPH)) {
         return true;
       }
     }
@@ -1026,6 +1034,31 @@ void BKE_base_set_visible(Scene *scene, ViewLayer *view_layer, Base *base, bool
   BKE_layer_collection_sync(scene, view_layer);
 }
 
+bool BKE_base_is_visible(const View3D *v3d, const Base *base)
+{
+  if ((base->flag & BASE_VISIBLE_DEPSGRAPH) == 0) {
+    return false;
+  }
+
+  if (v3d == NULL) {
+    return base->flag & BASE_VISIBLE_VIEWLAYER;
+  }
+
+  if ((v3d->localvd) && ((v3d->local_view_uuid & base->local_view_bits) == 0)) {
+    return false;
+  }
+
+  if (((1 << (base->object->type)) & v3d->object_type_exclude_viewport) != 0) {
+    return false;
+  }
+
+  if (v3d->flag & V3D_LOCAL_COLLECTIONS) {
+    return (v3d->local_collections_uuid & base->local_collections_bits) != 0;
+  }
+
+  return base->flag & BASE_VISIBLE_VIEWLAYER;
+}
+
 static void layer_collection_flag_set_recursive(LayerCollection *lc, const int flag)
 {
   lc->flag |= flag;
@@ -1050,13 +1083,13 @@ static void layer_collection_flag_unset_recursive(LayerCollection *lc, const int
  * If the collection or any of its parents is disabled, make it enabled.
  * Don't change the children disable state though.
  */
-void BKE_layer_collection_isolate(Scene *scene,
-                                  ViewLayer *view_layer,
-                                  LayerCollection *lc,
-                                  bool extend)
+void BKE_layer_collection_isolate_global(Scene *scene,
+                                         ViewLayer *view_layer,
+                                         LayerCollection *lc,
+                                         bool extend)
 {
   LayerCollection *lc_master = view_layer->layer_collections.first;
-  bool hide_it = extend && (lc->runtime_flag & LAYER_COLLECTION_VISIBLE);
+  bool hide_it = extend && (lc->runtime_flag & LAYER_COLLECTION_VISIBLE_VIEW_LAYER);
 
   if (!extend) {
     /* Hide all collections . */
@@ -1163,9 +1196,9 @@ void BKE_layer_collection_local_sync(ViewLayer *view_layer, View3D *v3d)
 /**
  * Isolate the collection locally
  *
- * Same as BKE_layer_collection_local_isolate but for a viewport
+ * Same as BKE_layer_collection_isolate_local but for a viewport
  */
-void BKE_layer_collection_local_isolate(ViewLayer *view_layer,
+void BKE_layer_collection_isolate_local(ViewLayer *view_layer,
                                         View3D *v3d,
                                         LayerCollection *lc,
                                         bool extend)
@@ -1436,12 +1469,12 @@ static void objects_iterator_end(BLI_Iterator *iter)
 
 void BKE_view_layer_selected_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
 {
-  objects_iterator_begin(iter, data_in, BASE_VISIBLE | BASE_SELECTED);
+  objects_iterator_begin(iter, data_in, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
 }
 
 void BKE_view_layer_selected_objects_iterator_next(BLI_Iterator *iter)
 {
-  objects_iterator_next(iter, BASE_VISIBLE | BASE_SELECTED);
+  objects_iterator_next(iter, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
 }
 
 void BKE_view_layer_selected_objects_iterator_end(BLI_Iterator *iter)
@@ -1478,7 +1511,7 @@ void BKE_view_layer_visible_objects_iterator_end(BLI_Iterator *iter)
 
 void BKE_view_layer_selected_editable_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
 {
-  objects_iterator_begin(iter, data_in, BASE_VISIBLE | BASE_SELECTED);
+  objects_iterator_begin(iter, data_in, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
   if (iter->valid) {
     if (BKE_object_is_libdata((Object *)iter->current) == false) {
       // First object is valid (selectable and not libdata) -> all good.
@@ -1495,7 +1528,7 @@ void BKE_view_layer_selected_editable_objects_iterator_next(BLI_Iterator *iter)
 {
   // Search while there are objects and the one we have is not editable (editable = not libdata).
   do {
-    objects_iterator_next(iter, BASE_VISIBLE | BASE_SELECTED);
+    objects_iterator_next(iter, BASE_VISIBLE_DEPSGRAPH | BASE_SELECTED);
   } while (iter->valid && BKE_object_is_libdata((Object *)iter->current) != false);
 }
 
@@ -1512,12 +1545,12 @@ void BKE_view_layer_selected_editable_objects_iterator_end(BLI_Iterator *iter)
 
 void BKE_view_layer_selected_bases_iterator_begin(BLI_Iterator *iter, void *data_in)
 {
-  objects_iterator_begin(iter, data_in, BASE_VISIB

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list