[Bf-blender-cvs] [5d4bd8f1bb3] master: Fix T66949: Can't select bones from multiple objects in wpaint mode

Campbell Barton noreply at git.blender.org
Thu Jul 18 07:48:23 CEST 2019


Commit: 5d4bd8f1bb3a77f501f03d2ed2fbdcbaf23d516e
Author: Campbell Barton
Date:   Thu Jul 18 14:18:43 2019 +1000
Branches: master
https://developer.blender.org/rB5d4bd8f1bb3a77f501f03d2ed2fbdcbaf23d516e

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.

===================================================================

M	source/blender/editors/armature/pose_select.c
M	source/blender/editors/include/ED_armature.h
M	source/blender/editors/space_view3d/view3d_select.c

===================================================================

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;
           }
         }



More information about the Bf-blender-cvs mailing list