[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25421] trunk/blender/source/blender/ editors/space_view3d/view3d_edit.c: bugfix [#20054] Continuous Zoom isn' t smooth

Campbell Barton ideasman42 at gmail.com
Thu Dec 17 00:05:59 CET 2009


Revision: 25421
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25421
Author:   campbellbarton
Date:     2009-12-17 00:05:59 +0100 (Thu, 17 Dec 2009)

Log Message:
-----------
bugfix [#20054] Continuous Zoom isn't smooth

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2009-12-16 21:27:07 UTC (rev 25420)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c	2009-12-16 23:05:59 UTC (rev 25421)
@@ -234,6 +234,10 @@
 	ARegion *ar;
 	RegionView3D *rv3d;
 
+	/* needed for continuous zoom */
+	wmTimer *timer;
+	double timer_lastdraw;
+
 	float oldquat[4];
 	float trackvec[3];
 	float reverse, dist0;
@@ -372,6 +376,9 @@
 	if(p && (p->flags & PAINT_FAST_NAVIGATE))
 		ED_region_tag_redraw(vod->ar);
 
+	if(vod->timer)
+		WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), vod->timer);
+
 	MEM_freeN(vod);
 	op->customdata= NULL;
 }
@@ -891,8 +898,12 @@
 	float zfac=1.0;
 
 	if(U.viewzoom==USER_ZOOM_CONT) {
+		double time= PIL_check_seconds_timer();
+		float time_step= (float)(time - vod->timer_lastdraw);
+
 		// oldstyle zoom
-		zfac = 1.0+(float)(vod->origx - x + vod->origy - y)/1000.0;
+		zfac = 1.0f + (((float)(vod->origx - x + vod->origy - y)/1000.0) * (time_step * 10.0f));
+		vod->timer_lastdraw= time;
 	}
 	else if(U.viewzoom==USER_ZOOM_SCALE) {
 		int ctr[2], len1, len2;
@@ -959,9 +970,12 @@
 	short event_code= VIEW_PASS;
 
 	/* execute the events */
-	if(event->type==MOUSEMOVE) {
+	if (event->type == TIMER && event->customdata == vod->timer) {
 		event_code= VIEW_APPLY;
 	}
+	else if(event->type==MOUSEMOVE) {
+		event_code= VIEW_APPLY;
+	}
 	else if(event->type==EVT_MODAL_MAP) {
 		switch (event->val) {
 			case VIEW_MODAL_CONFIRM:
@@ -1038,9 +1052,16 @@
 		viewzoom_exec(C, op);
 	}
 	else {
+		ViewOpsData *vod;
+
 		/* makes op->customdata */
 		viewops_data_create(C, op, event);
 
+		vod= op->customdata;
+
+		vod->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), TIMER, 0.01f);
+		vod->timer_lastdraw= PIL_check_seconds_timer();
+
 		/* add temp handler */
 		WM_event_add_modal_handler(C, op);
 





More information about the Bf-blender-cvs mailing list