diff options
Diffstat (limited to 'source/blender/editors/transform/transform.c')
-rw-r--r-- | source/blender/editors/transform/transform.c | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index e6b8662ce4c..e7749e6eb3a 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -2449,7 +2449,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short Mat3MulVecfl(pmtx, vec); // To Global space Mat3MulVecfl(mat, vec); // Applying rotation Mat3MulVecfl(imtx, vec); // To Local space - + VecAddf(vec, vec, center); /* vec now is the location where the object has to be */ @@ -2457,9 +2457,9 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short Mat3MulVecfl(pmtx, vec); // To Global space Mat3MulVecfl(td->smtx, vec);// To Pose space - + protectedTransBits(td->protectflag, vec); - + VecAddf(td->loc, td->iloc, vec); constraintTransLim(t, td); @@ -2467,19 +2467,40 @@ 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 - Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); - - Mat3ToQuat(fmat, quat); // Actual transform - - QuatMul(td->ext->quat, quat, td->ext->iquat); - /* this function works on end result */ - protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); + /* euler or quaternion? */ + if (td->flag & TD_USEQUAT) { + Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); + + Mat3ToQuat(fmat, quat); // Actual transform + + QuatMul(td->ext->quat, quat, td->ext->iquat); + /* this function works on end result */ + protectedQuaternionBits(td->protectflag, td->ext->quat, td->ext->iquat); + } + else { + float eulmat[3][3]; + + Mat3MulMat3(totmat, mat, td->mtx); + Mat3MulMat3(smat, td->smtx, totmat); + + /* calculate the total rotatation in eulers */ + VECCOPY(eul, td->ext->irot); + EulToMat3(eul, eulmat); + + /* mat = transform, obmat = bone rotation */ + Mat3MulMat3(fmat, smat, eulmat); + + Mat3ToCompatibleEul(fmat, eul, td->ext->rot); + + /* and apply (to end result only) */ + protectedRotateBits(td->protectflag, eul, td->ext->irot); + VECCOPY(td->ext->rot, eul); + } constraintRotLim(t, td); } } else { - if ((td->flag & TD_NO_LOC) == 0) { /* translation */ @@ -2506,7 +2527,8 @@ 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 - if(td->flag & TD_USEQUAT) { + /* euler or quaternion? */ + if (td->flag & TD_USEQUAT) { Mat3MulSerie(fmat, td->mtx, mat, td->smtx, 0, 0, 0, 0, 0); Mat3ToQuat(fmat, quat); // Actual transform |