Fix #89479: Unable to select hierarchies of multiple objects from outliner

`select hierarchy` is treated in similar way as we're selecting single element from outliner.
When `object_select_hierarchy_fn` is called for the first time, we clear select flag for all elements
in `outliner_item_select`. This causes issue when `select hierarchy` is called for multiple elements.
So fix is to not touch select and activate flags when `OL_ITEM_RECURSIVE` flag is set.

This also fixes the hierarchy selection when "sync select" is OFF.

Old Differential Revision: https://archive.blender.org/developer/D16804

Pull Request: https://projects.blender.org/blender/blender/pulls/104737
This commit is contained in:
Pratik Borhade
2023-08-17 13:23:46 +02:00
committed by Pratik Borhade
parent 33718b2d75
commit 594dceda7f

View File

@@ -362,6 +362,9 @@ static void tree_element_object_activate(bContext *C,
}
}
}
else if (recursive) {
/* Pass */
}
else {
/* De-select all. */
@@ -388,7 +391,9 @@ static void tree_element_object_activate(bContext *C,
}
if (set != OL_SETSEL_NONE) {
ED_object_base_activate_with_mode_exit_if_needed(C, base); /* adds notifier */
if (!recursive) {
ED_object_base_activate_with_mode_exit_if_needed(C, base); /* adds notifier */
}
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
@@ -1449,6 +1454,15 @@ static void do_outliner_item_activate_tree_element(bContext *C,
OL_SETSEL_NORMAL,
recursive && tselem->type == TSE_SOME_ID);
}
else if (recursive && !(space_outliner->flag & SO_SYNC_SELECT)) {
/* Selection of child objects in hierarchy when sync-selection is OFF. */
tree_iterator::all(te->subtree, [&](TreeElement *te) {
TreeStoreElem *tselem = TREESTORE(te);
if ((tselem->type == TSE_SOME_ID) && (te->idcode == ID_OB)) {
tselem->flag |= TSE_SELECTED;
}
});
}
if (tselem->type == TSE_SOME_ID) { /* The lib blocks. */
if (do_activate_data == false) {
@@ -1519,10 +1533,13 @@ void outliner_item_select(bContext *C,
const bool activate = select_flag & OL_ITEM_ACTIVATE;
const bool extend = select_flag & OL_ITEM_EXTEND;
const bool activate_data = select_flag & OL_ITEM_SELECT_DATA;
const bool recursive = select_flag & OL_ITEM_RECURSIVE;
/* Clear previous active when activating and clear selection when not extending selection */
const short clear_flag = (activate ? TSE_ACTIVE : 0) | (extend ? 0 : TSE_SELECTED);
if (clear_flag) {
/* Do not clear the active and select flag when selecting hierarchies. */
if (clear_flag && !recursive) {
outliner_flag_set(*space_outliner, clear_flag, false);
}
@@ -1537,7 +1554,10 @@ void outliner_item_select(bContext *C,
TreeViewContext tvc;
outliner_viewcontext_init(C, &tvc);
tselem->flag |= TSE_ACTIVE;
if (!recursive) {
tselem->flag |= TSE_ACTIVE;
}
do_outliner_item_activate_tree_element(C,
&tvc,
space_outliner,