70 switch (select_mode) {
97 selected_pose_bones.
add(&pchan);
100 return selected_pose_bones;
112 if (potential_parents.
contains(bone_iter)) {
115 bone_iter = bone_iter->
parent;
134 if (pose_bone->parent !=
nullptr) {
147 const Bone *bone = pose_bone->bone_get(armature);
163 const bool stop_at_root,
164 const bool modify_active)
169 bool changed_any_selection =
false;
170 for (
Object *pose_object : objects) {
171 bArmature *arm = id_cast<bArmature *>(pose_object->data);
182 if (!pchan->parent) {
185 Bone *parent_bone = pchan->
parent->bone_get(*arm);
190 if (modify_active && pchan->bone_get(*arm) == active_bone) {
193 changed_any_selection =
true;
197 return changed_any_selection;
226 const bool stop_at_leaf,
227 const bool modify_active)
232 bool changed_any_selection =
false;
234 for (
Object *pose_object : objects) {
235 bArmature *arm = id_cast<bArmature *>(pose_object->data);
245 for (
bPoseChannel &pchan : pose_object->pose->chanbase) {
249 Bone *bone = pchan.bone_get(*arm);
253 Bone *parent_bone = pchan.
parent->bone_get(*arm);
254 if (modify_active && parent_bone == active_bone) {
257 changed_any_selection =
true;
263 Bone *parent_bone = pchan.
parent->bone_get(*arm);
264 if (modify_active && parent_bone == active_bone) {
267 changed_any_selection =
true;
274 return changed_any_selection;
297 if (
ELEM(
nullptr, ob, ob->
pose, pchan)) {
301 Bone *bone = pchan->bone_get(*ob);
306 arm = id_cast<bArmature *>(ob->
data);
338 bool changed =
false;
340 if (ob->
pose && pchan) {
342 const Bone *bone = pchan->bone_get(*ob);
357 Object *ob_iter = base_iter->object;
392 Bone *pchan_bone = pchan->bone_get(*ob);
433 const Bone *bone = pchan->bone_get(*ob);
434 if (bone && bone == arm->
act_bone) {
456 return changed || found;
472 if (!ob || !ob->
pose) {
477 Base *base_dummy =
nullptr;
479 {base}, hit_results, hits,
true, do_nearest, &base_dummy);
496 for (; md; md = md->
next) {
500 if (ob_arm !=
nullptr) {
502 if ((base_arm !=
nullptr) && (base_arm != base_select) && (base_arm->
flag &
BASE_SELECTED))
519 if (ob->
pose ==
nullptr) {
537 bool changed =
false;
539 Bone *bone = pchan.bone_get(*ob);
546 int flag_prev = pchan.
flag;
548 changed = (changed || flag_prev != pchan.
flag);
569 for (
Base *base : bases) {
570 Object *ob_iter = base->object;
580 const bool ignore_visibility)
587 bool changed_multi =
false;
588 for (
Base *base : bases) {
589 Object *ob_iter = base->object;
592 changed_multi =
true;
595 return changed_multi;
615 Bone *bone_child = pose_child.bone_get(ob);
622 const bool is_input_bone = (&pose_child == &pose_bone);
625 const bool is_ok = is_selectable && is_connected;
652 Base *base =
nullptr;
661 for (curPChan = pchan; curPChan; curPChan = next) {
663 Bone *curBone = curPChan->bone_get(*ob);
704 ot->
name =
"Select Connected";
705 ot->
idname =
"POSE_OT_select_linked_pick";
707 "Select bones linked by connected parent/child relationships under the mouse cursor";
722 "Extend selection instead of deselecting everything first");
735 bArmature *arm = id_cast<bArmature *>(ob->data);
738 for (curBone = pchan; curBone; curBone = next) {
768 ot->
name =
"Select Connected";
769 ot->
idname =
"POSE_OT_select_linked";
771 "Select all bones linked by connected parent/child relationships from the current selection";
794 Object *ob_prev =
nullptr;
798 bArmature *arm = id_cast<bArmature *>(ob->data);
799 Bone *bone = pchan->bone_get(*ob);
824 ot->
name =
"(De)select All";
825 ot->
idname =
"POSE_OT_select_all";
826 ot->
description =
"Toggle selection status of all bones";
854 Bone *bone = pchan->bone_get(*ob);
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";
897 ListBaseT<bConstraintTarget> targets = {
nullptr,
nullptr};
903 if ((ct.subtarget[0] !=
'\0') && (ob !=
nullptr) && (ob->
type ==
OB_ARMATURE) &&
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";
954 bool changed =
false;
967 if (changed ==
false) {
981 {0,
nullptr, 0,
nullptr,
nullptr},
985 ot->
name =
"Select Hierarchy";
986 ot->
idname =
"POSE_OT_select_hierarchy";
987 ot->
description =
"Select immediate parent/children of selected bones";
1020 bool changed_any_selection =
false;
1035 updated_objects.
add(ob);
1036 changed_any_selection =
true;
1043 Object *pose_ob = id_cast<Object *>(active_pose_bone_ptr.
owner_id);
1045 Bone *active_bone = active_pose_bone->bone_get(*pose_ob);
1051 Bone *bone = pchan->bone_get(*ob);
1063 changed_any_selection =
true;
1064 updated_objects.
add(ob);
1068 if (!changed_any_selection) {
1072 for (
Object *ob : updated_objects) {
1080 bool changed_any_selection =
false;
1086 if (!active_pchan) {
1094 updated_objects.
add(ob);
1095 changed_any_selection =
true;
1102 Bone *active_bone = active_pchan->bone_get(*obpose);
1112 Bone *bone = pchan->bone_get(*ob);
1123 changed_any_selection =
true;
1124 updated_objects.
add(ob);
1129 for (
Object *ob : updated_objects) {
1133 return changed_any_selection;
1142 bool changed_any_selection =
false;
1143 for (
Object *pose_object : objects) {
1144 bArmature *arm = id_cast<bArmature *>(pose_object->data);
1147 for (
bPoseChannel &pchan : pose_object->pose->chanbase) {
1155 for (
bPoseChannel &pchan : pose_object->pose->chanbase) {
1156 Bone *bone = pchan.bone_get(*pose_object);
1169 changed_any_selection =
true;
1174 return changed_any_selection;
1183 bool changed_multi =
false;
1187 if (ks ==
nullptr) {
1192 if (ks->
paths.first_ ==
nullptr) {
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");
1207 if (extend ==
false) {
1219 for (
const int ob_index : objects.
index_range()) {
1221 bArmature *arm = id_cast<bArmature *>((ob) ? ob->
data :
nullptr);
1223 bool changed =
false;
1226 if (
ELEM(
nullptr, ob,
pose, arm)) {
1235 if ((ksp.
id == &ob->
id) && (ksp.
rna_path !=
nullptr)) {
1237 char boneName[
sizeof(pchan->
name)];
1253 if (changed || !extend) {
1255 changed_multi =
true;
1259 return changed_multi;
1267 bool changed =
false;
1270 if (ob->
pose ==
nullptr) {
1290 C,
true, extend,
false,
false);
1295 C,
false, extend,
false,
false);
1300 C, extend,
false,
false);
1308 printf(
"pose_select_grouped() - Unknown selection type %d\n",
int(mode));
1328 "Same collections as the active bone"},
1334 "All bones affected by active Keying Set"},
1339 "Select all children of currently selected bones"},
1341 "CHILDREN_IMMEDIATE",
1343 "Immediate Children",
1344 "Select direct children of currently selected bones"},
1349 "Select the parents of currently selected bones"},
1354 "Select all bones that have the same parent as currently selected bones"},
1355 {0,
nullptr, 0,
nullptr,
nullptr},
1359 ot->
name =
"Select Grouped";
1360 ot->
description =
"Select all visible bones grouped by similar properties";
1361 ot->
idname =
"POSE_OT_select_grouped";
1376 "Extend selection instead of deselecting everything first");
1385 pchan->
flag |= new_selection_flags;
1391 pchan->
flag = new_selection_flags;
1413 for (
Object *ob : objects) {
1414 bArmature *arm = id_cast<bArmature *>(ob->data);
1415 Bone *mirror_bone_act =
nullptr;
1433 if (!pchan_mirror) {
1440 Bone *pchan_bone = pchan.bone_get(*ob);
1441 Bone *mirror_bone = pchan_mirror->bone_get(*ob);
1443 mirror_bone_act = mirror_bone;
1447 if (active_only && !
ELEM(arm->
act_bone, pchan_bone, mirror_bone)) {
1452 set_bone_selection_flags(&pchan, flags_mirror);
1455 if (mirror_bone_act) {
1459 if (is_weight_paint) {
1479 ot->
name =
"Select Mirror";
1480 ot->
idname =
"POSE_OT_select_mirror";
1492 ot->
srna,
"only_active",
false,
"Active Only",
"Only operate on the active bone");
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 FOREACH_VISIBLE_BASE_END
#define FOREACH_VISIBLE_BASE_BEGIN(_bmain, _scene, _view_layer, _v3d, _instance)
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 BLI_assert_unreachable()
const Value & lookup(const Key &key) const
void add_new(const Key &key, const Value &value)
bool contains(const Key &key) const
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)
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
void base_select(Base *base, eObjectSelect_Mode mode)
void vgroup_select_by_name(Object *ob, const char *name)
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 ¶ms)
Vector< Object * > BKE_object_pose_array_get_unique(const Main &bmain, const Scene *scene, ViewLayer *view_layer, View3D *v3d)
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)
Object * BKE_object_pose_armature_get(Object *ob)
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)
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 ¶ms, 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)
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)
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 BoneCollection * bcoll
ListBaseT< BoneCollectionReference > collections
ListBaseT< Bone > childbase
ListBaseT< KS_Path > paths
struct ModifierData * next
struct ToolSettings * toolsettings
struct bPoseChannel * parent
ListBaseT< bPoseChannel > chanbase
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
struct ReportList * reports