Blender V5.3
pose_select.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2001-2002 NaN Holding BV. All rights reserved.
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cstring>
10
11#include "DNA_action_types.h"
12#include "DNA_anim_types.h"
13#include "DNA_armature_types.h"
15#include "DNA_object_types.h"
16#include "DNA_scene_types.h"
18
19#include "BLI_assert.hh"
20#include "BLI_listbase.hh"
21#include "BLI_map.hh"
22#include "BLI_string.hh"
23
24#include "BKE_action.hh"
25#include "BKE_armature.hh"
26#include "BKE_constraint.h"
27#include "BKE_context.hh"
28#include "BKE_layer.hh"
29#include "BKE_modifier.hh"
30#include "BKE_object.hh"
31#include "BKE_pose.hh"
32#include "BKE_report.hh"
33
34#include "DEG_depsgraph.hh"
35
36#include "RNA_access.hh"
37#include "RNA_define.hh"
38#include "RNA_types.hh"
39
40#include "WM_api.hh"
41#include "WM_types.hh"
42
43#include "ED_armature.hh"
44#include "ED_keyframing.hh"
45#include "ED_mesh.hh"
46#include "ED_object.hh"
47#include "ED_object_vgroup.hh"
48#include "ED_outliner.hh"
49#include "ED_screen.hh"
50#include "ED_select_utils.hh"
51#include "ED_view3d.hh"
52
53#include "ANIM_armature.hh"
54#include "ANIM_bonecolor.hh"
55#include "ANIM_keyingsets.hh"
56
57#include "armature_intern.hh"
58
59namespace blender {
60
61/* ***************** Pose Select Utilities ********************* */
62
63/* NOTE: SEL_TOGGLE is assumed to have already been handled! */
64static void pose_do_bone_select(const bke::PChanBone pchanbone, const int select_mode)
65{
66 bPoseChannel *pchan = pchanbone.pchan;
67 const Bone *bone = pchanbone.bone;
68
69 /* select pchan only if selectable, but deselect works always */
70 switch (select_mode) {
71 case SEL_SELECT:
72 if (!(bone->flag & BONE_UNSELECTABLE)) {
74 }
75 break;
76 case SEL_DESELECT:
78 break;
79 case SEL_INVERT:
80 if (pchan->flag & POSE_SELECTED) {
82 }
83 else if (!(bone->flag & BONE_UNSELECTABLE)) {
85 }
86 break;
87 }
88}
89
90/* Useful to get the selection before modifying it. */
92{
93 Set<bPoseChannel *> selected_pose_bones;
94 bArmature *arm = id_cast<bArmature *>(pose_object.data);
95 for (bPoseChannel &pchan : pose_object.pose->chanbase) {
96 if (animrig::bone_is_selected(arm, {&pchan, pchan.bone_get(pose_object)})) {
97 selected_pose_bones.add(&pchan);
98 }
99 }
100 return selected_pose_bones;
101}
102
108 const Set<bPoseChannel *> &potential_parents)
109{
110 bPoseChannel *bone_iter = bone.parent;
111 while (bone_iter) {
112 if (potential_parents.contains(bone_iter)) {
113 return true;
114 }
115 bone_iter = bone_iter->parent;
116 }
117 return false;
118}
119
120static void deselect_pose_bones(const Set<bPoseChannel *> &pose_bones)
121{
122 for (bPoseChannel *pose_bone : pose_bones) {
123 if (!pose_bone) {
124 /* There may be a nullptr in the set if selecting siblings of root bones. */
125 continue;
126 }
127 animrig::bone_deselect(pose_bone);
128 }
129}
130
131static bool any_parent_to_select(const Set<bPoseChannel *> &pose_bones)
132{
133 for (bPoseChannel *pose_bone : pose_bones) {
134 if (pose_bone->parent != nullptr) {
135 return true;
136 }
137 }
138 return false;
139}
140
144static bool any_child_to_select(const Set<bPoseChannel *> &pose_bones, const bArmature &armature)
145{
146 for (bPoseChannel *pose_bone : pose_bones) {
147 const Bone *bone = pose_bone->bone_get(armature);
148 if (!bone->childbase.is_empty()) {
149 return true;
150 }
151 }
152 return false;
153}
154
162 const bool extend,
163 const bool stop_at_root,
164 const bool modify_active)
165{
168
169 bool changed_any_selection = false;
170 for (Object *pose_object : objects) {
171 bArmature *arm = id_cast<bArmature *>(pose_object->data);
172 BLI_assert(arm);
173 Bone *active_bone = arm->act_bone;
174 Set<bPoseChannel *> selected_pose_bones = get_selected_pose_bones(*pose_object);
175 if (stop_at_root && !any_parent_to_select(selected_pose_bones)) {
176 continue;
177 }
178 if (!extend) {
179 deselect_pose_bones(selected_pose_bones);
180 }
181 for (bPoseChannel *pchan : selected_pose_bones) {
182 if (!pchan->parent) {
183 continue;
184 }
185 Bone *parent_bone = pchan->parent->bone_get(*arm);
186 if (!animrig::bone_is_selectable(arm, parent_bone)) {
187 continue;
188 }
189 pose_do_bone_select({pchan->parent, parent_bone}, SEL_SELECT);
190 if (modify_active && pchan->bone_get(*arm) == active_bone) {
191 arm->act_bone = parent_bone;
192 }
193 changed_any_selection = true;
194 }
196 }
197 return changed_any_selection;
198}
199
204static Bone *get_new_active_child(Bone &parent_bone)
205{
206 for (Bone &child : parent_bone.childbase) {
207 if (child.flag & BONE_CONNECTED) {
208 return &child;
209 }
210 }
211 return parent_bone.childbase.first();
212}
213
224 const bool all,
225 const bool extend,
226 const bool stop_at_leaf,
227 const bool modify_active)
228{
231
232 bool changed_any_selection = false;
233
234 for (Object *pose_object : objects) {
235 bArmature *arm = id_cast<bArmature *>(pose_object->data);
236 BLI_assert(arm);
237 Bone *active_bone = arm->act_bone;
238 Set<bPoseChannel *> selected_pose_bones = get_selected_pose_bones(*pose_object);
239 if (stop_at_leaf && !any_child_to_select(selected_pose_bones, *arm)) {
240 continue;
241 }
242 if (!extend) {
243 deselect_pose_bones(selected_pose_bones);
244 }
245 for (bPoseChannel &pchan : pose_object->pose->chanbase) {
246 if (!animrig::bone_is_selectable(arm, &pchan)) {
247 continue;
248 }
249 Bone *bone = pchan.bone_get(*arm);
250 if (all) {
251 if (pose_bone_is_below_one_of(pchan, selected_pose_bones)) {
252 pose_do_bone_select({&pchan, bone}, SEL_SELECT);
253 Bone *parent_bone = pchan.parent->bone_get(*arm);
254 if (modify_active && parent_bone == active_bone) {
255 arm->act_bone = get_new_active_child(*parent_bone);
256 }
257 changed_any_selection = true;
258 }
259 }
260 else {
261 if (selected_pose_bones.contains(pchan.parent)) {
262 pose_do_bone_select({&pchan, bone}, SEL_SELECT);
263 Bone *parent_bone = pchan.parent->bone_get(*arm);
264 if (modify_active && parent_bone == active_bone) {
265 arm->act_bone = get_new_active_child(*parent_bone);
266 }
267 changed_any_selection = true;
268 }
269 }
270 }
272 }
273
274 return changed_any_selection;
275}
276
278{
280 bArmature *arm = id_cast<bArmature *>(ob->data);
283
284 if (arm->flag & ARM_HAS_VIZ_DEPS) {
285 /* mask modifier ('armature' mode), etc. */
287 }
288
290}
291
292void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select, bool change_active)
293{
294 bArmature *arm;
295
296 /* sanity checks */
297 if (ELEM(nullptr, ob, ob->pose, pchan)) {
298 return;
299 }
300
301 Bone *bone = pchan->bone_get(*ob);
302 if (!bone) {
303 return;
304 }
305
306 arm = id_cast<bArmature *>(ob->data);
307
308 /* can only change selection state if bone can be modified */
309 if (animrig::bone_is_selectable(arm, {pchan, bone})) {
310 /* change selection state - activate too if selected */
311 if (select) {
313 if (change_active) {
314 arm->act_bone = bone;
315 }
316 }
317 else {
319 if (change_active) {
320 arm->act_bone = nullptr;
321 }
322 }
323
324 /* TODO: select and activate corresponding vgroup? */
326 }
327}
328
330 const Scene *scene,
331 ViewLayer *view_layer,
332 View3D *v3d,
333 Object *ob,
334 bPoseChannel *pchan,
335 const SelectPick_Params &params)
336{
337 bool found = false;
338 bool changed = false;
339
340 if (ob->pose && pchan) {
341 /* TODO: just use animrig::bone_is_selectable(). */
342 const Bone *bone = pchan->bone_get(*ob);
343 if (bone && ((bone->flag & BONE_UNSELECTABLE) == 0)) {
344 found = true;
345 }
346 }
347
348 if (params.sel_op == SEL_OP_SET) {
349 if ((found && params.select_passthrough) && (pchan->flag & POSE_SELECTED)) {
350 found = false;
351 }
352 else if (found || params.deselect_all) {
353 /* Deselect everything. */
354 /* Don't use #BKE_object_pose_base_array_get_unique
355 * because we may be selecting from object mode. */
356 FOREACH_VISIBLE_BASE_BEGIN (&bmain, scene, view_layer, v3d, base_iter) {
357 Object *ob_iter = base_iter->object;
358 if ((ob_iter->type == OB_ARMATURE) && (ob_iter->mode & OB_MODE_POSE)) {
359 if (ED_pose_deselect_all(ob_iter, SEL_DESELECT, true)) {
361 }
362 }
363 }
365 changed = true;
366 }
367 }
368
369 if (found) {
370 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
371 Object *ob_act = BKE_view_layer_active_object_get(view_layer);
372 BLI_assert(BKE_view_layer_edit_object_get(view_layer) == nullptr);
373
374 /* If the bone cannot be affected, don't do anything. */
375 bArmature *arm = id_cast<bArmature *>(ob->data);
376
377 /* Since we do unified select, we don't shift+select a bone if the
378 * armature object was not active yet.
379 * NOTE(@ideasman42): special exception for armature mode so we can do multi-select
380 * we could check for multi-select explicitly but think its fine to
381 * always give predictable behavior in weight paint mode. */
382 if ((ob_act == nullptr) || ((ob_act != ob) && (ob_act->mode & OB_MODE_ALL_WEIGHT_PAINT) == 0))
383 {
384 /* When we are entering into posemode via toggle-select,
385 * from another active object - always select the bone. */
386 if (params.sel_op == SEL_OP_SET) {
387 /* Re-select the bone again later in this function. */
389 }
390 }
391
392 Bone *pchan_bone = pchan->bone_get(*ob);
393 switch (params.sel_op) {
394 case SEL_OP_ADD: {
396 arm->act_bone = pchan_bone;
397 break;
398 }
399 case SEL_OP_SUB: {
401 break;
402 }
403 case SEL_OP_XOR: {
404 if (pchan->flag & POSE_SELECTED) {
405 /* If not active, we make it active. */
406 if (pchan_bone != arm->act_bone) {
407 arm->act_bone = pchan_bone;
408 }
409 else {
411 }
412 }
413 else {
415 arm->act_bone = pchan_bone;
416 }
417 break;
418 }
419 case SEL_OP_SET: {
421 arm->act_bone = pchan_bone;
422 break;
423 }
424 case SEL_OP_AND: {
425 BLI_assert_unreachable(); /* Doesn't make sense for picking. */
426 break;
427 }
428 }
429
430 if (ob_act) {
431 /* In weight-paint we select the associated vertex group too. */
432 if (ob_act->mode & OB_MODE_ALL_WEIGHT_PAINT) {
433 const Bone *bone = pchan->bone_get(*ob);
434 if (bone && bone == arm->act_bone) {
437 }
438 }
439 /* If there are some dependencies for visualizing armature state
440 * (e.g. Mask Modifier in 'Armature' mode), force update.
441 */
442 else if (arm->flag & ARM_HAS_VIZ_DEPS) {
443 /* NOTE: ob not ob_act here is intentional - it's the source of the
444 * bones being selected [#37247].
445 */
447 }
448
449 /* Tag armature for copy-on-evaluation update (since act_bone is in armature not object). */
451 }
452
453 changed = true;
454 }
455
456 return changed || found;
457}
458
460 const Scene *scene,
461 ViewLayer *view_layer,
462 View3D *v3d,
463 Base *base,
464 const GPUSelectResult *hit_results,
465 const int hits,
466 const SelectPick_Params &params,
467 bool do_nearest)
468{
469 Object *ob = base->object;
470 bPoseChannel *nearBone;
471
472 if (!ob || !ob->pose) {
473 return false;
474 }
475
476 /* Callers happen to already get the active base */
477 Base *base_dummy = nullptr;
479 {base}, hit_results, hits, true, do_nearest, &base_dummy);
480
481 return ED_armature_pose_select_pick_bone(bmain, scene, view_layer, v3d, ob, nearBone, params);
482}
483
485 const Scene *scene,
486 ViewLayer *view_layer,
487 Base *base_select)
488{
489 BLI_assert(base_select && (base_select->object->type == OB_ARMATURE));
490 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
491 Object *ob_active = BKE_view_layer_active_object_get(view_layer);
492 BLI_assert(ob_active && (ob_active->mode & OB_MODE_ALL_WEIGHT_PAINT));
493
494 VirtualModifierData virtual_modifier_data;
495 ModifierData *md = BKE_modifiers_get_virtual_modifierlist(ob_active, &virtual_modifier_data);
496 for (; md; md = md->next) {
497 if (md->type == eModifierType_Armature) {
498 ArmatureModifierData *amd = reinterpret_cast<ArmatureModifierData *>(md);
499 Object *ob_arm = amd->object;
500 if (ob_arm != nullptr) {
501 Base *base_arm = BKE_view_layer_base_find(view_layer, ob_arm);
502 if ((base_arm != nullptr) && (base_arm != base_select) && (base_arm->flag & BASE_SELECTED))
503 {
505 }
506 }
507 }
508 }
509 if ((base_select->flag & BASE_SELECTED) == 0) {
511 }
512}
513
514bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibility)
515{
516 bArmature *arm = id_cast<bArmature *>(ob->data);
517
518 /* we call this from outliner too */
519 if (ob->pose == nullptr) {
520 return false;
521 }
522
523 /* Determine if we're selecting or deselecting */
524 if (select_mode == SEL_TOGGLE) {
525 select_mode = SEL_SELECT;
526 for (bPoseChannel &pchan : ob->pose->chanbase) {
527 if (ignore_visibility || animrig::bone_is_visible(arm, {&pchan, pchan.bone_get(*ob)})) {
528 if (pchan.flag & POSE_SELECTED) {
529 select_mode = SEL_DESELECT;
530 break;
531 }
532 }
533 }
534 }
535
536 /* Set the flags accordingly */
537 bool changed = false;
538 for (bPoseChannel &pchan : ob->pose->chanbase) {
539 Bone *bone = pchan.bone_get(*ob);
540 if (!bone) {
541 /* Ignore the pchan if it doesn't have a corresponding bone. */
542 continue;
543 }
544 /* ignore the pchan if it isn't visible or if its selection cannot be changed */
545 if (ignore_visibility || animrig::bone_is_visible(arm, {&pchan, bone})) {
546 int flag_prev = pchan.flag;
547 pose_do_bone_select({&pchan, bone}, select_mode);
548 changed = (changed || flag_prev != pchan.flag);
549 }
550 }
551 return changed;
552}
553
554static bool ed_pose_is_any_selected(Object *ob, bool ignore_visibility)
555{
556 bArmature *arm = id_cast<bArmature *>(ob->data);
557 for (bPoseChannel &pchan : ob->pose->chanbase) {
558 if (ignore_visibility || animrig::bone_is_visible(arm, {&pchan, pchan.bone_get(*ob)})) {
559 if (pchan.flag & POSE_SELECTED) {
560 return true;
561 }
562 }
563 }
564 return false;
565}
566
567static bool ed_pose_is_any_selected_multi(const Span<Base *> bases, bool ignore_visibility)
568{
569 for (Base *base : bases) {
570 Object *ob_iter = base->object;
571 if (ed_pose_is_any_selected(ob_iter, ignore_visibility)) {
572 return true;
573 }
574 }
575 return false;
576}
577
579 int select_mode,
580 const bool ignore_visibility)
581{
582 if (select_mode == SEL_TOGGLE) {
583 select_mode = ed_pose_is_any_selected_multi(bases, ignore_visibility) ? SEL_DESELECT :
585 }
586
587 bool changed_multi = false;
588 for (Base *base : bases) {
589 Object *ob_iter = base->object;
590 if (ED_pose_deselect_all(ob_iter, select_mode, ignore_visibility)) {
592 changed_multi = true;
593 }
594 }
595 return changed_multi;
596}
597
598bool ED_pose_deselect_all_multi(bContext *C, int select_mode, const bool ignore_visibility)
599{
600 Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
602
604 *vc.bmain, vc.scene, vc.view_layer, vc.v3d);
605 return ED_pose_deselect_all_multi_ex(bases, select_mode, ignore_visibility);
606}
607
608/* ***************** Selections ********************** */
609
611 bPoseChannel &pose_bone,
612 const bool extend)
613{
614 animrig::pose_bone_descendent_depth_iterator(ob, pose_bone, [&](bPoseChannel &pose_child) {
615 Bone *bone_child = pose_child.bone_get(ob);
616 if (!bone_child) {
618 return false;
619 }
620 /* pose_bone_descendent_depth_iterator also visits `pose_bone` itself, and that should
621 * always be (de)selected, because it's always "connected" to itself. */
622 const bool is_input_bone = (&pose_child == &pose_bone);
623 const bool is_connected = is_input_bone || (bone_child->flag & BONE_CONNECTED);
624 const bool is_selectable = (bone_child->flag & BONE_UNSELECTABLE) == 0;
625 const bool is_ok = is_selectable && is_connected;
626 if (!is_ok) {
627 /* Stop when unconnected child or unselectable bone is encountered. */
628 return false;
629 }
630
631 if (extend) {
632 animrig::bone_deselect(&pose_child);
633 }
634 else {
635 animrig::bone_select(&pose_child);
636 }
637 return true;
638 });
639}
640
641/* within active object context */
642/* previously known as "selectconnected_posearmature" */
644 wmOperator *op,
645 const wmEvent *event)
646{
647 bPoseChannel *pchan, *curPChan, *next = nullptr;
648 const bool extend = RNA_boolean_get(op->ptr, "extend");
649
651
652 Base *base = nullptr;
653 pchan = ED_armature_pick_pchan(C, event->mval, !extend, &base);
654
655 if (!pchan) {
656 return OPERATOR_CANCELLED;
657 }
658
659 /* Select parents */
660 Object *ob = base->object;
661 for (curPChan = pchan; curPChan; curPChan = next) {
662 /* ignore bone if cannot be selected */
663 Bone *curBone = curPChan->bone_get(*ob);
664 if ((curBone->flag & BONE_UNSELECTABLE) == 0) {
665 if (extend) {
666 animrig::bone_deselect(curPChan);
667 }
668 else {
669 animrig::bone_select(curPChan);
670 }
671
672 if (curBone->flag & BONE_CONNECTED) {
673 next = curPChan->parent;
674 }
675 else {
676 next = nullptr;
677 }
678 }
679 else {
680 next = nullptr;
681 }
682 }
683
684 /* Select children */
685 selectconnected_posebonechildren(*base->object, *pchan, extend);
686
688
690
691 return OPERATOR_FINISHED;
692}
693
698
700{
701 PropertyRNA *prop;
702
703 /* identifiers */
704 ot->name = "Select Connected";
705 ot->idname = "POSE_OT_select_linked_pick";
706 ot->description =
707 "Select bones linked by connected parent/child relationships under the mouse cursor";
708
709 /* callbacks */
710 /* leave 'exec' unset */
713
714 /* flags */
716
717 /* props */
718 prop = RNA_def_boolean(ot->srna,
719 "extend",
720 false,
721 "Extend",
722 "Extend selection instead of deselecting everything first");
724}
725
727{
728 bPoseChannel *curBone, *next = nullptr;
729
730 CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
731 if ((pchan->flag & POSE_SELECTED) == 0) {
732 continue;
733 }
734
735 bArmature *arm = id_cast<bArmature *>(ob->data);
736
737 /* Select parents */
738 for (curBone = pchan; curBone; curBone = next) {
739 if (animrig::bone_is_selectable(arm, curBone)) {
740 animrig::bone_select(curBone);
741
742 if (curBone->bone_get(*ob)->flag & BONE_CONNECTED) {
743 next = curBone->parent;
744 }
745 else {
746 next = nullptr;
747 }
748 }
749 else {
750 next = nullptr;
751 }
752 }
753
754 /* Select children */
755 selectconnected_posebonechildren(*ob, *pchan, false);
757 }
759
761
762 return OPERATOR_FINISHED;
763}
764
766{
767 /* identifiers */
768 ot->name = "Select Connected";
769 ot->idname = "POSE_OT_select_linked";
770 ot->description =
771 "Select all bones linked by connected parent/child relationships from the current selection";
772
773 /* callbacks */
776
777 /* flags */
779}
780
781/* -------------------------------------- */
782
784{
785 int action = RNA_enum_get(op->ptr, "action");
786
787 Scene *scene = CTX_data_scene(C);
788 int multipaint = scene->toolsettings->multipaint;
789
790 if (action == SEL_TOGGLE) {
791 action = CTX_DATA_COUNT(C, selected_pose_bones) ? SEL_DESELECT : SEL_SELECT;
792 }
793
794 Object *ob_prev = nullptr;
795
796 /* Set the flags. */
797 CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
798 bArmature *arm = id_cast<bArmature *>(ob->data);
799 Bone *bone = pchan->bone_get(*ob);
800 pose_do_bone_select({pchan, bone}, action);
801
802 if (ob_prev != ob) {
803 /* Weight-paint or mask modifiers need depsgraph updates. */
804 if (multipaint || (arm->flag & ARM_HAS_VIZ_DEPS)) {
806 }
807 /* need to tag armature for cow updates, or else selection doesn't update */
809 ob_prev = ob;
810 }
811 }
813
815
817
818 return OPERATOR_FINISHED;
819}
820
822{
823 /* identifiers */
824 ot->name = "(De)select All";
825 ot->idname = "POSE_OT_select_all";
826 ot->description = "Toggle selection status of all bones";
827
828 /* API callbacks. */
831
832 /* flags */
834
836}
837
838/* -------------------------------------- */
839
841{
843 bArmature *arm = id_cast<bArmature *>(ob->data);
844 bPoseChannel *pchan, *parent;
845
846 /* Determine if there is an active bone */
848 if (pchan) {
849 parent = pchan->parent;
850 if (!parent || (parent->drawflag & PCHAN_DRAW_HIDDEN)) {
851 return OPERATOR_CANCELLED;
852 }
853
854 Bone *bone = pchan->bone_get(*ob);
855 if (!(bone->flag & BONE_UNSELECTABLE)) {
856 animrig::bone_select(parent);
857 arm->act_bone = bone;
858 }
859 else {
860 return OPERATOR_CANCELLED;
861 }
862 }
863 else {
864 return OPERATOR_CANCELLED;
865 }
866
868
870 return OPERATOR_FINISHED;
871}
872
874{
875 /* identifiers */
876 ot->name = "Select Parent Bone";
877 ot->idname = "POSE_OT_select_parent";
878 ot->description = "Select bones that are parents of the currently selected bones";
879
880 /* API callbacks. */
883
884 /* flags */
886}
887
888/* -------------------------------------- */
889
891{
892 bool found = false;
893
894 CTX_DATA_BEGIN (C, bPoseChannel *, pchan, visible_pose_bones) {
895 if (pchan->flag & POSE_SELECTED) {
896 for (bConstraint &con : pchan->constraints) {
897 ListBaseT<bConstraintTarget> targets = {nullptr, nullptr};
898 if (BKE_constraint_targets_get(&con, &targets)) {
899 for (bConstraintTarget &ct : targets) {
900 Object *ob = ct.tar;
901
902 /* Any armature that is also in pose mode should be selected. */
903 if ((ct.subtarget[0] != '\0') && (ob != nullptr) && (ob->type == OB_ARMATURE) &&
904 (ob->mode == OB_MODE_POSE))
905 {
906 bPoseChannel *pchanc = BKE_pose_channel_find_name(ob->pose, ct.subtarget);
907 if ((pchanc) && !(pchanc->bone_get(*ob)->flag & BONE_UNSELECTABLE)) {
908 animrig::bone_select(pchanc);
910 found = true;
911 }
912 }
913 }
914
915 BKE_constraint_targets_flush(&con, &targets, true);
916 }
917 }
918 }
919 }
921
922 if (!found) {
923 return OPERATOR_CANCELLED;
924 }
925
927
928 return OPERATOR_FINISHED;
929}
930
932{
933 /* identifiers */
934 ot->name = "Select Constraint Target";
935 ot->idname = "POSE_OT_select_constraint_target";
936 ot->description = "Select bones used as targets for the currently selected bones";
937
938 /* API callbacks. */
941
942 /* flags */
944}
945
946/* -------------------------------------- */
947
948/* No need to convert to multi-objects. Just like we keep the non-active bones
949 * selected we then keep the non-active objects untouched (selected/unselected). */
951{
952 const int direction = RNA_enum_get(op->ptr, "direction");
953 const bool extend = RNA_boolean_get(op->ptr, "extend");
954 bool changed = false;
955
956 if (direction == BONE_SELECT_PARENT) {
957 changed = pose_select_parents(C, extend, /* stop_at_root= */ true, /* modify_active= */ true);
958 }
959 else { /* direction == BONE_SELECT_CHILD */
960 changed = pose_select_children(C,
961 /* all= */ false,
962 extend,
963 /* stop_at_leaf= */ true,
964 /* modify_active= */ true);
965 }
966
967 if (changed == false) {
968 return OPERATOR_CANCELLED;
969 }
970
972
973 return OPERATOR_FINISHED;
974}
975
977{
978 static const EnumPropertyItem direction_items[] = {
979 {BONE_SELECT_PARENT, "PARENT", 0, "Select Parent", ""},
980 {BONE_SELECT_CHILD, "CHILD", 0, "Select Child", ""},
981 {0, nullptr, 0, nullptr, nullptr},
982 };
983
984 /* identifiers */
985 ot->name = "Select Hierarchy";
986 ot->idname = "POSE_OT_select_hierarchy";
987 ot->description = "Select immediate parent/children of selected bones";
988
989 /* API callbacks. */
992
993 /* flags */
995
996 /* props */
997 ot->prop = RNA_def_enum(
998 ot->srna, "direction", direction_items, BONE_SELECT_PARENT, "Direction", "");
999 RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
1000}
1001
1002/* -------------------------------------- */
1003
1004/* Modes for the `select_grouped` operator. */
1014
1015static bool pose_select_same_color(bContext *C, const bool extend)
1016{
1017 /* Get a set of all the colors of the selected bones. */
1018 Set<animrig::BoneColor> used_colors;
1019 Set<Object *> updated_objects;
1020 bool changed_any_selection = false;
1021
1022 /* Old approach that we may want to reinstate behind some option at some point. This will match
1023 * against the colors of all selected bones, instead of just the active one. It also explains why
1024 * there is a set of colors to begin with.
1025 *
1026 * CTX_DATA_BEGIN (C, bPoseChannel *, pchan, selected_pose_bones) {
1027 * auto color = animrig::ANIM_bonecolor_posebone_get(pchan);
1028 * used_colors.add(color);
1029 * }
1030 * CTX_DATA_END;
1031 */
1032 if (!extend) {
1033 CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
1035 updated_objects.add(ob);
1036 changed_any_selection = true;
1037 }
1039 }
1040
1041 /* Use the color of the active pose bone. */
1042 PointerRNA active_pose_bone_ptr = CTX_data_active_pose_bone_ptr(C);
1043 Object *pose_ob = id_cast<Object *>(active_pose_bone_ptr.owner_id);
1044 bPoseChannel *active_pose_bone = active_pose_bone_ptr.data_as<bPoseChannel>();
1045 Bone *active_bone = active_pose_bone->bone_get(*pose_ob);
1046 auto color = animrig::ANIM_bonecolor_posebone_get({active_pose_bone, active_bone});
1047 used_colors.add(color);
1048
1049 /* Select all visible bones that have the same color. */
1050 CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
1051 Bone *bone = pchan->bone_get(*ob);
1052 if ((bone->flag & BONE_UNSELECTABLE) && (pchan->flag & POSE_SELECTED)) {
1053 /* Skip bones that are unselectable or already selected. */
1054 continue;
1055 }
1056
1057 auto color = animrig::ANIM_bonecolor_posebone_get({pchan, bone});
1058 if (!used_colors.contains(color)) {
1059 continue;
1060 }
1061
1062 animrig::bone_select(pchan);
1063 changed_any_selection = true;
1064 updated_objects.add(ob);
1065 }
1067
1068 if (!changed_any_selection) {
1069 return false;
1070 }
1071
1072 for (Object *ob : updated_objects) {
1074 }
1075 return true;
1076}
1077
1078static bool pose_select_same_collection(bContext *C, const bool extend)
1079{
1080 bool changed_any_selection = false;
1081 Set<Object *> updated_objects;
1082
1083 /* Refuse to do anything if there is no active pose bone. */
1084 PointerRNA active_pchan_ptr = CTX_data_active_pose_bone_ptr(C);
1085 bPoseChannel *active_pchan = active_pchan_ptr.data_as<bPoseChannel>();
1086 if (!active_pchan) {
1087 return false;
1088 }
1089
1090 if (!extend) {
1091 /* Deselect all the bones. */
1092 CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) {
1094 updated_objects.add(ob);
1095 changed_any_selection = true;
1096 }
1098 }
1099
1100 /* Build a set of bone collection names, to allow cross-Armature selection. */
1101 Object *obpose = id_cast<Object *>(active_pchan_ptr.owner_id);
1102 Bone *active_bone = active_pchan->bone_get(*obpose);
1103 BLI_assert(active_bone);
1104
1105 Set<std::string> collection_names;
1106 for (BoneCollectionReference &bcoll_ref : active_bone->runtime.collections) {
1107 collection_names.add(bcoll_ref.bcoll->name);
1108 }
1109
1110 /* Select all bones that match any of the collection names. */
1111 CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, ob) {
1112 Bone *bone = pchan->bone_get(*ob);
1113 if ((pchan->flag & POSE_SELECTED) && bone->flag & BONE_UNSELECTABLE) {
1114 continue;
1115 }
1116
1117 for (BoneCollectionReference &bcoll_ref : bone->runtime.collections) {
1118 if (!collection_names.contains(bcoll_ref.bcoll->name)) {
1119 continue;
1120 }
1121
1122 animrig::bone_select(pchan);
1123 changed_any_selection = true;
1124 updated_objects.add(ob);
1125 }
1126 }
1128
1129 for (Object *ob : updated_objects) {
1131 }
1132
1133 return changed_any_selection;
1134}
1135
1136static bool pose_select_siblings(bContext *C, const bool extend)
1137{
1138 const Main *bmain = CTX_data_main(C);
1141
1142 bool changed_any_selection = false;
1143 for (Object *pose_object : objects) {
1144 bArmature *arm = id_cast<bArmature *>(pose_object->data);
1145 BLI_assert(arm);
1146 Set<bPoseChannel *> parents_of_selected;
1147 for (bPoseChannel &pchan : pose_object->pose->chanbase) {
1148 if (animrig::bone_is_selected(arm, {&pchan, pchan.bone_get(*pose_object)})) {
1149 parents_of_selected.add(pchan.parent);
1150 }
1151 }
1152 if (!extend) {
1153 deselect_pose_bones(parents_of_selected);
1154 }
1155 for (bPoseChannel &pchan : pose_object->pose->chanbase) {
1156 Bone *bone = pchan.bone_get(*pose_object);
1157 const bke::PChanBone pchanbone{&pchan, bone};
1158
1159 if (!animrig::bone_is_selectable(arm, pchanbone)) {
1160 continue;
1161 }
1162 if (!pchan.parent || !parents_of_selected.contains(pchan.parent)) {
1163 continue;
1164 }
1165 /* Checking if the bone is already selected so `changed_any_selection` stays true to its
1166 * word. */
1167 if (!animrig::bone_is_selected(arm, pchanbone)) {
1168 pose_do_bone_select(pchanbone, SEL_SELECT);
1169 changed_any_selection = true;
1170 }
1171 }
1172 ED_pose_bone_select_tag_update(pose_object);
1173 }
1174 return changed_any_selection;
1175}
1176
1177static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool extend)
1178{
1179 using namespace blender::animrig;
1180 const Main *bmain = CTX_data_main(C);
1181 Scene *scene = CTX_data_scene(C);
1182 ViewLayer *view_layer = CTX_data_view_layer(C);
1183 bool changed_multi = false;
1185
1186 /* sanity checks: validate Keying Set and object */
1187 if (ks == nullptr) {
1188 BKE_report(reports, RPT_ERROR, "No active Keying Set to use");
1189 return false;
1190 }
1191 if (validate_keyingset(C, nullptr, ks) != ModifyKeyReturn::SUCCESS) {
1192 if (ks->paths.first_ == nullptr) {
1193 if ((ks->flag & KEYINGSET_ABSOLUTE) == 0) {
1194 BKE_report(reports,
1195 RPT_ERROR,
1196 "Use another Keying Set, as the active one depends on the currently "
1197 "selected items or cannot find any targets due to unsuitable context");
1198 }
1199 else {
1200 BKE_report(reports, RPT_ERROR, "Keying Set does not contain any paths");
1201 }
1202 }
1203 return false;
1204 }
1205
1206 /* if not extending selection, deselect all selected first */
1207 if (extend == false) {
1208 CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, visible_pose_bones, Object *, pose_ob) {
1209 if ((pchan->bone_get(*pose_ob)->flag & BONE_UNSELECTABLE) == 0) {
1211 }
1212 }
1214 }
1215
1217 *bmain, scene, view_layer, CTX_wm_view3d(C));
1218
1219 for (const int ob_index : objects.index_range()) {
1220 Object *ob = BKE_object_pose_armature_get(objects[ob_index]);
1221 bArmature *arm = id_cast<bArmature *>((ob) ? ob->data : nullptr);
1222 bPose *pose = (ob) ? ob->pose : nullptr;
1223 bool changed = false;
1224
1225 /* Sanity checks. */
1226 if (ELEM(nullptr, ob, pose, arm)) {
1227 continue;
1228 }
1229
1230 /* iterate over elements in the Keying Set, setting selection depending on whether
1231 * that bone is visible or not...
1232 */
1233 for (KS_Path &ksp : ks->paths) {
1234 /* only items related to this object will be relevant */
1235 if ((ksp.id == &ob->id) && (ksp.rna_path != nullptr)) {
1236 bPoseChannel *pchan = nullptr;
1237 char boneName[sizeof(pchan->name)];
1238 if (!BLI_str_quoted_substr(ksp.rna_path, "bones[", boneName, sizeof(boneName))) {
1239 continue;
1240 }
1241 pchan = BKE_pose_channel_find_name(pose, boneName);
1242
1243 if (pchan) {
1244 /* select if bone is visible and can be affected */
1245 if (animrig::bone_is_selectable(arm, pchan)) {
1246 animrig::bone_select(pchan);
1247 changed = true;
1248 }
1249 }
1250 }
1251 }
1252
1253 if (changed || !extend) {
1255 changed_multi = true;
1256 }
1257 }
1258
1259 return changed_multi;
1260}
1261
1263{
1265 const SelectRelatedMode mode = SelectRelatedMode(RNA_enum_get(op->ptr, "type"));
1266 const bool extend = RNA_boolean_get(op->ptr, "extend");
1267 bool changed = false;
1268
1269 /* sanity check */
1270 if (ob->pose == nullptr) {
1271 return OPERATOR_CANCELLED;
1272 }
1273
1274 /* selection types */
1275 switch (mode) {
1277 changed = pose_select_same_collection(C, extend);
1278 break;
1279
1281 changed = pose_select_same_color(C, extend);
1282 break;
1283
1285 changed = pose_select_same_keyingset(C, op->reports, extend);
1286 break;
1287
1289 changed = pose_select_children(
1290 C, /* all= */ true, extend, /* stop_at_leaf= */ false, /* modify_active= */ false);
1291 break;
1292
1294 changed = pose_select_children(
1295 C, /* all= */ false, extend, /* stop_at_leaf= */ false, /* modify_active= */ false);
1296 break;
1297
1299 changed = pose_select_parents(
1300 C, extend, /* stop_at_root= */ false, /* modify_active= */ false);
1301 break;
1302
1304 changed = pose_select_siblings(C, extend);
1305 break;
1306
1307 default:
1308 printf("pose_select_grouped() - Unknown selection type %d\n", int(mode));
1309 break;
1310 }
1311
1312 /* report done status */
1313 if (changed) {
1315
1316 return OPERATOR_FINISHED;
1317 }
1318 return OPERATOR_CANCELLED;
1319}
1320
1322{
1323 static const EnumPropertyItem prop_select_grouped_types[] = {
1325 "COLLECTION",
1326 0,
1327 "Collection",
1328 "Same collections as the active bone"},
1329 {int(SelectRelatedMode::SAME_COLOR), "COLOR", 0, "Color", "Same color as the active bone"},
1331 "KEYINGSET",
1332 0,
1333 "Keying Set",
1334 "All bones affected by active Keying Set"},
1336 "CHILDREN",
1337 0,
1338 "Children",
1339 "Select all children of currently selected bones"},
1341 "CHILDREN_IMMEDIATE",
1342 0,
1343 "Immediate Children",
1344 "Select direct children of currently selected bones"},
1346 "PARENT",
1347 0,
1348 "Parents",
1349 "Select the parents of currently selected bones"},
1351 "SIBLINGS",
1352 0,
1353 "Siblings",
1354 "Select all bones that have the same parent as currently selected bones"},
1355 {0, nullptr, 0, nullptr, nullptr},
1356 };
1357
1358 /* identifiers */
1359 ot->name = "Select Grouped";
1360 ot->description = "Select all visible bones grouped by similar properties";
1361 ot->idname = "POSE_OT_select_grouped";
1362
1363 /* API callbacks. */
1364 ot->invoke = WM_menu_invoke;
1366 ot->poll = ED_operator_posemode; /* TODO: expand to support edit mode as well. */
1367
1368 /* flags */
1370
1371 /* properties */
1373 "extend",
1374 false,
1375 "Extend",
1376 "Extend selection instead of deselecting everything first");
1377 ot->prop = RNA_def_enum(ot->srna, "type", prop_select_grouped_types, 0, "Type", "");
1378}
1379
1380/* -------------------------------------- */
1381
1382/* Add the given selection flags to the bone flags. */
1383static void bone_selection_flags_add(bPoseChannel *pchan, const ePchan_Flag new_selection_flags)
1384{
1385 pchan->flag |= new_selection_flags;
1386}
1387
1388/* Set the bone flags to the given selection flags. */
1389static void bone_selection_flags_set(bPoseChannel *pchan, const ePchan_Flag new_selection_flags)
1390{
1391 pchan->flag = new_selection_flags;
1392}
1393
1398{
1399 const Main *bmain = CTX_data_main(C);
1400 const Scene *scene = CTX_data_scene(C);
1401 ViewLayer *view_layer = CTX_data_view_layer(C);
1402 Object *ob_active = CTX_data_active_object(C);
1403
1404 const bool is_weight_paint = (ob_active->mode & OB_MODE_WEIGHT_PAINT) != 0;
1405 const bool active_only = RNA_boolean_get(op->ptr, "only_active");
1406 const bool extend = RNA_boolean_get(op->ptr, "extend");
1407
1408 const auto set_bone_selection_flags = extend ? bone_selection_flags_add :
1410
1412 *bmain, scene, view_layer, CTX_wm_view3d(C));
1413 for (Object *ob : objects) {
1414 bArmature *arm = id_cast<bArmature *>(ob->data);
1415 Bone *mirror_bone_act = nullptr;
1416
1417 /* Remember the pre-mirroring selection flags of the bones. */
1418 Map<bPoseChannel *, ePchan_Flag> old_selection_flags;
1419 for (bPoseChannel &pchan : ob->pose->chanbase) {
1420 /* Treat invisible bones as deselected. */
1421 const int flags = animrig::bone_is_visible(arm, {&pchan, pchan.bone_get(*ob)}) ? pchan.flag :
1422 0;
1423
1424 old_selection_flags.add_new(&pchan, ePchan_Flag(flags));
1425 }
1426
1427 for (bPoseChannel &pchan : ob->pose->chanbase) {
1428 if (!animrig::bone_is_selectable(arm, &pchan)) {
1429 continue;
1430 }
1431
1432 bPoseChannel *pchan_mirror = BKE_pose_channel_get_mirrored(ob->pose, pchan.name);
1433 if (!pchan_mirror) {
1434 /* If a bone cannot be mirrored, keep its flags as-is. This makes it possible to select
1435 * the spine and an arm, and still flip the selection to the other arm (without losing
1436 * the selection on the spine). */
1437 continue;
1438 }
1439
1440 Bone *pchan_bone = pchan.bone_get(*ob);
1441 Bone *mirror_bone = pchan_mirror->bone_get(*ob);
1442 if (pchan_bone == arm->act_bone) {
1443 mirror_bone_act = mirror_bone;
1444 }
1445
1446 /* If active-only, don't touch unrelated bones. */
1447 if (active_only && !ELEM(arm->act_bone, pchan_bone, mirror_bone)) {
1448 continue;
1449 }
1450
1451 const ePchan_Flag flags_mirror = old_selection_flags.lookup(pchan_mirror);
1452 set_bone_selection_flags(&pchan, flags_mirror);
1453 }
1454
1455 if (mirror_bone_act) {
1456 arm->act_bone = mirror_bone_act;
1457
1458 /* In weight-paint we select the associated vertex group too. */
1459 if (is_weight_paint) {
1460 ed::object::vgroup_select_by_name(ob_active, mirror_bone_act->name);
1462 }
1463 }
1464
1466
1467 /* Need to tag armature for cow updates, or else selection doesn't update. */
1469 }
1470
1472
1473 return OPERATOR_FINISHED;
1474}
1475
1477{
1478 /* identifiers */
1479 ot->name = "Select Mirror";
1480 ot->idname = "POSE_OT_select_mirror";
1481 ot->description = "Mirror the bone selection";
1482
1483 /* API callbacks. */
1486
1487 /* flags */
1489
1490 /* properties */
1492 ot->srna, "only_active", false, "Active Only", "Only operate on the active bone");
1493 RNA_def_boolean(ot->srna, "extend", false, "Extend", "Extend the selection");
1494}
1495
1496} // namespace blender
Functions to deal with Armatures.
C++ part of the BoneColor DNA struct.
Functionality to interact with keying sets.
Blender kernel action and pose functionality.
#define CTX_DATA_BEGIN_WITH_ID(C, Type, instance, member, Type_id, instance_id)
#define CTX_DATA_BEGIN(C, Type, instance, member)
#define CTX_DATA_COUNT(C, member)
#define CTX_DATA_END
#define FOREACH_VISIBLE_BASE_END
Definition BKE_layer.hh:518
#define FOREACH_VISIBLE_BASE_BEGIN(_bmain, _scene, _view_layer, _v3d, _instance)
Definition BKE_layer.hh:505
General operations, lookup, etc. for blender objects.
#define OB_MODE_ALL_WEIGHT_PAINT
Object is a sort of wrapper for general info.
#define BONE_SELECT_CHILD
#define BONE_SELECT_PARENT
#define C
Definition RandGen.cpp:29
#define NC_GEOM
Definition WM_types.hh:406
#define ND_DATA
Definition WM_types.hh:552
#define ND_BONE_SELECT
Definition WM_types.hh:491
#define NC_OBJECT
Definition WM_types.hh:392
#define BLI_assert_unreachable()
#define ELEM(...)
const Value & lookup(const Key &key) const
Definition BLI_map.hh:545
void add_new(const Key &key, const Value &value)
Definition BLI_map.hh:265
bool contains(const Key &key) const
Definition BLI_set.hh:310
bool add(const Key &key)
Definition BLI_set.hh:248
IndexRange index_range() const
bool all(VecOp< bool, D >) RET
void bone_deselect(bPoseChannel *pchan)
KeyingSet * scene_get_active_keyingset(const Scene *scene)
const BoneColor & ANIM_bonecolor_posebone_get(bke::PChanBoneConst pchanbone)
Definition bonecolor.cc:90
bool bone_is_visible(const bArmature *armature, const Bone *bone)
bool bone_is_selected(const bArmature *armature, const Bone *bone)
bool pose_bone_descendent_depth_iterator(Object &pose_ob, bPoseChannel &pchan, FunctionRef< bool(bPoseChannel &child_bone)> callback)
bool bone_is_selectable(const bArmature *armature, const bke::PChanBoneConst pchanbone)
ModifyKeyReturn validate_keyingset(bContext *C, Vector< PointerRNA > *sources, KeyingSet *keyingset)
void bone_select(bPoseChannel *pchan)
PChanBoneT< bPoseChannel, Bone > PChanBone
Definition BKE_pose.hh:88
void base_select(Base *base, eObjectSelect_Mode mode)
void vgroup_select_by_name(Object *ob, const char *name)
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
static void selectconnected_posebonechildren(Object &ob, bPoseChannel &pose_bone, const bool extend)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
static bool pose_select_same_keyingset(bContext *C, ReportList *reports, bool extend)
wmOperatorStatus WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void bone_selection_flags_add(bPoseChannel *pchan, const ePchan_Flag new_selection_flags)
void POSE_OT_select_linked_pick(wmOperatorType *ot)
int RNA_enum_get(PointerRNA *ptr, const char *name)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
ViewContext ED_view3d_viewcontext_init(bContext *C, Depsgraph *depsgraph)
bool bool BLI_str_quoted_substr(const char *__restrict str, const char *__restrict prefix, char *result, size_t result_maxncpy)
void ED_outliner_select_sync_from_pose_bone_tag(bContext *C)
void BKE_constraint_targets_flush(struct bConstraint *con, ListBaseT< bConstraintTarget > *targets, bool no_copy)
static void deselect_pose_bones(const Set< bPoseChannel * > &pose_bones)
void POSE_OT_select_constraint_target(wmOperatorType *ot)
static Set< bPoseChannel * > get_selected_pose_bones(Object &pose_object)
static Bone * get_new_active_child(Bone &parent_bone)
void POSE_OT_select_linked(wmOperatorType *ot)
static bool pose_select_siblings(bContext *C, const bool extend)
bool ED_operator_posemode(bContext *C)
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, const int default_value, const char *ui_name, const char *ui_description)
void view3d_operator_needs_gpu(const bContext *C)
static wmOperatorStatus pose_select_grouped_exec(bContext *C, wmOperator *op)
bPoseChannel * ED_armature_pick_pchan_from_selectbuffer(Span< Base * > bases, const GPUSelectResult *hit_results, int hits, bool findunsel, bool do_nearest, Base **r_base)
ViewLayer * CTX_data_view_layer(const bContext *C)
void WM_operator_properties_select_all(wmOperatorType *ot)
static bool pose_select_same_color(bContext *C, const bool extend)
static wmOperatorStatus pose_select_parent_exec(bContext *C, wmOperator *)
bool ED_armature_pose_select_pick_bone(const Main &bmain, const Scene *scene, ViewLayer *view_layer, View3D *v3d, Object *ob, bPoseChannel *pchan, const SelectPick_Params &params)
Vector< Object * > BKE_object_pose_array_get_unique(const Main &bmain, const Scene *scene, ViewLayer *view_layer, View3D *v3d)
Definition object.cc:2587
bPoseChannel * ED_armature_pick_pchan(bContext *C, const int xy[2], bool findunsel, Base **r_base)
bPoseChannel * BKE_pose_channel_get_mirrored(const bPose *pose, const char *name) ATTR_WARN_UNUSED_RESULT
static bool pose_bone_is_below_one_of(bPoseChannel &bone, const Set< bPoseChannel * > &potential_parents)
void POSE_OT_select_grouped(wmOperatorType *ot)
Object * BKE_view_layer_edit_object_get(const ViewLayer *view_layer)
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
Object * BKE_object_pose_armature_get(Object *ob)
Definition object.cc:2507
PointerRNA CTX_data_active_pose_bone_ptr(const bContext *C)
bool ED_pose_deselect_all(Object *ob, int select_mode, const bool ignore_visibility)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
bool ED_pose_deselect_all_multi_ex(const Span< Base * > bases, int select_mode, const bool ignore_visibility)
ModifierData * BKE_modifiers_get_virtual_modifierlist(const Object *ob, VirtualModifierData *data)
static wmOperatorStatus pose_de_select_all_exec(bContext *C, wmOperator *op)
bool ED_pose_deselect_all_multi(bContext *C, int select_mode, const bool ignore_visibility)
void ED_pose_bone_select(Object *ob, bPoseChannel *pchan, bool select, bool change_active)
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
Vector< Base * > BKE_object_pose_base_array_get_unique(const Main &bmain, const Scene *scene, ViewLayer *view_layer, View3D *v3d)
Definition object.cc:2633
int BKE_constraint_targets_get(struct bConstraint *con, ListBaseT< bConstraintTarget > *r_targets)
void ED_armature_pose_select_in_wpaint_mode(const Main &bmain, const Scene *scene, ViewLayer *view_layer, Base *base_select)
bool ED_operator_view3d_active(bContext *C)
static void pose_do_bone_select(const bke::PChanBone pchanbone, const int select_mode)
bool ED_armature_pose_select_pick_with_buffer(const Main &bmain, const Scene *scene, ViewLayer *view_layer, View3D *v3d, Base *base, const GPUSelectResult *hit_results, const int hits, const SelectPick_Params &params, bool do_nearest)
bool RNA_boolean_get(PointerRNA *ptr, const char *name)
static wmOperatorStatus pose_select_constraint_target_exec(bContext *C, wmOperator *)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
static wmOperatorStatus pose_select_hierarchy_exec(bContext *C, wmOperator *op)
static bool pose_select_same_collection(bContext *C, const bool extend)
void POSE_OT_select_parent(wmOperatorType *ot)
void ED_pose_bone_select_tag_update(Object *ob)
static bool pose_select_linked_pick_poll(bContext *C)
void RNA_def_property_flag(PropertyRNA *prop, PropertyFlag flag)
static bool any_child_to_select(const Set< bPoseChannel * > &pose_bones, const bArmature &armature)
Main * CTX_data_main(const bContext *C)
static wmOperatorStatus pose_select_connected_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static bool ed_pose_is_any_selected_multi(const Span< Base * > bases, bool ignore_visibility)
static bool pose_select_children(bContext *C, const bool all, const bool extend, const bool stop_at_leaf, const bool modify_active)
@ ID_RECALC_SELECT
Definition DNA_ID.h:1101
@ ID_RECALC_SYNC_TO_EVAL
Definition DNA_ID.h:1118
@ ID_RECALC_GEOMETRY
Definition DNA_ID.h:1074
@ PROP_SKIP_SAVE
Definition RNA_types.hh:414
void POSE_OT_select_hierarchy(wmOperatorType *ot)
static bool ed_pose_is_any_selected(Object *ob, bool ignore_visibility)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
bPoseChannel * CTX_data_active_pose_bone(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
@ OPTYPE_REGISTER
Definition WM_types.hh:188
@ OPTYPE_UNDO
Definition WM_types.hh:190
void POSE_OT_select_mirror(wmOperatorType *ot)
void POSE_OT_select_all(wmOperatorType *ot)
static wmOperatorStatus pose_select_mirror_exec(bContext *C, wmOperator *op)
PropertyRNA * RNA_def_boolean(StructOrFunctionRNA *cont_, const char *identifier, const bool default_value, const char *ui_name, const char *ui_description)
static wmOperatorStatus pose_select_linked_exec(bContext *C, wmOperator *)
static void bone_selection_flags_set(bPoseChannel *pchan, const ePchan_Flag new_selection_flags)
Object * CTX_data_active_object(const bContext *C)
static bool pose_select_parents(bContext *C, const bool extend, const bool stop_at_root, const bool modify_active)
static bool any_parent_to_select(const Set< bPoseChannel * > &pose_bones)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
View3D * CTX_wm_view3d(const bContext *C)
struct Object * object
ListBaseT< BoneCollectionReference > collections
struct Bone * parent
Bone_Runtime runtime
ListBaseT< Bone > childbase
ListBaseT< KS_Path > paths
struct ModifierData * next
struct bPose * pose
T * data_as() const
Definition RNA_types.hh:139
struct ToolSettings * toolsettings
ViewLayer * view_layer
Definition ED_view3d.hh:80
struct bPoseChannel * parent
ListBaseT< bPoseChannel > chanbase
PoseChannelT * pchan
Definition BKE_pose.hh:61
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
struct ReportList * reports