[Bf-blender-cvs] [0449da54602] master: Outliner: Refactor: Move overrides tree items to new CPP code.

Bastien Montagne noreply at git.blender.org
Tue Mar 16 18:37:12 CET 2021


Commit: 0449da54602b2e9a1ea58d336f190c3919f3f27a
Author: Bastien Montagne
Date:   Tue Mar 16 18:35:53 2021 +0100
Branches: master
https://developer.blender.org/rB0449da54602b2e9a1ea58d336f190c3919f3f27a

Outliner: Refactor: Move overrides tree items to new CPP code.

Fairly straight forwards.

Also fixes the bug from recent refactor that would not show overrides as
a tree, but as a flat list directly under IDs.

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

M	source/blender/editors/space_outliner/CMakeLists.txt
M	source/blender/editors/space_outliner/tree/tree_element.cc
M	source/blender/editors/space_outliner/tree/tree_element_id.cc
M	source/blender/editors/space_outliner/tree/tree_element_id.hh
M	source/blender/editors/space_outliner/tree/tree_element_overrides.cc
M	source/blender/editors/space_outliner/tree/tree_element_overrides.hh

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

diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index eb3371e989a..4a1e5c1a12c 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -63,6 +63,7 @@ set(SRC
   tree/tree_element_id_library.cc
   tree/tree_element_id_scene.cc
   tree/tree_element_nla.cc
+  tree/tree_element_overrides.cc
   tree/tree_element_scene_objects.cc
   tree/tree_element_view_layer.cc
 
@@ -79,6 +80,7 @@ set(SRC
   tree/tree_element_id_library.hh
   tree/tree_element_id_scene.hh
   tree/tree_element_nla.hh
+  tree/tree_element_overrides.hh
   tree/tree_element_scene_objects.hh
   tree/tree_element_view_layer.hh
 )
diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc
index b0508e10671..113d421ed91 100644
--- a/source/blender/editors/space_outliner/tree/tree_element.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element.cc
@@ -27,6 +27,7 @@
 #include "tree_element_gpencil_layer.hh"
 #include "tree_element_id.hh"
 #include "tree_element_nla.hh"
+#include "tree_element_overrides.hh"
 #include "tree_element_scene_objects.hh"
 #include "tree_element_view_layer.hh"
 
@@ -72,6 +73,11 @@ static AbstractTreeElement *tree_element_create(int type, TreeElement &legacy_te
       return new TreeElementCollectionBase(legacy_te, *static_cast<Scene *>(idv));
     case TSE_SCENE_OBJECTS_BASE:
       return new TreeElementSceneObjectsBase(legacy_te, *static_cast<Scene *>(idv));
+    case TSE_LIBRARY_OVERRIDE_BASE:
+      return new TreeElementOverridesBase(legacy_te, id);
+    case TSE_LIBRARY_OVERRIDE:
+      return new TreeElementOverridesProperty(legacy_te,
+                                              *static_cast<TreeElementOverridesData *>(idv));
     default:
       break;
   }
diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.cc b/source/blender/editors/space_outliner/tree/tree_element_id.cc
index 823a7644f38..ce99b954204 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_id.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element_id.cc
@@ -106,46 +106,14 @@ TreeElementID::TreeElementID(TreeElement &legacy_te, ID &id)
   legacy_te_.idcode = GS(id.name);
 }
 
-void TreeElementID::expand_library_overrides(SpaceOutliner &space_outliner) const
-{
-  if (!id_.override_library) {
-    return;
-  }
-
-  PointerRNA idpoin;
-  RNA_id_pointer_create(&id_, &idpoin);
-
-  PointerRNA override_rna_ptr;
-  PropertyRNA *override_rna_prop;
-  int index = 0;
-
-  for (auto *override_prop :
-       ListBaseWrapper<IDOverrideLibraryProperty>(id_.override_library->properties)) {
-    if (!BKE_lib_override_rna_property_find(
-            &idpoin, override_prop, &override_rna_ptr, &override_rna_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(
-        &space_outliner, &legacy_te_.subtree, &id_, &legacy_te_, TSE_LIBRARY_OVERRIDE, index++);
-    ten->name = RNA_property_ui_name(override_rna_prop);
-  }
-}
-
 void TreeElementID::postExpand(SpaceOutliner &space_outliner) const
 {
   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(
+  if (lib_overrides_visible && ID_IS_OVERRIDE_LIBRARY_REAL(&id_)) {
+    outliner_add_element(
         &space_outliner, &legacy_te_.subtree, &id_, &legacy_te_, TSE_LIBRARY_OVERRIDE_BASE, 0);
-
-    ten->name = IFACE_("Library Overrides");
-    expand_library_overrides(space_outliner);
   }
 }
 
diff --git a/source/blender/editors/space_outliner/tree/tree_element_id.hh b/source/blender/editors/space_outliner/tree/tree_element_id.hh
index 2d077464b6d..b3b5ca2770c 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_id.hh
+++ b/source/blender/editors/space_outliner/tree/tree_element_id.hh
@@ -50,9 +50,6 @@ class TreeElementID : public AbstractTreeElement {
  protected:
   /* ID types with animation data can use this. */
   void expand_animation_data(SpaceOutliner &, const AnimData *) const;
-
- private:
-  void expand_library_overrides(SpaceOutliner &) const;
 };
 
 }  // namespace blender::ed::outliner
diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
index 4d9634541af..6b222e877b1 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
+++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc
@@ -45,9 +45,7 @@ TreeElementOverridesBase::TreeElementOverridesBase(TreeElement &legacy_te, ID &i
 
 void TreeElementOverridesBase::expand(SpaceOutliner &space_outliner) const
 {
-  if (!id_.override_library) {
-    return;
-  }
+  BLI_assert(id_.override_library != nullptr);
 
   PointerRNA idpoin;
   RNA_id_pointer_create(&id_, &idpoin);
diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.hh b/source/blender/editors/space_outliner/tree/tree_element_overrides.hh
index 9e80f3d6b08..b5c772f5b33 100644
--- a/source/blender/editors/space_outliner/tree/tree_element_overrides.hh
+++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.hh
@@ -44,8 +44,6 @@ class TreeElementOverridesProperty final : public AbstractTreeElement {
 
  public:
   TreeElementOverridesProperty(TreeElement &legacy_te, TreeElementOverridesData &override_data);
-
-  void expand(SpaceOutliner &) const override;
 };
 
 }  // namespace blender::ed::outliner



More information about the Bf-blender-cvs mailing list