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:
authorGermano Cavalcante <germano.costa@ig.com.br>2022-02-03 20:00:41 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2022-02-04 17:21:20 +0300
commit3d973d01fa62127f3ee10a11893fd9ce07772184 (patch)
treeb519c666ddbf5870483668941c4e78a6d7b22934 /source/blender/editors/space_view3d/view3d_navigate.c
parent7099d5b66129deba2d28102ea339b1d5339233fe (diff)
View3D: move some of the early returns from operators to the poll function
Some navigation operators check flags like `RV3D_LOCK_ROTATION` in the invoke function to see if the operation can be performed. As the comment indicates, these checks should be in the poll function. This avoids redundant initialization. Note that this brings functional changes as now operators with context `EXEC_DEFAULT` will also be affected by the flag. (There doesn't seem to be a problem with the current code). Differential Revision: https://developer.blender.org/D14005
Diffstat (limited to 'source/blender/editors/space_view3d/view3d_navigate.c')
-rw-r--r--source/blender/editors/space_view3d/view3d_navigate.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/source/blender/editors/space_view3d/view3d_navigate.c b/source/blender/editors/space_view3d/view3d_navigate.c
index 9b7304a6741..692a3005607 100644
--- a/source/blender/editors/space_view3d/view3d_navigate.c
+++ b/source/blender/editors/space_view3d/view3d_navigate.c
@@ -59,22 +59,29 @@
/** \name Navigation Polls
* \{ */
-static bool view3d_pan_poll(bContext *C)
+static bool view3d_navigation_poll_impl(bContext *C, const char viewlock)
{
- if (ED_operator_region_view3d_active(C)) {
- const RegionView3D *rv3d = CTX_wm_region_view3d(C);
- return !(RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_LOCATION);
+ if (!ED_operator_region_view3d_active(C)) {
+ return false;
}
- return false;
+
+ const RegionView3D *rv3d = CTX_wm_region_view3d(C);
+ return !(RV3D_LOCK_FLAGS(rv3d) & viewlock);
+}
+
+bool view3d_location_poll(bContext *C)
+{
+ return view3d_navigation_poll_impl(C, RV3D_LOCK_LOCATION);
+}
+
+bool view3d_rotation_poll(bContext *C)
+{
+ return view3d_navigation_poll_impl(C, RV3D_LOCK_ROTATION);
}
bool view3d_zoom_or_dolly_poll(bContext *C)
{
- if (ED_operator_region_view3d_active(C)) {
- const RegionView3D *rv3d = CTX_wm_region_view3d(C);
- return !(RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ZOOM_AND_DOLLY);
- }
- return false;
+ return view3d_navigation_poll_impl(C, RV3D_LOCK_ZOOM_AND_DOLLY);
}
/** \} */
@@ -1053,7 +1060,7 @@ void VIEW3D_OT_view_center_cursor(wmOperatorType *ot)
/* api callbacks */
ot->exec = viewcenter_cursor_exec;
- ot->poll = view3d_pan_poll;
+ ot->poll = view3d_location_poll;
/* flags */
ot->flag = 0;
@@ -1105,7 +1112,7 @@ void VIEW3D_OT_view_center_pick(wmOperatorType *ot)
/* api callbacks */
ot->invoke = viewcenter_pick_invoke;
- ot->poll = view3d_pan_poll;
+ ot->poll = view3d_location_poll;
/* flags */
ot->flag = 0;
@@ -1582,7 +1589,7 @@ void VIEW3D_OT_view_pan(wmOperatorType *ot)
/* api callbacks */
ot->invoke = viewpan_invoke;
- ot->poll = view3d_pan_poll;
+ ot->poll = view3d_location_poll;
/* flags */
ot->flag = 0;