[Bf-blender-cvs] [ee3d36f78a5] temp-outliner-new-element-storage: Outliner: Initial (half working) port to new element storage

Julian Eisel noreply at git.blender.org
Wed Sep 7 12:09:51 CEST 2022


Commit: ee3d36f78a59ebde397962d97fde4a4137f3aada
Author: Julian Eisel
Date:   Wed Sep 7 12:05:56 2022 +0200
Branches: temp-outliner-new-element-storage
https://developer.blender.org/rBee3d36f78a59ebde397962d97fde4a4137f3aada

Outliner: Initial (half working) port to new element storage

Basicaly the idea is to have a C++ class to better manage the runtime
tree element storage and access.

This branch doesn't even compile yet, it's just an early experiment so
far that I don't only want to keep locally.

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

M	source/blender/editors/space_outliner/outliner_dragdrop.cc
M	source/blender/editors/space_outliner/outliner_draw.cc
M	source/blender/editors/space_outliner/outliner_intern.hh
M	source/blender/editors/space_outliner/outliner_tree.cc
M	source/blender/editors/space_outliner/outliner_utils.cc
M	source/blender/editors/space_outliner/space_outliner.cc
M	source/blender/editors/space_outliner/tree/common.cc
M	source/blender/editors/space_outliner/tree/common.hh
M	source/blender/editors/space_outliner/tree/tree_display.hh
M	source/blender/editors/space_outliner/tree/tree_display_data.cc
M	source/blender/editors/space_outliner/tree/tree_display_libraries.cc
M	source/blender/editors/space_outliner/tree/tree_display_orphaned.cc
M	source/blender/editors/space_outliner/tree/tree_display_override_library_hierarchies.cc
M	source/blender/editors/space_outliner/tree/tree_display_override_library_properties.cc
M	source/blender/editors/space_outliner/tree/tree_display_scenes.cc
M	source/blender/editors/space_outliner/tree/tree_display_sequencer.cc
M	source/blender/editors/space_outliner/tree/tree_display_view_layer.cc
M	source/blender/editors/space_outliner/tree/tree_element.cc
M	source/blender/editors/space_outliner/tree/tree_element.hh
M	source/blender/editors/space_outliner/tree/tree_element_anim_data.cc
M	source/blender/editors/space_outliner/tree/tree_element_driver.cc
M	source/blender/editors/space_outliner/tree/tree_element_id.cc
M	source/blender/editors/space_outliner/tree/tree_element_id_scene.cc
M	source/blender/editors/space_outliner/tree/tree_element_nla.cc
M	source/blender/editors/space_outliner/tree/tree_element_overrides.cc
M	source/blender/editors/space_outliner/tree/tree_element_rna.cc
M	source/blender/editors/space_outliner/tree/tree_element_scene_objects.cc
M	source/blender/editors/space_outliner/tree/tree_element_seq.cc
M	source/blender/editors/space_outliner/tree/tree_element_view_layer.cc

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

diff --git a/source/blender/editors/space_outliner/outliner_dragdrop.cc b/source/blender/editors/space_outliner/outliner_dragdrop.cc
index 4a0e00b8bf1..4f27af6bcea 100644
--- a/source/blender/editors/space_outliner/outliner_dragdrop.cc
+++ b/source/blender/editors/space_outliner/outliner_dragdrop.cc
@@ -64,9 +64,9 @@ static TreeElement *outliner_dropzone_element(TreeElement *te,
     }
   }
   /* Not it.  Let's look at its children. */
-  if (children && (TREESTORE(te)->flag & TSE_CLOSED) == 0 && (te->subtree.first)) {
-    LISTBASE_FOREACH (TreeElement *, te_sub, &te->subtree) {
-      TreeElement *te_valid = outliner_dropzone_element(te_sub, fmval, children);
+  if (children && (TREESTORE(te)->flag & TSE_CLOSED) == 0) {
+    for (TreeElement &te_sub : te->child_elements) {
+      TreeElement *te_valid = outliner_dropzone_element(&te_sub, fmval, children);
       if (te_valid) {
         return te_valid;
       }
@@ -139,14 +139,14 @@ static TreeElement *outliner_drop_insert_find(bContext *C,
 
     if (view_mval[1] < (te_hovered->ys + margin)) {
       if (TSELEM_OPEN(TREESTORE(te_hovered), space_outliner) &&
-          !BLI_listbase_is_empty(&te_hovered->subtree)) {
+          !te_hovered->child_elements.is_empty()) {
         /* inserting after a open item means we insert into it, but as first child */
-        if (BLI_listbase_is_empty(&te_hovered->subtree)) {
+        if (te_hovered->child_elements.is_empty()) {
           *r_insert_type = TE_INSERT_INTO;
           return te_hovered;
         }
         *r_insert_type = TE_INSERT_BEFORE;
-        return static_cast<TreeElement *>(te_hovered->subtree.first);
+        return &*te_hovered->child_elements.begin();
       }
       *r_insert_type = TE_INSERT_AFTER;
       return te_hovered;
diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc
index 3f99b19cd16..acddf2b2b1d 100644
--- a/source/blender/editors/space_outliner/outliner_draw.cc
+++ b/source/blender/editors/space_outliner/outliner_draw.cc
@@ -81,22 +81,22 @@ namespace blender::ed::outliner {
  * \{ */
 
 static void outliner_tree_dimensions_impl(SpaceOutliner *space_outliner,
-                                          ListBase *lb,
+                                          SubTree &subtree,
                                           int *width,
                                           int *height)
 {
-  LISTBASE_FOREACH (TreeElement *, te, lb) {
-    *width = MAX2(*width, te->xend);
+  for (TreeElement &te : subtree) {
+    *width = MAX2(*width, te.xend);
     if (height != nullptr) {
       *height += UI_UNIT_Y;
     }
 
-    TreeStoreElem *tselem = TREESTORE(te);
+    TreeStoreElem *tselem = TREESTORE(&te);
     if (TSELEM_OPEN(tselem, space_outliner)) {
-      outliner_tree_dimensions_impl(space_outliner, &te->subtree, width, height);
+      outliner_tree_dimensions_impl(space_outliner, te.child_elements, width, height);
     }
     else {
-      outliner_tree_dimensions_impl(space_outliner, &te->subtree, width, nullptr);
+      outliner_tree_dimensions_impl(space_outliner, te.child_elements, width, nullptr);
     }
   }
 }
@@ -105,7 +105,8 @@ void outliner_tree_dimensions(SpaceOutliner *space_outliner, int *r_width, int *
 {
   *r_width = 0;
   *r_height = 0;
-  outliner_tree_dimensions_impl(space_outliner, &space_outliner->tree, r_width, r_height);
+  outliner_tree_dimensions_impl(
+      space_outliner, space_outliner->runtime->root_elements, r_width, r_height);
 }
 
 /**
@@ -1030,7 +1031,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
                                        ViewLayer *view_layer,
                                        ARegion *region,
                                        SpaceOutliner *space_outliner,
-                                       ListBase *lb,
+                                       SubTree &subtree,
                                        RestrictPropertiesActive props_active_parent)
 {
   /* Get RNA properties (once for speed). */
@@ -1105,16 +1106,16 @@ static void outliner_draw_restrictbuts(uiBlock *block,
   /* Create buttons. */
   uiBut *bt;
 
-  LISTBASE_FOREACH (TreeElement *, te, lb) {
-    TreeStoreElem *tselem = TREESTORE(te);
+  for (TreeElement &te : subtree) {
+    TreeStoreElem *tselem = TREESTORE(&te);
     RestrictPropertiesActive props_active = props_active_parent;
 
-    if (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te->ys <= region->v2d.cur.ymax) {
+    if (te.ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin && te.ys <= region->v2d.cur.ymax) {
       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 = static_cast<ViewLayer *>(te->directdata);
+          ViewLayer *layer = static_cast<ViewLayer *>(te.directdata);
 
           bt = uiDefIconButBitS(block,
                                 UI_BTYPE_ICON_TOGGLE_N,
@@ -1122,7 +1123,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
                                 0,
                                 ICON_RESTRICT_RENDER_OFF,
                                 (int)(region->v2d.cur.xmax - restrict_offsets.render),
-                                te->ys,
+                                te.ys,
                                 UI_UNIT_X,
                                 UI_UNIT_Y,
                                 &layer->flag,
@@ -1136,18 +1137,18 @@ static void outliner_draw_restrictbuts(uiBlock *block,
           UI_but_drawflag_enable(bt, UI_BUT_ICON_REVERSE);
         }
       }
-      else if (((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) &&
-               (te->flag & TE_CHILD_NOT_IN_COLLECTION)) {
+      else if (((tselem->type == TSE_SOME_ID) && (te.idcode == ID_OB)) &&
+               (te.flag & TE_CHILD_NOT_IN_COLLECTION)) {
         /* Don't show restrict columns for children that are not directly inside the collection. */
       }
-      else if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
+      else if ((tselem->type == TSE_SOME_ID) && (te.idcode == ID_OB)) {
         PointerRNA ptr;
         Object *ob = (Object *)tselem->id;
         RNA_id_pointer_create(&ob->id, &ptr);
 
         if (space_outliner->show_restrict_flags & SO_RESTRICT_HIDE) {
-          Base *base = (te->directdata) ? (Base *)te->directdata :
-                                          BKE_view_layer_base_find(view_layer, ob);
+          Base *base = (te.directdata) ? (Base *)te.directdata :
+                                         BKE_view_layer_base_find(view_layer, ob);
           if (base) {
             PointerRNA base_ptr;
             RNA_pointer_create(&scene->id, &RNA_ObjectBase, base, &base_ptr);
@@ -1156,7 +1157,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
                                     0,
                                     0,
                                     (int)(region->v2d.cur.xmax - restrict_offsets.hide),
-                                    te->ys,
+                                    te.ys,
                                     UI_UNIT_X,
                                     UI_UNIT_Y,
                                     &base_ptr,
@@ -1183,7 +1184,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
                                   0,
                                   0,
                                   (int)(region->v2d.cur.xmax - restrict_offsets.select),
-                                  te->ys,
+                                  te.ys,
                                   UI_UNIT_X,
                                   UI_UNIT_Y,
                                   &ptr,
@@ -1208,7 +1209,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
                                   0,
                                   0,
                                   (int)(region->v2d.cur.xmax - restrict_offsets.viewport),
-                                  te->ys,
+                                  te.ys,
                                   UI_UNIT_X,
                                   UI_UNIT_Y,
                                   &ptr,
@@ -1233,7 +1234,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
                                   0,
                                   0,
                                   (int)(region->v2d.cur.xmax - restrict_offsets.render),
-                                  te->ys,
+                                  te.ys,
                                   UI_UNIT_X,
                                   UI_UNIT_Y,
                                   &ptr,
@@ -1253,7 +1254,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
         }
       }
       else if (tselem->type == TSE_CONSTRAINT) {
-        bConstraint *con = (bConstraint *)te->directdata;
+        bConstraint *con = (bConstraint *)te.directdata;
 
         PointerRNA ptr;
         RNA_pointer_create(tselem->id, &RNA_Constraint, con, &ptr);
@@ -1264,7 +1265,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
                                   0,
                                   0,
                                   (int)(region->v2d.cur.xmax - restrict_offsets.hide),
-                                  te->ys,
+                                  te.ys,
                                   UI_UNIT_X,
                                   UI_UNIT_Y,
                                   &ptr,
@@ -1282,7 +1283,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
         }
       }
       else if (tselem->type == TSE_MODIFIER) {
-        ModifierData *md = (ModifierData *)te->directdata;
+        ModifierData *md = (ModifierData *)te.directdata;
 
         PointerRNA ptr;
         RNA_pointer_create(tselem->id, &RNA_Modifier, md, &ptr);
@@ -1293,7 +1294,7 @@ static void outliner_draw_restrictbuts(uiBlock *block,
                                   0,
                                   0,
                                   (int)(region->v2d.cur.xmax - restrict_offsets.viewport),
-                                  te->ys,
+                                  te.ys,
                     

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list