90 *temp_con_data = *targetless_con;
116 for (; con; con = con->
next) {
122 if (
data->tar ==
nullptr) {
143 if (pchan ==
nullptr) {
163 if (
data->rootbone == 0) {
218 Bone *bone = pchan->bone_get(ob);
229 data->max_rootbone =
data->rootbone;
239 short wentdeeper = 0, added = 0;
248 if (wentdeeper == 0) {
269 arm = id_cast<bArmature *>(ob->
data);
274 Bone *pchan_bone = pchan.bone_get(*ob);
279 for (bonec = pchan_bone->
childbase.first(); bonec; bonec = bonec->
next) {
292 for (parent = pchan.
parent; parent; parent = parent->
parent) {
299 if (parent ==
nullptr) {
316 return (tot_ik) ? 1 : 0;
352 bool is_mirror_relative)
374 if (is_mirror_relative) {
375 float pchan_mtx[4][4];
376 float pchan_mtx_mirror[4][4];
378 float flip_mtx[4][4];
385 mul_m4_m4m4(pchan_mtx_mirror, pchan_mtx_mirror, flip_mtx);
386 mul_m4_m4m4(pchan_mtx_mirror, flip_mtx, pchan_mtx_mirror);
405 Bone *bone = pchan->bone_get(*ob);
406 float pmat[3][3], omat[3][3];
407 float cmat[3][3], tmat[3][3];
428 td->
extra = MEM_new<bke::PChanBone>(__func__, pchan, bone);
441 td_ext->
quat =
nullptr;
446 td_ext->
rot =
nullptr;
449 td_ext->
quat =
nullptr;
455 td_ext->
rot =
nullptr;
465 copy_m3_m4(omat, ob->object_to_world().ptr());
579 if (custom_data->
data !=
nullptr) {
581 custom_data->
data =
nullptr;
586 for (
int i = 0; i < tc->
data_len; i++) {
593 MEM_delete(pchanbone);
604 bool has_translate_rotate_buf[2] = {
false,
false};
605 bool *has_translate_rotate = (t->
mode ==
TFM_TRANSLATION) ? has_translate_rotate_buf :
nullptr;
615 if ((arm ==
nullptr) || (
pose ==
nullptr)) {
628 Bone *bone = pchan.bone_get(*ob);
639 if (has_translate_rotate !=
nullptr) {
640 if (has_translate_rotate[0] && has_translate_rotate[1]) {
647 has_translate_rotate[0] =
true;
652 has_translate_rotate[0] =
true;
656 has_translate_rotate[1] =
true;
660 has_translate_rotate[0] =
true;
665 if (tc->data_len == 0) {
678 int total_mirrored = 0;
688 (total_mirrored + 1),
"PoseInitData_Mirror");
691 pid[total_mirrored].
pchan =
nullptr;
694 tc->custom.type.use_free =
true;
699 if (tc->data_len == 0) {
710 if (
pose ==
nullptr) {
730 Bone *bone = pchan.bone_get(*ob);
731 Bone *bone_mirror = pchan_mirror->bone_get(*ob);
734 &pid[pid_index], {pchan_mirror, bone_mirror}, {&pchan, bone}, is_mirror_relative);
745 has_translate_rotate[0] =
true;
761 tc->custom.type.use_free =
true;
763 if (td != (tc->data + tc->data_len)) {
776 if (has_translate_rotate[1]) {
790 custom_data->
data =
nullptr;
798 bArmature *arm = id_cast<bArmature *>(tc->obedit->data);
799 ListBaseT<EditBone> *edbo = arm->
edbo;
801 int total_mirrored = 0;
805 const int data_len_prev = tc->data_len;
828 if (mirror && (data_len_prev < tc->data_len)) {
843 tc->custom.type.data = bid;
845 tc->custom.type.use_free =
true;
858 bArmature *arm = id_cast<bArmature *>(tc->obedit->data);
859 ListBaseT<EditBone> *edbo = arm->
edbo;
861 float mtx[3][3], smtx[3][3], bonemat[3][3];
865 copy_m3_m4(mtx, tc->obedit->object_to_world().ptr());
874 ebo.oldlength = ebo.length;
879 td->
val = &ebo.rad_head;
893 td->
val = &ebo.rad_tail;
915 td->
loc = &ebo.xwidth;
936 td->
val = &(ebo.roll);
1006 if (mirror && (td_old != td)) {
1010 bone_data.
bone = eboflip;
1019 bid.append(bone_data);
1038 arm = id_cast<bArmature *>(tc->
obedit->
data);
1083 bArmature *arm = id_cast<bArmature *>(tc->obedit->data);
1084 ListBaseT<EditBone> *edbo = arm->
edbo;
1135 for (i = 0; i < tc->data_len; i++, td++) {
1137 float vec[3], up_axis[3];
1186 float flip_mtx[4][4];
1188 flip_mtx[0][0] = -1;
1202 for (
int i = tc->
data_len; i--; td++) {
1208 const Bone *bone_orig = pchanbone_orig->
bone;
1221 if (pchan ==
nullptr) {
1224 Bone *pchan_bone = pchan->bone_get(*ob);
1236 float pchan_mtx_final[4][4];
1238 mul_m4_m4m4(pchan_mtx_final, pchan_mtx_final, flip_mtx);
1239 mul_m4_m4m4(pchan_mtx_final, flip_mtx, pchan_mtx_final);
1255 if (
data ==
nullptr) {
1325 const bool targetless_ik,
1326 const bool is_connected,
1327 const bool transforming_more_than_one_bone)
1333 if (transforming_more_than_one_bone &&
1336 rna_paths.
append({
"location"});
1339 rna_paths.
append({
"location"});
1367 if (!is_connected) {
1370 if (targetless_ik) {
1371 rna_paths.
append({rotation_path});
1378 rna_paths.
append({rotation_path});
1384 rna_paths.
append({
"scale"});
1397 short targetless_ik,
1399 const bool transforming_more_than_one_bone)
1404 Bone *pchan_bone = pchan.bone_get(*ob);
1416 const bool is_connected = pchan_bone->
parent !=
nullptr &&
1423 transforming_more_than_one_bone);
1426 rna_paths = {{
"location"}, {rotation_path}, {
"scale"}};
1440 Object *ob = tc->poseobj;
1465 Object *ob = tc->poseobj;
1496 motionpath_updates.
add(ob);
1504 if (!motionpath_updates.
is_empty()) {
1507 for (
Object *ob : motionpath_updates) {
1527 if (&pchan == &child) {
1530 Bone *bone = child.bone_get(pose_ob);
1580 int segcount, apply = 0;
1597 for (; parchan; parchan = parchan->
parent) {
1598 chanlist[segcount] = parchan;
1601 if (segcount ==
data->rootbone || segcount > 255) {
1605 for (; segcount; segcount--) {
1613 parchan = chanlist[segcount - 1];
1620 float rmat3[3][3],
scale[3];
1657 bool relations_changed =
false;
1666 for (con = pchan.
constraints.first(); con; con = next) {
1671 relations_changed =
true;
1689 if (relations_changed) {
1718 short targetless_ik = 0;
1726 Object *pose_ob = tc->poseobj;
1765 motionpath_updates.
add(ob);
1773 for (
Object *ob : motionpath_updates) {
1780 for (
Object *ob : motionpath_updates) {
Functions and classes to work with Actions.
Functions to deal with Armatures.
C++ functions to deal with Armature collections (i.e. the successor of bone layers).
Functions to insert, delete or modify keyframes.
Helper functions for animation to interact with the RNA system.
Blender kernel action and pose functionality.
#define PSEUDOINVERSE_EPSILON
#define mul_m3_series(...)
Read Blender memory allocation and freeing.
#define BLI_assert_unreachable()
void append(const T &value)
void reserve(const int64_t min_capacity)
void append_non_duplicates(const T &value)
Span< T > as_span() const
float3x3 scale(float3x3 mat, float2 scale)
bool is_autokey_on(const Scene *scene)
bool autokeyframe_cfra_can_key(const Scene *scene, ID *id)
StringRefNull get_rotation_mode_path(eRotationModes rotation_mode)
bool bone_is_visible(const bArmature *armature, const Bone *bone)
bool is_keying_flag(const Scene *scene, eKeying_Flag flag)
void autokeyframe_pose_channel(bContext *C, Scene *scene, Object *ob, bPoseChannel *pose_channel, Span< RNAPath > rna_paths, short targetless_ik)
void pose_bone_descendent_iterator(Object &pose_ob, bPoseChannel &pchan, FunctionRef< void(bPoseChannel &child_bone)> callback)
PChanBoneT< bPoseChannel, Bone > PChanBone
PChanBoneT< const bPoseChannel, const Bone > PChanBoneConst
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
bArmature * BKE_armature_from_object(Object *ob)
void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, const float mat[3][3], bool use_compat)
void mat4_to_loc_rot_size(float loc[3], float rot[3][3], float size[3], const float wmat[4][4])
void animviz_clear_motionpath_preview(Span< MPathTarget > targets)
struct bConstraint * BKE_constraint_add_for_pose(struct Object *ob, struct bPoseChannel *pchan, const char *name, eBConstraint_Types type)
MINLINE void copy_v3_v3(float r[3], const float a[3])
void * MEM_new_array_uninitialized(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
void copy_m3_m4(float m1[3][3], const float m2[4][4])
@ CONSTRAINT_TYPE_KINEMATIC
void copy_m3_m3(float m1[3][3], const float m2[3][3])
void ED_armature_edit_transform_mirror_update(Object *obedit)
float angle_compat_rad(float angle, float angle_compat)
bool invert_m3_m3(float inverse[3][3], const float mat[3][3])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
void normalize_m3(float R[3][3]) ATTR_NONNULL()
void BKE_pchan_protected_location_set(bPoseChannel *pchan, const float location[3])
@ V3D_AROUND_LOCAL_ORIGINS
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void BKE_pchan_protected_scale_set(bPoseChannel *pchan, const float scale[3])
void rotation_between_vecs_to_quat(float q[4], const float v1[3], const float v2[3])
bool invert_m4(float mat[4][4])
void BKE_pchan_to_mat4(bke::PChanBoneConst pchanbone, float r_chanmat[4][4])
void BKE_pose_where_is(Depsgraph *depsgraph, Scene *scene, Object *ob)
void BIK_clear_data(struct bPose *pose)
void BKE_pose_channel_transform_orientation(const bArmature *arm, const bPoseChannel *pose_bone, float r_pose_orientation[3][3])
void MEM_delete_void(void *vmemh)
void mul_qt_v3(const float q[4], float r[3])
void animviz_build_motionpath_targets(Object *ob, Vector< MPathTarget > &r_targets)
EditBone * ED_armature_ebone_get_mirrored(const ListBaseT< EditBone > *edbo, EditBone *ebo)
void BKE_pchan_protected_rotation_set(bPoseChannel *pchan, const float mat[3][3])
void BKE_pose_channel_transform_location(const bArmature *arm, const bPoseChannel *pose_bone, float r_pose_space_pivot[3])
bPoseChannel * BKE_pose_channel_get_mirrored(const bPose *pose, const char *name) ATTR_WARN_UNUSED_RESULT
void ED_armature_ebone_to_mat3(EditBone *ebone, float r_mat[3][3])
void BKE_armature_mat_pose_to_bone(bke::PChanBoneConst pchanbone, const float inmat[4][4], float outmat[4][4])
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
void copy_qt_qt(float q[4], const float a[4])
void DEG_id_tag_update(ID *id, unsigned int flags)
void BKE_report(ReportList *reports, eReportType type, const char *message)
BMesh const char void * data
void ANIM_deselect_keys_in_animation_editors(bContext *C)
Depsgraph * CTX_data_ensure_evaluated_depsgraph(const bContext *C, bool rna_write_check=false)
void unit_m4(float m[4][4])
void normalize_m4_ex(float R[4][4], float r_scale[3]) ATTR_NONNULL()
MINLINE float normalize_v3(float n[3])
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
Main * CTX_data_main(const bContext *C)
@ POSE_TRANSFORM_AROUND_CUSTOM_TX
void pseudoinverse_m3_m3(float inverse[3][3], const float mat[3][3], float epsilon)
void DEG_relations_tag_update(Main *bmain)
bool BKE_pose_is_bonecoll_visible(const bArmature *arm, const bPoseChannel *pchan) ATTR_WARN_UNUSED_RESULT
@ AUTOKEY_FLAG_INSERTNEEDED
void mul_m3_m3m3(float R[3][3], const float A[3][3], const float B[3][3])
float ED_armature_ebone_roll_to_vector(const EditBone *bone, const float align_axis[3], const bool axis_only)
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
@ MOTIONPATH_BAKE_HAS_PATHS
@ POSE_RUNTIME_HINGE_CHILD_TRANSFORM
@ POSE_RUNTIME_TRANSFORM_CHILD
void BKE_bone_parent_transform_calc_from_pchan(bke::PChanBoneConst pchanbone, BoneParentTransform *r_bpt)
bPoseChannel * BKE_pose_channel_find_name(const bPose *pose, const char *name)
void ED_pose_recalculate_paths(bContext *C, Scene *scene, Object *ob)
void animviz_update_motionpath_preview(Depsgraph &depsgraph, Span< MPathTarget > targets)
void * MEM_new_array_zeroed(size_t len, size_t size, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1
ListBaseT< Bone > childbase
struct ToolSettings * toolsettings
eMotionPath_BakeFlag path_bakeflag
eAnimViz_RecalcFlags recalc
ListBaseT< EditBone > * edbo
struct bConstraint * next
bPoseChannelRuntimeFlag flag
struct bPoseChannel_Runtime runtime
struct bPoseChannel * parent
ListBaseT< struct bConstraint > constraints
ePchan_ConstFlag constflag
ListBaseT< bPoseChannel > chanbase