diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-09-12 09:06:28 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-09-12 09:06:28 +0400 |
commit | 83074d0b3758c1b2d2811974726d4dd33f3034da (patch) | |
tree | 6ef4208631de9435d71cdd29637ee9ca329f6e68 /source/blender/makesrna | |
parent | f0eb02a36b5a04d18a1a587b1e36419daa6a6f23 (diff) |
2.5 - More work on Axis-Angle Rotations
* Added a few new methods for axis-angle conversions, and used these instead of manually performing those steps elsewhere
* Axis-angles to other representations now get their axes normalised to make sure that odd scaling doesn't occur.
* Made a few more tools work with axis-angles properly
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_pose.c | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 0a88b084307..d143c94ebb1 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -115,14 +115,9 @@ static void rna_PoseChannel_euler_rotation_get(PointerRNA *ptr, float *value) { bPoseChannel *pchan= ptr->data; - if(pchan->rotmode == PCHAN_ROT_AXISANGLE) { - float m[3][3]; - - /* go through a 3x3 matrix */ - VecRotToMat3(&pchan->quat[1], pchan->quat[0], m); - Mat3ToEul(m, value); - } - else if(pchan->rotmode == PCHAN_ROT_QUAT) /* default XYZ eulers when using axis-angle... */ + if(pchan->rotmode == PCHAN_ROT_AXISANGLE) /* default XYZ eulers */ + AxisAngleToEulO(&pchan->quat[1], pchan->quat[0], value, EULER_ORDER_DEFAULT); + else if(pchan->rotmode == PCHAN_ROT_QUAT) /* default XYZ eulers */ QuatToEul(pchan->quat, value); else VECCOPY(value, pchan->eul); @@ -133,14 +128,9 @@ static void rna_PoseChannel_euler_rotation_set(PointerRNA *ptr, const float *val { bPoseChannel *pchan= ptr->data; - if(pchan->rotmode == PCHAN_ROT_AXISANGLE) { /* default XYZ eulers when using axis-angle... */ - float q[4]; - - /* convert to temp quat, then to axis angle (since stored in same var) */ - EulToQuat((float *)value, q); - QuatToAxisAngle(q, &pchan->quat[1], &pchan->quat[0]); - } - else if(pchan->rotmode == PCHAN_ROT_QUAT) /* default XYZ eulers when using quats... */ + if(pchan->rotmode == PCHAN_ROT_AXISANGLE) /* default XYZ eulers */ + EulOToAxisAngle((float *)value, EULER_ORDER_DEFAULT, &pchan->quat[1], &pchan->quat[0]); + else if(pchan->rotmode == PCHAN_ROT_QUAT) /* default XYZ eulers */ EulToQuat((float*)value, pchan->quat); else VECCOPY(pchan->eul, value); @@ -177,13 +167,7 @@ static void rna_PoseChannel_rotation_mode_set(PointerRNA *ptr, int value) if (value > 0) { /* to euler */ if (pchan->rotmode == PCHAN_ROT_AXISANGLE) { /* axis-angle to euler */ - float m[3][3]; - - /* convert to 3x3 matrix, then to euler - * - axis angle is stored in quats - */ - VecRotToMat3(&pchan->quat[1], pchan->quat[0], m); - Mat3ToEulO(m, pchan->eul, value); + AxisAngleToEulO(&pchan->quat[1], pchan->quat[0], pchan->eul, value); } else if (pchan->rotmode == PCHAN_ROT_QUAT) { /* quat to euler */ @@ -209,11 +193,7 @@ static void rna_PoseChannel_rotation_mode_set(PointerRNA *ptr, int value) else { /* to axis-angle */ if (pchan->rotmode > 0) { /* euler to axis angle */ - float q[4]; - - /* convert to temp quat, then to axis angle (since stored in same var) */ - EulOToQuat(pchan->eul, pchan->rotmode, q); - QuatToAxisAngle(q, &pchan->quat[1], &pchan->quat[0]); + EulOToAxisAngle(pchan->eul, pchan->rotmode, &pchan->quat[1], &pchan->quat[0]); } else if (pchan->rotmode == PCHAN_ROT_QUAT) { /* quat to axis angle */ |