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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-09-16 08:04:44 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-09-16 08:04:44 +0400
commit23626e0149f25f13855735bbb7f65121e0c40ca0 (patch)
tree2688b304463fee3a042496727032f6772d447642 /source
parent43bd8c2b28d06953b64ed6d1e72cead9e42463a0 (diff)
fix [#36444] view3d.viewnumpad operator should not animate
when running viewport operations with exec() rather then invoke(), perform the action immediately rather then using smoothview. makes viewport operations usable from python scripts.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/UI_view2d.h2
-rw-r--r--source/blender/editors/interface/view2d_ops.c9
-rw-r--r--source/blender/editors/space_graph/graph_edit.c15
-rw-r--r--source/blender/editors/space_logic/logic_ops.c5
-rw-r--r--source/blender/editors/space_node/node_intern.h3
-rw-r--r--source/blender/editors/space_node/node_select.c5
-rw-r--r--source/blender/editors/space_node/node_view.c15
-rw-r--r--source/blender/editors/space_sequencer/sequencer_edit.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c85
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h5
-rw-r--r--source/blender/editors/space_view3d/view3d_view.c20
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h8
-rw-r--r--source/blender/windowmanager/WM_api.h1
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c2
-rw-r--r--source/blender/windowmanager/intern/wm_operators.c5
15 files changed, 127 insertions, 63 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index fb70ad50b5d..c9a19ab4d8e 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -216,7 +216,7 @@ 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);
+ const struct rctf *cur, const int smooth_viewtx);
#endif /* __UI_VIEW2D_H__ */
diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c
index 03bd7e4631b..22c20842723 100644
--- a/source/blender/editors/interface/view2d_ops.c
+++ b/source/blender/editors/interface/view2d_ops.c
@@ -1144,6 +1144,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
rctf rect;
rctf cur_new = v2d->cur;
int gesture_mode;
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* convert coordinates of rect to 'tot' rect coordinates */
UI_view2d_region_to_view(v2d, RNA_int_get(op->ptr, "xmin"), RNA_int_get(op->ptr, "ymin"), &rect.xmin, &rect.ymin);
@@ -1195,7 +1196,7 @@ static int view_borderzoom_exec(bContext *C, wmOperator *op)
}
}
- UI_view2d_smooth_view(C, ar, &cur_new);
+ UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
return OPERATOR_FINISHED;
}
@@ -1269,7 +1270,7 @@ static float smooth_view_rect_to_fac(const rctf *rect_a, const rctf *rect_b)
/* will start timer if appropriate */
/* the arguments are the desired situation */
void UI_view2d_smooth_view(bContext *C, ARegion *ar,
- const rctf *cur)
+ const rctf *cur, const int smooth_viewtx)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
@@ -1289,7 +1290,7 @@ void UI_view2d_smooth_view(bContext *C, ARegion *ar,
fac = smooth_view_rect_to_fac(&v2d->cur, cur);
}
- if (U.smooth_viewtx && fac > FLT_EPSILON) {
+ if (smooth_viewtx && fac > FLT_EPSILON) {
int changed = FALSE;
if (BLI_rctf_compare(&sms.new_cur, &v2d->cur, FLT_EPSILON) == FALSE)
@@ -1300,7 +1301,7 @@ void UI_view2d_smooth_view(bContext *C, ARegion *ar,
if (changed) {
sms.orig_cur = v2d->cur;
- sms.time_allowed = (double)U.smooth_viewtx / 1000.0;
+ sms.time_allowed = (double)smooth_viewtx / 1000.0;
/* scale the time allowed the change in view */
sms.time_allowed *= (double)fac;
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 5546682e470..274c06bf871 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -214,7 +214,8 @@ void GRAPH_OT_previewrange_set(wmOperatorType *ot)
/* ****************** View-All Operator ****************** */
-static int graphkeys_viewall(bContext *C, const short do_sel_only, const short include_handles)
+static int graphkeys_viewall(bContext *C, const short do_sel_only, const short include_handles,
+ const int smooth_viewtx)
{
bAnimContext ac;
rctf cur_new;
@@ -231,7 +232,7 @@ static int graphkeys_viewall(bContext *C, const short do_sel_only, const short i
BLI_rctf_scale(&cur_new, 1.1f);
- UI_view2d_smooth_view(C, ac.ar, &cur_new);
+ UI_view2d_smooth_view(C, ac.ar, &cur_new, smooth_viewtx);
return OPERATOR_FINISHED;
}
@@ -240,18 +241,20 @@ static int graphkeys_viewall(bContext *C, const short do_sel_only, const short i
static int graphkeys_viewall_exec(bContext *C, wmOperator *op)
{
- short include_handles = RNA_boolean_get(op->ptr, "include_handles");
+ const short include_handles = RNA_boolean_get(op->ptr, "include_handles");
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* whole range */
- return graphkeys_viewall(C, FALSE, include_handles);
+ return graphkeys_viewall(C, false, include_handles, smooth_viewtx);
}
static int graphkeys_view_selected_exec(bContext *C, wmOperator *op)
{
- short include_handles = RNA_boolean_get(op->ptr, "include_handles");
+ const short include_handles = RNA_boolean_get(op->ptr, "include_handles");
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* only selected */
- return graphkeys_viewall(C, TRUE, include_handles);
+ return graphkeys_viewall(C, true, include_handles, smooth_viewtx);
}
void GRAPH_OT_view_all(wmOperatorType *ot)
diff --git a/source/blender/editors/space_logic/logic_ops.c b/source/blender/editors/space_logic/logic_ops.c
index fadf4c0b113..fac564f33fb 100644
--- a/source/blender/editors/space_logic/logic_ops.c
+++ b/source/blender/editors/space_logic/logic_ops.c
@@ -739,16 +739,17 @@ static void LOGIC_OT_texface_convert(wmOperatorType *ot)
/* ************************ view ********************* */
-static int logic_view_all_exec(bContext *C, wmOperator *UNUSED(op))
+static int logic_view_all_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
rctf cur_new = ar->v2d.tot;
float aspect = BLI_rctf_size_y(&ar->v2d.cur) / BLI_rctf_size_x(&ar->v2d.cur);
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* force the view2d code to zoom to width, not height */
cur_new.ymin = cur_new.ymax - BLI_rctf_size_x(&cur_new) * aspect;
- UI_view2d_smooth_view(C, ar, &cur_new);
+ UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 9b7b00fba00..176b81f9503 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -122,7 +122,8 @@ void NODE_OT_select_same_type_step(struct wmOperatorType *ot);
void NODE_OT_find_node(struct wmOperatorType *ot);
/* node_view.c */
-int space_node_view_flag(struct bContext *C, SpaceNode *snode, ARegion *ar, const int node_flag);
+int space_node_view_flag(struct bContext *C, SpaceNode *snode, ARegion *ar,
+ const int node_flag, const int smooth_viewtx);
void NODE_OT_view_all(struct wmOperatorType *ot);
void NODE_OT_view_selected(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_node/node_select.c b/source/blender/editors/space_node/node_select.c
index 6ce31783bff..958a3433337 100644
--- a/source/blender/editors/space_node/node_select.c
+++ b/source/blender/editors/space_node/node_select.c
@@ -831,7 +831,8 @@ static int node_select_same_type_step_exec(bContext *C, wmOperator *op)
if (active->totr.xmax < ar->v2d.cur.xmin || active->totr.xmin > ar->v2d.cur.xmax ||
active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax)
{
- space_node_view_flag(C, snode, CTX_wm_region(C), NODE_SELECT);
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+ space_node_view_flag(C, snode, ar, NODE_SELECT, smooth_viewtx);
}
}
@@ -895,7 +896,7 @@ static void node_find_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2
if (active->totr.xmax < ar->v2d.cur.xmin || active->totr.xmin > ar->v2d.cur.xmax ||
active->totr.ymax < ar->v2d.cur.ymin || active->totr.ymin > ar->v2d.cur.ymax)
{
- space_node_view_flag(C, snode, ar, NODE_SELECT);
+ space_node_view_flag(C, snode, ar, NODE_SELECT, U.smooth_viewtx);
}
}
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index e47a1315663..e4a9c4fa5db 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -66,7 +66,8 @@
/* **************** View All Operator ************** */
-int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, const int node_flag)
+int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar,
+ const int node_flag, const int smooth_viewtx)
{
bNode *node;
rctf cur_new;
@@ -125,22 +126,23 @@ int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, const int n
BLI_rctf_scale(&cur_new, 1.1f);
}
- UI_view2d_smooth_view(C, ar, &cur_new);
+ UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
}
return (tot != 0);
}
-static int node_view_all_exec(bContext *C, wmOperator *UNUSED(op))
+static int node_view_all_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
SpaceNode *snode = CTX_wm_space_node(C);
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* is this really needed? */
snode->xof = 0;
snode->yof = 0;
- if (space_node_view_flag(C, snode, ar, 0)) {
+ if (space_node_view_flag(C, snode, ar, 0, smooth_viewtx)) {
return OPERATOR_FINISHED;
}
else {
@@ -163,12 +165,13 @@ void NODE_OT_view_all(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
-static int node_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
+static int node_view_selected_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
SpaceNode *snode = CTX_wm_space_node(C);
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
- if (space_node_view_flag(C, snode, ar, NODE_SELECT)) {
+ if (space_node_view_flag(C, snode, ar, NODE_SELECT, smooth_viewtx)) {
return OPERATOR_FINISHED;
}
else {
diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c
index 955a9c78c56..d8b4824b528 100644
--- a/source/blender/editors/space_sequencer/sequencer_edit.c
+++ b/source/blender/editors/space_sequencer/sequencer_edit.c
@@ -2155,12 +2155,13 @@ void SEQUENCER_OT_meta_separate(wmOperatorType *ot)
}
/* view_all operator */
-static int sequencer_view_all_exec(bContext *C, wmOperator *UNUSED(op))
+static int sequencer_view_all_exec(bContext *C, wmOperator *op)
{
ARegion *ar = CTX_wm_region(C);
View2D *v2d = UI_view2d_fromcontext(C);
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
- UI_view2d_smooth_view(C, ar, &v2d->tot);
+ UI_view2d_smooth_view(C, ar, &v2d->tot, smooth_viewtx);
return OPERATOR_FINISHED;
}
@@ -2322,7 +2323,7 @@ void SEQUENCER_OT_view_toggle(wmOperatorType *ot)
/* view_selected operator */
-static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
+static int sequencer_view_selected_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
View2D *v2d = UI_view2d_fromcontext(C);
@@ -2355,6 +2356,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
}
if (ymax != 0) {
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
xmax += xmargin;
xmin -= xmargin;
@@ -2377,7 +2379,7 @@ static int sequencer_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
cur_new.ymax = ymid + (orig_height / 2);
}
- UI_view2d_smooth_view(C, ar, &cur_new);
+ UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
return OPERATOR_FINISHED;
}
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 4765ff6364a..50e72c7520b 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -2311,7 +2311,7 @@ void VIEW3D_OT_dolly(wmOperatorType *ot)
static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar,
const float min[3], const float max[3],
- bool ok_dist)
+ bool ok_dist, const int smooth_viewtx)
{
RegionView3D *rv3d = ar->regiondata;
float afm[3];
@@ -2373,10 +2373,14 @@ static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar,
if (rv3d->persp == RV3D_CAMOB && !ED_view3d_camera_lock_check(v3d, rv3d)) {
rv3d->persp = RV3D_PERSP;
- view3d_smooth_view(C, v3d, ar, v3d->camera, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL);
+ ED_view3d_smooth_view(C, v3d, ar, v3d->camera, NULL,
+ new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL,
+ smooth_viewtx);
}
else {
- view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL);
+ ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
+ new_ofs, NULL, ok_dist ? &new_dist : NULL, NULL,
+ smooth_viewtx);
}
/* smooth view does viewlock RV3D_BOXVIEW copy */
@@ -2385,7 +2389,7 @@ static void view3d_from_minmax(bContext *C, View3D *v3d, ARegion *ar,
/* same as view3d_from_minmax but for all regions (except cameras) */
static void view3d_from_minmax_multi(bContext *C, View3D *v3d,
const float min[3], const float max[3],
- const bool ok_dist)
+ const bool ok_dist, const int smooth_viewtx)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar;
@@ -2395,7 +2399,7 @@ static void view3d_from_minmax_multi(bContext *C, View3D *v3d,
/* when using all regions, don't jump out of camera view,
* but _do_ allow locked cameras to be moved */
if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) {
- view3d_from_minmax(C, v3d, ar, min, max, ok_dist);
+ view3d_from_minmax(C, v3d, ar, min, max, ok_dist, smooth_viewtx);
}
}
}
@@ -2413,6 +2417,7 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in
/* any one of the regions may be locked */
(use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA));
const bool center = RNA_boolean_get(op->ptr, "center");
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
float min[3], max[3];
bool change = false;
@@ -2452,10 +2457,10 @@ static int view3d_all_exec(bContext *C, wmOperator *op) /* was view3d_home() in
}
if (use_all_regions) {
- view3d_from_minmax_multi(C, v3d, min, max, true);
+ view3d_from_minmax_multi(C, v3d, min, max, true, smooth_viewtx);
}
else {
- view3d_from_minmax(C, v3d, ar, min, max, true);
+ view3d_from_minmax(C, v3d, ar, min, max, true, smooth_viewtx);
}
return OPERATOR_FINISHED;
@@ -2497,6 +2502,7 @@ static int viewselected_exec(bContext *C, wmOperator *op)
const bool skip_camera = (ED_view3d_camera_lock_check(v3d, ar->regiondata) ||
/* any one of the regions may be locked */
(use_all_regions && v3d->flag2 & V3D_LOCK_CAMERA));
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
INIT_MINMAX(min, max);
@@ -2572,10 +2578,10 @@ static int viewselected_exec(bContext *C, wmOperator *op)
}
if (use_all_regions) {
- view3d_from_minmax_multi(C, v3d, min, max, ok_dist);
+ view3d_from_minmax_multi(C, v3d, min, max, ok_dist, smooth_viewtx);
}
else {
- view3d_from_minmax(C, v3d, ar, min, max, ok_dist);
+ view3d_from_minmax(C, v3d, ar, min, max, ok_dist, smooth_viewtx);
}
// XXX BIF_view3d_previewrender_signal(curarea, PR_DBASE|PR_DISPRECT);
@@ -2687,7 +2693,7 @@ void VIEW3D_OT_view_lock_to_active(wmOperatorType *ot)
ot->flag = 0;
}
-static int viewcenter_cursor_exec(bContext *C, wmOperator *UNUSED(op))
+static int viewcenter_cursor_exec(bContext *C, wmOperator *op)
{
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -2695,11 +2701,14 @@ static int viewcenter_cursor_exec(bContext *C, wmOperator *UNUSED(op))
if (rv3d) {
ARegion *ar = CTX_wm_region(C);
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* non camera center */
float new_ofs[3];
negate_v3_v3(new_ofs, give_cursor(scene, v3d));
- view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, NULL, NULL);
+ ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
+ new_ofs, NULL, NULL, NULL,
+ smooth_viewtx);
/* smooth view does viewlock RV3D_BOXVIEW copy */
}
@@ -2722,7 +2731,7 @@ void VIEW3D_OT_view_center_cursor(wmOperatorType *ot)
ot->flag = 0;
}
-static int viewcenter_pick_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *event)
+static int viewcenter_pick_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
View3D *v3d = CTX_wm_view3d(C);
RegionView3D *rv3d = CTX_wm_region_view3d(C);
@@ -2731,6 +2740,7 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
if (rv3d) {
float new_ofs[3];
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
view3d_operator_needs_opengl(C);
@@ -2743,7 +2753,9 @@ static int viewcenter_pick_invoke(bContext *C, wmOperator *UNUSED(op), const wmE
ED_view3d_win_to_3d_int(ar, new_ofs, event->mval, new_ofs);
}
negate_v3(new_ofs);
- view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, NULL, NULL);
+ ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
+ new_ofs, NULL, NULL, NULL,
+ smooth_viewtx);
}
return OPERATOR_FINISHED;
@@ -2992,6 +3004,7 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
RegionView3D *rv3d = CTX_wm_region_view3d(C);
Scene *scene = CTX_data_scene(C);
int gesture_mode;
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* Zooms in on a border drawn by the user */
rcti rect;
@@ -3123,7 +3136,9 @@ static int view3d_zoom_border_exec(bContext *C, wmOperator *op)
new_dist = dist_range_min;
}
- view3d_smooth_view(C, v3d, ar, NULL, NULL, new_ofs, NULL, &new_dist, NULL);
+ ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
+ new_ofs, NULL, &new_dist, NULL,
+ smooth_viewtx);
if (rv3d->viewlock & RV3D_BOXVIEW)
view3d_boxview_sync(CTX_wm_area(C), ar);
@@ -3228,7 +3243,8 @@ static EnumPropertyItem prop_view_items[] = {
static void axis_set_view(bContext *C, View3D *v3d, ARegion *ar,
float q1, float q2, float q3, float q4,
- short view, int perspo, bool align_active)
+ short view, int perspo, bool align_active,
+ const int smooth_viewtx)
{
RegionView3D *rv3d = ar->regiondata; /* no NULL check is needed, poll checks */
float new_quat[4];
@@ -3289,14 +3305,18 @@ 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;
- view3d_smooth_view(C, v3d, ar, v3d->camera, NULL, rv3d->ofs, new_quat, NULL, NULL);
+ ED_view3d_smooth_view(C, v3d, ar, v3d->camera, NULL,
+ rv3d->ofs, new_quat, NULL, NULL,
+ smooth_viewtx);
}
else {
if (U.uiflag & USER_AUTOPERSP) rv3d->persp = view ? RV3D_ORTHO : RV3D_PERSP;
else if (rv3d->persp == RV3D_CAMOB) rv3d->persp = perspo;
- view3d_smooth_view(C, v3d, ar, NULL, NULL, NULL, new_quat, NULL, NULL);
+ ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
+ NULL, new_quat, NULL, NULL,
+ smooth_viewtx);
}
}
@@ -3310,6 +3330,7 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
static int perspo = RV3D_PERSP;
int viewnum, nextperspo;
bool align_active;
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
/* no NULL check is needed, poll checks */
ED_view3d_context_user_region(C, &v3d, &ar);
@@ -3334,32 +3355,32 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
switch (viewnum) {
case RV3D_VIEW_BOTTOM:
axis_set_view(C, v3d, ar, 0.0, -1.0, 0.0, 0.0,
- viewnum, nextperspo, align_active);
+ viewnum, nextperspo, align_active, smooth_viewtx);
break;
case RV3D_VIEW_BACK:
axis_set_view(C, v3d, ar, 0.0, 0.0, -M_SQRT1_2, -M_SQRT1_2,
- viewnum, nextperspo, align_active);
+ viewnum, nextperspo, align_active, smooth_viewtx);
break;
case RV3D_VIEW_LEFT:
axis_set_view(C, v3d, ar, 0.5, -0.5, 0.5, 0.5,
- viewnum, nextperspo, align_active);
+ viewnum, nextperspo, align_active, smooth_viewtx);
break;
case RV3D_VIEW_TOP:
axis_set_view(C, v3d, ar, 1.0, 0.0, 0.0, 0.0,
- viewnum, nextperspo, align_active);
+ viewnum, nextperspo, align_active, smooth_viewtx);
break;
case RV3D_VIEW_FRONT:
axis_set_view(C, v3d, ar, M_SQRT1_2, -M_SQRT1_2, 0.0, 0.0,
- viewnum, nextperspo, align_active);
+ viewnum, nextperspo, align_active, smooth_viewtx);
break;
case RV3D_VIEW_RIGHT:
axis_set_view(C, v3d, ar, 0.5, -0.5, -0.5, -0.5,
- viewnum, nextperspo, align_active);
+ viewnum, nextperspo, align_active, smooth_viewtx);
break;
case RV3D_VIEW_CAMERA:
@@ -3415,7 +3436,9 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
/* finally do snazzy view zooming */
rv3d->persp = RV3D_CAMOB;
- view3d_smooth_view(C, v3d, ar, NULL, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);
+ ED_view3d_smooth_view(C, v3d, ar, NULL, v3d->camera,
+ rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens,
+ smooth_viewtx);
}
else {
@@ -3423,7 +3446,8 @@ static int viewnumpad_exec(bContext *C, wmOperator *op)
/* 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);
+ rv3d->lview, rv3d->lpersp, 0,
+ smooth_viewtx);
}
}
break;
@@ -3483,6 +3507,7 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
if (rv3d->viewlock == 0) {
if ((rv3d->persp != RV3D_CAMOB) || ED_view3d_camera_lock_check(v3d, rv3d)) {
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
float angle = DEG2RADF((float)U.pad_rot_angle);
float quat_mul[4];
float quat_new[4];
@@ -3510,7 +3535,9 @@ static int vieworbit_exec(bContext *C, wmOperator *op)
mul_qt_qtqt(quat_new, rv3d->viewquat, quat_mul);
rv3d->view = RV3D_VIEW_USER;
- view3d_smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL, NULL, quat_new, NULL, NULL);
+ ED_view3d_smooth_view(C, CTX_wm_view3d(C), ar, NULL, NULL,
+ NULL, quat_new, NULL, NULL,
+ smooth_viewtx);
return OPERATOR_FINISHED;
}
@@ -3639,11 +3666,15 @@ static int viewroll_exec(bContext *C, wmOperator *op)
float mousevec[3];
float quat_new[4];
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+
normalize_v3_v3(mousevec, rv3d->viewinv[2]);
negate_v3(mousevec);
view_roll_angle(ar, quat_new, rv3d->viewquat, mousevec, angle);
- view3d_smooth_view(C, v3d, ar, NULL, NULL, NULL, quat_new, NULL, NULL);
+ ED_view3d_smooth_view(C, v3d, ar, NULL, NULL,
+ NULL, quat_new, NULL, NULL,
+ smooth_viewtx);
viewops_data_free(C, op);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 54999b1ae95..a496bbba72f 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -187,8 +187,9 @@ void VIEW3D_OT_game_start(struct wmOperatorType *ot);
bool ED_view3d_boundbox_clip(RegionView3D *rv3d, float obmat[4][4], const struct BoundBox *bb);
-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 ED_view3d_smooth_view(struct bContext *C, struct View3D *v3d, struct ARegion *ar, struct Object *, struct Object *,
+ float *ofs, float *quat, float *dist, float *lens,
+ const int smooth_viewtx);
void setwinmatrixview3d(ARegion *ar, View3D *v3d, rctf *rect);
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 0246e2b75a9..7e39c0b6be0 100644
--- a/source/blender/editors/space_view3d/view3d_view.c
+++ b/source/blender/editors/space_view3d/view3d_view.c
@@ -153,8 +153,9 @@ static void view3d_smooth_view_state_restore(const struct SmoothView3DState *sms
/* will start timer if appropriate */
/* the arguments are the desired situation */
-void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera,
- float *ofs, float *quat, float *dist, float *lens)
+void ED_view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera, Object *camera,
+ float *ofs, float *quat, float *dist, float *lens,
+ const int smooth_viewtx)
{
wmWindowManager *wm = CTX_wm_manager(C);
wmWindow *win = CTX_wm_window(C);
@@ -203,7 +204,7 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera
}
/* skip smooth viewing for render engine draw */
- if (U.smooth_viewtx && v3d->drawtype != OB_RENDER) {
+ if (smooth_viewtx && v3d->drawtype != OB_RENDER) {
bool changed = false; /* zero means no difference */
if (oldcamera != camera)
@@ -232,7 +233,7 @@ void view3d_smooth_view(bContext *C, View3D *v3d, ARegion *ar, Object *oldcamera
rv3d->view = RV3D_VIEW_USER;
}
- sms.time_allowed = (double)U.smooth_viewtx / 1000.0;
+ sms.time_allowed = (double)smooth_viewtx / 1000.0;
/* if this is view rotation only
* we can decrease the time allowed by
@@ -506,7 +507,7 @@ void VIEW3D_OT_camera_to_view_selected(wmOperatorType *ot)
}
-static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op))
+static int view3d_setobjectascamera_exec(bContext *C, wmOperator *op)
{
View3D *v3d;
ARegion *ar;
@@ -515,6 +516,8 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op))
Scene *scene = CTX_data_scene(C);
Object *ob = CTX_data_active_object(C);
+ const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
+
/* no NULL check is needed, poll checks */
ED_view3d_context_user_region(C, &v3d, &ar);
rv3d = ar->regiondata;
@@ -526,8 +529,11 @@ static int view3d_setobjectascamera_exec(bContext *C, wmOperator *UNUSED(op))
if (v3d->scenelock)
scene->camera = ob;
- if (camera_old != ob) /* unlikely but looks like a glitch when set to the same */
- view3d_smooth_view(C, v3d, ar, camera_old, v3d->camera, rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens);
+ if (camera_old != ob) { /* unlikely but looks like a glitch when set to the same */
+ ED_view3d_smooth_view(C, v3d, ar, camera_old, v3d->camera,
+ rv3d->ofs, rv3d->viewquat, &rv3d->dist, &v3d->lens,
+ smooth_viewtx);
+ }
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS | NC_OBJECT | ND_DRAW, CTX_data_scene(C));
}
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 27aef3b8ec6..07a679be571 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -339,6 +339,12 @@ typedef struct wmOperator {
#define OPERATOR_RETVAL_CHECK(ret) (void)ret, BLI_assert(ret != 0 && (ret & OPERATOR_FLAGS_ALL) == ret)
/* wmOperator flag */
-#define OP_GRAB_POINTER 1
+enum {
+ OP_GRAB_POINTER = (1 << 0),
+
+ /* low level flag so exec() operators can tell if they were invoked, use with care.
+ * typically this shouldn't make any difference, but it rare cases its needed (see smooth-view) */
+ OP_IS_INVOKE = (1 << 1),
+};
#endif /* __DNA_WINDOWMANAGER_TYPES_H__ */
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index c55898d178c..ce4513425d4 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -187,6 +187,7 @@ void WM_event_timer_sleep(struct wmWindowManager *wm, struct wmWindow *win, str
/* operator api, default callbacks */
/* invoke callback, uses enum property named "type" */
int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
+int WM_operator_smooth_viewtx_get(const struct wmOperator *op);
int WM_menu_invoke (struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
int WM_enum_search_invoke(struct bContext *C, struct wmOperator *op, const struct wmEvent *event);
/* invoke callback, confirm menu + exec */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 0299ae4c656..46cce278d0e 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -975,6 +975,8 @@ static int wm_operator_invoke(bContext *C, wmOperatorType *ot, wmEvent *event,
wmOperator *op = wm_operator_create(wm, ot, properties, reports); /* if reports == NULL, they'll be initialized */
const short is_nested_call = (wm->op_undo_depth != 0);
+ op->flag |= OP_IS_INVOKE;
+
/* initialize setting from previous run */
if (!is_nested_call) { /* not called by py script */
WM_operator_last_properties_init(op);
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c
index a7d03afb7d3..de4b864ac1e 100644
--- a/source/blender/windowmanager/intern/wm_operators.c
+++ b/source/blender/windowmanager/intern/wm_operators.c
@@ -921,6 +921,11 @@ int WM_operator_view3d_distance_invoke(struct bContext *C, struct wmOperator *op
return op->type->exec(C, op);
}
+int WM_operator_smooth_viewtx_get(const wmOperator *op)
+{
+ return (op->flag & OP_IS_INVOKE) ? U.smooth_viewtx : 0;
+}
+
/* invoke callback, uses enum property named "type" */
int WM_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
{