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>2012-08-12 05:07:31 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-08-12 05:07:31 +0400
commit9cce2d864554cb78abfb5e2909dfb1a506933d3c (patch)
tree57f1037cb16ce26791f4bb1cd5fb0a88293d8af9 /source/blender/editors
parent1aaaf67a9e42cfbba6d8c955a9e0a7519b296933 (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')
-rw-r--r--source/blender/editors/include/UI_view2d.h3
-rw-r--r--source/blender/editors/interface/view2d_ops.c157
-rw-r--r--source/blender/editors/space_graph/graph_edit.c25
-rw-r--r--source/blender/editors/space_node/node_view.c11
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c42
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c24
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h4
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c31
8 files changed, 203 insertions, 94 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index f0bdb2fc2ea..9ab024a8b76 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -202,5 +202,8 @@ void UI_view2d_text_cache_draw(struct ARegion *ar);
void UI_view2d_operatortypes(void);
void UI_view2d_keymap(struct wmKeyConfig *keyconf);
+void UI_view2d_smooth_view(struct bContext *C, struct ARegion *ar,
+ const struct rctf *cur);
+
#endif /* __UI_VIEW2D_H__ */
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index c70f661cb14..5b5ccc0582c 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1100,6 +1100,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
ARegion *ar = CTX_wm_region(C);
View2D *v2d = &ar->v2d;
rctf rect;
+ rctf cur_new = v2d->cur;
int gesture_mode;
/* convert coordinates of rect to 'tot' rect coordinates */
@@ -1116,12 +1117,12 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
* if zoom is allowed to be changed
*/
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
- v2d->cur.xmin = rect.xmin;
- v2d->cur.xmax = rect.xmax;
+ cur_new.xmin = rect.xmin;
+ cur_new.xmax = rect.xmax;
}
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
- v2d->cur.ymin = rect.ymin;
- v2d->cur.ymax = rect.ymax;
+ cur_new.ymin = rect.ymin;
+ cur_new.ymax = rect.ymax;
}
}
else { /* if (gesture_mode == GESTURE_MODAL_OUT) */
@@ -1135,29 +1136,24 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
/* TODO: is this zoom factor calculation valid? It seems to produce same results everytime... */
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
- size = (v2d->cur.xmax - v2d->cur.xmin);
+ size = (cur_new.xmax - cur_new.xmin);
zoom = size / (rect.xmax - rect.xmin);
- center = (v2d->cur.xmax + v2d->cur.xmin) * 0.5f;
+ center = (cur_new.xmax + cur_new.xmin) * 0.5f;
- v2d->cur.xmin = center - (size * zoom);
- v2d->cur.xmax = center + (size * zoom);
+ cur_new.xmin = center - (size * zoom);
+ cur_new.xmax = center + (size * zoom);
}
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
- size = (v2d->cur.ymax - v2d->cur.ymin);
+ size = (cur_new.ymax - cur_new.ymin);
zoom = size / (rect.ymax - rect.ymin);
- center = (v2d->cur.ymax + v2d->cur.ymin) * 0.5f;
+ center = (cur_new.ymax + cur_new.ymin) * 0.5f;
- v2d->cur.ymin = center - (size * zoom);
- v2d->cur.ymax = center + (size * zoom);
+ cur_new.ymin = center - (size * zoom);
+ cur_new.ymax = center + (size * zoom);
}
}
- /* validate that view is in valid configuration after this operation */
- UI_view2d_curRect_validate(v2d);
-
- /* request updates to be done... */
- ED_region_tag_redraw(ar);
- UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
+ UI_view2d_smooth_view(C, ar, &cur_new);
return OPERATOR_FINISHED;
}
@@ -1182,6 +1178,127 @@ static void VIEW2D_OT_zoom_border(wmOperatorType *ot)
}
/* ********************************************************* */
+/* SMOOTH VIEW */
+
+struct SmoothView2DStore {
+ rctf orig_cur, new_cur;
+
+ double time_allowed;
+};
+
+/* will start timer if appropriate */
+/* the arguments are the desired situation */
+void UI_view2d_smooth_view(bContext *C, ARegion *ar,
+ const rctf *cur)
+{
+ wmWindowManager *wm = CTX_wm_manager(C);
+ wmWindow *win = CTX_wm_window(C);
+
+ View2D *v2d = &ar->v2d;
+ struct SmoothView2DStore sms = {{0}};
+ short ok = FALSE;
+
+ /* initialize sms */
+ sms.new_cur = v2d->cur;
+
+ /* store the options we want to end with */
+ if (cur) sms.new_cur = *cur;
+
+ if (C && U.smooth_viewtx) {
+ int changed = 0; /* zero means no difference */
+
+ if (BLI_rctf_compare(&sms.new_cur, &v2d->cur, FLT_EPSILON) == FALSE)
+ changed = 1;
+ changed=1;
+
+ /* The new view is different from the old one
+ * so animate the view */
+ if (changed) {
+ sms.orig_cur = v2d->cur;
+
+ sms.time_allowed = (double)U.smooth_viewtx / 1000.0;
+
+ /* keep track of running timer! */
+ if (v2d->sms == NULL)
+ v2d->sms = MEM_mallocN(sizeof(struct SmoothView2DStore), "smoothview v2d");
+ *v2d->sms = sms;
+ if (v2d->smooth_timer)
+ WM_event_remove_timer(wm, win, v2d->smooth_timer);
+ /* TIMER1 is hardcoded in keymap */
+ v2d->smooth_timer = WM_event_add_timer(wm, win, TIMER1, 1.0 / 100.0); /* max 30 frs/sec */
+
+ ok = TRUE;
+ }
+ }
+
+ /* if we get here nothing happens */
+ if (ok == FALSE) {
+ v2d->cur = sms.new_cur;
+
+ UI_view2d_curRect_validate(v2d);
+ ED_region_tag_redraw(ar);
+ UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
+ }
+}
+
+/* only meant for timer usage */
+static int view2d_smoothview_invoke(bContext *C, wmOperator *UNUSED(op), wmEvent *event)
+{
+ ARegion *ar = CTX_wm_region(C);
+ View2D *v2d = &ar->v2d;
+ struct SmoothView2DStore *sms = v2d->sms;
+ float step;
+
+ /* escape if not our timer */
+ if (v2d->smooth_timer == NULL || v2d->smooth_timer != event->customdata)
+ return OPERATOR_PASS_THROUGH;
+
+ if (sms->time_allowed != 0.0)
+ step = (float)((v2d->smooth_timer->duration) / sms->time_allowed);
+ else
+ step = 1.0f;
+
+ /* end timer */
+ if (step >= 1.0f) {
+ v2d->cur = sms->new_cur;
+
+ MEM_freeN(v2d->sms);
+ v2d->sms = NULL;
+
+ WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), v2d->smooth_timer);
+ v2d->smooth_timer = NULL;
+ }
+ else {
+ /* ease in/out */
+ step = (3.0f * step * step - 2.0f * step * step * step);
+
+ BLI_rctf_interp(&v2d->cur, &sms->orig_cur, &sms->new_cur, step);
+ }
+
+ UI_view2d_curRect_validate(v2d);
+ UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
+ ED_region_tag_redraw(ar);
+
+ return OPERATOR_FINISHED;
+}
+
+static void VIEW2D_OT_smoothview(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Smooth View 2D";
+ ot->description = "Zoom in the view to the nearest item contained in the border";
+ ot->idname = "VIEW2D_OT_smoothview";
+
+ /* api callbacks */
+ ot->invoke = view2d_smoothview_invoke;
+
+ ot->poll = view2d_poll;
+
+ /* rna */
+ WM_operator_properties_gesture_border(ot, FALSE);
+}
+
+/* ********************************************************* */
/* SCROLLERS */
/* Scrollers should behave in the following ways, when clicked on with LMB (and dragged):
@@ -1678,6 +1795,8 @@ void UI_view2d_operatortypes(void)
WM_operatortype_append(VIEW2D_OT_zoom);
WM_operatortype_append(VIEW2D_OT_zoom_border);
+
+ WM_operatortype_append(VIEW2D_OT_smoothview);
WM_operatortype_append(VIEW2D_OT_scroller_activate);
@@ -1711,6 +1830,8 @@ void UI_view2d_keymap(wmKeyConfig *keyconf)
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_out", PADMINUS, KM_PRESS, 0, 0);
WM_keymap_add_item(keymap, "VIEW2D_OT_zoom_in", PADPLUSKEY, KM_PRESS, 0, 0);
+ WM_keymap_verify_item(keymap, "VIEW2D_OT_smoothview", TIMER1, KM_ANY, KM_ANY, 0);
+
/* scroll up/down - no modifiers, only when zoom fails */
/* these may fail if zoom is disallowed, in which case they should pass on event */
WM_keymap_add_item(keymap, "VIEW2D_OT_scroll_down", WHEELDOWNMOUSE, KM_PRESS, 0, 0);
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 55dca725131..8a0538eddb0 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -202,33 +202,28 @@ void GRAPH_OT_previewrange_set(wmOperatorType *ot)
static int graphkeys_viewall(bContext *C, const short do_sel_only, const short include_handles)
{
bAnimContext ac;
- View2D *v2d;
float extra;
+ rctf cur_new;
/* get editor data */
if (ANIM_animdata_get_context(C, &ac) == 0)
return OPERATOR_CANCELLED;
- v2d = &ac.ar->v2d;
/* set the horizontal range, with an extra offset so that the extreme keys will be in view */
get_graph_keyframe_extents(&ac,
- &v2d->cur.xmin, &v2d->cur.xmax,
- &v2d->cur.ymin, &v2d->cur.ymax,
+ &cur_new.xmin, &cur_new.xmax,
+ &cur_new.ymin, &cur_new.ymax,
do_sel_only, include_handles);
- extra = 0.1f * (v2d->cur.xmax - v2d->cur.xmin);
- v2d->cur.xmin -= extra;
- v2d->cur.xmax += extra;
-
- extra = 0.1f * (v2d->cur.ymax - v2d->cur.ymin);
- v2d->cur.ymin -= extra;
- v2d->cur.ymax += extra;
+ extra = 0.1f * (cur_new.xmax - cur_new.xmin);
+ cur_new.xmin -= extra;
+ cur_new.xmax += extra;
- /* do View2D syncing */
- UI_view2d_sync(CTX_wm_screen(C), CTX_wm_area(C), v2d, V2D_LOCK_COPY);
+ extra = 0.1f * (cur_new.ymax - cur_new.ymin);
+ cur_new.ymin -= extra;
+ cur_new.ymax += extra;
- /* set notifier that things have changed */
- ED_area_tag_redraw(CTX_wm_area(C));
+ UI_view2d_smooth_view(C, ac.ar, &cur_new);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index 7ad283b9869..0566611dc0e 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -43,6 +43,8 @@
#include "ED_space_api.h"
#include "ED_image.h"
+#include "UI_view2d.h"
+
#include "RNA_access.h"
#include "RNA_define.h"
@@ -61,7 +63,7 @@
/* **************** View All Operator ************** */
-static int space_node_view_flag(SpaceNode *snode, ARegion *ar, const int node_flag)
+static int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, const int node_flag)
{
bNode *node;
rctf cur_new;
@@ -118,8 +120,7 @@ static int space_node_view_flag(SpaceNode *snode, ARegion *ar, const int node_fl
}
}
- ar->v2d.tot = ar->v2d.cur = cur_new;
- UI_view2d_curRect_validate(&ar->v2d);
+ UI_view2d_smooth_view(C, ar, &cur_new);
}
return (tot != 0);
@@ -134,7 +135,7 @@ static int node_view_all_exec(bContext *C, wmOperator *UNUSED(op))
snode->xof = 0;
snode->yof = 0;
- if (space_node_view_flag(snode, ar, 0)) {
+ if (space_node_view_flag(C, snode, ar, 0)) {
ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
@@ -164,7 +165,7 @@ static int node_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
ARegion *ar = CTX_wm_region(C);
SpaceNode *snode = CTX_wm_space_node(C);
- if (space_node_view_flag(snode, ar, NODE_SELECT)) {
+ if (space_node_view_flag(C, snode, ar, NODE_SELECT)) {
ED_region_tag_redraw(ar);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index b4832306daf..9e730fff940 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -2042,17 +2042,10 @@ void SEQUENCER_OT_meta_separate(wmOperatorType *ot)
/* view_all operator */
static int sequencer_view_all_exec(bContext *C, wmOperator *UNUSED(op))
{
- //Scene *scene= CTX_data_scene(C);
- bScreen *sc = CTX_wm_screen(C);
- ScrArea *area = CTX_wm_area(C);
- //ARegion *ar= CTX_wm_region(C);
+ ARegion *ar = CTX_wm_region(C);
View2D *v2d = UI_view2d_fromcontext(C);
- v2d->cur = v2d->tot;
- UI_view2d_curRect_validate(v2d);
- UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY);
-
- ED_area_tag_redraw(CTX_wm_area(C));
+ UI_view2d_smooth_view(C, ar, &v2d->tot);
return OPERATOR_FINISHED;
}
@@ -2218,10 +2211,10 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
{
Scene *scene = CTX_data_scene(C);
View2D *v2d = UI_view2d_fromcontext(C);
- ScrArea *area = CTX_wm_area(C);
- bScreen *sc = CTX_wm_screen(C);
+ ARegion *ar = CTX_wm_region(C);
Editing *ed = BKE_sequencer_editing_get(scene, FALSE);
Sequence *seq;
+ rctf cur_new = v2d->cur;
int xmin = MAXFRAME * 2;
int xmax = -MAXFRAME * 2;
@@ -2252,29 +2245,30 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
ymax += ymargin;
ymin -= ymargin;
- orig_height = v2d->cur.ymax - v2d->cur.ymin;
+ orig_height = cur_new.ymax - cur_new.ymin;
- v2d->cur.xmin = xmin;
- v2d->cur.xmax = xmax;
+ cur_new.xmin = xmin;
+ cur_new.xmax = xmax;
- v2d->cur.ymin = ymin;
- v2d->cur.ymax = ymax;
+ cur_new.ymin = ymin;
+ cur_new.ymax = ymax;
/* only zoom out vertically */
- if (orig_height > v2d->cur.ymax - v2d->cur.ymin) {
- ymid = (v2d->cur.ymax + v2d->cur.ymin) / 2;
+ if (orig_height > cur_new.ymax - cur_new.ymin) {
+ ymid = (cur_new.ymax + cur_new.ymin) / 2;
- v2d->cur.ymin = ymid - (orig_height / 2);
- v2d->cur.ymax = ymid + (orig_height / 2);
+ cur_new.ymin = ymid - (orig_height / 2);
+ cur_new.ymax = ymid + (orig_height / 2);
}
- UI_view2d_curRect_validate(v2d);
- UI_view2d_sync(sc, area, v2d, V2D_LOCK_COPY);
+ UI_view2d_smooth_view(C, ar, &cur_new);
- ED_area_tag_redraw(CTX_wm_area(C));
+ return OPERATOR_FINISHED;
+ }
+ else {
+ return OPERATOR_CANCELLED;
}
- return OPERATOR_FINISHED;
}
void SEQUENCER_OT_view_selected(wmOperatorType *ot)
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 */
}
}