[Bf-committers] back to last view of camera view

Joilnen Batista Leite vma_bad_list at yahoo.com
Mon Jun 26 13:33:47 CEST 2006


Sometimes I do rotation and translation in coordenate
space changing view of all scene so switch to camera
view, but I can't back to last view of camera in an
easy way. Well I don't found this feature at least :).
Here a patch for that. Use PAD0 to swicth camera view
and back to last view.

Thanks to consider, Joilnen

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
-------------- next part --------------
Index: blender/source/blender/src/space.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/space.c,v
retrieving revision 1.359
diff -u -r1.359 space.c
--- blender/source/blender/src/space.c	23 Jun 2006 15:08:13 -0000	1.359
+++ blender/source/blender/src/space.c	26 Jun 2006 05:50:07 -0000
@@ -1970,6 +1970,7 @@
 						
 						if(G.vd->persp==2) G.vd->persp= 1;
 						scrarea_queue_winredraw(curarea);
+						persptoetsen(event);
 					}
 				}
 				break;
Index: blender/source/blender/src/toets.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/toets.c,v
retrieving revision 1.79
diff -u -r1.79 toets.c
--- blender/source/blender/src/toets.c	16 Jun 2006 09:28:51 -0000	1.79
+++ blender/source/blender/src/toets.c	26 Jun 2006 05:50:36 -0000
@@ -125,6 +125,11 @@
 	float phi, si, q1[4], vec[3];
 	static int perspo=1;
 	int preview3d_event= 1;
+	static struct {
+		float viewquat[4];
+		int view, persp;
+	} view_buff;
+	static short firsttime= 1;
 	
 	if(event==PADENTER) {
 		if (G.qual == LR_SHIFTKEY) {
@@ -251,6 +256,18 @@
 			else G.vd->persp=1;
 		}
 		else if(event==PAD0) {
+
+			if (firsttime) {
+				firsttime= 0;
+
+				view_buff.viewquat[0]= G.vd->viewquat[0];
+				view_buff.viewquat[1]= G.vd->viewquat[1];
+				view_buff.viewquat[2]= G.vd->viewquat[2];
+				view_buff.viewquat[3]= G.vd->viewquat[3];
+				view_buff.persp= G.vd->persp;
+				view_buff.view= G.vd->view;
+			}
+
 			if(G.qual==LR_ALTKEY) {
 				if(oldcamera && is_an_active_object(oldcamera)) {
 					G.vd->camera= oldcamera;
@@ -277,17 +294,30 @@
 				G.vd->camera= scene_find_camera(G.scene);
 				handle_view3d_lock();
 			}
-			
+
+
 			if(G.vd->camera) {
-				G.vd->persp= 2;
-				G.vd->view= 0;
-				if(((G.qual & LR_CTRLKEY) && (G.qual & LR_ALTKEY)) || (G.qual & LR_SHIFTKEY)) {
-					void setcameratoview3d(void);	// view.c
-					setcameratoview3d();
-					DAG_object_flush_update(G.scene, G.scene->camera, OB_RECALC_OB);
-					allqueue(REDRAWVIEW3D, 0);
+ 
+				if (G.vd->persp==2 && G.vd->view==0) {
+					G.vd->viewquat[0]= view_buff.viewquat[0];
+					G.vd->viewquat[1]= view_buff.viewquat[1]; 
+					G.vd->viewquat[2]= view_buff.viewquat[2];
+					G.vd->viewquat[3]= view_buff.viewquat[3];
+					G.vd->view= view_buff.view;
+					G.vd->persp= view_buff.persp;
+				}
+				else {
+					G.vd->persp= 2;
+					G.vd->view= 0;
+					if(((G.qual & LR_CTRLKEY) && (G.qual & LR_ALTKEY)) || (G.qual & LR_SHIFTKEY)) {
+						void setcameratoview3d(void);	// view.c
+						setcameratoview3d();
+						DAG_object_flush_update(G.scene, G.scene->camera, OB_RECALC_OB);
+						allqueue(REDRAWVIEW3D, 0);
+					}
 				}				
 			}
+
 		}
 		else if(event==PAD9) {
 			countall();
@@ -326,6 +356,16 @@
 		}
 
 		if(G.vd->persp<2) perspo= G.vd->persp;
+
+	}
+
+	if (event!=PAD0) {
+		view_buff.viewquat[0]= G.vd->viewquat[0];
+		view_buff.viewquat[1]= G.vd->viewquat[1];
+		view_buff.viewquat[2]= G.vd->viewquat[2];
+		view_buff.viewquat[3]= G.vd->viewquat[3];
+		view_buff.persp= G.vd->persp;
+		view_buff.view= G.vd->view;
 	}
 	
 	if(preview3d_event) 


More information about the Bf-committers mailing list