Move rotOrder to proper transform data structure

This commit is contained in:
Martin Poirier 2010-11-14 19:19:58 +00:00
parent ba965b0f7a
commit 43e6ccd57b
3 changed files with 27 additions and 34 deletions

@ -1986,9 +1986,10 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
* - current space should be local * - current space should be local
*/ */
memset(cob, 0, sizeof(bConstraintOb)); memset(cob, 0, sizeof(bConstraintOb));
if (td->rotOrder == ROT_MODE_QUAT) { if (td->ext)
/* quats */ {
if (td->ext) { if (td->ext->rotOrder == ROT_MODE_QUAT) {
/* quats */
/* objects and bones do normalization first too, otherwise /* objects and bones do normalization first too, otherwise
we don't necessarily end up with a rotation matrix, and we don't necessarily end up with a rotation matrix, and
then conversion back to quat gives a different result */ then conversion back to quat gives a different result */
@ -1997,22 +1998,14 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td)
normalize_qt(quat); normalize_qt(quat);
quat_to_mat4(cob->matrix, quat); quat_to_mat4(cob->matrix, quat);
} }
else else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) {
return; /* axis angle */
}
else if (td->rotOrder == ROT_MODE_AXISANGLE) {
/* axis angle */
if (td->ext)
axis_angle_to_mat4(cob->matrix, &td->ext->quat[1], td->ext->quat[0]); axis_angle_to_mat4(cob->matrix, &td->ext->quat[1], td->ext->quat[0]);
else }
return; else {
} /* eulers */
else { eulO_to_mat4(cob->matrix, td->ext->rot, td->ext->rotOrder);
/* eulers */ }
if (td->ext)
eulO_to_mat4(cob->matrix, td->ext->rot, td->rotOrder);
else
return;
} }
} }
@ -2070,17 +2063,17 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td)
if(dolimit) { if(dolimit) {
/* copy results from cob->matrix */ /* copy results from cob->matrix */
if (td->rotOrder == ROT_MODE_QUAT) { if (td->ext->rotOrder == ROT_MODE_QUAT) {
/* quats */ /* quats */
mat4_to_quat( td->ext->quat,cob.matrix); mat4_to_quat( td->ext->quat,cob.matrix);
} }
else if (td->rotOrder == ROT_MODE_AXISANGLE) { else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) {
/* axis angle */ /* axis angle */
mat4_to_axis_angle( &td->ext->quat[1], &td->ext->quat[0],cob.matrix); mat4_to_axis_angle( &td->ext->quat[1], &td->ext->quat[0],cob.matrix);
} }
else { else {
/* eulers */ /* eulers */
mat4_to_eulO( td->ext->rot, td->rotOrder,cob.matrix); mat4_to_eulO( td->ext->rot, td->ext->rotOrder,cob.matrix);
} }
} }
} }
@ -2946,7 +2939,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
/* rotation */ /* rotation */
if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
/* euler or quaternion/axis-angle? */ /* euler or quaternion/axis-angle? */
if (td->rotOrder == ROT_MODE_QUAT) { if (td->ext->rotOrder == ROT_MODE_QUAT) {
mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
mat3_to_quat( quat,fmat); // Actual transform mat3_to_quat( quat,fmat); // Actual transform
@ -2956,7 +2949,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
} }
else if (td->rotOrder == ROT_MODE_AXISANGLE) { else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) {
/* calculate effect based on quats */ /* calculate effect based on quats */
float iquat[4], tquat[4]; float iquat[4], tquat[4];
@ -2979,12 +2972,12 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
/* calculate the total rotatation in eulers */ /* calculate the total rotatation in eulers */
VECCOPY(eul, td->ext->irot); VECCOPY(eul, td->ext->irot);
eulO_to_mat3( eulmat,eul, td->rotOrder); eulO_to_mat3( eulmat,eul, td->ext->rotOrder);
/* mat = transform, obmat = bone rotation */ /* mat = transform, obmat = bone rotation */
mul_m3_m3m3(fmat, smat, eulmat); mul_m3_m3m3(fmat, smat, eulmat);
mat3_to_compatible_eulO( eul, td->ext->rot, td->rotOrder,fmat); mat3_to_compatible_eulO( eul, td->ext->rot, td->ext->rotOrder,fmat);
/* and apply (to end result only) */ /* and apply (to end result only) */
protectedRotateBits(td->protectflag, eul, td->ext->irot); protectedRotateBits(td->protectflag, eul, td->ext->irot);
@ -3016,7 +3009,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
/* rotation */ /* rotation */
if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself
/* euler or quaternion? */ /* euler or quaternion? */
if ((td->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) { if ((td->ext->rotOrder == ROT_MODE_QUAT) || (td->flag & TD_USEQUAT)) {
mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); mul_serie_m3(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0);
mat3_to_quat( quat,fmat); // Actual transform mat3_to_quat( quat,fmat); // Actual transform
@ -3024,7 +3017,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
/* this function works on end result */ /* this function works on end result */
protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat);
} }
else if (td->rotOrder == ROT_MODE_AXISANGLE) { else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) {
/* calculate effect based on quats */ /* calculate effect based on quats */
float iquat[4], tquat[4]; float iquat[4], tquat[4];
@ -3047,11 +3040,11 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short
/* calculate the total rotatation in eulers */ /* calculate the total rotatation in eulers */
add_v3_v3v3(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */ add_v3_v3v3(eul, td->ext->irot, td->ext->drot); /* we have to correct for delta rot */
eulO_to_mat3( obmat,eul, td->rotOrder); eulO_to_mat3( obmat,eul, td->ext->rotOrder);
/* mat = transform, obmat = object rotation */ /* mat = transform, obmat = object rotation */
mul_m3_m3m3(fmat, smat, obmat); mul_m3_m3m3(fmat, smat, obmat);
mat3_to_compatible_eulO( eul, td->ext->rot, td->rotOrder,fmat); mat3_to_compatible_eulO( eul, td->ext->rot, td->ext->rotOrder,fmat);
/* correct back for delta rot */ /* correct back for delta rot */
sub_v3_v3v3(eul, eul, td->ext->drot); sub_v3_v3v3(eul, eul, td->ext->drot);

@ -147,6 +147,7 @@ typedef struct TransDataExtension {
float isize[3]; /* Initial size */ float isize[3]; /* Initial size */
float obmat[4][4]; /* Object matrix */ float obmat[4][4]; /* Object matrix */
float l_smtx[3][3]; /* use instead of td->smtx, It is the same but without the 'bone->bone_mat', see TD_PBONE_LOCAL_MTX_C */ float l_smtx[3][3]; /* use instead of td->smtx, It is the same but without the 'bone->bone_mat', see TD_PBONE_LOCAL_MTX_C */
int rotOrder; /* rotation mode, as defined in eRotationModes (DNA_action_types.h) */
} TransDataExtension; } TransDataExtension;
typedef struct TransData2D { typedef struct TransData2D {
@ -233,7 +234,6 @@ typedef struct TransData {
void *extra; /* extra data (mirrored element pointer, in editmode mesh to EditVert) (editbone for roll fixing) (...) */ void *extra; /* extra data (mirrored element pointer, in editmode mesh to EditVert) (editbone for roll fixing) (...) */
int flag; /* Various flags */ int flag; /* Various flags */
short protectflag; /* If set, copy of Object or PoseChannel protection */ short protectflag; /* If set, copy of Object or PoseChannel protection */
int rotOrder; /* rotation mode, as defined in eRotationModes (DNA_action_types.h) */
} TransData; } TransData;
typedef struct MouseInput { typedef struct MouseInput {

@ -548,7 +548,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr
QUATCOPY(td->ext->iquat, pchan->quat); QUATCOPY(td->ext->iquat, pchan->quat);
} }
td->rotOrder= pchan->rotmode; td->ext->rotOrder= pchan->rotmode;
/* proper way to get parent transform + own transform + constraints transform */ /* proper way to get parent transform + own transform + constraints transform */
@ -4329,7 +4329,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob)
QUATCOPY(td->ext->iquat, ob->quat); QUATCOPY(td->ext->iquat, ob->quat);
QUATCOPY(td->ext->dquat, ob->dquat); QUATCOPY(td->ext->dquat, ob->dquat);
} }
td->rotOrder=ob->rotmode; td->ext->rotOrder=ob->rotmode;
td->ext->size = ob->size; td->ext->size = ob->size;
VECCOPY(td->ext->isize, ob->size); VECCOPY(td->ext->isize, ob->size);
@ -5158,7 +5158,7 @@ static void createTransObject(bContext *C, TransInfo *t)
td->flag = TD_SELECTED; td->flag = TD_SELECTED;
td->protectflag= ob->protectflag; td->protectflag= ob->protectflag;
td->ext = tx; td->ext = tx;
td->rotOrder= ob->rotmode; td->ext->rotOrder= ob->rotmode;
if (base->flag & BA_TRANSFORM_CHILD) if (base->flag & BA_TRANSFORM_CHILD)
{ {
@ -5192,7 +5192,7 @@ static void createTransObject(bContext *C, TransInfo *t)
{ {
td->protectflag= ob->protectflag; td->protectflag= ob->protectflag;
td->ext = tx; td->ext = tx;
td->rotOrder= ob->rotmode; td->ext->rotOrder= ob->rotmode;
ObjectToTransData(t, td, ob); ObjectToTransData(t, td, ob);
td->val = NULL; td->val = NULL;