Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-07-18 07:18:43 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-07-18 08:45:39 +0300
commit5d4bd8f1bb3a77f501f03d2ed2fbdcbaf23d516e (patch)
treeca7121ae5c9a1ea901195772d8d9bfdee0be430f
parentbf8393c1c9d7af85b8efd0697b9d52747fcc8123 (diff)
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.
-rw-r--r--source/blender/editors/armature/pose_select.c33
-rw-r--r--source/blender/editors/include/ED_armature.h4
-rw-r--r--source/blender/editors/space_view3d/view3d_select.c11
3 files changed, 45 insertions, 3 deletions
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 5c20b03b908..8434fee6e78 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -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). */
diff --git a/source/blender/editors/include/ED_armature.h b/source/blender/editors/include/ED_armature.h
index 60634cbebbf..6629eed8328 100644
--- a/source/blender/editors/include/ED_armature.h
+++ b/source/blender/editors/include/ED_armature.h
@@ -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);
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index e39bd3f945f..61de61c8e31 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -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;
}
}