Fix Outliner editbone selection with 'Sync Selection'

When editbones were selected from the Outliner (and they were connected
to a parent) with the 'Sync Selection' option turned ON, they could not
get duplicated.

For duplication to work, the (connected) parent bone's tip also has to
be selected [which was not the case when selection is done from the
Outliner under above circumstances]. The reason being that
armature_duplicate_selected_exec ->
ED_armature_edit_sync_selection clears the BONE_ROOTSEL flag if the
parent bone's BONE_TIPSEL is not set.

Caused by rB71eb65328078 btw.

The correct "parent-tip-selection" would actually happen in activation
- `tree_element_active_ebone`
-- `tree_element_active_ebone__sel`
but for 'Sync Selection' this happens [also] in
- `outliner_sync_selection_from_outliner`
-- `outliner_select_sync_to_edit_bone`
which did not do the "flushing" to the parent bone's tip

Now use existing dedicated function for this.

ref. T82347

Reviewers: Zachman

Differential Revision: https://developer.blender.org/D9470
This commit is contained in:
Philipp Oeser 2020-11-05 14:11:01 +01:00
parent 02677ec4e0
commit 28e703b0a1
Notes: blender-bot 2023-02-14 00:29:15 +01:00
Referenced by issue #82457, Python error when clicking on a tool in the viewport while a compositor editor is open.
Referenced by issue #82347, Problem duplicating after selecting from outliner, and lots of console error messages after deleting child bones
2 changed files with 5 additions and 14 deletions

View File

@ -714,20 +714,9 @@ static eOLDrawState tree_element_active_bone(bContext *C,
static void tree_element_active_ebone__sel(bContext *C, bArmature *arm, EditBone *ebone, short sel)
{
if (sel) {
ebone->flag |= BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL;
arm->act_edbone = ebone;
/* Flush to parent? */
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
ebone->parent->flag |= BONE_TIPSEL;
}
}
else {
ebone->flag &= ~(BONE_SELECTED | BONE_ROOTSEL | BONE_TIPSEL);
/* Flush to parent? */
if (ebone->parent && (ebone->flag & BONE_CONNECTED)) {
ebone->parent->flag &= ~BONE_TIPSEL;
}
}
ED_armature_ebone_select_set(ebone, sel);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, CTX_data_edit_object(C));
}
static eOLDrawState tree_element_active_ebone(bContext *C,

View File

@ -252,11 +252,13 @@ static void outliner_select_sync_to_edit_bone(ViewLayer *view_layer,
if (EBONE_SELECTABLE(arm, ebone)) {
if (tselem->flag & TSE_SELECTED) {
ebone->flag |= (BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
ED_armature_ebone_select_set(ebone, true);
add_selected_item(selected_ebones, ebone);
}
else if (!is_edit_bone_selected(selected_ebones, ebone)) {
/* Dont flush to parent bone tip, synced selection is iterating the whole tree so deselecting
* potential children with 'ED_armature_ebone_select_set(ebone, false)' would leave own tip
* deselected. */
ebone->flag &= ~(BONE_SELECTED | BONE_TIPSEL | BONE_ROOTSEL);
}
}