diff options
author | Alexander Ewering <blender@instinctive.de> | 2004-07-15 17:31:18 +0400 |
---|---|---|
committer | Alexander Ewering <blender@instinctive.de> | 2004-07-15 17:31:18 +0400 |
commit | f25b0df75136aff38b7d4f46b1e8230b8d50c5f3 (patch) | |
tree | 7ab26a56c3a7dab5fc9a8d281cea1efba3cbe376 /source | |
parent | 3dbd149de21b2416b60e3ced129885a940aba3bd (diff) |
Commit for the 4 aforementioned "features":
- "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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/include/BIF_resources.h | 5 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_userdef_types.h | 3 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_view3d_types.h | 1 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 10 | ||||
-rw-r--r-- | source/blender/src/editobject.c | 310 | ||||
-rw-r--r-- | source/blender/src/space.c | 46 | ||||
-rw-r--r-- | source/blender/src/toets.c | 19 | ||||
-rw-r--r-- | source/blender/src/view.c | 2 |
8 files changed, 233 insertions, 163 deletions
diff --git a/source/blender/include/BIF_resources.h b/source/blender/include/BIF_resources.h index ededfab7489..0456ec4251b 100644 --- a/source/blender/include/BIF_resources.h +++ b/source/blender/include/BIF_resources.h @@ -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, diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 7c2773f0b5b..9b9fe1010f2 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -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 */ diff --git a/source/blender/makesdna/DNA_view3d_types.h b/source/blender/makesdna/DNA_view3d_types.h index ac867c315b1..9a0b4180de0 100644 --- a/source/blender/makesdna/DNA_view3d_types.h +++ b/source/blender/makesdna/DNA_view3d_types.h @@ -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 diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 6a0ef9a11b5..e882a1d09c0 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -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); } diff --git a/source/blender/src/editobject.c b/source/blender/src/editobject.c index 39cd046b5bd..c7ee3f83f4f 100644 --- a/source/blender/src/editobject.c +++ b/source/blender/src/editobject.c @@ -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) { diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 8683d66e232..c20d26ab0ed 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -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:", diff --git a/source/blender/src/toets.c b/source/blender/src/toets.c index 1e41d6b0024..75b4b70adcc 100644 --- a/source/blender/src/toets.c +++ b/source/blender/src/toets.c @@ -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() */ diff --git a/source/blender/src/view.c b/source/blender/src/view.c index d292f5a310c..9d876712567 100644 --- a/source/blender/src/view.c +++ b/source/blender/src/view.c @@ -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] */ |