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-06 11:22:32 +0400
committerJoshua Leung <aligorith@gmail.com>2009-09-06 11:22:32 +0400
commit51aa207d200d2cef1cdc7f4e90a6a0f7a4b31c8e (patch)
tree73427c20de71473fd6af131e027f1b3604c9d090
parent0a3694cd6ebec710da7110e9f168a72d47c71ee0 (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.
-rw-r--r--source/blender/blenlib/intern/arithb.c55
-rw-r--r--source/blender/editors/animation/keyingsets.c14
-rw-r--r--source/blender/editors/transform/transform.c8
3 files changed, 41 insertions, 36 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];
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 15d47211615..2639d49b5be 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -801,24 +801,24 @@ static bBuiltinKeyingSet def_builtin_keyingsets_v3d[] =
/* Keying Sets with Keying Flags ************************* */
/* Keying Set - "VisualLoc" ---------- */
- BI_KS_DEFINE_BEGIN("VisualLoc", 0)
+ BI_KS_DEFINE_BEGIN("VisualLoc", INSERTKEY_MATRIX)
BI_KS_PATHS_BEGIN(1)
- BI_KSP_DEFINE(ID_OB, KSP_TEMPLATE_OBJECT|KSP_TEMPLATE_PCHAN, "location", INSERTKEY_MATRIX, KSP_FLAG_WHOLE_ARRAY, KSP_GROUP_TEMPLATE_ITEM)
+ BI_KSP_DEFINE(ID_OB, KSP_TEMPLATE_OBJECT|KSP_TEMPLATE_PCHAN, "location", 0, KSP_FLAG_WHOLE_ARRAY, KSP_GROUP_TEMPLATE_ITEM)
BI_KS_PATHS_END
BI_KS_DEFINE_END,
/* Keying Set - "Rotation" ---------- */
- BI_KS_DEFINE_BEGIN("VisualRot", 0)
+ BI_KS_DEFINE_BEGIN("VisualRot", INSERTKEY_MATRIX)
BI_KS_PATHS_BEGIN(1)
- BI_KSP_DEFINE(ID_OB, KSP_TEMPLATE_OBJECT|KSP_TEMPLATE_PCHAN|KSP_TEMPLATE_PCHAN_ROT, "rotation", INSERTKEY_MATRIX, KSP_FLAG_WHOLE_ARRAY, KSP_GROUP_TEMPLATE_ITEM)
+ BI_KSP_DEFINE(ID_OB, KSP_TEMPLATE_OBJECT|KSP_TEMPLATE_PCHAN|KSP_TEMPLATE_PCHAN_ROT, "rotation", 0, KSP_FLAG_WHOLE_ARRAY, KSP_GROUP_TEMPLATE_ITEM)
BI_KS_PATHS_END
BI_KS_DEFINE_END,
/* Keying Set - "VisualLocRot" ---------- */
- BI_KS_DEFINE_BEGIN("VisualLocRot", 0)
+ BI_KS_DEFINE_BEGIN("VisualLocRot", INSERTKEY_MATRIX)
BI_KS_PATHS_BEGIN(2)
- BI_KSP_DEFINE(ID_OB, KSP_TEMPLATE_OBJECT|KSP_TEMPLATE_PCHAN, "location", INSERTKEY_MATRIX, KSP_FLAG_WHOLE_ARRAY, KSP_GROUP_TEMPLATE_ITEM),
- BI_KSP_DEFINE(ID_OB, KSP_TEMPLATE_OBJECT|KSP_TEMPLATE_PCHAN|KSP_TEMPLATE_PCHAN_ROT, "rotation", INSERTKEY_MATRIX, KSP_FLAG_WHOLE_ARRAY, KSP_GROUP_TEMPLATE_ITEM)
+ BI_KSP_DEFINE(ID_OB, KSP_TEMPLATE_OBJECT|KSP_TEMPLATE_PCHAN, "location", 0, KSP_FLAG_WHOLE_ARRAY, KSP_GROUP_TEMPLATE_ITEM),
+ BI_KSP_DEFINE(ID_OB, KSP_TEMPLATE_OBJECT|KSP_TEMPLATE_PCHAN|KSP_TEMPLATE_PCHAN_ROT, "rotation", 0, KSP_FLAG_WHOLE_ARRAY, KSP_GROUP_TEMPLATE_ITEM)
BI_KS_PATHS_END
BI_KS_DEFINE_END
};
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 370e98ebd07..1f568be3e10 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1738,12 +1738,12 @@ static void constraintRotLim(TransInfo *t, TransData *td)
eul[1]= tdi->roty[0];
eul[2]= tdi->rotz[0];
- EulToMat4(eul, cob.matrix);
+ EulOToMat4(eul, td->rotOrder, cob.matrix);
}
else {
/* eulers */
if (td->ext)
- EulToMat4(td->ext->rot, cob.matrix);
+ EulOToMat4(td->ext->rot, td->rotOrder, cob.matrix);
else
return;
}
@@ -1796,7 +1796,7 @@ static void constraintRotLim(TransInfo *t, TransData *td)
TransDataIpokey *tdi= td->tdi;
float eul[3];
- Mat4ToEul(cob.matrix, eul);
+ Mat4ToEulO(cob.matrix, eul, td->rotOrder);
tdi->rotx[0]= eul[0];
tdi->roty[0]= eul[1];
@@ -1804,7 +1804,7 @@ static void constraintRotLim(TransInfo *t, TransData *td)
}
else {
/* eulers */
- Mat4ToEul(cob.matrix, td->ext->rot);
+ Mat4ToEulO(cob.matrix, td->ext->rot, td->rotOrder);
}
}
}