Revision: 15179
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15179
Author:   theeth
Date:     2008-06-09 20:07:12 +0200 (Mon, 09 Jun 2008)

Log Message:
-----------
Revision 14869 merged from apricot 
----------------------------------
Centralize handling of individual center for rotations

Revision Links:
--------------
    
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14869

Modified Paths:
--------------
    trunk/blender/source/blender/src/transform.c

Modified: trunk/blender/source/blender/src/transform.c
===================================================================
--- trunk/blender/source/blender/src/transform.c        2008-06-09 17:50:21 UTC 
(rev 15178)
+++ trunk/blender/source/blender/src/transform.c        2008-06-09 18:07:12 UTC 
(rev 15179)
@@ -2415,15 +2415,28 @@
 static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3]) {
        float vec[3], totmat[3][3], smat[3][3];
        float eul[3], fmat[3][3], quat[4];
-
+       float *center = t->center;
+       
+       /* local constraint shouldn't alter center */
+       if (t->around == V3D_LOCAL) {
+               if (t->flag & (T_OBJECT|T_POSE)) {
+                       center = td->center;
+               }
+               else {
+                       if(G.vd->around==V3D_LOCAL && (G.scene->selectmode & 
SCE_SELECT_FACE)) {
+                               center = td->center;
+                       }
+               }
+       }
+               
        if (t->flag & T_POINTS) {
                Mat3MulMat3(totmat, mat, td->mtx);
                Mat3MulMat3(smat, td->smtx, totmat);
                
-               VecSubf(vec, td->iloc, t->center);
+               VecSubf(vec, td->iloc, center);
                Mat3MulVecfl(smat, vec);
                
-               VecAddf(td->loc, vec, t->center);
+               VecAddf(td->loc, vec, center);
 
                VecSubf(vec,td->loc,td->iloc);
                protectedTransBits(td->protectflag, vec);
@@ -2460,13 +2473,13 @@
                Mat3CpyMat4(pmtx, t->poseobj->obmat);
                Mat3Inv(imtx, pmtx);
                
-               VecSubf(vec, td->center, t->center);
+               VecSubf(vec, td->center, center);
                
                Mat3MulVecfl(pmtx, vec);        // To Global space
                Mat3MulVecfl(mat, vec);         // Applying rotation
                Mat3MulVecfl(imtx, vec);        // To Local space
 
-               VecAddf(vec, vec, t->center);
+               VecAddf(vec, vec, center);
                /* vec now is the location where the object has to be */
                
                VecSubf(vec, vec, td->center); // Translation needed from the 
initial location
@@ -2495,9 +2508,9 @@
        }
        else {
                /* translation */
-               VecSubf(vec, td->center, t->center);
+               VecSubf(vec, td->center, center);
                Mat3MulVecfl(mat, vec);
-               VecAddf(vec, vec, t->center);
+               VecAddf(vec, vec, center);
                /* vec now is the location where the object has to be */
                VecSubf(vec, vec, td->center);
                Mat3MulVecfl(td->smtx, vec);
@@ -2593,17 +2606,9 @@
 static void applyRotation(TransInfo *t, float angle, float axis[3]) 
 {
        TransData *td = t->data;
-       float mat[3][3], center[3];
+       float mat[3][3];
        int i;
 
-       /* saving original center */
-       if (t->around == V3D_LOCAL) {
-               VECCOPY(center, t->center);
-       }
-       else {
-               center[0] = center[1] = center[2] = 0.0f;
-       }
-
        VecRotToMat3(axis, angle, mat);
        
        for(i = 0 ; i < t->total; i++, td++) {
@@ -2614,18 +2619,6 @@
                if (td->flag & TD_SKIP)
                        continue;
                
-               /* local constraint shouldn't alter center */
-               if (t->around == V3D_LOCAL) {
-                       if (t->flag & (T_OBJECT|T_POSE)) {
-                               VECCOPY(t->center, td->center);
-                       }
-                       else {
-                               if(G.vd->around==V3D_LOCAL && 
(G.scene->selectmode & SCE_SELECT_FACE)) {
-                                       VECCOPY(t->center, td->center);
-                               }
-                       }
-               }
-               
                if (t->con.applyRot) {
                        t->con.applyRot(t, td, axis);
                        VecRotToMat3(axis, angle * td->factor, mat);
@@ -2636,11 +2629,6 @@
 
                ElementRotation(t, td, mat);
        }
-
-       /* restoring original center */
-       if (t->around == V3D_LOCAL) {
-               VECCOPY(t->center, center);
-       }
 }
 
 int Rotation(TransInfo *t, short mval[2]) 
@@ -2737,7 +2725,6 @@
 {
        TransData *td = t->data;
        float mat[3][3], smat[3][3], totmat[3][3];
-       float center[3];
        int i;
 
        VecRotToMat3(axis1, angles[0], smat);
@@ -2752,20 +2739,6 @@
                if (td->flag & TD_SKIP)
                        continue;
                
-               VECCOPY(center, t->center);
-               
-               if (t->around == V3D_LOCAL) {
-                       /* local-mode shouldn't change center */
-                       if (t->flag & (T_OBJECT|T_POSE)) {
-                               VECCOPY(t->center, td->center);
-                       }
-                       else {
-                               if(G.vd->around==V3D_LOCAL && 
(G.scene->selectmode & SCE_SELECT_FACE)) {
-                                       VECCOPY(t->center, td->center);
-                               }
-                       }
-               }
-               
                if (t->flag & T_PROP_EDIT) {
                        VecRotToMat3(axis1, td->factor * angles[0], smat);
                        VecRotToMat3(axis2, td->factor * angles[1], totmat);
@@ -2774,8 +2747,6 @@
                }
                
                ElementRotation(t, td, mat);
-               
-               VECCOPY(t->center, center);
        }
 }
 


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to