Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2016-05-03 20:38:20 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-05-03 20:38:20 +0300
commit568514c875d47def3bd05c89b4c03c7a1ece35bc (patch)
treeabcaacfc139519169f6e776d298354ba4425a53d /source/blender/editors/space_view3d
parent9d3d9ac0b90deceb6020652f931ea3a0b7099b2f (diff)
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.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c13
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h4
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c49
3 files changed, 55 insertions, 11 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 8ca7331fb37..ca0c6230f49 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 c398356e941..074e94e68f3 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 305b4a3785e..18caf999c67 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)
{