Fix weight-paint & pose-select & lock-mode combination
authorCampbell Barton <ideasman42@gmail.com>
Thu, 18 Jul 2019 05:31:04 +0000 (15:31 +1000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 18 Jul 2019 05:42:14 +0000 (15:42 +1000)
Extend pose object checks to all pose-mode objects
used by the mesh.

source/blender/editors/space_view3d/view3d_view.c

index 5865efa0ffa7b5240da68aec3586455f0ac44457..c0902cd1cd559a92ee24d2cdd92b516d4fa42b4a 100644 (file)
@@ -30,6 +30,7 @@
 #include "BLI_math.h"
 #include "BLI_rect.h"
 #include "BLI_utildefines.h"
+#include "BLI_linklist.h"
 
 #include "BKE_action.h"
 #include "BKE_camera.h"
@@ -38,6 +39,7 @@
 #include "BKE_global.h"
 #include "BKE_layer.h"
 #include "BKE_main.h"
+#include "BKE_modifier.h"
 #include "BKE_report.h"
 #include "BKE_scene.h"
 
@@ -962,8 +964,8 @@ static bool drw_select_filter_object_mode_lock(Object *ob, void *user_data)
  * we want to select pose bones (this doesn't switch modes). */
 static bool drw_select_filter_object_mode_lock_for_weight_paint(Object *ob, void *user_data)
 {
-  const Object *ob_pose = user_data;
-  return (DEG_get_original_object(ob) == ob_pose);
+  LinkNode *ob_pose_list = user_data;
+  return ob_pose_list && (BLI_linklist_index(ob_pose_list, DEG_get_original_object(ob)) != -1);
 }
 
 /**
@@ -1044,10 +1046,22 @@ int view3d_opengl_select(ViewContext *vc,
     case VIEW3D_SELECT_FILTER_WPAINT_POSE_MODE_LOCK: {
       Object *obact = vc->obact;
       BLI_assert(obact && (obact->mode & OB_MODE_WEIGHT_PAINT));
-      Object *ob_pose = BKE_object_pose_armature_get(obact);
 
+      /* While this uses 'alloca' in a loop (which we typically avoid),
+       * the number of items is nearly always 1, maybe 2..3 in rare cases. */
+      LinkNode *ob_pose_list = NULL;
+      VirtualModifierData virtualModifierData;
+      const ModifierData *md = modifiers_getVirtualModifierList(obact, &virtualModifierData);
+      for (; md; md = md->next) {
+        if (md->type == eModifierType_Armature) {
+          ArmatureModifierData *amd = (ArmatureModifierData *)md;
+          if (amd->object && (amd->object->mode & OB_MODE_POSE)) {
+            BLI_linklist_prepend_alloca(&ob_pose_list, amd->object);
+          }
+        }
+      }
       object_filter.fn = drw_select_filter_object_mode_lock_for_weight_paint;
-      object_filter.user_data = ob_pose;
+      object_filter.user_data = ob_pose_list;
       break;
     }
     case VIEW3D_SELECT_FILTER_NOP: