[Bf-blender-cvs] [4292bb060d5] master: Outliner: Port scene elements and some related types to new tree-element code design

Julian Eisel noreply at git.blender.org
Mon Mar 8 18:38:31 CET 2021


Commit: 4292bb060d598659889e7448e02142248564fae7
Author: Julian Eisel
Date:   Mon Mar 8 15:13:35 2021 +0100
Branches: master
https://developer.blender.org/rB4292bb060d598659889e7448e02142248564fae7

Outliner: Port scene elements and some related types to new tree-element code design

Continuation of work in 2e221de4ceee, 249e4df110e0 and 3a907e742507.

Adds new tree-element classes for the scene-ID, scene collections, scene
objects, and the view layers base.
There is some more temporary stuff in here, which can be removed once we're
further along with the porting. Noted that in comments.

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

M	source/blender/editors/space_outliner/CMakeLists.txt
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_outliner/tree/tree_display.h
M	source/blender/editors/space_outliner/tree/tree_element.cc
M	source/blender/editors/space_outliner/tree/tree_element.h
M	source/blender/editors/space_outliner/tree/tree_element.hh
A	source/blender/editors/space_outliner/tree/tree_element_collection_base.cc
A	source/blender/editors/space_outliner/tree/tree_element_collection_base.hh
M	source/blender/editors/space_outliner/tree/tree_element_id.cc
M	source/blender/editors/space_outliner/tree/tree_element_id.hh
A	source/blender/editors/space_outliner/tree/tree_element_scene_objects_base.cc
A	source/blender/editors/space_outliner/tree/tree_element_scene_objects_base.hh
A	source/blender/editors/space_outliner/tree/tree_element_view_layer_base.cc
A	source/blender/editors/space_outliner/tree/tree_element_view_layer_base.hh

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

diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index 7b9bc44f986..82c87a7b199 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -56,10 +56,13 @@ set(SRC
   tree/tree_display_view_layer.cc
   tree/tree_element.cc
   tree/tree_element_anim_data.cc
+  tree/tree_element_collection_base.cc
   tree/tree_element_driver_base.cc
   tree/tree_element_gpencil_layer.cc
   tree/tree_element_id.cc
   tree/tree_element_nla.cc
+  tree/tree_element_scene_objects_base.cc
+  tree/tree_element_view_layer_base.cc
 
   outliner_intern.h
   tree/tree_display.h
@@ -67,10 +70,13 @@ set(SRC
   tree/tree_element.h
   tree/tree_element.hh
   tree/tree_element_anim_data.hh
+  tree/tree_element_collection_base.hh
   tree/tree_element_driver_base.hh
   tree/tree_element_gpencil_layer.hh
   tree/tree_element_id.hh
   tree/tree_element_nla.hh
+  tree/tree_element_scene_objects_base.hh
+  tree/tree_element_view_layer_base.hh
 )
 
 set(LIB
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 6ca986660c1..6319b890b3b 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -1,4 +1,4 @@
-/*
+/*
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
@@ -92,9 +92,6 @@
 #endif
 
 /* prototypes */
-static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
-                                                      Collection *collection,
-                                                      TreeElement *ten);
 static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner);
 
 /* ********************************************************* */
@@ -274,7 +271,7 @@ static void outliner_add_bone(SpaceOutliner *space_outliner,
   }
 }
 
-static bool outliner_animdata_test(AnimData *adt)
+bool outliner_animdata_test(const AnimData *adt)
 {
   if (adt) {
     return (adt->action || adt->drivers.first || adt->nla_tracks.first);
@@ -314,46 +311,6 @@ static void outliner_add_line_styles(SpaceOutliner *space_outliner,
 }
 #endif
 
-static void outliner_add_scene_contents(SpaceOutliner *space_outliner,
-                                        ListBase *lb,
-                                        Scene *sce,
-                                        TreeElement *te)
-{
-  /* View layers */
-  TreeElement *ten = outliner_add_element(space_outliner, lb, sce, te, TSE_R_LAYER_BASE, 0);
-  ten->name = IFACE_("View Layers");
-
-  ViewLayer *view_layer;
-  for (view_layer = sce->view_layers.first; view_layer; view_layer = view_layer->next) {
-    TreeElement *tenlay = outliner_add_element(
-        space_outliner, &ten->subtree, sce, ten, TSE_R_LAYER, 0);
-    tenlay->name = view_layer->name;
-    tenlay->directdata = view_layer;
-  }
-
-  /* World */
-  outliner_add_element(space_outliner, lb, sce->world, te, TSE_SOME_ID, 0);
-
-  /* Collections */
-  ten = outliner_add_element(space_outliner, lb, &sce->id, te, TSE_SCENE_COLLECTION_BASE, 0);
-  ten->name = IFACE_("Scene Collection");
-  outliner_add_collection_recursive(space_outliner, sce->master_collection, ten);
-
-  /* Objects */
-  ten = outliner_add_element(space_outliner, lb, sce, te, TSE_SCENE_OBJECTS_BASE, 0);
-  ten->name = IFACE_("Objects");
-  FOREACH_SCENE_OBJECT_BEGIN (sce, ob) {
-    outliner_add_element(space_outliner, &ten->subtree, ob, ten, TSE_SOME_ID, 0);
-  }
-  FOREACH_SCENE_OBJECT_END;
-  outliner_make_object_parent_hierarchy(&ten->subtree);
-
-  /* Animation Data */
-  if (outliner_animdata_test(sce->adt)) {
-    outliner_add_element(space_outliner, lb, sce, te, TSE_ANIM_DATA, 0);
-  }
-}
-
 /* Can be inlined if necessary. */
 static void outliner_add_object_contents(SpaceOutliner *space_outliner,
                                          TreeElement *te,
@@ -629,32 +586,6 @@ static void outliner_add_object_contents(SpaceOutliner *space_outliner,
   }
 }
 
-static void outliner_add_library_override_contents(SpaceOutliner *soops, TreeElement *te, ID *id)
-{
-  if (!id->override_library) {
-    return;
-  }
-
-  PointerRNA idpoin;
-  RNA_id_pointer_create(id, &idpoin);
-
-  PointerRNA override_ptr;
-  PropertyRNA *override_prop;
-  int index = 0;
-  LISTBASE_FOREACH (IDOverrideLibraryProperty *, op, &id->override_library->properties) {
-    if (!BKE_lib_override_rna_property_find(&idpoin, op, &override_ptr, &override_prop)) {
-      /* This is fine, override properties list is not always fully up-to-date with current
-       * RNA/IDProps etc., this gets cleaned up when re-generating the overrides rules,
-       * no error here. */
-      continue;
-    }
-
-    TreeElement *ten = outliner_add_element(
-        soops, &te->subtree, id, te, TSE_LIBRARY_OVERRIDE, index++);
-    ten->name = RNA_property_ui_name(override_prop);
-  }
-}
-
 /* Can be inlined if necessary. */
 static void outliner_add_id_contents(SpaceOutliner *space_outliner,
                                      TreeElement *te,
@@ -668,14 +599,10 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
 
   /* expand specific data always */
   switch (GS(id->name)) {
-    case ID_LI: {
-      te->name = ((Library *)id)->filepath;
-      break;
-    }
-    case ID_SCE: {
-      outliner_add_scene_contents(space_outliner, &te->subtree, (Scene *)id, te);
+    case ID_LI:
+    case ID_SCE:
+      BLI_assert(!"ID type expected to be expanded through new tree-element design");
       break;
-    }
     case ID_OB: {
       outliner_add_object_contents(space_outliner, te, tselem, (Object *)id);
       break;
@@ -902,17 +829,6 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
     default:
       break;
   }
-
-  const bool lib_overrides_visible = !SUPPORT_FILTER_OUTLINER(space_outliner) ||
-                                     ((space_outliner->filter & SO_FILTER_NO_LIB_OVERRIDE) == 0);
-
-  if (lib_overrides_visible && ID_IS_OVERRIDE_LIBRARY(id)) {
-    TreeElement *ten = outliner_add_element(
-        space_outliner, &te->subtree, id, te, TSE_LIBRARY_OVERRIDE_BASE, 0);
-
-    ten->name = IFACE_("Library Overrides");
-    outliner_add_library_override_contents(space_outliner, ten, id);
-  }
 }
 
 /**
@@ -1001,7 +917,11 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
     /* Other cases must be caught above. */
     BLI_assert(TSE_IS_REAL_ID(tselem));
 
-    te->name = id->name + 2; /* Default, can be overridden by Library or non-ID data. */
+    /* The new type design sets the name already, don't override that here. We need to figure out
+     * how to deal with the idcode for non-TSE_SOME_ID types still. Some rely on it... */
+    if (!te->type) {
+      te->name = id->name + 2; /* Default, can be overridden by Library or non-ID data. */
+    }
     te->idcode = GS(id->name);
   }
 
@@ -1009,11 +929,10 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
     outliner_tree_element_type_expand(te->type, space_outliner);
   }
   else if (type == TSE_SOME_ID) {
-    TreeStoreElem *tsepar = parent ? TREESTORE(parent) : NULL;
-
-    /* ID data-block. */
-    if (tsepar == NULL || tsepar->type != TSE_ID_BASE || space_outliner->filter_id_type) {
+    /* ID types not (fully) ported to new design yet. */
+    if (outliner_tree_element_type_expand_poll(te->type, space_outliner)) {
       outliner_add_id_contents(space_outliner, te, tselem, id);
+      outliner_tree_element_type_post_expand(te->type, space_outliner);
     }
   }
   else if (ELEM(type,
@@ -1233,9 +1152,9 @@ BLI_INLINE void outliner_add_collection_objects(SpaceOutliner *space_outliner,
   }
 }
 
-static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
-                                                      Collection *collection,
-                                                      TreeElement *ten)
+TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
+                                               Collection *collection,
+                                               TreeElement *ten)
 {
   outliner_add_collection_init(ten, collection);
 
diff --git a/source/blender/editors/space_outliner/tree/tree_display.h b/source/blender/editors/space_outliner/tree/tree_display.h
index 4ef71ded133..c0a751f2cd5 100644
--- a/source/blender/editors/space_outliner/tree/tree_display.h
+++ b/source/blender/editors/space_outliner/tree/tree_display.h
@@ -56,6 +56,10 @@ struct TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
                                          short type,
                                          short index);
 void outliner_make_object_parent_hierarchy(ListBase *lb);
+bool outliner_animdata_test(const struct AnimData *adt);
+TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
+                                               struct Collection *collection,
+                                               TreeElement *ten);
 
 const char *outliner_idcode_to_plural(short idcode);
 
diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc
index 79c2831475f..75ecfb5584a 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element.cc
@@ -21,10 +21,13 @@
 #include "DNA_listBase.h"
 
 #include "tree_element_anim_data.hh"
+#include "tree_element_collection_base.hh"
 #include "tree_element_driver_base.hh"
 #include "tree_element_gpencil_layer.hh"
 #include "tree_element_id.hh"
 #include "tree_element_nla.hh"
+#include "tree_element_scene_objects_base.hh"
+#include "tree_element_view_layer_base.hh"
 
 #include "tree_element.h"
 #include "tree_element.hh"
@@ -52,6 +55,12 @@ static AbstractTreeElement *tree_element_create(int type, TreeElement &legacy_te
       return new TreeElementNLAAction(legacy_te);
     case TSE_GP_LAYER:
       return new TreeEl

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list