Fix #110475: 'Use Mouse Position' option for navigation not working

Caused by 384c2e1f36

The 'Use Mouse Position' option was always being false which caused
navigation operators to behave as if the cursor was in the middle of
the region.
This commit is contained in:
Germano Cavalcante
2023-07-25 21:35:43 -03:00
parent aebc743bf1
commit fce95f330d
7 changed files with 11 additions and 17 deletions

View File

@@ -220,8 +220,7 @@ void ViewOpsData::init_navigation(bContext *C,
eViewOpsFlag viewops_flag = nav_type->flag & viewops_flag_from_prefs();
if (!use_cursor_init) {
viewops_flag &= ~(VIEWOPS_FLAG_USE_MOUSE_INIT | VIEWOPS_FLAG_DEPTH_NAVIGATE |
VIEWOPS_FLAG_ZOOM_TO_MOUSE);
viewops_flag &= ~(VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_ZOOM_TO_MOUSE);
}
bool calc_rv3d_dist = true;
@@ -318,7 +317,7 @@ void ViewOpsData::init_navigation(bContext *C,
copy_v2_v2_int(this->init.event_xy, event->xy);
copy_v2_v2_int(this->prev.event_xy, event->xy);
if (viewops_flag & VIEWOPS_FLAG_USE_MOUSE_INIT) {
if (use_cursor_init) {
zero_v2_int(this->init.event_xy_offset);
}
else {

View File

@@ -71,12 +71,10 @@ enum eViewOpsFlag {
* Some operations don't require this (view zoom/pan or NDOF where subtle rotation is common
* so we don't want it to trigger auto-perspective). */
VIEWOPS_FLAG_PERSP_ENSURE = (1 << 2),
/** When set, ignore any options that depend on initial cursor location. */
VIEWOPS_FLAG_USE_MOUSE_INIT = (1 << 3),
VIEWOPS_FLAG_ZOOM_TO_MOUSE = (1 << 4),
VIEWOPS_FLAG_ZOOM_TO_MOUSE = (1 << 3),
VIEWOPS_FLAG_INIT_ZFAC = (1 << 5),
VIEWOPS_FLAG_INIT_ZFAC = (1 << 4),
};
ENUM_OPERATORS(eViewOpsFlag, VIEWOPS_FLAG_INIT_ZFAC);
@@ -126,8 +124,8 @@ struct ViewOpsData {
/** #wmEvent.xy. */
int event_xy[2];
/** Offset to use when #VIEWOPS_FLAG_USE_MOUSE_INIT is not set.
* so we can simulate pressing in the middle of the screen. */
/* Offset used when "use_cursor_init" is false to simulate pressing in the middle of the
* region. */
int event_xy_offset[2];
/** #wmEvent.type that triggered the operator. */
int event_type;

View File

@@ -331,8 +331,7 @@ void VIEW3D_OT_dolly(wmOperatorType *ot)
/** \} */
ViewOpsType ViewOpsType_dolly = {
/*flag*/ (VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_ZOOM_TO_MOUSE |
VIEWOPS_FLAG_USE_MOUSE_INIT),
/*flag*/ (VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_ZOOM_TO_MOUSE),
/*idname*/ "VIEW3D_OT_dolly",
/*init_fn*/ nullptr,
/*apply_fn*/ nullptr,

View File

@@ -134,7 +134,7 @@ void VIEW3D_OT_move(wmOperatorType *ot)
/** \} */
const ViewOpsType ViewOpsType_move = {
/*flag*/ (VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_USE_MOUSE_INIT | VIEWOPS_FLAG_INIT_ZFAC),
/*flag*/ (VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_INIT_ZFAC),
/*idname*/ "VIEW3D_OT_move",
/*poll_fn*/ view3d_location_poll,
/*init_fn*/ viewmove_invoke_impl,

View File

@@ -119,7 +119,7 @@ void VIEW3D_OT_view_pan(wmOperatorType *ot)
/** \} */
const ViewOpsType ViewOpsType_pan = {
/*flag*/ (VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_USE_MOUSE_INIT | VIEWOPS_FLAG_INIT_ZFAC),
/*flag*/ (VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_INIT_ZFAC),
/*idname*/ "VIEW3D_OT_view_pan",
/*poll_fn*/ view3d_location_poll,
/*init_fn*/ viewpan_invoke_impl,

View File

@@ -390,8 +390,7 @@ void VIEW3D_OT_rotate(wmOperatorType *ot)
/** \} */
const ViewOpsType ViewOpsType_rotate = {
/*flag*/ (VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_USE_MOUSE_INIT |
VIEWOPS_FLAG_PERSP_ENSURE | VIEWOPS_FLAG_ORBIT_SELECT),
/*flag*/ (VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_PERSP_ENSURE | VIEWOPS_FLAG_ORBIT_SELECT),
/*idname*/ "VIEW3D_OT_rotate",
/*poll_fn*/ view3d_rotation_poll,
/*init_fn*/ viewrotate_invoke_impl,

View File

@@ -553,8 +553,7 @@ void VIEW3D_OT_zoom(wmOperatorType *ot)
/** \} */
const ViewOpsType ViewOpsType_zoom = {
/*flag*/ (VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_USE_MOUSE_INIT |
VIEWOPS_FLAG_ZOOM_TO_MOUSE),
/*flag*/ (VIEWOPS_FLAG_DEPTH_NAVIGATE | VIEWOPS_FLAG_ZOOM_TO_MOUSE),
/*idname*/ "VIEW3D_OT_zoom",
/*poll_fn*/ view3d_zoom_or_dolly_poll,
/*init_fn*/ viewzoom_invoke_impl,