diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-09-11 16:05:09 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-09-11 16:05:09 +0400 |
commit | d5009eb1423c3c0359cbc85c7346412c597b8663 (patch) | |
tree | c56d97bdd477682c5dacbf42f500c4e3eec79fef /source/blender/editors/transform | |
parent | 40576677b1dff5373d5b673b599ea9beb094b1ea (diff) |
2.5 Rotations: As a experiment, enabling Axis-Angle for Bones
The support for this is really quite hacky, and I might disable this later if we cannot get some parts to work nicely.
Some notes:
* This is currently stored in the same variable that quaternions are stored in, since they both have 4 components. However, in RNA, I've added 2 properties specially for this.
* There are some shearing issues using certain axes - i.e. (1,1,0) - that will need to be checked on.
* Transform code is really quite temporary for this. Just a quick demo of what can be done...
Diffstat (limited to 'source/blender/editors/transform')
-rw-r--r-- | source/blender/editors/transform/transform.c | 11 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 4 |
2 files changed, 13 insertions, 2 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index f049566d640..ac5d688cd1c 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2663,7 +2663,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short /* rotation */ if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself - /* euler or quaternion? */ + /* euler or quaternion/axis-angle? */ if (td->flag & TD_USEQUAT) { Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); @@ -2672,6 +2672,15 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short QuatMul(td->ext->quat, quat, td->ext->iquat); /* this function works on end result */ protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); + + /* if axis-angle, we now convert the quat representation to axis-angle again + * - this means that the math above is not totally correct, but it works well enough so far... + */ + if (td->rotOrder == PCHAN_ROT_AXISANGLE) { + /* make temp copy (since stored in same place) */ + QuatCopy(quat, td->ext->quat); + QuatToAxisAngle(quat, &td->ext->quat[1], &td->ext->quat[0]); + } } else { float eulmat[3][3]; diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 504563b797b..7a37ffdeeca 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -552,8 +552,9 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->ob = ob; td->flag = TD_SELECTED; - if (pchan->rotmode == PCHAN_ROT_QUAT) + if ((pchan->rotmode == PCHAN_ROT_QUAT) || (pchan->rotmode == PCHAN_ROT_AXISANGLE)) { + // XXX: for now, axis-angle will be treated like for quats (the only difference is the normalisation) td->flag |= TD_USEQUAT; } if (bone->flag & BONE_HINGE_CHILD_TRANSFORM) @@ -587,6 +588,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr td->ext->quat= pchan->quat; QUATCOPY(td->ext->iquat, pchan->quat); + td->rotOrder= pchan->rotmode; } |