diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-09-06 11:22:32 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-09-06 11:22:32 +0400 |
commit | 51aa207d200d2cef1cdc7f4e90a6a0f7a4b31c8e (patch) | |
tree | 73427c20de71473fd6af131e027f1b3604c9d090 /source/blender/blenlib/intern | |
parent | 0a3694cd6ebec710da7110e9f168a72d47c71ee0 (diff) |
2.5 Anim Bugfixes:
* Rotation order code should be more correct now. Previously was only shuffling axes, and was also doing some evil things to provided that that it shouldn't have been doing, which was causing some flipping issues.
* Built-in keyingsets for 'visual' options should now be more correct. The old code had typos, giving wrong array indices to start from.
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/arithb.c | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index 9d67ac50108..7a4aaa1a858 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -2835,9 +2835,9 @@ void EulOToQuat(float e[3], short order, float q[4]) double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss; double a[3]; - if (R->parity) e[1] = -e[1]; + if (R->parity) e[1] = -e[1]; // xxx watch it! - ti = e[0]/2; tj = e[1]/2; th = e[2]/2; + ti = e[i]/2; tj = e[j]/2; th = e[k]/2; ci = cos(ti); cj = cos(tj); ch = cos(th); si = sin(ti); sj = sin(tj); sh = sin(th); @@ -2874,12 +2874,11 @@ void EulOToMat3(float e[3], short order, float M[3][3]) double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss; if (R->parity) { - e[0] = -e[0]; - e[1] = -e[1]; - e[2] = -e[2]; + ti = -e[i]; tj = -e[j]; th = -e[k]; + } + else { + ti = e[i]; tj = e[j]; th = e[k]; } - - ti = e[0]; tj = e[1]; th = e[2]; ci = cos(ti); cj = cos(tj); ch = cos(th); si = sin(ti); sj = sin(tj); sh = sin(th); @@ -2908,17 +2907,17 @@ void Mat3ToEulO(float M[3][3], float e[3], short order) { RotOrderInfo *R= GET_ROTATIONORDER_INFO(order); short i=R->i, j=R->j, k=R->k; - double cy = sqrt(M[i][i]*M[i][i] + M[j][i]*M[j][i]); + double cy = sqrt(M[i][i]*M[i][i] + M[i][j]*M[i][j]); if (cy > 16*FLT_EPSILON) { - e[0] = atan2(M[j][k], M[k][k]); - e[1] = atan2(-M[i][k], cy); - e[2] = atan2(M[i][j], M[i][i]); + e[i] = atan2(M[j][k], M[k][k]); + e[j] = atan2(-M[i][k], cy); + e[k] = atan2(M[i][j], M[i][i]); } else { - e[0] = atan2(-M[k][j], M[j][j]); - e[1] = atan2(-M[i][k], cy); - e[2] = 0; + e[i] = atan2(-M[k][j], M[j][j]); + e[j] = atan2(-M[i][k], cy); + e[k] = 0; } if (R->parity) { @@ -2944,21 +2943,28 @@ static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, short order) { RotOrderInfo *R= GET_ROTATIONORDER_INFO(order); short i=R->i, j=R->j, k=R->k; - double cy = sqrt(M[i][i]*M[i][i] + M[j][i]*M[j][i]); + float m[3][3]; + double cy; + + /* process the matrix first */ + Mat3CpyMat3(m, M); + Mat3Ortho(m); + + cy= sqrt(m[i][i]*m[i][i] + m[i][j]*m[i][j]); if (cy > 16*FLT_EPSILON) { - e1[0] = atan2(M[j][k], M[k][k]); - e1[1] = atan2(-M[i][k], cy); - e1[2] = atan2(M[i][j], M[i][i]); + e1[i] = atan2(m[j][k], m[k][k]); + e1[j] = atan2(-m[i][k], cy); + e1[k] = atan2(m[i][j], m[i][i]); - e2[0] = atan2(-M[j][k], -M[k][k]); - e2[1] = atan2(-M[i][k], -cy); - e2[2] = atan2(-M[i][j], -M[i][i]); + e2[i] = atan2(-m[j][k], -m[k][k]); + e2[j] = atan2(-m[i][k], -cy); + e2[k] = atan2(-m[i][j], -m[i][i]); } else { - e1[0] = atan2(-M[k][j], M[j][j]); - e1[1] = atan2(-M[i][k], cy); - e1[2] = 0; + e1[i] = atan2(-m[k][j], m[j][j]); + e1[j] = atan2(-m[i][k], cy); + e1[k] = 0; VecCopyf(e2, e1); } @@ -2975,7 +2981,6 @@ static void mat3_to_eulo2(float M[3][3], float *e1, float *e2, short order) } /* uses 2 methods to retrieve eulers, and picks the closest */ -// FIXME: this does not work well with the other rotation modes... void Mat3ToCompatibleEulO(float mat[3][3], float eul[3], float oldrot[3], short order) { float eul1[3], eul2[3]; |