Fix T66949: Can't select bones from multiple objects in wpaint mode
This fix relies on 2.7x logic, only de-selecting other armature objects, making multiple armatures in weight paint mode usable.
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include "BKE_object.h"
|
||||
#include "BKE_report.h"
|
||||
#include "BKE_layer.h"
|
||||
#include "BKE_modifier.h"
|
||||
|
||||
#include "DEG_depsgraph.h"
|
||||
|
||||
@@ -247,6 +248,38 @@ bool ED_armature_pose_select_pick_with_buffer(ViewLayer *view_layer,
|
||||
return nearBone != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* While in weight-paint mode, a single pose may be active as well.
|
||||
* While not common, it's possible we have multiple armatures deforming a mesh.
|
||||
*
|
||||
* This function de-selects all other objects, and selects the new base.
|
||||
* It can't be set to the active object because we need
|
||||
* to keep this set to the weight paint object.
|
||||
*/
|
||||
void ED_armature_pose_select_in_wpaint_mode(ViewLayer *view_layer, Base *base_select)
|
||||
{
|
||||
BLI_assert(base_select && (base_select->object->type == OB_ARMATURE));
|
||||
Object *ob_active = OBACT(view_layer);
|
||||
BLI_assert(ob_active && (ob_active->mode & OB_MODE_WEIGHT_PAINT));
|
||||
VirtualModifierData virtualModifierData;
|
||||
ModifierData *md = modifiers_getVirtualModifierList(ob_active, &virtualModifierData);
|
||||
for (; md; md = md->next) {
|
||||
if (md->type == eModifierType_Armature) {
|
||||
ArmatureModifierData *amd = (ArmatureModifierData *)md;
|
||||
Object *ob_arm = amd->object;
|
||||
if (ob_arm != NULL) {
|
||||
Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm);
|
||||
if ((base_arm != NULL) && (base_arm != base_select) && (base_arm->flag & BASE_SELECTED)) {
|
||||
ED_object_base_select(base_arm, BA_DESELECT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ((base_select->flag & BASE_SELECTED) == 0) {
|
||||
ED_object_base_select(base_select, BA_SELECT);
|
||||
}
|
||||
}
|
||||
|
||||
/* 'select_mode' is usual SEL_SELECT/SEL_DESELECT/SEL_TOGGLE/SEL_INVERT.
|
||||
* When true, 'ignore_visibility' makes this func also affect invisible bones
|
||||
* (hidden or on hidden layers). */
|
||||
|
||||
@@ -170,6 +170,10 @@ bool ED_armature_pose_select_pick_with_buffer(struct ViewLayer *view_layer,
|
||||
bool deselect,
|
||||
bool toggle,
|
||||
bool do_nearest);
|
||||
|
||||
void ED_armature_pose_select_in_wpaint_mode(struct ViewLayer *view_layer,
|
||||
struct Base *base_select);
|
||||
|
||||
bool ED_armature_edit_select_pick(
|
||||
struct bContext *C, const int mval[2], bool extend, bool deselect, bool toggle);
|
||||
|
||||
|
||||
@@ -2321,10 +2321,15 @@ static bool ed_object_select_pick(bContext *C,
|
||||
WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, basact->object);
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_BASE_FLAGS);
|
||||
|
||||
/* in weightpaint, we use selected bone to select vertexgroup,
|
||||
* so no switch to new active object */
|
||||
/* 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_WEIGHT_PAINT)) {
|
||||
/* prevent activating */
|
||||
/* 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);
|
||||
|
||||
basact = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user