Fix T66949: Can't select bones from multiple objects in wpaint mode

This commit is contained in:
Campbell Barton
2019-07-17 18:28:32 +10:00
parent f8a70db556
commit 9e9fbb39d7
3 changed files with 36 additions and 0 deletions

View File

@@ -382,6 +382,7 @@ struct Object *modifiers_isDeformedByMeshDeform(struct Object *ob);
struct Object *modifiers_isDeformedByLattice(struct Object *ob);
struct Object *modifiers_isDeformedByCurve(struct Object *ob);
bool modifiers_usesArmature(struct Object *ob, struct bArmature *arm);
bool modifiers_usesArmatureObject(struct Object *ob, struct Object *ob_armature);
bool modifiers_usesSubsurfFacedots(struct Scene *scene, struct Object *ob);
bool modifiers_isCorrectableDeformed(struct Scene *scene, struct Object *ob);
void modifier_freeTemporaryData(struct ModifierData *md);

View File

@@ -778,6 +778,23 @@ bool modifiers_usesArmature(Object *ob, bArmature *arm)
return false;
}
bool modifiers_usesArmatureObject(Object *ob, Object *ob_armature)
{
VirtualModifierData virtualModifierData;
ModifierData *md = modifiers_getVirtualModifierList(ob, &virtualModifierData);
for (; md; md = md->next) {
if (md->type == eModifierType_Armature) {
ArmatureModifierData *amd = (ArmatureModifierData *)md;
if (amd->object && amd->object == ob_armature) {
return true;
}
}
}
return false;
}
bool modifiers_usesSubsurfFacedots(struct Scene *scene, Object *ob)
{
/* Search (backward) in the modifier stack to find if we have a subsurf modifier (enabled) before

View File

@@ -72,6 +72,7 @@
#include "BKE_scene.h"
#include "BKE_tracking.h"
#include "BKE_workspace.h"
#include "BKE_modifier.h"
#include "DEG_depsgraph.h"
@@ -2149,6 +2150,12 @@ static bool ed_object_select_pick(bContext *C,
/* In pose mode we don't want to mess with object selection. */
const bool is_pose_mode = (vc.obact && vc.obact->mode & OB_MODE_POSE);
/* Support changing pose objects when the a mesh uses multiple armatures. */
Object *old_obpose = NULL;
if (vc.obact && vc.obact->mode & OB_MODE_WEIGHT_PAINT) {
old_obpose = BKE_object_pose_armature_get(vc.obact);
}
/* always start list from basact in wire mode */
startbase = FIRSTBASE(view_layer);
if (oldbasact && oldbasact->next) {
@@ -2375,6 +2382,17 @@ static bool ed_object_select_pick(bContext *C,
object_deselect_all_except(view_layer, basact);
ED_object_base_select(basact, BA_SELECT);
}
else if (old_obpose && modifiers_usesArmatureObject(oldbasact->object, basact->object)) {
/* The user is in weight-paint mode with an armature selected,
* in this case the user is selecting a new armature which is
* also used by the mesh. In this case use selection to switch
* the pose object, keeping the weight paint object active. */
Base *old_basepose = BKE_view_layer_base_find(view_layer, old_obpose);
if (old_basepose != NULL) {
ED_object_base_select(old_basepose, BA_DESELECT);
}
ED_object_base_select(basact, BA_SELECT);
}
/* also prevent making it active on mouse selection */
else if (BASE_SELECTABLE(v3d, basact)) {
if (extend) {