diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-08-12 05:07:31 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-08-12 05:07:31 +0400 |
commit | 9cce2d864554cb78abfb5e2909dfb1a506933d3c (patch) | |
tree | 57f1037cb16ce26791f4bb1cd5fb0a88293d8af9 /source/blender/editors/space_view3d | |
parent | 1aaaf67a9e42cfbba6d8c955a9e0a7519b296933 (diff) |
smooth-view for 2d views, graph editor, sequencer, node view, works with border zoom, view selected, view all.
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 24 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 31 |
3 files changed, 27 insertions, 32 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 9cda4900c8d..8b8adb193bf 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -2081,7 +2081,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in * I think no, because we always move the cursor, with or without * object, but in this case there is no change in the scene, * only the cursor so I choice a ED_region_tag like - * smooth_view do for the center_cursor. + * view3d_smooth_view do for the center_cursor. * See bug #22640 */ return OPERATOR_FINISHED; @@ -2109,10 +2109,10 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in if ((rv3d->persp == RV3D_CAMOB) && !ED_view3d_camera_lock_check(v3d, rv3d)) { rv3d->persp = RV3D_PERSP; - smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); + view3d_smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, &new_dist, NULL); } else { - smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL); + view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL); } } // XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT); @@ -2266,10 +2266,10 @@ static int viewselected_exec(bContext *C, wmOperator *UNUSED(op)) if (rv3d->persp == RV3D_CAMOB && !ED_view3d_camera_lock_check(v3d, rv3d)) { rv3d->persp = RV3D_PERSP; - smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL); + view3d_smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL); } else { - smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL); + view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL); } /* smooth view does viewlock RV3D_BOXVIEW copy */ @@ -2390,7 +2390,7 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *UNUSED(op)) /* non camera center */ float new_ofs[3]; negate_v3_v3(new_ofs, give_cursor(scene, v3d)); - smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, NULL, NULL); + view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, NULL, NULL); /* smooth view does viewlock RV3D_BOXVIEW copy */ } @@ -2662,7 +2662,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op) new_dist = dist_range_min; } - smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL); + view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL); if (rv3d->viewlock & RV3D_BOXVIEW) view3d_boxview_sync(CTX_wm_area(C), ar); @@ -2828,14 +2828,14 @@ static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar, if (U.uiflag & USER_AUTOPERSP) rv3d->persp = view ? RV3D_ORTHO : RV3D_PERSP; else if (rv3d->persp == RV3D_CAMOB) rv3d->persp = perspo; - smooth_view(C, v3d, ar, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL); + view3d_smooth_view(C, v3d, ar, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL); } else { if (U.uiflag & USER_AUTOPERSP) rv3d->persp = view ? RV3D_ORTHO : RV3D_PERSP; else if (rv3d->persp == RV3D_CAMOB) rv3d->persp = perspo; - smooth_view(C, v3d, ar, NULL, NULL, NULL, new_quat, NULL, NULL); + view3d_smooth_view(C, v3d, ar, NULL, NULL, NULL, new_quat, NULL, NULL); } } @@ -2953,12 +2953,12 @@ static int viewnumpad_exec(bContext *C, wmOperator *op) /* finally do snazzy view zooming */ rv3d->persp = RV3D_CAMOB; - smooth_view(C, v3d, ar, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); + view3d_smooth_view(C, v3d, ar, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); } else { /* return to settings of last view */ - /* does smooth_view too */ + /* does view3d_smooth_view too */ axis_set_view(C, v3d, ar, rv3d->lviewquat[0], rv3d->lviewquat[1], rv3d->lviewquat[2], rv3d->lviewquat[3], rv3d->lview, rv3d->lpersp, 0); @@ -3048,7 +3048,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op) mul_qt_qtqt(quat_new, rv3d->viewquat, quat_mul); rv3d->view = RV3D_VIEW_USER; - smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL, NULL, quat_new, NULL, NULL); + view3d_smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL, NULL, quat_new, NULL, NULL); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 3c6a0dd4b9f..8b51e6cf226 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -173,8 +173,8 @@ void VIEW3D_OT_game_start(struct wmOperatorType *ot); int ED_view3d_boundbox_clip(RegionView3D * rv3d, float obmat[][4], struct BoundBox *bb); -void smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *, - float *ofs, float *quat, float *dist, float *lens); +void view3d_smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *, + float *ofs, float *quat, float *dist, float *lens); void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect); /* rect: for picking */ void setviewmatrixview3d(Scene *scene, 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 f9776855d61..604d101abd5 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -110,7 +110,7 @@ float *give_cursor(Scene *scene, View3D *v3d) /* ****************** smooth view operator ****************** */ /* This operator is one of the 'timer refresh' ones like animation playback */ -struct SmoothViewStore { +struct SmoothView3DStore { float orig_dist, new_dist; float orig_lens, new_lens; float orig_quat[4], new_quat[4]; @@ -123,15 +123,15 @@ struct SmoothViewStore { /* will start timer if appropriate */ /* the arguments are the desired situation */ -void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera, - float *ofs, float *quat, float *dist, float *lens) +void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera, + float *ofs, float *quat, float *dist, float *lens) { wmWindowManager *wm = CTX_wm_manager(C); wmWindow *win = CTX_wm_window(C); ScrArea *sa = CTX_wm_area(C); RegionView3D *rv3d = ar->regiondata; - struct SmoothViewStore sms = {0}; + struct SmoothView3DStore sms = {0}; short ok = FALSE; /* initialize sms */ @@ -227,7 +227,7 @@ void smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Objec /* keep track of running timer! */ if (rv3d->sms == NULL) - rv3d->sms = MEM_mallocN(sizeof(struct SmoothViewStore), "smoothview v3d"); + rv3d->sms = MEM_mallocN(sizeof(struct SmoothView3DStore), "smoothview v3d"); *rv3d->sms = sms; if (rv3d->smooth_timer) WM_event_remove_timer(wm, win, rv3d->smooth_timer); @@ -259,7 +259,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent { View3D *v3d = CTX_wm_view3d(C); RegionView3D *rv3d = CTX_wm_region_view3d(C); - struct SmoothViewStore *sms = rv3d->sms; + struct SmoothView3DStore *sms = rv3d->sms; float step, step_inv; /* escape if not our timer */ @@ -303,17 +303,12 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent rv3d->rflag &= ~RV3D_NAVIGATING; } else { - int i; - /* ease in/out */ - if (step < 0.5f) step = (float)pow(step * 2.0f, 2.0) / 2.0f; - else step = (float)1.0f - (powf(2.0f * (1.0f - step), 2.0f) / 2.0f); + step = (3.0f * step * step - 2.0f * step * step * step); step_inv = 1.0f - step; - for (i = 0; i < 3; i++) - rv3d->ofs[i] = sms->new_ofs[i] * step + sms->orig_ofs[i] * step_inv; - + interp_v3_v3v3(rv3d->ofs, sms->new_ofs, sms->orig_ofs, step); interp_qt_qtqt(rv3d->viewquat, sms->orig_quat, sms->new_quat, step); rv3d->dist = sms->new_dist * step + sms->orig_dist * step_inv; @@ -490,7 +485,7 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op)) scene->camera = ob; if (camera_old != ob) /* unlikely but looks like a glitch when set to the same */ - smooth_view(C, v3d, ar, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); + view3d_smooth_view(C, v3d, ar, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens); WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS | NC_OBJECT | ND_DRAW, CTX_data_scene(C)); } @@ -1100,14 +1095,14 @@ static void obmat_to_viewmat(View3D *v3d, RegionView3D *rv3d, Object *ob, short rv3d->dist = 0.0; ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); - smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); /* XXX */ + view3d_smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); /* XXX */ rv3d->persp = RV3D_CAMOB; /* just to be polite, not needed */ } else { mat3_to_quat(new_quat, tmat); - smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); /* XXX */ + view3d_smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); /* XXX */ } } else { @@ -1872,11 +1867,11 @@ static void UNUSED_FUNCTION(view3d_align_axis_to_vector)(View3D *v3d, RegionView rv3d->persp = RV3D_PERSP; rv3d->dist = 0.0; ED_view3d_from_object(v3d->camera, rv3d->ofs, NULL, NULL, &v3d->lens); - smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); /* XXX */ + view3d_smooth_view(NULL, NULL, NULL, NULL, NULL, orig_ofs, new_quat, &orig_dist, &orig_lens); /* XXX */ } else { if (rv3d->persp == RV3D_CAMOB) rv3d->persp = RV3D_PERSP; /* switch out of camera mode */ - smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); /* XXX */ + view3d_smooth_view(NULL, NULL, NULL, NULL, NULL, NULL, new_quat, NULL, NULL); /* XXX */ } } |