Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-05-01 06:15:44 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-05-01 06:17:10 +0300
commit5915d1f453e94c722cd1bfea45cbce0bf436309d (patch)
tree2f00ad3578bb342b1ba8de3e899c584875e2337b /source/blender/blenkernel/intern/armature.c
parent340c564020f580579e2d7db63ba860527cd72ea3 (diff)
BKE_pchan: add BKE_pchan_rot_to_mat3
Useful to get the un-scaled rotation from a pose channel.
Diffstat (limited to 'source/blender/blenkernel/intern/armature.c')
-rw-r--r--source/blender/blenkernel/intern/armature.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 7f374c1d66e..9645721d29b 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1873,6 +1873,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);