Blender V5.3
BKE_armature.hh File Reference
#include <optional>
#include "BLI_bounds_types.hh"
#include "BLI_function_ref.hh"
#include "BLI_math_matrix_types.hh"
#include "BLI_math_vector_types.hh"
#include "BLI_mutex.hh"
#include "BLI_set.hh"
#include "DNA_armature_types.h"
#include "DNA_listBase.h"
#include "BKE_pose.hh"

Go to the source code of this file.

Classes

struct  blender::EditBone
struct  blender::PoseTarget
struct  blender::PoseTree
struct  blender::BoneParentTransform
struct  blender::Mat4
struct  blender::BBoneSplineParameters
struct  blender::bke::bArmature_Runtime
struct  blender::bke::SelectedBonesResult

Namespaces

namespace  blender
 BMesh Iterators.
namespace  blender::bke

Macros

#define MAX_BBONE_SUBDIV   32
#define FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN(_ob, _pchan)
#define FOREACH_PCHAN_SELECTED_IN_OBJECT_END
#define FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN(_ob, _pchan)
#define FOREACH_PCHAN_VISIBLE_IN_OBJECT_END

Typedefs

using blender::ForeachBoneFn = FunctionRef<void(int index, const Bone &bone)>
using blender::bke::SelectedBoneCallback = FunctionRef<void(Bone *bone)>
using blender::bke::BoneNameSet = Set<std::string>

Functions

void blender::BKE_armature_foreach_bone (const bArmature &armature, ForeachBoneFn callback)
bool blender::bone_autoside_name (char name[64], int strip_number, short axis, float head, float tail)
void blender::vec_roll_to_mat3 (const float vec[3], float roll, float r_mat[3][3])
void blender::BKE_pose_splineik_init_tree (Scene *scene, Object *ob, float ctime)
void blender::BKE_splineik_execute_tree (Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan_root, float ctime)
void blender::BKE_pose_pchan_index_rebuild (bPose *pose)
void blender::BKE_pose_eval_init (Depsgraph *depsgraph, Scene *scene, Object *object)
void blender::BKE_pose_eval_init_ik (Depsgraph *depsgraph, Scene *scene, Object *object)
void blender::BKE_pose_eval_bone (Depsgraph *depsgraph, Scene *scene, Object *object, int pchan_index)
void blender::BKE_pose_constraints_evaluate (Depsgraph *depsgraph, Scene *scene, Object *object, int pchan_index)
void blender::BKE_pose_bone_done (Depsgraph *depsgraph, Object *object, int pchan_index)
void blender::BKE_pose_eval_bbone_segments (Depsgraph *depsgraph, Object *object, int pchan_index)
void blender::BKE_pose_iktree_evaluate (Depsgraph *depsgraph, Scene *scene, Object *object, int rootchan_index)
void blender::BKE_pose_splineik_evaluate (Depsgraph *depsgraph, Scene *scene, Object *object, int rootchan_index)
void blender::BKE_pose_eval_done (Depsgraph *depsgraph, Object *object)
void blender::BKE_pose_eval_cleanup (Depsgraph *depsgraph, Scene *scene, Object *object)
SelectedBonesResult blender::bke::BKE_armature_find_selected_bones (const bArmature *armature, SelectedBoneCallback callback)
BoneNameSet blender::bke::BKE_armature_find_selected_bone_names (const bArmature *armature)
BoneNameSet blender::bke::BKE_pose_channel_find_selected_names (const Object *object)
Generic Data-Level Functions
bArmature * blender::BKE_armature_add (Main *bmain, const char *name)
bArmature * blender::BKE_armature_from_object (Object *ob)
int blender::BKE_armature_bonelist_count (const ListBaseT< Bone > *lb)
void blender::BKE_armature_bonelist_free (ListBaseT< Bone > *lb, bool do_id_user)
void blender::BKE_armature_editbonelist_free (ListBaseT< EditBone > *lb, bool do_id_user)
Armature Transform Copy
void blender::BKE_armature_copy_bone_transforms (bArmature *armature_dst, const bArmature *armature_src)
Armature Transform by 4x4 Matrix
See also
ED_armature_edit_transform for the edit-mode version of this function.
void blender::BKE_armature_transform (bArmature *arm, const float mat[4][4], bool do_props)
Calculate Bounding Box (Armature & Pose)
std::optional< Bounds< float3 > > blender::BKE_armature_min_max (const Object *ob)
void blender::BKE_pchan_minmax (const Object *ob, bke::PChanBoneConst pchanbone, bool use_empty_drawtype, float3 &r_min, float3 &r_max)
std::optional< Bounds< float3 > > blender::BKE_pose_minmax (const Object *ob, bool use_select)
Armature Bone Find by Name

Using fast GHash lookups when available.

Bone * blender::BKE_armature_find_bone_name (bArmature *arm, const char *name)
void blender::BKE_armature_bone_hash_make (bArmature *arm)
void blender::BKE_armature_bone_hash_free (bArmature *arm)
Armature Bone Flags
bool blender::BKE_armature_bone_flag_test_recursive (const Bone *bone, int flag)
Armature Deform Internal Utilities
float blender::distfactor_to_bone (const float3 &position, const float3 &head, const float3 &tail, float radius_head, float radius_tail, float falloff_distance)
Armature Bone Matrix Calculation (Recursive)
void blender::BKE_armature_where_is (bArmature *arm)
void blender::BKE_armature_where_is_bone (Bone *bone, const Bone *bone_parent, bool use_recursion)
Pose Rebuild
void blender::BKE_pose_clear_pointers (bPose *pose)
void blender::BKE_pchan_rebuild_bbone_handles (bPose *pose, bke::PChanBone pchanbone)
void blender::BKE_pose_channels_clear_with_null_bone (Object *armature_ob, bool do_id_user)
void blender::BKE_pose_rebuild (Main *bmain, Object *ob, bArmature *arm, bool do_id_user)
void blender::BKE_pose_ensure (Main *bmain, Object *ob, bArmature *arm, bool do_id_user)
void blender::BKE_pose_ensure_bone_indices (const Object &pose_object)
Pose Solver
void blender::BKE_pose_where_is (Depsgraph *depsgraph, Scene *scene, Object *ob)
void blender::BKE_pose_where_is_bone (Depsgraph *depsgraph, Scene *scene, Object *ob, bPoseChannel *pchan, float ctime, bool do_extra)
void blender::BKE_pose_where_is_bone_tail (bke::PChanBone pchanbone)
void blender::BKE_pchan_to_mat4 (bke::PChanBoneConst pchanbone, float r_chanmat[4][4])
void blender::BKE_pchan_calc_mat (bke::PChanBone pchanbone)
Bone Vector, Roll Conversion

Used for Objects and Pose Channels, since both can have multiple rotation representations.

How it Works

This is the bone transformation trick; they're hierarchical so each bone(b) is in the coord system of bone(b-1):

arm_mat(b)= arm_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b)

-> yoffs is just the y axis translation in parent's coord system -> d_root is the translation of the bone root, also in parent's coord system

pose_mat(b)= pose_mat(b-1) * yoffs(b-1) * d_root(b) * bone_mat(b) * chan_mat(b)

we then - in init deform - store the deform in chan_mat, such that:

pose_mat(b)= arm_mat(b) * chan_mat(b)

void blender::vec_roll_to_mat3_normalized (const float nor[3], float roll, float r_mat[3][3])
void blender::mat3_to_vec_roll (const float mat[3][3], float r_vec[3], float *r_roll)
void blender::mat3_vec_to_roll (const float mat[3][3], const float vec[3], float *r_roll)
Bone Space to Space Conversion API
void blender::BKE_armature_mat_world_to_pose (Object *ob, const float inmat[4][4], float outmat[4][4])
void blender::BKE_armature_loc_world_to_pose (Object *ob, const float inloc[3], float outloc[3])
Bone Matrix Calculation API
void blender::BKE_armature_mat_pose_to_bone (bke::PChanBoneConst pchanbone, const float inmat[4][4], float outmat[4][4])
void blender::BKE_armature_loc_pose_to_bone (bke::PChanBoneConst pchanbone, const float inloc[3], float outloc[3])
void blender::BKE_armature_mat_bone_to_pose (bke::PChanBoneConst pchanbone, const float inmat[4][4], float outmat[4][4])
void blender::BKE_bone_offset_matrix_get (const Bone *bone, float offs_bone[4][4])
void blender::BKE_bone_parent_transform_clear (BoneParentTransform *bpt)
void blender::BKE_bone_parent_transform_invert (BoneParentTransform *bpt)
void blender::BKE_bone_parent_transform_combine (const BoneParentTransform *in1, const BoneParentTransform *in2, BoneParentTransform *result)
void blender::BKE_bone_parent_transform_apply (const BoneParentTransform *bpt, const float inmat[4][4], float outmat[4][4])
void blender::BKE_bone_parent_transform_calc_from_pchan (bke::PChanBoneConst pchanbone, BoneParentTransform *r_bpt)
void blender::BKE_bone_parent_transform_calc_from_matrices (int bone_flag, int inherit_scale_mode, const float offs_bone[4][4], const float parent_arm_mat[4][4], const float parent_pose_mat[4][4], BoneParentTransform *r_bpt)
Bone Matrix Read/Write API

High level functions for transforming bones and reading the transform values.

void blender::BKE_armature_mat_pose_to_delta (float delta_mat[4][4], float pose_mat[4][4], float arm_mat[4][4])
void blender::BKE_armature_mat_pose_to_bone_ex (Depsgraph *depsgraph, Object *ob, const bPoseChannel *pchan, const float inmat[4][4], float outmat[4][4])
void blender::BKE_pchan_mat3_to_rot (bPoseChannel *pchan, const float mat[3][3], bool use_compat)
void blender::BKE_pchan_rot_to_mat3 (const bPoseChannel *pchan, float r_mat[3][3])
float4 blender::BKE_pchan_rot_to_quat (const bPoseChannel &pchan)
void blender::BKE_pchan_quat_to_rot (bPoseChannel &pchan, const float4 &quat)
void blender::BKE_pchan_apply_mat4 (bPoseChannel *pchan, const float mat[4][4], bool use_compat)
Rotation Mode Conversions

Used for Objects and Pose Channels, since both can have multiple rotation representations.

void blender::BKE_rotMode_change_values (float quat[4], float eul[3], float axis[3], float *angle, eRotationModes oldMode, eRotationModes newMode)
Protected Transform Channel Assignment
void blender::BKE_pchan_protected_location_set (bPoseChannel *pchan, const float location[3])
void blender::BKE_pchan_protected_rotation_set (bPoseChannel *pchan, const float mat[3][3])
void blender::BKE_pchan_protected_scale_set (bPoseChannel *pchan, const float scale[3])
void blender::BKE_pchan_protected_rotation_quaternion_set (bPoseChannel *pchan, const float quat[4])
void blender::BKE_pchan_protected_rotation_euler_set (bPoseChannel *pchan, const float rotation_euler[3])
void blender::BKE_pchan_protected_rotation_axisangle_set (bPoseChannel *pchan, const float axis[3], float angle)
Armature B-Bone Support
void blender::BKE_pchan_bbone_handles_get (bke::PChanBoneConst pchanbone, bPoseChannel **r_prev, bPoseChannel **r_next)
void blender::BKE_pchan_bbone_spline_params_get (bke::PChanBoneConst pchanbone, const bArmature &armature, bool rest, BBoneSplineParameters *param)
void blender::BKE_pchan_bbone_spline_setup (bke::PChanBone pchanbone, const bArmature &armature, bool rest, bool for_deform, Mat4 *result_array)
void blender::BKE_pchan_bbone_handles_compute (const BBoneSplineParameters *param, float h1[3], float *r_roll1, float h2[3], float *r_roll2, bool ease, bool offsets)
int blender::BKE_pchan_bbone_spline_compute (BBoneSplineParameters *param, bool for_deform, Mat4 *result_array)
void blender::BKE_pchan_bbone_segments_cache_compute (bke::PChanBone pchanbone, const bArmature &armature)
void blender::BKE_pchan_bbone_segments_cache_copy (bPoseChannel *pchan, bPoseChannel *pchan_from)
void blender::BKE_pchan_bbone_deform_clamp_segment_index (const Bone &bone, float head_tail, int *r_index, float *r_blend_next)
void blender::BKE_pchan_bbone_deform_segment_index (bke::PChanBoneConst pchanbone, const float *co, int *r_index, float *r_blend_next)
Graph Evaluation
bPoseChannel * blender::BKE_armature_ik_solver_find_root (bPoseChannel *pchan, bKinematicConstraint *data)
bPoseChannel * blender::BKE_armature_splineik_solver_find_root (bPoseChannel *pchan, bSplineIKConstraint *data)
Deform 3D Coordinates by Armature (<tt>armature_deform.cc</tt>)
void blender::BKE_armature_deform_coords_with_curves (const Object &ob_arm, const Object &ob_target, const ListBaseT< bDeformGroup > *defbase, MutableSpan< float3 > vert_coords, std::optional< Span< float3 > > vert_coords_prev, std::optional< MutableSpan< float3x3 > > vert_deform_mats, Span< MDeformVert > dverts, int deformflag, StringRefNull defgrp_name)
void blender::BKE_armature_deform_coords_with_mesh (const Object &ob_arm, const Object &ob_target, MutableSpan< float3 > vert_coords, std::optional< Span< float3 > > vert_coords_prev, std::optional< MutableSpan< float3x3 > > vert_deform_mats, int deformflag, StringRefNull defgrp_name, const Mesh *me_target)
void blender::BKE_armature_deform_coords_with_editmesh (const Object &ob_arm, const Object &ob_target, MutableSpan< float3 > vert_coords, std::optional< Span< float3 > > vert_coords_prev, std::optional< MutableSpan< float3x3 > > vert_deform_mats, int deformflag, StringRefNull defgrp_name, const BMesh &bm_target)

Macro Definition Documentation

◆ FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN

#define FOREACH_PCHAN_SELECTED_IN_OBJECT_BEGIN ( _ob,
_pchan )
Value:
for (bPoseChannel *_pchan = (_ob)->pose->chanbase.first(); _pchan; _pchan = _pchan->next) { \
if (animrig::bone_is_visible(((bArmature *)(_ob)->data), {_pchan, _pchan->bone_get(*_ob)}) && \
((_pchan)->flag & POSE_SELECTED)) \
{

Definition at line 628 of file BKE_armature.hh.

Referenced by blender::bone_collection_assign_pchans(), blender::pose_clear_transform_generic_exec(), blender::pose_flip_names_exec(), blender::pose_flip_quats_exec(), blender::screen_ctx_selected_pose_bones(), and blender::screen_ctx_selected_pose_bones_from_active_object().

◆ FOREACH_PCHAN_SELECTED_IN_OBJECT_END

◆ FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN

#define FOREACH_PCHAN_VISIBLE_IN_OBJECT_BEGIN ( _ob,
_pchan )
Value:
for (bPoseChannel *_pchan = (_ob)->pose->chanbase.first(); _pchan; _pchan = _pchan->next) { \
if (animrig::bone_is_visible(((bArmature *)(_ob)->data), {_pchan, pchan->bone_get(*_ob)})) {

Definition at line 638 of file BKE_armature.hh.

Referenced by blender::screen_ctx_visible_pose_bones().

◆ FOREACH_PCHAN_VISIBLE_IN_OBJECT_END

#define FOREACH_PCHAN_VISIBLE_IN_OBJECT_END
Value:
} \
} \
((void)0)

Definition at line 641 of file BKE_armature.hh.

Referenced by blender::screen_ctx_visible_pose_bones().

◆ MAX_BBONE_SUBDIV