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:
authorJoshua Leung <aligorith@gmail.com>2009-09-12 09:06:28 +0400
committerJoshua Leung <aligorith@gmail.com>2009-09-12 09:06:28 +0400
commit83074d0b3758c1b2d2811974726d4dd33f3034da (patch)
tree6ef4208631de9435d71cdd29637ee9ca329f6e68 /source/blender/editors
parentf0eb02a36b5a04d18a1a587b1e36419daa6a6f23 (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/editors')
-rw-r--r--source/blender/editors/animation/keyingsets.c2
-rw-r--r--source/blender/editors/armature/editarmature.c1
-rw-r--r--source/blender/editors/armature/poseobject.c29
-rw-r--r--source/blender/editors/transform/transform.c12
-rw-r--r--source/blender/editors/transform/transform_conversions.c4
5 files changed, 38 insertions, 10 deletions
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 2639d49b5be..60efcce4e73 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -1177,7 +1177,7 @@ int modify_keyframes (bContext *C, ListBase *dsources, bAction *act, KeyingSet *
/* if this path is exactly "rotation", and the rotation mode is set to eulers,
* use "euler_rotation" instead so that rotations will be keyed correctly
*/
- if (strcmp(ksp->rna_path, "rotation")==0 && (cks->pchan->rotmode))
+ if (strcmp(ksp->rna_path, "rotation")==0 && (cks->pchan->rotmode > 0))
BLI_dynstr_append(pathds, "euler_rotation");
else
BLI_dynstr_append(pathds, ksp->rna_path);
diff --git a/source/blender/editors/armature/editarmature.c b/source/blender/editors/armature/editarmature.c
index 3b6c9e9d13d..e2293b65878 100644
--- a/source/blender/editors/armature/editarmature.c
+++ b/source/blender/editors/armature/editarmature.c
@@ -4865,6 +4865,7 @@ static int pose_clear_rot_exec(bContext *C, wmOperator *op)
eul[0]= eul[1]= eul[2]= 0.0f;
+ // TODO: for 4 channel rotations, we need special flags for those too...
if (pchan->protectflag & OB_LOCK_ROTX)
eul[0]= oldeul[0];
if (pchan->protectflag & OB_LOCK_ROTY)
diff --git a/source/blender/editors/armature/poseobject.c b/source/blender/editors/armature/poseobject.c
index 9a404e24e12..b473b9ee226 100644
--- a/source/blender/editors/armature/poseobject.c
+++ b/source/blender/editors/armature/poseobject.c
@@ -1009,12 +1009,25 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
}
}
else if (pchan->rotmode > 0) {
- /* quat to euler */
- QuatToEulO(chan->quat, pchan->eul, pchan->rotmode);
+ /* quat/axis-angle to euler */
+ if (chan->rotmode == PCHAN_ROT_AXISANGLE)
+ AxisAngleToEulO(&chan->quat[1], chan->quat[0], pchan->eul, pchan->rotmode);
+ else
+ QuatToEulO(chan->quat, pchan->eul, pchan->rotmode);
+ }
+ else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
+ /* quat/euler to axis angle */
+ if (chan->rotmode > 0)
+ EulOToAxisAngle(chan->eul, chan->rotmode, &pchan->quat[1], &pchan->quat[0]);
+ else
+ QuatToAxisAngle(chan->quat, &pchan->quat[1], &pchan->quat[0]);
}
else {
- /* euler to quat */
- EulOToQuat(chan->eul, chan->rotmode, pchan->quat);
+ /* euler/axis-angle to quat */
+ if (chan->rotmode > 0)
+ EulOToQuat(chan->eul, chan->rotmode, pchan->quat);
+ else
+ AxisAngleToQuat(pchan->quat, &chan->quat[1], chan->quat[0]);
}
/* paste flipped pose? */
@@ -1026,6 +1039,14 @@ static int pose_paste_exec (bContext *C, wmOperator *op)
pchan->eul[1] *= -1;
pchan->eul[2] *= -1;
}
+ else if (pchan->rotmode == PCHAN_ROT_AXISANGLE) {
+ float eul[3];
+
+ AxisAngleToEulO(&pchan->quat[1], pchan->quat[0], eul, EULER_ORDER_DEFAULT);
+ eul[1]*= -1;
+ eul[2]*= -1;
+ EulOToAxisAngle(eul, EULER_ORDER_DEFAULT, &pchan->quat[1], &pchan->quat[0]);
+ }
else {
float eul[3];
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 6405e87c4c0..467f5c59e3d 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1614,7 +1614,8 @@ static void protectedQuaternionBits(short protectflag, float *quat, float *oldqu
{
/* quaternions get limited with euler... */
/* this function only does the delta rotation */
-
+
+ // FIXME: need special checks for quality here...
if(protectflag) {
float eul[3], oldeul[3], quat1[4];
@@ -2686,12 +2687,13 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
QuatMul(td->ext->quat, quat, iquat);
- /* this function works on end result */
- protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
-
/* make temp copy (since stored in same place) */
- QuatCopy(quat, td->ext->quat);
+ QuatCopy(quat, td->ext->quat); // this is just a 4d vector copying function
QuatToAxisAngle(quat, &td->ext->quat[1], &td->ext->quat[0]);
+
+ /* this function works on end result */
+ // TODO: we really need a specialised version of this for axis-angle that doesn't try to do quats...
+ protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
}
else {
float eulmat[3][3];
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index e0d058f160f..6386c0d4eb7 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -509,6 +509,8 @@ static short apply_targetless_ik(Object *ob)
/* rotation */
if (parchan->rotmode > 0)
Mat3ToEulO(rmat3, parchan->eul, parchan->rotmode);
+ else if (parchan->rotmode == PCHAN_ROT_AXISANGLE)
+ Mat3ToAxisAngle(rmat3, &parchan->quat[1], &parchan->quat[0]);
else
Mat3ToQuat(rmat3, parchan->quat);
@@ -517,6 +519,8 @@ static short apply_targetless_ik(Object *ob)
if (data->flag & CONSTRAINT_IK_STRETCH) {
if (parchan->rotmode > 0)
EulOToMat3(parchan->eul, parchan->rotmode, qrmat);
+ else if (parchan->rotmode == PCHAN_ROT_AXISANGLE)
+ AxisAngleToMat3(&parchan->quat[1], parchan->quat[0], qrmat);
else
QuatToMat3(parchan->quat, qrmat);