BKE_pchan: add BKE_pchan_rot_to_mat3
Useful to get the un-scaled rotation from a pose channel.
This commit is contained in:
parent
340c564020
commit
5915d1f453
|
@ -144,8 +144,9 @@ void BKE_armature_mat_pose_to_bone_ex(struct Depsgraph *depsgraph,
|
|||
float outmat[4][4]);
|
||||
|
||||
void BKE_pchan_mat3_to_rot(struct bPoseChannel *pchan, float mat[3][3], bool use_compat);
|
||||
void BKE_pchan_rot_to_mat3(const struct bPoseChannel *pchan, float mat[3][3]);
|
||||
void BKE_pchan_apply_mat4(struct bPoseChannel *pchan, float mat[4][4], bool use_comat);
|
||||
void BKE_pchan_to_mat4(struct bPoseChannel *pchan, float chan_mat[4][4]);
|
||||
void BKE_pchan_to_mat4(const struct bPoseChannel *pchan, float chan_mat[4][4]);
|
||||
void BKE_pchan_calc_mat(struct bPoseChannel *pchan);
|
||||
|
||||
/* Simple helper, computes the offset bone matrix. */
|
||||
|
|
|
@ -153,7 +153,7 @@ struct Object *BKE_object_duplicate(struct Main *bmain,
|
|||
void BKE_object_obdata_size_init(struct Object *ob, const float scale);
|
||||
|
||||
void BKE_object_scale_to_mat3(struct Object *ob, float mat[3][3]);
|
||||
void BKE_object_rot_to_mat3(struct Object *ob, float mat[3][3], bool use_drot);
|
||||
void BKE_object_rot_to_mat3(const struct Object *ob, float mat[3][3], bool use_drot);
|
||||
void BKE_object_mat3_to_rot(struct Object *ob, float mat[3][3], bool use_compat);
|
||||
void BKE_object_to_mat3(struct Object *ob, float mat[3][3]);
|
||||
void BKE_object_to_mat4(struct Object *ob, float mat[4][4]);
|
||||
|
|
|
@ -1872,6 +1872,33 @@ void BKE_pchan_mat3_to_rot(bPoseChannel *pchan, float mat[3][3], bool use_compat
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as #BKE_object_rot_to_mat3().
|
||||
*/
|
||||
void BKE_pchan_rot_to_mat3(const bPoseChannel *pchan, float mat[3][3])
|
||||
{
|
||||
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
|
||||
if (pchan->rotmode > 0) {
|
||||
/* euler rotations (will cause gimble lock,
|
||||
* but this can be alleviated a bit with rotation orders) */
|
||||
eulO_to_mat3(mat, pchan->eul, pchan->rotmode);
|
||||
}
|
||||
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
|
||||
/* axis-angle - not really that great for 3D-changing orientations */
|
||||
axis_angle_to_mat3(mat, pchan->rotAxis, pchan->rotAngle);
|
||||
}
|
||||
else {
|
||||
/* quats are normalized before use to eliminate scaling issues */
|
||||
float quat[4];
|
||||
|
||||
/* NOTE: we now don't normalize the stored values anymore,
|
||||
* since this was kindof evil in some cases but if this proves to be too problematic,
|
||||
* switch back to the old system of operating directly on the stored copy. */
|
||||
normalize_qt_qt(quat, pchan->quat);
|
||||
quat_to_mat3(mat, quat);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a 4x4 matrix to the pose bone,
|
||||
* similar to #BKE_object_apply_mat4().
|
||||
|
@ -2468,7 +2495,7 @@ void BKE_pose_rebuild(Main *bmain, Object *ob, bArmature *arm, const bool do_id_
|
|||
/* ********************** THE POSE SOLVER ******************* */
|
||||
|
||||
/* loc/rot/size to given mat4 */
|
||||
void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4])
|
||||
void BKE_pchan_to_mat4(const bPoseChannel *pchan, float chan_mat[4][4])
|
||||
{
|
||||
float smat[3][3];
|
||||
float rmat[3][3];
|
||||
|
@ -2477,26 +2504,8 @@ void BKE_pchan_to_mat4(bPoseChannel *pchan, float chan_mat[4][4])
|
|||
/* get scaling matrix */
|
||||
size_to_mat3(smat, pchan->size);
|
||||
|
||||
/* rotations may either be quats, eulers (with various rotation orders), or axis-angle */
|
||||
if (pchan->rotmode > 0) {
|
||||
/* euler rotations (will cause gimble lock,
|
||||
* but this can be alleviated a bit with rotation orders) */
|
||||
eulO_to_mat3(rmat, pchan->eul, pchan->rotmode);
|
||||
}
|
||||
else if (pchan->rotmode == ROT_MODE_AXISANGLE) {
|
||||
/* axis-angle - not really that great for 3D-changing orientations */
|
||||
axis_angle_to_mat3(rmat, pchan->rotAxis, pchan->rotAngle);
|
||||
}
|
||||
else {
|
||||
/* quats are normalized before use to eliminate scaling issues */
|
||||
float quat[4];
|
||||
|
||||
/* NOTE: we now don't normalize the stored values anymore,
|
||||
* since this was kindof evil in some cases but if this proves to be too problematic,
|
||||
* switch back to the old system of operating directly on the stored copy. */
|
||||
normalize_qt_qt(quat, pchan->quat);
|
||||
quat_to_mat3(rmat, quat);
|
||||
}
|
||||
/* get rotation matrix */
|
||||
BKE_pchan_rot_to_mat3(pchan, rmat);
|
||||
|
||||
/* calculate matrix of bone (as 3x3 matrix, but then copy the 4x4) */
|
||||
mul_m3_m3m3(tmat, rmat, smat);
|
||||
|
|
|
@ -2016,7 +2016,7 @@ void BKE_object_scale_to_mat3(Object *ob, float mat[3][3])
|
|||
size_to_mat3(mat, vec);
|
||||
}
|
||||
|
||||
void BKE_object_rot_to_mat3(Object *ob, float mat[3][3], bool use_drot)
|
||||
void BKE_object_rot_to_mat3(const Object *ob, float mat[3][3], bool use_drot)
|
||||
{
|
||||
float rmat[3][3], dmat[3][3];
|
||||
|
||||
|
|
Loading…
Reference in New Issue