Blender V5.0
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 "DNA_armature_types.h"
16
17namespace blender::animrig {
18
22inline bool bone_is_visible(const bArmature *armature, const Bone *bone)
23{
24 const bool bone_itself_visible = (bone->flag & BONE_HIDDEN_P) == 0;
25 return bone_itself_visible && ANIM_bone_in_visible_collection(armature, bone);
26}
27
28inline bool bone_is_visible(const bArmature *armature, const bPoseChannel *pchan)
29{
30 const bool bone_itself_visible = (pchan->drawflag & PCHAN_DRAW_HIDDEN) == 0;
31 return bone_itself_visible && ANIM_bone_in_visible_collection(armature, pchan->bone);
32}
33
34inline bool bone_is_visible(const bArmature *armature, const EditBone *ebone)
35{
36 const bool bone_itself_visible = (ebone->flag & BONE_HIDDEN_A) == 0;
37 return bone_itself_visible && ANIM_bonecoll_is_visible_editbone(armature, ebone);
38}
39
44inline bool bone_is_selected(const bArmature *armature, const Bone *bone)
45{
46 return (bone->flag & BONE_SELECTED) && bone_is_visible(armature, bone);
47}
48
49inline bool bone_is_selected(const bArmature *armature, const bPoseChannel *pchan)
50{
51 return (pchan->flag & POSE_SELECTED) && bone_is_visible(armature, pchan);
52}
53
54inline bool bone_is_selected(const bArmature *armature, const EditBone *ebone)
55{
56 return (ebone->flag & BONE_SELECTED) && bone_is_visible(armature, ebone);
57}
58
59inline bool bone_is_selectable(const bArmature *armature, const bPoseChannel *pchan)
60{
61 return bone_is_visible(armature, pchan) && !(pchan->bone->flag & BONE_UNSELECTABLE);
62}
63
64inline bool bone_is_selectable(const bArmature *armature, const Bone *bone)
65{
66 return bone_is_visible(armature, bone) && !(bone->flag & BONE_UNSELECTABLE);
67}
68
74 bPoseChannel &pose_bone,
75 FunctionRef<void(bPoseChannel &child_bone)> callback);
76
83 bPoseChannel &pose_bone,
84 FunctionRef<bool(bPoseChannel &child_bone)> callback);
85} // namespace blender::animrig
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
bool ANIM_bonecoll_is_visible_editbone(const bArmature *armature, const EditBone *ebone)
bool ANIM_bone_in_visible_collection(const bArmature *armature, const Bone *bone)
@ PCHAN_DRAW_HIDDEN
@ POSE_SELECTED
@ BONE_SELECTED
@ BONE_UNSELECTABLE
@ BONE_HIDDEN_A
@ BONE_HIDDEN_P
void pose_bone_descendent_iterator(bPose &pose, bPoseChannel &pose_bone, FunctionRef< void(bPoseChannel &child_bone)> callback)
bool bone_is_visible(const bArmature *armature, const Bone *bone)
bool bone_is_selectable(const bArmature *armature, const bPoseChannel *pchan)
bool bone_is_selected(const bArmature *armature, const Bone *bone)
bool pose_bone_descendent_depth_iterator(bPose &pose, bPoseChannel &pose_bone, FunctionRef< bool(bPoseChannel &child_bone)> callback)
struct Bone * bone