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.
This commit is contained in:
Alexander Ewering
2004-07-15 13:31:18 +00:00
parent 3dbd149de2
commit f25b0df751
8 changed files with 225 additions and 155 deletions

View File

@@ -89,12 +89,13 @@ typedef enum {
ICON_POSE_HLT, ICON_POSE_HLT,
ICON_BORDERMOVE, ICON_BORDERMOVE,
ICON_MAYBE_ITS_A_LASSO, 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_ROTATE,
ICON_CURSOR, ICON_CURSOR,
ICON_ROTATECOLLECTION, ICON_ROTATECOLLECTION,
ICON_ROTATECENTER, ICON_ROTATECENTER,
ICON_BLANK7, ICON_ALIGN,
ICON_BLANK8, ICON_BLANK8,
ICON_BLANK9, ICON_BLANK9,
ICON_BLANK10, ICON_BLANK10,

View File

@@ -189,6 +189,9 @@ extern UserDef U; /* from usiblender.c !!!! */
#define USER_ALLWINCODECS 256 #define USER_ALLWINCODECS 256
#define USER_MENUOPENAUTO 512 #define USER_MENUOPENAUTO 512
#define USER_PANELPINNED 1024 #define USER_PANELPINNED 1024
#define USER_AUTOPERSP 2048
#define USER_LOCKAROUND 4096
/* transopts */ /* transopts */

View File

@@ -120,6 +120,7 @@ typedef struct View3D {
#define V3D_POSEMODE 128 #define V3D_POSEMODE 128
#define V3D_TEXTUREPAINT 256 #define V3D_TEXTUREPAINT 256
#define V3D_WEIGHTPAINT 512 #define V3D_WEIGHTPAINT 512
#define V3D_ALIGN 1024
/* View3D->around */ /* View3D->around */
#define V3D_CENTRE 0 #define V3D_CENTRE 0

View File

@@ -535,6 +535,7 @@ static void drawgrid(void)
/* check zoom out */ /* check zoom out */
BIF_ThemeColor(TH_GRID); BIF_ThemeColor(TH_GRID);
persp(PERSP_WIN); persp(PERSP_WIN);
setlinestyle(3);
if(dx<6.0) { if(dx<6.0) {
dx*= 10.0; dx*= 10.0;
@@ -586,12 +587,15 @@ static void drawgrid(void)
BIF_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); BIF_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0);
drawgrid_draw(wx, wy, x, y, dx); drawgrid_draw(wx, wy, x, y, dx);
BIF_ThemeColor(TH_GRID); BIF_ThemeColor(TH_GRID);
drawgrid_draw(wx, wy, x, y, dx*10); setlinestyle(0);
drawgrid_draw(wx, wy, x, y, dx*10); /* 1:1 */
} }
} }
else { else {
BIF_ThemeColorBlend(TH_BACK, TH_GRID, dx/60.0); 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); BIF_ThemeColor(TH_GRID);
drawgrid_draw(wx, wy, x, y, dx*10); drawgrid_draw(wx, wy, x, y, dx*10);
} }

View File

@@ -4969,113 +4969,116 @@ void transform(int mode)
* 3. multiply with its own rotation, calculate euler. * 3. multiply with its own rotation, calculate euler.
*/ */
/* Roll around local axis */ if ((G.vd->flag & V3D_ALIGN)==0) {
if (mode=='r' || mode=='R'){
if (tob && axismode && (turntable == 0)){ /* Roll around local axis */
if (axismode == XTRANSLOCAL){ if (mode=='r' || mode=='R'){
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) if (tob && axismode && (turntable == 0)){
VecRotToMat3(vec, addvec[0] * M_PI / 180.0, mat); if (axismode == XTRANSLOCAL){
else VECCOPY(vec, tob->axismat[0]);
VecRotToMat3(vec, phi, mat); }
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);
Mat3MulSerie(smat, tob->parmat, mat, tob->parinv, 0, 0, 0, 0, 0); else
VecRotToMat3(vec, phi, mat);
/* 2 */ }
if( (tob->ob->transflag & OB_QUAT) == 0 && tob->rot){ }
Mat3ToEul(smat, eul); Mat3MulSerie(smat, tob->parmat, mat, tob->parinv, 0, 0, 0, 0, 0);
EulToMat3(eul, smat);
}
/* 3 */ /* 2 */
/* we now work with rot+drot */ if( (tob->ob->transflag & OB_QUAT) == 0 && tob->rot){
Mat3ToEul(smat, eul);
EulToMat3(eul, smat);
}
if(tob->ob->transflag & OB_QUAT || !tob->rot) { /* 3 */
/* we now work with rot+drot */
/* drot+rot TO DO! */ if(tob->ob->transflag & OB_QUAT || !tob->rot) {
Mat3ToQuat(smat, quat); // Original
QuatMul(tob->quat, quat, tob->oldquat);
if(tob->flag & TOB_IPO) { /* drot+rot TO DO! */
Mat3ToQuat(smat, quat); // Original
QuatMul(tob->quat, quat, tob->oldquat);
if(tob->flag & TOB_IPODROT) { if(tob->flag & TOB_IPO) {
/* VecSubf(rot, eul, tob->oldrot); */
}
else {
/* VecSubf(rot, eul, tob->olddrot); */
}
/* VecMulf(rot, 9.0/M_PI_2); */ if(tob->flag & TOB_IPODROT) {
/* VecSubf(rot, rot, tob->oldrot+3); */ /* VecSubf(rot, eul, tob->oldrot); */
}
else {
/* VecSubf(rot, eul, tob->olddrot); */
}
/* add_ipo_tob_poin(tob->rotx, tob->oldrot+3, rot[0]); */ /* VecMulf(rot, 9.0/M_PI_2); */
/* add_ipo_tob_poin(tob->roty, tob->oldrot+4, rot[1]); */ /* VecSubf(rot, rot, tob->oldrot+3); */
/* add_ipo_tob_poin(tob->rotz, tob->oldrot+5, rot[2]); */
} /* add_ipo_tob_poin(tob->rotx, tob->oldrot+3, rot[0]); */
else { /* add_ipo_tob_poin(tob->roty, tob->oldrot+4, rot[1]); */
/* QuatSub(tob->quat, quat, tob->oldquat); */ /* add_ipo_tob_poin(tob->rotz, tob->oldrot+5, rot[2]); */
}
}
else {
VecAddf(eul, tob->oldrot, tob->olddrot);
EulToMat3(eul, tmat);
Mat3MulMat3(totmat, smat, tmat); }
else {
/* QuatSub(tob->quat, quat, tob->oldquat); */
}
}
else {
VecAddf(eul, tob->oldrot, tob->olddrot);
EulToMat3(eul, tmat);
Mat3ToEul(totmat, eul); Mat3MulMat3(totmat, smat, tmat);
/* Eul is not allowed to differ too much from old eul. Mat3ToEul(totmat, eul);
* This has only been tested for dx && dz
*/
compatible_eul(eul, tob->oldrot); /* Eul is not allowed to differ too much from old eul.
* This has only been tested for dx && dz
*/
if(tob->flag & TOB_IPO) { compatible_eul(eul, tob->oldrot);
if(tob->flag & TOB_IPODROT) { if(tob->flag & TOB_IPO) {
VecSubf(rot, eul, tob->oldrot);
}
else {
VecSubf(rot, eul, tob->olddrot);
}
VecMulf(rot, 9.0/M_PI_2); if(tob->flag & TOB_IPODROT) {
VecSubf(rot, rot, tob->oldrot+3); 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->rotx, tob->oldrot+3, rot[0]);
add_ipo_tob_poin(tob->roty, tob->oldrot+4, rot[1]); add_ipo_tob_poin(tob->roty, tob->oldrot+4, rot[1]);
add_ipo_tob_poin(tob->rotz, tob->oldrot+5, rot[2]); add_ipo_tob_poin(tob->rotz, tob->oldrot+5, rot[2]);
} }
else { else {
VecSubf(tob->rot, eul, tob->olddrot); VecSubf(tob->rot, eul, tob->olddrot);
} }
/* See if we've moved */ /* See if we've moved */
if (!VecCompare (tob->loc, tob->oldloc, 0.01)){ if (!VecCompare (tob->loc, tob->oldloc, 0.01)){
keyflags |= KEYFLAG_LOC; keyflags |= KEYFLAG_LOC;
} }
} }
}
if(G.vd->around!=V3D_LOCAL && (!G.obpose)) { if(G.vd->around!=V3D_LOCAL && (!G.obpose)) {
float vec[3]; // make local, the other vec stores rot axis 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 */ /* size local with respect to parent AND own rotation */
/* local wrt parent: */ /* 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(smat, tob->parmat, mat, tob->parinv, 0, 0,0 ,0, 0);
Mat3MulSerie(totmat, tob->obmat, smat, tob->obinv, 0, 0, 0,0 ,0);
/* XXX this can yield garbage in case of inverted sizes (< 0.0) /* local wrt own rotation: */
*/ Mat3MulSerie(totmat, tob->obmat, smat, tob->obinv, 0, 0, 0,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 */ /* XXX this can yield garbage in case of inverted sizes (< 0.0)
/**/ /* sizelo[0]*= xref; */ */
/* y flip */ if(!midtog) {
/**/ /* sizelo[1]*= yref; */ sizelo[0]= size[0];
/* z flip */ sizelo[1]= size[1];
/**/ /* sizelo[2]*= zref; */ 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! */ /* what you see is what you want; not what you get! */
/* correction for delta size */ /* correction for delta size */
if(tob->flag & TOB_IPO) { if(tob->flag & TOB_IPO) {
/* calculate delta size (equal for size and dsize) */ /* calculate delta size (equal for size and dsize) */
vec[0]= (tob->oldsize[0]+tob->olddsize[0])*(sizelo[0] -1.0); 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[1]= (tob->oldsize[1]+tob->olddsize[1])*(sizelo[1] -1.0);
vec[2]= (tob->oldsize[2]+tob->olddsize[2])*(sizelo[2] -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->sizex, tob->oldsize+3, vec[0]);
add_ipo_tob_poin(tob->sizey, tob->oldsize+4, vec[1]); add_ipo_tob_poin(tob->sizey, tob->oldsize+4, vec[1]);
add_ipo_tob_poin(tob->sizez, tob->oldsize+5, vec[2]); add_ipo_tob_poin(tob->sizez, tob->oldsize+5, vec[2]);
} }
else { else {
tob->size[0]= (tob->oldsize[0]+tob->olddsize[0])*sizelo[0] -tob->olddsize[0]; 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[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]; tob->size[2]= (tob->oldsize[2]+tob->olddsize[2])*sizelo[2] -tob->olddsize[2];
}
} }
if(G.vd->around!=V3D_LOCAL && !G.obpose) { if(G.vd->around!=V3D_LOCAL && !G.obpose) {

View 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() void handle_view3d_lock()
{ {
if (G.vd != NULL) { if (G.vd != NULL) {
@@ -2141,6 +2178,15 @@ void drawinfospace(ScrArea *sa, void *spacedata)
&(U.viewzoom), 40, USER_ZOOM_SCALE, 0, 0, &(U.viewzoom), 40, USER_ZOOM_SCALE, 0, 0,
"Zooms in and out like scaling the view, mouse movements relative to center."); "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:", uiDefBut(block, LABEL,0,"View rotation:",

View File

@@ -59,6 +59,7 @@
#include "DNA_screen_types.h" #include "DNA_screen_types.h"
#include "DNA_space_types.h" #include "DNA_space_types.h"
#include "DNA_view3d_types.h" #include "DNA_view3d_types.h"
#include "DNA_userdef_types.h"
#include "BKE_utildefines.h" #include "BKE_utildefines.h"
#include "BKE_global.h" #include "BKE_global.h"
@@ -273,7 +274,8 @@ void persptoetsen(unsigned short event)
G.vd->viewquat[2]= 0.0; G.vd->viewquat[2]= 0.0;
G.vd->viewquat[3]= 0.0; G.vd->viewquat[3]= 0.0;
G.vd->view= 7; 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) { else if(event==PAD1) {
G.vd->viewquat[0]= 0.0; 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[2]= (float)-cos(M_PI/4.0);
G.vd->viewquat[3]= (float)-cos(M_PI/4.0); G.vd->viewquat[3]= (float)-cos(M_PI/4.0);
G.vd->view=1; 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) { else if(event==PAD3) {
G.vd->viewquat[0]= 0.5; G.vd->viewquat[0]= 0.5;
@@ -289,7 +292,8 @@ void persptoetsen(unsigned short event)
G.vd->viewquat[2]= 0.5; G.vd->viewquat[2]= 0.5;
G.vd->viewquat[3]= 0.5; G.vd->viewquat[3]= 0.5;
G.vd->view=3; 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) { else if(event==PADMINUS) {
/* this min and max is also in viewmove() */ /* 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[2]= 0.0;
G.vd->viewquat[3]= 0.0; G.vd->viewquat[3]= 0.0;
G.vd->view=7; 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) { else if(event==PAD1) {
G.vd->viewquat[0]= (float)cos(M_PI/4.0); 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[2]= 0.0;
G.vd->viewquat[3]= 0.0; G.vd->viewquat[3]= 0.0;
G.vd->view=1; 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) { else if(event==PAD3) {
G.vd->viewquat[0]= 0.5; G.vd->viewquat[0]= 0.5;
@@ -343,7 +349,8 @@ void persptoetsen(unsigned short event)
G.vd->viewquat[2]= -0.5; G.vd->viewquat[2]= -0.5;
G.vd->viewquat[3]= -0.5; G.vd->viewquat[3]= -0.5;
G.vd->view=3; 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) { else if(event==PADMINUS) {
/* this min and max is also in viewmove() */ /* this min and max is also in viewmove() */

View File

@@ -450,6 +450,8 @@ void viewmove(int mode)
if(mode==0) { /* view rotate */ if(mode==0) { /* view rotate */
if (U.uiflag & USER_AUTOPERSP) G.vd->persp= 1;
/* if turntable method, we don't change mvalball[0] */ /* if turntable method, we don't change mvalball[0] */
if(U.flag & USER_TRACKBALL) mvalball[0]= mval[0]; if(U.flag & USER_TRACKBALL) mvalball[0]= mval[0];