diff options
author | Martin Poirier <theeth@yahoo.com> | 2009-11-02 00:10:54 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2009-11-02 00:10:54 +0300 |
commit | 94209d58aa45455793d0148299755c28ab832ba1 (patch) | |
tree | f8b7e8eaba40e14ef1f57cea70a3db8f0b10aff8 /source/blender/blenlib/intern/arithb.c | |
parent | 7bb6e18f20916b73618a4a42a4ebf285f5e3f6a9 (diff) |
Simplify gimbal axis code and make gimbal orientation work correctly with parents (objects or pose bones). Works for all euler orders too, obviously.
Diffstat (limited to 'source/blender/blenlib/intern/arithb.c')
-rw-r--r-- | source/blender/blenlib/intern/arithb.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index fe8f97b4bcf..874756135e5 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -3471,28 +3471,25 @@ void EulToGimbalAxis(float gmat[][3], float *eul, short order) { RotOrderInfo *R= GET_ROTATIONORDER_INFO(order); - float quat[4]; + float mat[3][3]; float teul[3]; - float tvec[3]; - int i, a; - - for(i= 0; i<3; i++) { - tvec[0]= tvec[1]= tvec[2]= 0.0f; - tvec[i] = 1.0f; - - VecCopyf(teul, eul); - - /* TODO - only works on XYZ and ZXY */ - for(a= R->axis[i]; a >= 1; a--) - teul[R->axis[a-1]]= 0.0f; - - EulOToQuat(teul, order, quat); - NormalQuat(quat); - QuatMulVecf(quat, tvec); - Normalize(tvec); - VecCopyf(gmat[i], tvec); - } + /* first axis is local */ + EulOToMat3(eul, order, mat); + VecCopyf(gmat[R->axis[0]], mat[R->axis[0]]); + + /* second axis is local minus first rotation */ + VecCopyf(teul, eul); + teul[R->axis[0]] = 0; + EulOToMat3(teul, order, mat); + VecCopyf(gmat[R->axis[1]], mat[R->axis[1]]); + + + /* Last axis is global */ + gmat[R->axis[2]][0] = 0; + gmat[R->axis[2]][1] = 0; + gmat[R->axis[2]][2] = 0; + gmat[R->axis[2]][R->axis[2]] = 1; } /* ************ AXIS ANGLE *************** */ |