[Bf-blender-cvs] [e07b245fe1f] blender-v2.83-release: Armature posemode: add mouse independent "Select Linked" operator

Philipp Oeser noreply at git.blender.org
Wed Apr 29 11:09:44 CEST 2020


Commit: e07b245fe1f41cab13d772c3e26adc2521126324
Author: Philipp Oeser
Date:   Mon Apr 27 15:41:22 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rBe07b245fe1f41cab13d772c3e26adc2521126324

Armature posemode: add mouse independent "Select Linked" operator

The current "Select Linked" operator works based on mouse position and
makes no sense to call from the menus and was removed in rB536055e1ee0b.

This patch adds an operator independent from mouse position that just
selects all bones in relation to selected bones (and adds back menu
entries, adds keymap entry CTRL+L).

The original operator is renamed to 'select_linked_pick' internally
(this is now more in line to how "Select Linked" works for meshes,
curves etc)

ref T76071

Maniphest Tasks: T76071

Differential Revision: https://developer.blender.org/D7542

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

M	release/scripts/presets/keyconfig/keymap_data/blender_default.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/editors/armature/armature_intern.h
M	source/blender/editors/armature/armature_ops.c
M	source/blender/editors/armature/pose_select.c

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

diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index 7be6ddb5bca..07916fa9799 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -3859,7 +3859,8 @@ def km_pose(params):
          {"properties": [("direction", 'CHILD'), ("extend", False)]}),
         ("pose.select_hierarchy", {"type": 'RIGHT_BRACKET', "value": 'PRESS', "shift": True},
          {"properties": [("direction", 'CHILD'), ("extend", True)]}),
-        ("pose.select_linked", {"type": 'L', "value": 'PRESS'}, None),
+        ("pose.select_linked", {"type": 'L', "value": 'PRESS', "ctrl": True}, None),
+        ("pose.select_linked_pick", {"type": 'L', "value": 'PRESS'}, None),
         ("pose.select_grouped", {"type": 'G', "value": 'PRESS', "shift": True}, None),
         ("pose.select_mirror", {"type": 'M', "value": 'PRESS', "shift": True, "ctrl": True}, None),
         ("pose.constraint_add_with_targets", {"type": 'C', "value": 'PRESS', "shift": True, "ctrl": True}, None),
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index c0a786d9658..5d47566d880 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1469,6 +1469,7 @@ class VIEW3D_MT_select_pose(Menu):
         layout.separator()
 
         layout.operator("pose.select_constraint_target", text="Constraint Target")
+        layout.operator("pose.select_linked", text="Linked")
 
         layout.separator()
 
diff --git a/source/blender/editors/armature/armature_intern.h b/source/blender/editors/armature/armature_intern.h
index 3d41fd5f0c6..08d82bf13c9 100644
--- a/source/blender/editors/armature/armature_intern.h
+++ b/source/blender/editors/armature/armature_intern.h
@@ -104,6 +104,7 @@ void POSE_OT_select_all(struct wmOperatorType *ot);
 void POSE_OT_select_parent(struct wmOperatorType *ot);
 void POSE_OT_select_hierarchy(struct wmOperatorType *ot);
 void POSE_OT_select_linked(struct wmOperatorType *ot);
+void POSE_OT_select_linked_pick(struct wmOperatorType *ot);
 void POSE_OT_select_constraint_target(struct wmOperatorType *ot);
 void POSE_OT_select_grouped(struct wmOperatorType *ot);
 void POSE_OT_select_mirror(struct wmOperatorType *ot);
diff --git a/source/blender/editors/armature/armature_ops.c b/source/blender/editors/armature/armature_ops.c
index b304ce92a54..da1b29307b1 100644
--- a/source/blender/editors/armature/armature_ops.c
+++ b/source/blender/editors/armature/armature_ops.c
@@ -100,6 +100,7 @@ void ED_operatortypes_armature(void)
   WM_operatortype_append(POSE_OT_select_parent);
   WM_operatortype_append(POSE_OT_select_hierarchy);
   WM_operatortype_append(POSE_OT_select_linked);
+  WM_operatortype_append(POSE_OT_select_linked_pick);
   WM_operatortype_append(POSE_OT_select_constraint_target);
   WM_operatortype_append(POSE_OT_select_grouped);
   WM_operatortype_append(POSE_OT_select_mirror);
diff --git a/source/blender/editors/armature/pose_select.c b/source/blender/editors/armature/pose_select.c
index 41ad5433931..ce652b0eaf4 100644
--- a/source/blender/editors/armature/pose_select.c
+++ b/source/blender/editors/armature/pose_select.c
@@ -454,22 +454,22 @@ static int pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEve
   return OPERATOR_FINISHED;
 }
 
-static bool pose_select_linked_poll(bContext *C)
+static bool pose_select_linked_pick_poll(bContext *C)
 {
   return (ED_operator_view3d_active(C) && ED_operator_posemode(C));
 }
 
-void POSE_OT_select_linked(wmOperatorType *ot)
+void POSE_OT_select_linked_pick(wmOperatorType *ot)
 {
   /* identifiers */
   ot->name = "Select Connected";
-  ot->idname = "POSE_OT_select_linked";
-  ot->description = "Select bones related to selected ones by parent/child relationships";
+  ot->idname = "POSE_OT_select_linked_pick";
+  ot->description = "Select bones linked by parent/child connections under the mouse cursor";
 
   /* callbacks */
   /* leave 'exec' unset */
   ot->invoke = pose_select_connected_invoke;
-  ot->poll = pose_select_linked_poll;
+  ot->poll = pose_select_linked_pick_poll;
 
   /* flags */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -482,6 +482,62 @@ void POSE_OT_select_linked(wmOperatorType *ot)
                   "Extend selection instead of deselecting everything first");
 }
 
+static int pose_select_linked_exec(bContext *C, wmOperator *UNUSED(op))
+{
+  Bone *curBone, *next = NULL;
+
+  CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
+    if ((pchan->bone->flag & BONE_SELECTED) == 0) {
+      continue;
+    }
+
+    bArmature *arm = ob->data;
+
+    /* Select parents */
+    for (curBone = pchan->bone; curBone; curBone = next) {
+      if (PBONE_SELECTABLE(arm, curBone)) {
+        curBone->flag |= BONE_SELECTED;
+
+        if (curBone->flag & BONE_CONNECTED) {
+          next = curBone->parent;
+        }
+        else {
+          next = NULL;
+        }
+      }
+      else {
+        next = NULL;
+      }
+    }
+
+    /* Select children */
+    for (curBone = pchan->bone->childbase.first; curBone; curBone = curBone->next) {
+      selectconnected_posebonechildren(ob, curBone, false);
+    }
+    ED_pose_bone_select_tag_update(ob);
+  }
+  CTX_DATA_END;
+
+  ED_outliner_select_sync_from_pose_bone_tag(C);
+
+  return OPERATOR_FINISHED;
+}
+
+void POSE_OT_select_linked(wmOperatorType *ot)
+{
+  /* identifiers */
+  ot->name = "Select Connected";
+  ot->idname = "POSE_OT_select_linked";
+  ot->description = "Select all bones linked by parent/child connections to the current selection";
+
+  /* callbacks */
+  ot->exec = pose_select_linked_exec;
+  ot->poll = ED_operator_posemode;
+
+  /* flags */
+  ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
 /* -------------------------------------- */
 
 static int pose_de_select_all_exec(bContext *C, wmOperator *op)



More information about the Bf-blender-cvs mailing list