Fix T96663: Selecting a pose-bone doesn't activate the object

Regression in [0] that removed object selection changes while remaining
in pose-mode. This unintentionally removed object activation.

[0]: 859c062a2a
This commit is contained in:
Campbell Barton
2022-03-22 13:13:11 +11:00
parent 4046f61b39
commit 59870796ea

View File

@@ -2381,6 +2381,9 @@ static bool ed_object_select_pick(bContext *C,
float dist = ED_view3d_select_dist_px() * 1.3333f;
const float mval_fl[2] = {(float)mval[0], (float)mval[1]};
/* Handle setting the new base active */
bool use_activate_selected_base = false;
/* When enabled, don't attempt any further selection. */
bool handled = false;
bool changed = false;
@@ -2526,34 +2529,39 @@ static bool ed_object_select_pick(bContext *C,
* not-selected active object in pose-mode won't work well for tools */
ED_object_base_select(basact, BA_SELECT);
if (is_pose_mode && (basact->object->mode & OB_MODE_POSE)) {
/* Within pose-mode, keep the current selection when switching pose bones,
* this is noticeable when in pose mode with multiple objects at once.
* Where selecting the bone of a different object would de-select this one.
* After that, exiting pose-mode would only have the active armature selected.
* This matches multi-object edit-mode behavior. */
handled = true;
}
else {
/* Don't set `handled` here as the object selection may be necessary
* when starting out in object-mode and moving into pose-mode,
* when moving from pose to object-mode using object selection also makes sense. */
}
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_SELECT, basact->object);
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object);
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
/* In weight-paint, we use selected bone to select vertex-group,
* so don't switch to new active object. */
if (oldbasact && (oldbasact->object->mode & OB_MODE_ALL_WEIGHT_PAINT)) {
/* Prevent activating.
* Selection causes this to be considered the 'active' pose in weight-paint mode.
* Eventually this limitation may be removed.
* For now, de-select all other pose objects deforming this mesh. */
ED_armature_pose_select_in_wpaint_mode(view_layer, basact);
if (oldbasact) {
if (oldbasact->object->mode & OB_MODE_ALL_WEIGHT_PAINT) {
/* Prevent activating.
* Selection causes this to be considered the 'active' pose in weight-paint mode.
* Eventually this limitation may be removed.
* For now, de-select all other pose objects deforming this mesh. */
ED_armature_pose_select_in_wpaint_mode(view_layer, basact);
handled = true;
handled = true;
}
else if (is_pose_mode && (basact->object->mode & OB_MODE_POSE)) {
/* Within pose-mode, keep the current selection when switching pose bones,
* this is noticeable when in pose mode with multiple objects at once.
* Where selecting the bone of a different object would de-select this one.
* After that, exiting pose-mode would only have the active armature selected.
* This matches multi-object edit-mode behavior. */
handled = true;
if (oldbasact != basact) {
use_activate_selected_base = true;
}
}
else {
/* Don't set `handled` here as the object selection may be necessary
* when starting out in object-mode and moving into pose-mode,
* when moving from pose to object-mode using object selection also makes sense. */
}
}
}
}
@@ -2621,7 +2629,7 @@ static bool ed_object_select_pick(bContext *C,
}
/* Also prevent making it active on mouse selection. */
else if (BASE_SELECTABLE(v3d, basact)) {
const bool use_activate_selected_base = (oldbasact != basact) && (is_obedit == false);
use_activate_selected_base |= (oldbasact != basact) && (is_obedit == false);
switch (params->sel_op) {
case SEL_OP_ADD: {
@@ -2657,14 +2665,22 @@ static bool ed_object_select_pick(bContext *C,
break;
}
}
}
if (use_activate_selected_base) {
ED_object_base_activate(C, basact); /* adds notifier */
if ((scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) == 0) {
WM_toolsystem_update_from_context_view3d(C);
}
}
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
if (use_activate_selected_base && (basact != NULL)) {
changed = true;
ED_object_base_activate(C, basact); /* adds notifier */
if ((scene->toolsettings->object_flag & SCE_OBJECT_MODE_LOCK) == 0) {
WM_toolsystem_update_from_context_view3d(C);
}
}
if (changed) {
if (use_activate_selected_base) {
/* Set special modes for grease pencil
* The grease pencil modes are not real modes, but a hack to make the interface
* consistent, so need some tricks to keep UI synchronized */
@@ -2686,11 +2702,6 @@ static bool ed_object_select_pick(bContext *C,
}
}
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
}
if (changed) {
if (vc.obact && vc.obact->mode & OB_MODE_POSE) {
ED_outliner_select_sync_from_pose_bone_tag(C);
}