[Bf-blender-cvs] [bb2648ebf00] master: Outliner: View Layers filter for View Layer Mode

Dalai Felinto noreply at git.blender.org
Mon Jun 28 09:46:59 CEST 2021


Commit: bb2648ebf0022186bdd27e451194388d1fd4cce0
Author: Dalai Felinto
Date:   Fri Jun 25 17:12:10 2021 +0200
Branches: master
https://developer.blender.org/rBbb2648ebf0022186bdd27e451194388d1fd4cce0

Outliner: View Layers filter for View Layer Mode

This option allow users to see the view layer in context to the
others. It is particularly useful to see which view layers have which
collections enabled, and their render settings (holdout, ...).

This option is off by default.

Differential Revision: https://developer.blender.org/D11708

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

M	release/scripts/startup/bl_ui/space_outliner.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/space_outliner.c
M	source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index 6eafa570f4c..7a694108e14 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -369,6 +369,10 @@ class OUTLINER_PT_filter(Panel):
 
         col = layout.column(align=True)
 
+        row = col.row()
+        row.label(icon='RENDERLAYERS')
+        row.prop(space, "use_filter_view_layers", text="All View Layers")
+
         row = col.row()
         row.label(icon='OUTLINER_COLLECTION')
         row.prop(space, "use_filter_collection", text="Collections")
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index bac982708bc..110b9fc4252 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -39,7 +39,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 5
+#define BLENDER_FILE_SUBVERSION 6
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 85b063ae54c..84021755cef 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -415,6 +415,21 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
       }
     }
   }
+
+  if (!MAIN_VERSION_ATLEAST(bmain, 300, 6)) {
+    LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+      LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+        LISTBASE_FOREACH (SpaceLink *, space, &area->spacedata) {
+          /* Disable View Layers filter. */
+          if (space->spacetype == SPACE_OUTLINER) {
+            SpaceOutliner *space_outliner = (SpaceOutliner *)space;
+            space_outliner->filter |= SO_FILTER_NO_VIEW_LAYERS;
+          }
+        }
+      }
+    }
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index cb61e548d53..4fe29d4e9bd 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1090,7 +1090,8 @@ static void outliner_draw_restrictbuts(uiBlock *block,
     RestrictPropertiesActive props_active = props_active_parent;
 
     if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
-      if (tselem->type == TSE_R_LAYER && (space_outliner->outlinevis == SO_SCENES)) {
+      if (tselem->type == TSE_R_LAYER &&
+          ELEM(space_outliner->outlinevis, SO_SCENES, SO_VIEW_LAYER)) {
         if (space_outliner->show_restrict_flags & SO_RESTRICT_RENDER) {
           /* View layer render toggle. */
           ViewLayer *layer = te->directdata;
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 728be1ccaaf..a2032fa1dc0 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -331,6 +331,7 @@ static SpaceLink *outliner_create(const ScrArea *UNUSED(area), const Scene *UNUS
   space_outliner->outlinevis = SO_VIEW_LAYER;
   space_outliner->sync_select_dirty |= WM_OUTLINER_SYNC_SELECT_FROM_ALL;
   space_outliner->flag = SO_SYNC_SELECT | SO_MODE_COLUMN;
+  space_outliner->filter = SO_FILTER_NO_VIEW_LAYERS;
 
   /* header */
   region = MEM_callocN(sizeof(ARegion), "header for outliner");
diff --git a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
index f00cf3c34c0..f6cf951498c 100644
--- a/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
+++ b/source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
@@ -71,33 +71,56 @@ ListBase TreeDisplayViewLayer::buildTree(const TreeSourceData &source_data)
 {
   ListBase tree = {nullptr};
 
-  view_layer_ = source_data.view_layer;
+  Scene *scene = source_data.scene;
   show_objects_ = !(space_outliner_.filter & SO_FILTER_NO_OBJECT);
 
   const bool show_children = (space_outliner_.filter & SO_FILTER_NO_CHILDREN) == 0;
 
-  if (space_outliner_.filter & SO_FILTER_NO_COLLECTION) {
-    /* Show objects in the view layer. */
-    for (Base *base : List<Base>(view_layer_->object_bases)) {
-      TreeElement *te_object = outliner_add_element(
-          &space_outliner_, &tree, base->object, nullptr, TSE_SOME_ID, 0);
-      te_object->directdata = base;
+  for (auto *view_layer : ListBaseWrapper<ViewLayer>(scene->view_layers)) {
+    if (space_outliner_.filter & SO_FILTER_NO_VIEW_LAYERS) {
+      if (view_layer != source_data.view_layer) {
+        continue;
+      }
     }
 
-    if (show_children) {
-      outliner_make_object_parent_hierarchy(&tree);
+    TreeElement &te_view_layer = *outliner_add_element(
+        &space_outliner_, &tree, scene, nullptr, TSE_R_LAYER, 0);
+    TREESTORE(&te_view_layer)->flag &= ~TSE_CLOSED;
+    te_view_layer.name = view_layer->name;
+    te_view_layer.directdata = view_layer;
+    view_layer_ = view_layer;
+
+    if (space_outliner_.filter & SO_FILTER_NO_COLLECTION) {
+      /* Show objects in the view layer. */
+      for (Base *base : List<Base>(view_layer_->object_bases)) {
+        TreeElement *te_object = outliner_add_element(&space_outliner_,
+                                                      &te_view_layer.subtree,
+                                                      base->object,
+                                                      &te_view_layer,
+                                                      TSE_SOME_ID,
+                                                      0);
+        te_object->directdata = base;
+      }
+
+      if (show_children) {
+        outliner_make_object_parent_hierarchy(&tree);
+      }
     }
-  }
-  else {
-    /* Show collections in the view layer. */
-    TreeElement &ten = *outliner_add_element(
-        &space_outliner_, &tree, source_data.scene, nullptr, TSE_VIEW_COLLECTION_BASE, 0);
-    ten.name = IFACE_("Scene Collection");
-    TREESTORE(&ten)->flag &= ~TSE_CLOSED;
-
-    add_view_layer(ten.subtree, ten);
-    if (show_children) {
-      add_layer_collection_objects_children(ten);
+    else {
+      /* Show collections in the view layer. */
+      TreeElement &ten = *outliner_add_element(&space_outliner_,
+                                               &te_view_layer.subtree,
+                                               source_data.scene,
+                                               &te_view_layer,
+                                               TSE_VIEW_COLLECTION_BASE,
+                                               0);
+      ten.name = IFACE_("Scene Collection");
+      TREESTORE(&ten)->flag &= ~TSE_CLOSED;
+
+      add_view_layer(ten.subtree, ten);
+      if (show_children) {
+        add_layer_collection_objects_children(ten);
+      }
     }
   }
 
diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h
index 9a66d16610d..556a9e48de5 100644
--- a/source/blender/makesdna/DNA_space_types.h
+++ b/source/blender/makesdna/DNA_space_types.h
@@ -338,8 +338,9 @@ typedef enum eSpaceOutliner_Filter {
   SO_FILTER_OB_STATE_SELECTED = (1 << 15), /* Not set via DNA. */
   SO_FILTER_OB_STATE_ACTIVE = (1 << 16),   /* Not set via DNA. */
   SO_FILTER_NO_COLLECTION = (1 << 17),
+  SO_FILTER_NO_VIEW_LAYERS = (1 << 18),
 
-  SO_FILTER_ID_TYPE = (1 << 18),
+  SO_FILTER_ID_TYPE = (1 << 19),
 } eSpaceOutliner_Filter;
 
 #define SO_FILTER_OB_TYPE \
@@ -352,7 +353,7 @@ typedef enum eSpaceOutliner_Filter {
 
 #define SO_FILTER_ANY \
   (SO_FILTER_NO_OB_CONTENT | SO_FILTER_NO_CHILDREN | SO_FILTER_OB_TYPE | SO_FILTER_OB_STATE | \
-   SO_FILTER_NO_COLLECTION | SO_FILTER_NO_LIB_OVERRIDE)
+   SO_FILTER_NO_COLLECTION | SO_FILTER_NO_VIEW_LAYERS | SO_FILTER_NO_LIB_OVERRIDE)
 
 /* SpaceOutliner.filter_state */
 typedef enum eSpaceOutliner_StateFilter {
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 40316d4661f..d0a7e4aeea3 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -3624,6 +3624,11 @@ static void rna_def_space_outliner(BlenderRNA *brna)
   RNA_def_property_ui_text(prop, "Show Collections", "Show collections");
   RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
 
+  prop = RNA_def_property(srna, "use_filter_view_layers", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_boolean_negative_sdna(prop, NULL, "filter", SO_FILTER_NO_VIEW_LAYERS);
+  RNA_def_property_ui_text(prop, "Show All View Layers", "Show all the view layers");
+  RNA_def_property_update(prop, NC_SPACE | ND_SPACE_OUTLINER, NULL);
+
   /* Filters object state. */
   prop = RNA_def_property(srna, "filter_state", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_sdna(prop, NULL, "filter_state");



More information about the Bf-blender-cvs mailing list