Blender V5.3
ANIM_armature.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
10
11#pragma once
12
14
15#include "BKE_pose.hh"
16#include "DNA_armature_types.h"
17
18namespace blender::animrig {
19
20constexpr char bone_default_name[] = "Bone";
21
25inline bool bone_is_visible(const bArmature *armature, const Bone *bone)
26{
27 const bool bone_itself_visible = (bone->flag & BONE_HIDDEN_P) == 0;
28 return bone_itself_visible && ANIM_bone_in_visible_collection(armature, bone);
29}
30
31inline bool bone_is_visible(const bArmature *armature, const bke::PChanBoneConst pchanbone)
32{
33 const bool bone_itself_visible = (pchanbone.pchan->drawflag & PCHAN_DRAW_HIDDEN) == 0;
34 return bone_itself_visible && ANIM_bone_in_visible_collection(armature, pchanbone.bone);
35}
36
37inline bool bone_is_visible(const bArmature *armature, const EditBone *ebone)
38{
39 const bool bone_itself_visible = (ebone->flag & BONE_HIDDEN_A) == 0;
40 return bone_itself_visible && ANIM_bonecoll_is_visible_editbone(armature, ebone);
41}
42
47inline bool bone_is_selected(const bArmature *armature, const Bone *bone)
48{
49 return (bone->flag & BONE_SELECTED) && bone_is_visible(armature, bone);
50}
51
52inline bool bone_is_selected(const bArmature *armature, const bke::PChanBoneConst pchanbone)
53{
54 return (pchanbone.pchan->flag & POSE_SELECTED) && bone_is_visible(armature, pchanbone);
55}
56
57inline bool bone_is_selected(const bArmature *armature, const EditBone *ebone)
58{
59 return (ebone->flag & BONE_SELECTED) && bone_is_visible(armature, ebone);
60}
61
62inline bool bone_is_selectable(const bArmature *armature, const bke::PChanBoneConst pchanbone)
63{
64 return bone_is_visible(armature, pchanbone) && !(pchanbone.bone->flag & BONE_UNSELECTABLE);
65}
66inline bool bone_is_selectable(const bArmature *armature, const bPoseChannel *pchan)
67{
68 return bone_is_selectable(armature, {pchan, pchan->bone_get(*armature)});
69}
70
71inline bool bone_is_selectable(const bArmature *armature, const Bone *bone)
72{
73 return bone_is_visible(armature, bone) && !(bone->flag & BONE_UNSELECTABLE);
74}
75
81inline void bone_select(bPoseChannel *pchan)
82{
83 pchan->flag |= POSE_SELECTED_ALL;
84}
85
86inline void bone_deselect(bPoseChannel *pchan)
87{
88 pchan->flag &= ~POSE_SELECTED_ALL;
89}
90
96 bPoseChannel &pchan,
97 FunctionRef<void(bPoseChannel &child_bone)> callback);
98
105 bPoseChannel &pchan,
106 FunctionRef<bool(bPoseChannel &child_bone)> callback);
107} // namespace blender::animrig
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
void bone_deselect(bPoseChannel *pchan)
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)
constexpr char bone_default_name[]
void pose_bone_descendent_iterator(Object &pose_ob, bPoseChannel &pchan, FunctionRef< void(bPoseChannel &child_bone)> callback)
void bone_select(bPoseChannel *pchan)
PChanBoneT< const bPoseChannel, const Bone > PChanBoneConst
Definition BKE_pose.hh:89
bool ANIM_bone_in_visible_collection(const bArmature *armature, const Bone *bone)
bool ANIM_bonecoll_is_visible_editbone(const bArmature *armature, const EditBone *ebone)
PoseChannelT * pchan
Definition BKE_pose.hh:61