diff options
author | Martin Poirier <theeth@yahoo.com> | 2010-11-14 22:19:58 +0300 |
---|---|---|
committer | Martin Poirier <theeth@yahoo.com> | 2010-11-14 22:19:58 +0300 |
commit | 43e6ccd57b8fe813cfc40de81da64e347ce2dd3b (patch) | |
tree | 4d782d058a32f44012c638e3a7350ba7f75d1166 /source/blender/editors | |
parent | ba965b0f7adc6b9dc2774ae8806924afe1e966b2 (diff) |
Move rotOrder to proper transform data structure
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/transform/transform.c | 51 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.h | 2 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 8 |
3 files changed, 27 insertions, 34 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e839a51561c..78044f0d11a 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1986,9 +1986,10 @@ static void constraintob_from_transdata(bConstraintOb *cob, TransData *td) * - current space should be local */ memset(cob, 0, sizeof(bConstraintOb)); - if (td->rotOrder == ROT_MODE_QUAT) { - /* quats */ - if (td->ext) { + if (td->ext) + { + if (td->ext->rotOrder == ROT_MODE_QUAT) { + /* quats */ /* objects and bones do normalization first too, otherwise we don't necessarily end up with a rotation matrix, and 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); quat_to_mat4(cob->matrix, quat); } - else - return; - } - else if (td->rotOrder == ROT_MODE_AXISANGLE) { - /* axis angle */ - if (td->ext) + else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) { + /* axis angle */ axis_angle_to_mat4(cob->matrix, &td->ext->quat[1], td->ext->quat[0]); - else - return; - } - else { - /* eulers */ - if (td->ext) - eulO_to_mat4(cob->matrix, td->ext->rot, td->rotOrder); - else - return; + } + else { + /* eulers */ + eulO_to_mat4(cob->matrix, td->ext->rot, td->ext->rotOrder); + } } } @@ -2070,17 +2063,17 @@ static void constraintRotLim(TransInfo *UNUSED(t), TransData *td) if(dolimit) { /* copy results from cob->matrix */ - if (td->rotOrder == ROT_MODE_QUAT) { + if (td->ext->rotOrder == ROT_MODE_QUAT) { /* quats */ 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 */ mat4_to_axis_angle( &td->ext->quat[1], &td->ext->quat[0],cob.matrix); } else { /* 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 */ if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself /* 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); 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); } - else if (td->rotOrder == ROT_MODE_AXISANGLE) { + else if (td->ext->rotOrder == ROT_MODE_AXISANGLE) { /* calculate effect based on quats */ 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 */ 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 */ 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) */ protectedRotateBits(td->protectflag, eul, td->ext->irot); @@ -3016,7 +3009,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short /* rotation */ if ((t->flag & T_V3D_ALIGN)==0) { // align mode doesn't rotate objects itself /* 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); 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 */ 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 */ 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 */ 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 */ 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 */ sub_v3_v3v3(eul, eul, td->ext->drot); diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index b9f3382e9d3..de978626b3e 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -147,6 +147,7 @@ typedef struct TransDataExtension { float isize[3]; /* Initial size */ 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 */ + int rotOrder; /* rotation mode, as defined in eRotationModes (DNA_action_types.h) */ } TransDataExtension; 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) (...) */ int flag; /* Various flags */ short protectflag; /* If set, copy of Object or PoseChannel protection */ - int rotOrder; /* rotation mode, as defined in eRotationModes (DNA_action_types.h) */ } TransData; typedef struct MouseInput { diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index e0324ae60bd..54b724d69f7 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -548,7 +548,7 @@ static void add_pose_transdata(TransInfo *t, bPoseChannel *pchan, Object *ob, Tr 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 */ @@ -4329,7 +4329,7 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) QUATCOPY(td->ext->iquat, ob->quat); QUATCOPY(td->ext->dquat, ob->dquat); } - td->rotOrder=ob->rotmode; + td->ext->rotOrder=ob->rotmode; td->ext->size = ob->size; VECCOPY(td->ext->isize, ob->size); @@ -5158,7 +5158,7 @@ static void createTransObject(bContext *C, TransInfo *t) td->flag = TD_SELECTED; td->protectflag= ob->protectflag; td->ext = tx; - td->rotOrder= ob->rotmode; + td->ext->rotOrder= ob->rotmode; if (base->flag & BA_TRANSFORM_CHILD) { @@ -5192,7 +5192,7 @@ static void createTransObject(bContext *C, TransInfo *t) { td->protectflag= ob->protectflag; td->ext = tx; - td->rotOrder= ob->rotmode; + td->ext->rotOrder= ob->rotmode; ObjectToTransData(t, td, ob); td->val = NULL; |