Recoded pidhash's recent Pad0 (Lastview) commits (r.16802 and r.16810). It was causing major issues with Ortho perspective + rotating the view with the MMB. Setting G.vd->view to -1 was not such a valid way to do so (and also, this didn't play nicely with smoothview).

This feature should now work correctly, though there are still one or two places where it doesn't always seem totally correct yet. 
The basic idea of this feature, is that after going into camera mode (Pad0), pressing Pad0 again lets you go back to the view as you had it before entering camera mode.
This commit is contained in:
Joshua Leung 2008-09-29 08:11:26 +00:00
parent 638c51ba7d
commit e17c2c51bf
4 changed files with 24 additions and 24 deletions

@ -147,8 +147,9 @@ typedef struct View3D {
/* last view */
float lviewquat[4];
short lpersp, pad4;
int pad5;
short lpersp, lview;
short lastview_set;
short pad5;
} View3D;

@ -1709,7 +1709,6 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case MIDDLEMOUSE:
handle_view_middlemouse();
G.vd->view = -1;
break;
case RIGHTMOUSE:
if((G.obedit) && (G.qual & LR_CTRLKEY)==0) {

@ -289,9 +289,22 @@ void persptoetsen(unsigned short event)
if(G.vd->persp==V3D_PERSP) G.vd->persp=V3D_ORTHO;
else G.vd->persp=V3D_PERSP;
}
G.vd->lpersp = G.vd->persp;
}
else if(event==PAD0) {
/* lastview - */
if(G.vd->lastview_set==0) {
/* store settings of current view before allowing overwriting with camera view */
QUATCOPY(G.vd->lviewquat, G.vd->viewquat);
G.vd->lview= G.vd->view;
G.vd->lpersp= G.vd->persp;
G.vd->lastview_set= 1;
}
else if(G.vd->lastview_set) {
/* return to settings of last view */
axis_set_view(G.vd->lviewquat[0], G.vd->lviewquat[1], G.vd->lviewquat[2], G.vd->lviewquat[3], G.vd->lview, G.vd->lpersp);
G.vd->lastview_set= 0;
}
if(G.qual==LR_ALTKEY) {
if(oldcamera && is_an_active_object(oldcamera)) {
G.vd->camera= oldcamera;
@ -314,18 +327,12 @@ void persptoetsen(unsigned short event)
handle_view3d_lock();
}
}
if(G.vd->camera==0) {
G.vd->camera= scene_find_camera(G.scene);
handle_view3d_lock();
}
if(!G.vd->view) {
QUATCOPY(G.vd->viewquat, G.vd->lviewquat);
G.vd->persp = G.vd->lpersp;
}
else {
QUATCOPY(G.vd->lviewquat, G.vd->viewquat);
G.vd->lpersp = G.vd->persp;
}
if(G.vd->camera && (G.vd->camera != act_cam_orig)) {
G.vd->persp= V3D_CAMOB;
G.vd->view= 0;
@ -350,8 +357,6 @@ void persptoetsen(unsigned short event)
VECCOPY(G.vd->ofs, orig_ofs);
G.vd->lens = orig_lens;
}
}
}
else if(event==PAD9) {
@ -370,11 +375,6 @@ void persptoetsen(unsigned short event)
q1[1]= q1[2]= 0.0;
q1[3]= si;
QuatMul(G.vd->viewquat, G.vd->viewquat, q1);
QUATCOPY(G.vd->lviewquat, G.vd->viewquat);
G.vd->lpersp = G.vd->persp;
G.vd->view= 0;
}
if(event==PAD2 || event==PAD8) {
/* horizontal axis */
@ -389,11 +389,6 @@ void persptoetsen(unsigned short event)
q1[2]*= si;
q1[3]*= si;
QuatMul(G.vd->viewquat, G.vd->viewquat, q1);
QUATCOPY(G.vd->lviewquat, G.vd->viewquat);
G.vd->lpersp = G.vd->persp;
G.vd->view= 0;
}
}

@ -894,6 +894,11 @@ void viewmove(int mode)
return;
}
/* clear lastview flag (used to return to previous view when
* pressing Pad0 again after entering Camera view)
*/
if (G.vd->lastview_set) G.vd->lastview_set= 0;
// dist correction from other movement devices
if((dz_flag)||G.vd->dist==0) {
dz_flag = 0;