[Bf-blender-cvs] [568514c] master: Fix T48340: Smooth view cancels previous view action

Campbell Barton noreply at git.blender.org
Tue May 3 19:34:53 CEST 2016


Commit: 568514c875d47def3bd05c89b4c03c7a1ece35bc
Author: Campbell Barton
Date:   Wed May 4 03:38:20 2016 +1000
Branches: master
https://developer.blender.org/rB568514c875d47def3bd05c89b4c03c7a1ece35bc

Fix T48340: Smooth view cancels previous view action

Previously users needed to wait for view orbit to finished,
so quickly pressing keys would gave different result.

===================================================================

M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_intern.h
M	source/blender/editors/space_view3d/view3d_view.c

===================================================================

diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 8ca7331..ca0c623 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -2838,6 +2838,8 @@ static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar,
 	float afm[3];
 	float size;
 
+	ED_view3d_smooth_view_finish(C, v3d, ar);
+
 	/* SMOOTHVIEW */
 	float new_ofs[3];
 	float new_dist;
@@ -3196,6 +3198,8 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
 		ARegion *ar = CTX_wm_region(C);
 		const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
 
+		ED_view3d_smooth_view_finish(C, v3d, ar);
+
 		/* non camera center */
 		float new_ofs[3];
 		negate_v3_v3(new_ofs, ED_view3d_cursor3d_get(scene, v3d));
@@ -3235,6 +3239,8 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *ev
 		float new_ofs[3];
 		const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
 
+		ED_view3d_smooth_view_finish(C, v3d, ar);
+
 		view3d_operator_needs_opengl(C);
 
 		if (ED_view3d_autodist(scene, ar, v3d, event->mval, new_ofs, false, NULL)) {
@@ -3840,6 +3846,8 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
 	ED_view3d_context_user_region(C, &v3d, &ar);
 	rv3d = ar->regiondata;
 
+	ED_view3d_smooth_view_finish(C, v3d, ar);
+
 	viewnum = RNA_enum_get(op->ptr, "type");
 	align_active = RNA_boolean_get(op->ptr, "align_active");
 
@@ -3990,6 +3998,8 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
 		rv3d = ar->regiondata;
 	}
 
+	ED_view3d_smooth_view_finish(C, v3d, ar);
+
 	if ((rv3d->viewlock & RV3D_LOCKED) == 0 || (view_opposite != RV3D_VIEW_USER)) {
 		if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) {
 			int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
@@ -4195,6 +4205,9 @@ static int viewroll_exec(bContext *C, wmOperator *op)
 
 	rv3d = ar->regiondata;
 	if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) {
+
+		ED_view3d_smooth_view_finish(C, v3d, ar);
+
 		int type = RNA_enum_get(op->ptr, "type");
 		float angle = (type == 0) ? RNA_float_get(op->ptr, "angle") : DEG2RADF(U.pad_rot_angle);
 		float mousevec[3];
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index c398356..074e94e 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -229,6 +229,10 @@ void ED_view3d_smooth_view(
         struct View3D *v3d, struct ARegion *ar, const int smooth_viewtx,
         const V3D_SmoothParams *sview);
 
+void ED_view3d_smooth_view_finish(
+        struct bContext *C,
+        struct View3D *v3d, struct ARegion *ar);
+
 void view3d_winmatrix_set(ARegion *ar, const View3D *v3d, const rctf *rect);
 void view3d_viewmatrix_set(Scene *scene, const View3D *v3d, RegionView3D *rv3d);
 
diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c
index 305b4a3..18caf99 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -337,17 +337,12 @@ void ED_view3d_smooth_view(
 }
 
 /* only meant for timer usage */
-static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+static void view3d_smoothview_apply(bContext *C, View3D *v3d, ARegion *ar, bool sync_boxview)
 {
-	View3D *v3d = CTX_wm_view3d(C);
-	RegionView3D *rv3d = CTX_wm_region_view3d(C);
+	RegionView3D *rv3d = ar->regiondata;
 	struct SmoothView3DStore *sms = rv3d->sms;
 	float step, step_inv;
 	
-	/* escape if not our timer */
-	if (rv3d->smooth_timer == NULL || rv3d->smooth_timer != event->customdata)
-		return OPERATOR_PASS_THROUGH;
-	
 	if (sms->time_allowed != 0.0)
 		step = (float)((rv3d->smooth_timer->duration) / sms->time_allowed);
 	else
@@ -404,8 +399,9 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
 
 	}
 	
-	if (rv3d->viewlock & RV3D_BOXVIEW)
-		view3d_boxview_copy(CTX_wm_area(C), CTX_wm_region(C));
+	if (sync_boxview && (rv3d->viewlock & RV3D_BOXVIEW)) {
+		view3d_boxview_copy(CTX_wm_area(C), ar);
+	}
 
 	/* note: this doesn't work right because the v3d->lens is now used in ortho mode r51636,
 	 * when switching camera in quad-view the other ortho views would zoom & reset.
@@ -416,12 +412,43 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const w
 		WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
 	}
 	else {
-		ED_region_tag_redraw(CTX_wm_region(C));
+		ED_region_tag_redraw(ar);
 	}
-	
+}
+
+static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+{
+	View3D *v3d = CTX_wm_view3d(C);
+	ARegion *ar = CTX_wm_region(C);
+	RegionView3D *rv3d = ar->regiondata;
+
+	/* escape if not our timer */
+	if (rv3d->smooth_timer == NULL || rv3d->smooth_timer != event->customdata) {
+		return OPERATOR_PASS_THROUGH;
+	}
+
+	view3d_smoothview_apply(C, v3d, ar, true);
+
 	return OPERATOR_FINISHED;
 }
 
+void ED_view3d_smooth_view_finish(
+        bContext *C,
+        View3D *v3d, ARegion *ar)
+{
+	RegionView3D *rv3d = ar->regiondata;
+
+	if (rv3d && rv3d->sms) {
+		rv3d->sms->time_allowed = 0.0;  /* force finishing */
+		view3d_smoothview_apply(C, v3d, ar, false);
+
+		/* force update of view matrix so tools that run immediately after
+		 * can use them without redrawing first */
+		Scene *scene = CTX_data_scene(C);
+		ED_view3d_update_viewmat(scene, v3d, ar, NULL, NULL);
+	}
+}
+
 void VIEW3D_OT_smoothview(wmOperatorType *ot)
 {




More information about the Bf-blender-cvs mailing list