[Bf-blender-cvs] [c1cee363cd3] master: Fix T81555: Outliner object state filter not updating correctly

Julian Eisel noreply at git.blender.org
Mon Oct 12 18:22:54 CEST 2020


Commit: c1cee363cd39aaf25cbf4e099a07d1c4df6d37d7
Author: Julian Eisel
Date:   Mon Oct 12 18:04:52 2020 +0200
Branches: master
https://developer.blender.org/rBc1cee363cd39aaf25cbf4e099a07d1c4df6d37d7

Fix T81555: Outliner object state filter not updating correctly

When changing the selected, active or visible object(s), the Outliner
has to be rebuilt while using the corresponding object state filters.

The object hiding operators also have to send the proper notifiers (they
changed visibility without notifying about that).

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

M	source/blender/editors/object/object_edit.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_outliner/space_outliner.c

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

diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 0170e391708..3e7f028bd95 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -257,6 +257,7 @@ static int object_hide_view_clear_exec(bContext *C, wmOperator *op)
   BKE_layer_collection_sync(scene, view_layer);
   DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
   WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+  WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene);
 
   return OPERATOR_FINISHED;
 }
@@ -314,6 +315,7 @@ static int object_hide_view_set_exec(bContext *C, wmOperator *op)
   BKE_layer_collection_sync(scene, view_layer);
   DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
   WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
+  WM_event_add_notifier(C, NC_SCENE | ND_OB_VISIBLE, scene);
 
   return OPERATOR_FINISHED;
 }
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index 9ef3d8eed7a..d0614302502 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -236,6 +236,8 @@ void outliner_build_tree(struct Main *mainvar,
                          struct SpaceOutliner *space_outliner,
                          struct ARegion *region);
 
+bool outliner_requires_rebuild_on_select_or_active_change(
+    const struct SpaceOutliner *space_outliner);
 bool outliner_mode_requires_always_rebuild(const struct SpaceOutliner *space_outliner);
 
 typedef struct IDsSelectedData {
diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c
index 632f7d63ad4..5ace27a7103 100644
--- a/source/blender/editors/space_outliner/outliner_tree.c
+++ b/source/blender/editors/space_outliner/outliner_tree.c
@@ -94,6 +94,7 @@ static TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outli
                                                       Collection *collection,
                                                       TreeElement *ten);
 static void outliner_make_object_parent_hierarchy(ListBase *lb);
+static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner);
 
 /* ********************************************************* */
 /* Persistent Data */
@@ -245,6 +246,14 @@ static TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
 
 /* -------------------------------------------------------- */
 
+bool outliner_requires_rebuild_on_select_or_active_change(const SpaceOutliner *space_outliner)
+{
+  int exclude_flags = outliner_exclude_filter_get(space_outliner);
+  /* Need to rebuild tree to re-apply filter if select/active changed while filtering based on
+   * select/active. */
+  return exclude_flags & (SO_FILTER_OB_STATE_SELECTED | SO_FILTER_OB_STATE_ACTIVE);
+}
+
 /**
  * Check if a display mode needs a full rebuild if the open/collapsed state changes.
  * Element types in these modes don't actually add children if collapsed, so the rebuild is needed.
@@ -2164,7 +2173,7 @@ static void outliner_store_scrolling_position(SpaceOutliner *space_outliner,
   }
 }
 
-static int outliner_exclude_filter_get(SpaceOutliner *space_outliner)
+static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner)
 {
   int exclude_filter = space_outliner->filter & ~SO_FILTER_OB_STATE;
 
diff --git a/source/blender/editors/space_outliner/space_outliner.c b/source/blender/editors/space_outliner/space_outliner.c
index 2ed834a15dd..8be7f4d1bad 100644
--- a/source/blender/editors/space_outliner/space_outliner.c
+++ b/source/blender/editors/space_outliner/space_outliner.c
@@ -102,18 +102,25 @@ static void outliner_main_region_free(ARegion *UNUSED(region))
 }
 
 static void outliner_main_region_listener(wmWindow *UNUSED(win),
-                                          ScrArea *UNUSED(area),
+                                          ScrArea *area,
                                           ARegion *region,
                                           wmNotifier *wmn,
                                           const Scene *UNUSED(scene))
 {
+  SpaceOutliner *space_outliner = area->spacedata.first;
+
   /* context changes */
   switch (wmn->category) {
     case NC_SCENE:
       switch (wmn->data) {
         case ND_OB_ACTIVE:
         case ND_OB_SELECT:
-          ED_region_tag_redraw_no_rebuild(region);
+          if (outliner_requires_rebuild_on_select_or_active_change(space_outliner)) {
+            ED_region_tag_redraw(region);
+          }
+          else {
+            ED_region_tag_redraw_no_rebuild(region);
+          }
           break;
         case ND_OB_VISIBLE:
         case ND_OB_RENDER:



More information about the Bf-blender-cvs mailing list