[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [24177] trunk/blender/source/blender: - Simplified EulToGimbalAxis, its still only works on XYZ and ZXY but at least its more clear whats going on .
Campbell Barton
ideasman42 at gmail.com
Fri Oct 30 13:11:04 CET 2009
Revision: 24177
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=24177
Author: campbellbarton
Date: 2009-10-30 13:11:04 +0100 (Fri, 30 Oct 2009)
Log Message:
-----------
- Simplified EulToGimbalAxis, its still only works on XYZ and ZXY but at least its more clear whats going on.
- Made RotOrderInfo use a vector rather then i/j/k
- Added gimbal_axis to transform.h (was extern)
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/arithb.c
trunk/blender/source/blender/editors/transform/transform.h
trunk/blender/source/blender/editors/transform/transform_manipulator.c
trunk/blender/source/blender/editors/transform/transform_orientations.c
Modified: trunk/blender/source/blender/blenlib/intern/arithb.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/arithb.c 2009-10-30 09:50:35 UTC (rev 24176)
+++ trunk/blender/source/blender/blenlib/intern/arithb.c 2009-10-30 12:11:04 UTC (rev 24177)
@@ -2995,10 +2995,8 @@
/* Type for rotation order info - see wiki for derivation details */
typedef struct RotOrderInfo {
- short i; /* first axis index */
- short j; /* second axis index */
- short k; /* third axis index */
- short parity; /* parity of axis permuation (even=0, odd=1) - 'n' in original code */
+ short axis[3];
+ short parity; /* parity of axis permutation (even=0, odd=1) - 'n' in original code */
} RotOrderInfo;
/* Array of info for Rotation Order calculations
@@ -3006,12 +3004,12 @@
*/
static RotOrderInfo rotOrders[]= {
/* i, j, k, n */
- {0, 1, 2, 0}, // XYZ
- {0, 2, 1, 1}, // XZY
- {1, 0, 2, 1}, // YXZ
- {1, 2, 0, 0}, // YZX
- {2, 0, 1, 0}, // ZXY
- {2, 1, 0, 1} // ZYZ
+ {{0, 1, 2}, 0}, // XYZ
+ {{0, 2, 1}, 1}, // XZY
+ {{1, 0, 2}, 1}, // YXZ
+ {{1, 2, 0}, 0}, // YZX
+ {{2, 0, 1}, 0}, // ZXY
+ {{2, 1, 0}, 1} // ZYZ
};
/* Get relevant pointer to rotation order set from the array
@@ -3024,7 +3022,7 @@
void EulOToQuat(float e[3], short order, float q[4])
{
RotOrderInfo *R= GET_ROTATIONORDER_INFO(order);
- short i=R->i, j=R->j, k=R->k;
+ short i=R->axis[0], j=R->axis[1], k=R->axis[2];
double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss;
double a[3];
@@ -3063,7 +3061,7 @@
void EulOToMat3(float e[3], short order, float M[3][3])
{
RotOrderInfo *R= GET_ROTATIONORDER_INFO(order);
- short i=R->i, j=R->j, k=R->k;
+ short i=R->axis[0], j=R->axis[1], k=R->axis[2];
double ti, tj, th, ci, cj, ch, si, sj, sh, cc, cs, sc, ss;
if (R->parity) {
@@ -3099,7 +3097,7 @@
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;
+ short i=R->axis[0], j=R->axis[1], k=R->axis[2];
double cy = sqrt(M[i][i]*M[i][i] + M[i][j]*M[i][j]);
if (cy > 16*FLT_EPSILON) {
@@ -3135,7 +3133,7 @@
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;
+ short i=R->axis[0], j=R->axis[1], k=R->axis[2];
float m[3][3];
double cy;
@@ -3472,30 +3470,21 @@
void EulToGimbalAxis(float gmat[][3], float *eul, short order)
{
RotOrderInfo *R= GET_ROTATIONORDER_INFO(order);
- short R_order[3];
- short R_order2[3];
float quat[4];
float teul[3];
float tvec[3];
int i, a;
- R_order2[R->i]= 0;
- R_order2[R->j]= 1;
- R_order2[R->k]= 2;
-
- R_order[0]= R->i;
- R_order[1]= R->j;
- R_order[2]= R->k;
-
for(i= 0; i<3; i++) {
tvec[0]= tvec[1]= tvec[2]= 0.0f;
tvec[i] = 1.0f;
VecCopyf(teul, eul);
- for(a= R_order2[i]; a >= 1; a--)
- teul[R_order[a-1]]= 0.0f;
+ /* 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);
@@ -3504,31 +3493,6 @@
VecCopyf(gmat[i], tvec);
}
-
-
-#if 0
-
- for(i= 0; i<3; i++) {
- tvec[0]= tvec[1]= tvec[2]= 0.0f;
- tvec[i] = 1.0f;
-
- VecCopyf(teul, eul);
-
- for(a= R_order2[i]; a >= 1; a--)
- teul[R_order[a-1]]= 0.0f;
-
- EulToQuat(teul, quat);
- NormalQuat(quat);
- QuatMulVecf(quat, tvec);
- Normalize(tvec);
-
- VecCopyf(gmat[i], tvec);
- }
-#endif
-
-
-
-
}
/* ************ AXIS ANGLE *************** */
Modified: trunk/blender/source/blender/editors/transform/transform.h
===================================================================
--- trunk/blender/source/blender/editors/transform/transform.h 2009-10-30 09:50:35 UTC (rev 24176)
+++ trunk/blender/source/blender/editors/transform/transform.h 2009-10-30 12:11:04 UTC (rev 24177)
@@ -535,6 +535,7 @@
void flushTransSeq(TransInfo *t);
/*********************** exported from transform_manipulator.c ********** */
+void gimbal_axis(struct Object *ob, float gmat[][3]);
int calc_manipulator_stats(const struct bContext *C);
float get_drawsize(struct ARegion *ar, float *co);
Modified: trunk/blender/source/blender/editors/transform/transform_manipulator.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_manipulator.c 2009-10-30 09:50:35 UTC (rev 24176)
+++ trunk/blender/source/blender/editors/transform/transform_manipulator.c 2009-10-30 12:11:04 UTC (rev 24177)
@@ -181,7 +181,7 @@
return (ELEM(rotmode, ROT_MODE_AXISANGLE, ROT_MODE_QUAT)) ? 0:1;
}
-void gimbalAxis(Object *ob, float gmat[][3])
+void gimbal_axis(Object *ob, float gmat[][3])
{
if(ob->mode & OB_MODE_POSE)
{
@@ -475,7 +475,7 @@
{
float mat[3][3];
Mat3One(mat);
- gimbalAxis(ob, mat);
+ gimbal_axis(ob, mat);
Mat4CpyMat3(rv3d->twmat, mat);
break;
}
Modified: trunk/blender/source/blender/editors/transform/transform_orientations.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_orientations.c 2009-10-30 09:50:35 UTC (rev 24176)
+++ trunk/blender/source/blender/editors/transform/transform_orientations.c 2009-10-30 12:11:04 UTC (rev 24177)
@@ -510,7 +510,6 @@
return total;
}
-extern void gimbalAxis(Object *ob, float gimbal_vecs[][3]);
void initTransformOrientation(bContext *C, TransInfo *t)
{
View3D *v3d = CTX_wm_view3d(C);
@@ -528,7 +527,7 @@
case V3D_MANIP_GIMBAL:
Mat3One(t->spacemtx);
if(ob)
- gimbalAxis(ob, t->spacemtx);
+ gimbal_axis(ob, t->spacemtx);
break;
case V3D_MANIP_NORMAL:
if(obedit || (ob && ob->mode & OB_MODE_POSE)) {
More information about the Bf-blender-cvs
mailing list