Commit for the 4 aforementioned "features":
authorAlexander Ewering <blender@instinctive.de>
Thu, 15 Jul 2004 13:31:18 +0000 (13:31 +0000)
committerAlexander Ewering <blender@instinctive.de>
Thu, 15 Jul 2004 13:31:18 +0000 (13:31 +0000)
 - "Global Pivot": Maintains a global Pivot and Align mode setting for
   all 3d views when enabled, instead of seperate settings per 3d view

 - "Auto Perspective": Switch to ortho mode automatically on 1/3/7, and
   to Perspective when the view is rotated with the mouse

 - "Align mode": As suggested on the list, when enabled, transformations
   on several objects only transform their locations, not their sizes or
   rotations.

 - Grid dotted when not 1:1

***ATTENTION***! The User Interface parts of these features have not been
committed, as I work on my own modified UI here. The three features need
toggle buttons to turn them on and off.

I used the following 3 buttons (first two features are in userprefs,
third as a 3d view setting):

        uiDefButBitS(block, TOG, USER_AUTOPERSP, B_DRAWINFO, "Auto Persp",
            (xpos+edgespace+(3*medprefbut)+(3*midspace)+smallprefbut+2),y3+10,smallprefbut,buth,
            &(U.uiflag), 0, 0, 0, 0,
            "Automatically switch between orthographic and perspective");

        uiDefButBitS(block, TOG, USER_LOCKAROUND, B_DRAWINFO, "Global Pivot",
            (xpos+edgespace+(4*midspace)+(4*medprefbut)),y3+10,smallprefbut,buth,
            &(U.uiflag), 0, 0, 0, 0,
            "Use global pivot setting for all 3d views");

    uiDefIconButS(block, TOG|BIT|10, B_AROUND, ICON_ALIGN,
                xco+=XIC,0,XIC,YIC,
                &G.vd->flag, 0, 0, 0, 0, "Translate only (align)");

Someone needs to add these to the interface in an appropriate manner!

Thanks.

source/blender/include/BIF_resources.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/DNA_view3d_types.h
source/blender/src/drawview.c
source/blender/src/editobject.c
source/blender/src/space.c
source/blender/src/toets.c
source/blender/src/view.c

index ededfab748914c9a05e1652f7df0cc81e9602160..0456ec4251bbcdd82022a3c0753542f5d7580003 100644 (file)
@@ -89,12 +89,13 @@ typedef enum {
        ICON_POSE_HLT,
        ICON_BORDERMOVE,
        ICON_MAYBE_ITS_A_LASSO,
-       ICON_BLANK1,
+       ICON_BLANK1,    /* ATTENTION, someone decided to use this throughout blender
+                          and didn't care to neither rename it nor update the PNG */
        ICON_ROTATE,
        ICON_CURSOR,
        ICON_ROTATECOLLECTION,
        ICON_ROTATECENTER,
-       ICON_BLANK7,
+       ICON_ALIGN,
        ICON_BLANK8,
        ICON_BLANK9,
        ICON_BLANK10,
index 7c2773f0b5b79b9140e28c3ead11f5e007bc9978..9b9fe1010f28d6f7379647191c6c9ba86ddb9e6f 100644 (file)
@@ -189,6 +189,9 @@ extern UserDef U; /* from usiblender.c !!!! */
 #define USER_ALLWINCODECS              256
 #define USER_MENUOPENAUTO              512
 #define USER_PANELPINNED               1024
+#define USER_AUTOPERSP                 2048
+#define USER_LOCKAROUND        4096
+
 
 /* transopts */
 
index ac867c315b1bfeaaf5521ed16462d72da767a63f..9a0b4180de086cc47332b89efa807bd586f160f1 100644 (file)
@@ -120,6 +120,7 @@ typedef struct View3D {
 #define V3D_POSEMODE           128
 #define V3D_TEXTUREPAINT       256
 #define V3D_WEIGHTPAINT                512
+#define V3D_ALIGN                      1024
 
 /* View3D->around */
 #define V3D_CENTRE             0
index 6a0ef9a11b52918e8f7ddd86569fc4088b9800e7..e882a1d09c0238093e9156b9d2655013972d2e4a 100644 (file)
@@ -535,6 +535,7 @@ static void drawgrid(void)
        /* check zoom out */
        BIF_ThemeColor(TH_GRID);
        persp(PERSP_WIN);
+       setlinestyle(3);
 
        if(dx<6.0) {
                dx*= 10.0;
@@ -585,13 +586,16 @@ static void drawgrid(void)
                        else {
                                BIF_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0);
                                drawgrid_draw(wx, wy, x, y, dx);
-                               BIF_ThemeColor(TH_GRID);
-                               drawgrid_draw(wx, wy, x, y, dx*10);
+                               BIF_ThemeColor(TH_GRID);                                
+                               setlinestyle(0);
+                               drawgrid_draw(wx, wy, x, y, dx*10);                     /* 1:1 */
                        }
                }
                else {
                        BIF_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0);
-                       drawgrid_draw(wx, wy, x, y, dx);
+                       setlinestyle(0);
+                       drawgrid_draw(wx, wy, x, y, dx);                                /* 1:1 */
+                       setlinestyle(3);
                        BIF_ThemeColor(TH_GRID);
                        drawgrid_draw(wx, wy, x, y, dx*10);
                }
index 39cd046b5bdf377df236e5574ca1e9f8ecc3d2f5..c7ee3f83f4f33e6e6cf786b80672b73d8eeefb5b 100644 (file)
@@ -4968,114 +4968,117 @@ void transform(int mode)
                                                         * 2. distill from this the euler. Always do this step because MatToEul is pretty weak
                                                         * 3. multiply with its own rotation, calculate euler.
                                                         */
-                                               
-                                                       /* Roll around local axis */
-                                                       if (mode=='r' || mode=='R'){
-
-                                                               if (tob && axismode && (turntable == 0)){
-                                                                       if (axismode == XTRANSLOCAL){ 
-                                                                               VECCOPY(vec, tob->axismat[0]);
-                                                                       }
-                                                                       if (axismode == YTRANSLOCAL){
-                                                                               VECCOPY(vec, tob->axismat[1]);
-                                                                       }
-                                                                       if (axismode == ZTRANSLOCAL){
-                                                                               VECCOPY(vec, tob->axismat[2]);
-                                                                       }
-                                                                       /* Correct the vector */
-                                                                       if ((axismode & TRANSLOCAL) && ((G.vd->viewmat[0][2] * vec[0]+G.vd->viewmat[1][2] * vec[1]+G.vd->viewmat[2][2] * vec[2])>0)){
-                                                                               vec[0]*=-1;
-                                                                               vec[1]*=-1;
-                                                                               vec[2]*=-1;
-                                                                       }
-
-                                                                       if (typemode)
-                                                                               VecRotToMat3(vec, addvec[0] * M_PI / 180.0, mat);
-                                                                       else
-                                                                               VecRotToMat3(vec, phi, mat);
-                                                                               
-                                                               }
-                                                       }
-                                                       Mat3MulSerie(smat, tob->parmat, mat, tob->parinv, 0, 0, 0, 0, 0);
-
-                                                       /* 2 */
-                                                       if( (tob->ob->transflag & OB_QUAT) == 0 && tob->rot){
-                                                               Mat3ToEul(smat, eul);
-                                                               EulToMat3(eul, smat);
-                                                       }
-                                               
-                                                       /* 3 */
-                                                       /* we now work with rot+drot */
-                                                               
-                                                       if(tob->ob->transflag & OB_QUAT || !tob->rot) {
                                                        
-                                                               /* drot+rot TO DO! */
-                                                               Mat3ToQuat(smat, quat); // Original
-                                                               QuatMul(tob->quat, quat, tob->oldquat);
-                                                               
-                                                               if(tob->flag & TOB_IPO) {
-                                                                       
-                                                                       if(tob->flag & TOB_IPODROT) {
-                                                                               /* VecSubf(rot, eul, tob->oldrot); */
-                                                                       }
-                                                                       else {
-                                                                               /* VecSubf(rot, eul, tob->olddrot); */
-                                                                       }
-       
-                                                                       /* VecMulf(rot, 9.0/M_PI_2); */
-                                                                       /* VecSubf(rot, rot, tob->oldrot+3); */
-
-                                                                       /* add_ipo_tob_poin(tob->rotx, tob->oldrot+3, rot[0]); */
-                                                                       /* add_ipo_tob_poin(tob->roty, tob->oldrot+4, rot[1]); */
-                                                                       /* add_ipo_tob_poin(tob->rotz, tob->oldrot+5, rot[2]); */
-       
-                                                               }
-                                                               else {
-                                                                       /* QuatSub(tob->quat, quat, tob->oldquat); */
-                                                               }
-                                                       }
-                                                       else {
-                                                               VecAddf(eul, tob->oldrot, tob->olddrot);
-                                                               EulToMat3(eul, tmat);
-
-                                                               Mat3MulMat3(totmat, smat, tmat);
-
-                                                               Mat3ToEul(totmat, eul);
-
-                                                               /* Eul is not allowed to differ too much from old eul.
-                                                                * This has only been tested for dx && dz
-                                                                */
-                                                               
-                                                               compatible_eul(eul, tob->oldrot);
+                                                       if ((G.vd->flag & V3D_ALIGN)==0) {
                                                        
-                                                               if(tob->flag & TOB_IPO) {
-                                                                       
-                                                                       if(tob->flag & TOB_IPODROT) {
-                                                                               VecSubf(rot, eul, tob->oldrot);
-                                                                       }
-                                                                       else {
-                                                                               VecSubf(rot, eul, tob->olddrot);
-                                                                       }
-       
-                                                                       VecMulf(rot, 9.0/M_PI_2);
-                                                                       VecSubf(rot, rot, tob->oldrot+3);
-
-
-                                                                       add_ipo_tob_poin(tob->rotx, tob->oldrot+3, rot[0]);
-                                                                       add_ipo_tob_poin(tob->roty, tob->oldrot+4, rot[1]);
-                                                                       add_ipo_tob_poin(tob->rotz, tob->oldrot+5, rot[2]);
-       
-                                                               }
-                                                               else {
-                                                                       VecSubf(tob->rot, eul, tob->olddrot);
-                                                               }
-                                                               
-                                                               /* See if we've moved */
-                                                               if (!VecCompare (tob->loc, tob->oldloc, 0.01)){
-                                                                       keyflags |= KEYFLAG_LOC;
-                                                               }
-
-                                                       }
+                                                       /* Roll around local axis */
+                                                       if (mode=='r' || mode=='R'){
+
+                                                               if (tob && axismode && (turntable == 0)){
+                                                                       if (axismode == XTRANSLOCAL){ 
+                                                                               VECCOPY(vec, tob->axismat[0]);
+                                                                       }
+                                                                       if (axismode == YTRANSLOCAL){
+                                                                               VECCOPY(vec, tob->axismat[1]);
+                                                                       }
+                                                                       if (axismode == ZTRANSLOCAL){
+                                                                               VECCOPY(vec, tob->axismat[2]);
+                                                                       }
+                                                                       /* Correct the vector */
+                                                                       if ((axismode & TRANSLOCAL) && ((G.vd->viewmat[0][2] * vec[0]+G.vd->viewmat[1][2] * vec[1]+G.vd->viewmat[2][2] * vec[2])>0)){
+                                                                               vec[0]*=-1;
+                                                                               vec[1]*=-1;
+                                                                               vec[2]*=-1;
+                                                                       }
+
+                                                                       if (typemode)
+                                                                               VecRotToMat3(vec, addvec[0] * M_PI / 180.0, mat);
+                                                                       else
+                                                                               VecRotToMat3(vec, phi, mat);
+                                                                               
+                                                               }
+                                                       }
+                                                       Mat3MulSerie(smat, tob->parmat, mat, tob->parinv, 0, 0, 0, 0, 0);
+
+                                                       /* 2 */
+                                                       if( (tob->ob->transflag & OB_QUAT) == 0 && tob->rot){
+                                                               Mat3ToEul(smat, eul);
+                                                               EulToMat3(eul, smat);
+                                                       }
+                                               
+                                                       /* 3 */
+                                                       /* we now work with rot+drot */
+                                                               
+                                                       if(tob->ob->transflag & OB_QUAT || !tob->rot) {
+                                                       
+                                                               /* drot+rot TO DO! */
+                                                               Mat3ToQuat(smat, quat); // Original
+                                                               QuatMul(tob->quat, quat, tob->oldquat);
+                                                               
+                                                               if(tob->flag & TOB_IPO) {
+                                                                       
+                                                                       if(tob->flag & TOB_IPODROT) {
+                                                                               /* VecSubf(rot, eul, tob->oldrot); */
+                                                                       }
+                                                                       else {
+                                                                               /* VecSubf(rot, eul, tob->olddrot); */
+                                                                       }
+       
+                                                                       /* VecMulf(rot, 9.0/M_PI_2); */
+                                                                       /* VecSubf(rot, rot, tob->oldrot+3); */
+
+                                                                       /* add_ipo_tob_poin(tob->rotx, tob->oldrot+3, rot[0]); */
+                                                                       /* add_ipo_tob_poin(tob->roty, tob->oldrot+4, rot[1]); */
+                                                                       /* add_ipo_tob_poin(tob->rotz, tob->oldrot+5, rot[2]); */
+       
+                                                               }
+                                                               else {
+                                                                       /* QuatSub(tob->quat, quat, tob->oldquat); */
+                                                               }
+                                                       }
+                                                       else {
+                                                               VecAddf(eul, tob->oldrot, tob->olddrot);
+                                                               EulToMat3(eul, tmat);
+
+                                                               Mat3MulMat3(totmat, smat, tmat);
+
+                                                               Mat3ToEul(totmat, eul);
+
+                                                               /* Eul is not allowed to differ too much from old eul.
+                                                                * This has only been tested for dx && dz
+                                                                */
+                                                               
+                                                               compatible_eul(eul, tob->oldrot);
+                                                       
+                                                               if(tob->flag & TOB_IPO) {
+                                                                       
+                                                                       if(tob->flag & TOB_IPODROT) {
+                                                                               VecSubf(rot, eul, tob->oldrot);
+                                                                       }
+                                                                       else {
+                                                                               VecSubf(rot, eul, tob->olddrot);
+                                                                       }
+       
+                                                                       VecMulf(rot, 9.0/M_PI_2);
+                                                                       VecSubf(rot, rot, tob->oldrot+3);
+
+
+                                                                       add_ipo_tob_poin(tob->rotx, tob->oldrot+3, rot[0]);
+                                                                       add_ipo_tob_poin(tob->roty, tob->oldrot+4, rot[1]);
+                                                                       add_ipo_tob_poin(tob->rotz, tob->oldrot+5, rot[2]);
+       
+                                                               }
+                                                               else {
+                                                                       VecSubf(tob->rot, eul, tob->olddrot);
+                                                               }
+                                                               
+                                                               /* See if we've moved */
+                                                               if (!VecCompare (tob->loc, tob->oldloc, 0.01)){
+                                                                       keyflags |= KEYFLAG_LOC;
+                                                               }
+
+                                                       }
+                                                       }
                                                        
                                                        if(G.vd->around!=V3D_LOCAL && (!G.obpose))  {
                                                                float vec[3];   // make local, the other vec stores rot axis
@@ -5265,53 +5268,56 @@ void transform(int mode)
                                                        /* size local with respect to parent AND own rotation */
                                                        /* local wrt parent: */
                                                        
-                                                       Mat3MulSerie(smat, tob->parmat, mat, tob->parinv, 0, 0,0 ,0, 0);
+                                                       if ((G.vd->flag & V3D_ALIGN)==0)  {                                                     
                                                        
-                                                       /* local wrt own rotation: */
-                                                       Mat3MulSerie(totmat, tob->obmat, smat, tob->obinv, 0, 0, 0,0 ,0);
-
-                                                       /* XXX this can yield garbage in case of inverted sizes (< 0.0)
-                                                                                                       */
-                                                       if(!midtog) {
-                                                               sizelo[0]= size[0];
-                                                               sizelo[1]= size[1];
-                                                               sizelo[2]= size[2];
-                                                       } else {        
-                                                       /* in this case the previous calculation of the size is wrong */
-                                                               sizelo[0]= totmat[0][0];        
-                                                               sizelo[1]= totmat[1][1];        
-                                                               sizelo[2]= totmat[2][2];
-                                                               apply_keyb_grid(sizelo, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
-                                                               apply_keyb_grid(sizelo+1, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
-                                                               apply_keyb_grid(sizelo+2, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
-                                                       } 
-
-                                                               /* x flip */
-/**/                                           /* sizelo[0]*= xref; */
-                                                               /* y flip */
-/**/                                           /* sizelo[1]*= yref; */
-                                                               /* z flip */
-/**/                                           /* sizelo[2]*= zref; */
-
-
-                                                       /* what you see is what you want; not what you get! */
-                                                       /* correction for delta size */
-                                                       if(tob->flag & TOB_IPO) {
-                                                               /* calculate delta size (equal for size and dsize) */
-                                                               
-                                                               vec[0]= (tob->oldsize[0]+tob->olddsize[0])*(sizelo[0] -1.0);
-                                                               vec[1]= (tob->oldsize[1]+tob->olddsize[1])*(sizelo[1] -1.0);
-                                                               vec[2]= (tob->oldsize[2]+tob->olddsize[2])*(sizelo[2] -1.0);
-
-                                                               add_ipo_tob_poin(tob->sizex, tob->oldsize+3, vec[0]);
-                                                               add_ipo_tob_poin(tob->sizey, tob->oldsize+4, vec[1]);
-                                                               add_ipo_tob_poin(tob->sizez, tob->oldsize+5, vec[2]);
-                                                               
-                                                       }
-                                                       else {
-                                                               tob->size[0]= (tob->oldsize[0]+tob->olddsize[0])*sizelo[0] -tob->olddsize[0];
-                                                               tob->size[1]= (tob->oldsize[1]+tob->olddsize[1])*sizelo[1] -tob->olddsize[1];
-                                                               tob->size[2]= (tob->oldsize[2]+tob->olddsize[2])*sizelo[2] -tob->olddsize[2];
+                                                       Mat3MulSerie(smat, tob->parmat, mat, tob->parinv, 0, 0,0 ,0, 0);
+                                                       
+                                                       /* local wrt own rotation: */
+                                                       Mat3MulSerie(totmat, tob->obmat, smat, tob->obinv, 0, 0, 0,0 ,0);
+
+                                                       /* XXX this can yield garbage in case of inverted sizes (< 0.0)
+                                                                                                       */
+                                                       if(!midtog) {
+                                                               sizelo[0]= size[0];
+                                                               sizelo[1]= size[1];
+                                                               sizelo[2]= size[2];
+                                                       } else {        
+                                                       /* in this case the previous calculation of the size is wrong */
+                                                               sizelo[0]= totmat[0][0];        
+                                                               sizelo[1]= totmat[1][1];        
+                                                               sizelo[2]= totmat[2][2];
+                                                               apply_keyb_grid(sizelo, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
+                                                               apply_keyb_grid(sizelo+1, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
+                                                               apply_keyb_grid(sizelo+2, 0.0, 0.1, 0.01, gridflag & USER_AUTOSIZEGRID);
+                                                       } 
+
+                                                               /* x flip */
+    /**/                                               /* sizelo[0]*= xref; */
+                                                               /* y flip */
+    /**/                                               /* sizelo[1]*= yref; */
+                                                               /* z flip */
+    /**/                                               /* sizelo[2]*= zref; */
+
+
+                                                       /* what you see is what you want; not what you get! */
+                                                       /* correction for delta size */
+                                                       if(tob->flag & TOB_IPO) {
+                                                               /* calculate delta size (equal for size and dsize) */
+                                                               
+                                                               vec[0]= (tob->oldsize[0]+tob->olddsize[0])*(sizelo[0] -1.0);
+                                                               vec[1]= (tob->oldsize[1]+tob->olddsize[1])*(sizelo[1] -1.0);
+                                                               vec[2]= (tob->oldsize[2]+tob->olddsize[2])*(sizelo[2] -1.0);
+
+                                                               add_ipo_tob_poin(tob->sizex, tob->oldsize+3, vec[0]);
+                                                               add_ipo_tob_poin(tob->sizey, tob->oldsize+4, vec[1]);
+                                                               add_ipo_tob_poin(tob->sizez, tob->oldsize+5, vec[2]);
+                                                               
+                                                       }
+                                                       else {
+                                                               tob->size[0]= (tob->oldsize[0]+tob->olddsize[0])*sizelo[0] -tob->olddsize[0];
+                                                               tob->size[1]= (tob->oldsize[1]+tob->olddsize[1])*sizelo[1] -tob->olddsize[1];
+                                                               tob->size[2]= (tob->oldsize[2]+tob->olddsize[2])*sizelo[2] -tob->olddsize[2];
+                                                       }
                                                        }
                                                        
                                                        if(G.vd->around!=V3D_LOCAL && !G.obpose) {
index 8683d66e232e3eb0e9d2200e81be534ede2fbade..c20d26ab0edeb3f7af6ac9d4351f3b9f4f808f9f 100644 (file)
@@ -267,6 +267,43 @@ void copy_view3d_lock(short val)
        }
 }
 
+void handle_view3d_around()
+{
+       bScreen *sc;
+       int bit;
+       
+       if ((U.uiflag & USER_LOCKAROUND)==0) return;
+       
+       /* copies from G.vd->around to other view3ds */
+       
+       sc= G.main->screen.first;
+       
+       while(sc) {
+               if(sc->scene==G.scene) {
+                       ScrArea *sa= sc->areabase.first;
+                       while(sa) {
+                               SpaceLink *sl= sa->spacedata.first;
+                               while(sl) {
+                                       if(sl->spacetype==SPACE_VIEW3D) {
+                                               View3D *vd= (View3D*) sl;
+                                               if (vd != G.vd) {
+                                                       vd->around= G.vd->around;
+                                                       if (G.vd->flag & V3D_ALIGN)
+                                                               vd->flag |= V3D_ALIGN;
+                                                       else
+                                                               vd->flag &= ~V3D_ALIGN;
+                                                       scrarea_queue_headredraw(sa);
+                                               }
+                                       }
+                                       sl= sl->next;
+                               }
+                               sa= sa->next;
+                       }
+               }
+               sc= sc->id.next;
+       }
+}
+
 void handle_view3d_lock()
 {
        if (G.vd != NULL) {
@@ -2141,6 +2178,15 @@ void drawinfospace(ScrArea *sa, void *spacedata)
                        &(U.viewzoom), 40, USER_ZOOM_SCALE, 0, 0,
                        "Zooms in and out like scaling the view, mouse movements relative to center.");
 
+               uiDefButBitS(block, TOG, USER_AUTOPERSP, B_DRAWINFO, "Auto Persp",
+                       (xpos+edgespace+(3*medprefbut)+(3*midspace)+smallprefbut+2),y3+10,smallprefbut,buth,
+                       &(U.uiflag), 0, 0, 0, 0,
+                       "Automatically switch between orthographic and perspective");
+                       
+               uiDefButBitS(block, TOG, USER_LOCKAROUND, B_DRAWINFO, "Global Pivot",
+                       (xpos+edgespace+(4*midspace)+(4*medprefbut)),y3+10,smallprefbut,buth,
+                       &(U.uiflag), 0, 0, 0, 0,
+                       "Use global pivot setting for all 3d views");                   
 
                        
                uiDefBut(block, LABEL,0,"View rotation:",
index 1e41d6b0024d99428a051c6cc6730fd4fa26459f..75b4b70adccb236a32c37cf727f9fc272dd591fa 100644 (file)
@@ -59,6 +59,7 @@
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
 #include "DNA_view3d_types.h"
+#include "DNA_userdef_types.h"
 
 #include "BKE_utildefines.h"
 #include "BKE_global.h"
@@ -273,7 +274,8 @@ void persptoetsen(unsigned short event)
                        G.vd->viewquat[2]= 0.0;
                        G.vd->viewquat[3]= 0.0;
                        G.vd->view= 7;
-                       if(G.vd->persp>=2) G.vd->persp= perspo;
+                       if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0; 
+                       else if(G.vd->persp>=2) G.vd->persp= perspo;
                }
                else if(event==PAD1) {
                        G.vd->viewquat[0]= 0.0;
@@ -281,7 +283,8 @@ void persptoetsen(unsigned short event)
                        G.vd->viewquat[2]= (float)-cos(M_PI/4.0);
                        G.vd->viewquat[3]= (float)-cos(M_PI/4.0);
                        G.vd->view=1;
-                       if(G.vd->persp>=2) G.vd->persp= perspo;
+                       if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
+                       else if(G.vd->persp>=2) G.vd->persp= perspo;
                }
                else if(event==PAD3) {
                        G.vd->viewquat[0]= 0.5;
@@ -289,7 +292,8 @@ void persptoetsen(unsigned short event)
                        G.vd->viewquat[2]= 0.5;
                        G.vd->viewquat[3]= 0.5;
                        G.vd->view=3;
-                       if(G.vd->persp>=2) G.vd->persp= perspo;
+                       if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
+                       else if(G.vd->persp>=2) G.vd->persp= perspo;
                }
                else if(event==PADMINUS) {
                        /* this min and max is also in viewmove() */
@@ -327,7 +331,8 @@ void persptoetsen(unsigned short event)
                        G.vd->viewquat[2]= 0.0;
                        G.vd->viewquat[3]= 0.0;
                        G.vd->view=7;
-                       if(G.vd->persp>=2) G.vd->persp= perspo;
+                       if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
+                       else if(G.vd->persp>=2) G.vd->persp= perspo;
                }
                else if(event==PAD1) {
                        G.vd->viewquat[0]= (float)cos(M_PI/4.0);
@@ -335,7 +340,8 @@ void persptoetsen(unsigned short event)
                        G.vd->viewquat[2]= 0.0;
                        G.vd->viewquat[3]= 0.0;
                        G.vd->view=1;
-                       if(G.vd->persp>=2) G.vd->persp= perspo;
+                       if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
+                       else if(G.vd->persp>=2) G.vd->persp= perspo;
                }
                else if(event==PAD3) {
                        G.vd->viewquat[0]= 0.5;
@@ -343,7 +349,8 @@ void persptoetsen(unsigned short event)
                        G.vd->viewquat[2]= -0.5;
                        G.vd->viewquat[3]= -0.5;
                        G.vd->view=3;
-                       if(G.vd->persp>=2) G.vd->persp= perspo;
+                       if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 0;
+                       else if(G.vd->persp>=2) G.vd->persp= perspo;
                }
                else if(event==PADMINUS) {
                        /* this min and max is also in viewmove() */
index d292f5a310c2dbd54e133a844389c6807431a943..9d876712567c4372fb83dd79797cbffdfca10c9b 100644 (file)
@@ -449,6 +449,8 @@ void viewmove(int mode)
 
 
                        if(mode==0) {   /* view rotate */
+
+                               if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 1;
                        
                                /* if turntable method, we don't change mvalball[0] */