Fix #144751: NDOF, pan/zoom reversed in orthographic views, in fly mode

Use viewport navigation options in the orthographic view as well.
While the intention was to have the 3D-navigation preference only
impacting 3D views, inconsistencies between 2D/3D views tend to be
confusing for users, so use the same behavior in both.

Also expose the preference in the "3D Mouse" popup for 2D views as
this preference is used there as well.
This commit is contained in:
Campbell Barton
2025-08-28 02:35:03 +00:00
parent ab078f5122
commit ee000da266
4 changed files with 17 additions and 32 deletions

View File

@@ -2093,11 +2093,11 @@ class USERPREF_PT_ndof_settings(Panel):
@staticmethod
def draw_settings(layout, props, show_3dview_settings=True):
layout.separator()
# Include this setting as it impacts 2D views as well (inverting translation).
col = layout.column()
col.row().prop(props, "ndof_navigation_mode", text="Navigation Mode")
if show_3dview_settings:
col = layout.column()
col.row().prop(props, "ndof_navigation_mode", text="Navigation Mode")
col.prop(props, "ndof_lock_horizon", text="Lock Horizon")
layout.separator()

View File

@@ -72,22 +72,6 @@ static bool ndof_has_rotate(const wmNDOFMotionData &ndof, const RegionView3D *rv
return !is_zero_v3(ndof.rvec) && ((RV3D_LOCK_FLAGS(rv3d) & RV3D_LOCK_ROTATION) == 0);
}
/**
* Return true when `rv3d` should use the navigation preference.
*
* Views which enforce 2D behavior, typically where rotation is disabled should return false.
* (camera views and axis-aligned quad views for example).
*/
static bool view3d_ndof_use_navigation_mode(const RegionView3D *rv3d)
{
/* Note that there is no need to check orthographic-axis-aligned views
* as these are rotation locked too. */
if (rv3d->viewlock & RV3D_LOCK_ROTATION) {
return false;
}
return true;
}
/**
* \param depth_pt: A point to calculate the depth (in perspective mode)
*/
@@ -154,26 +138,22 @@ static void view3d_ndof_pan_zoom(const wmNDOFMotionData &ndof,
return;
}
blender::float3 pan_vec_no_navigation = -WM_event_ndof_translation_get(ndof);
blender::float3 pan_vec = view3d_ndof_use_navigation_mode(rv3d) ?
WM_event_ndof_translation_get_for_navigation(ndof) :
pan_vec_no_navigation;
blender::float3 pan_vec = WM_event_ndof_translation_get_for_navigation(ndof);
if (has_zoom) {
/* zoom with Z */
/* "zoom in" or "translate"? depends on zoom mode in user settings? */
if (pan_vec[2]) {
float zoom_distance = rv3d->dist * ndof.time_delta * pan_vec[2];
rv3d->dist += zoom_distance;
}
/* Zoom!
* velocity should be proportional to the linear velocity attained by rotational motion
* of same strength [got that?] proportional to `arclength = radius * angle`.
*/
pan_vec[2] = 0.0f;
/* "zoom in" or "translate"? depends on zoom mode in user settings? */
if (pan_vec_no_navigation[2]) {
float zoom_distance = rv3d->dist * ndof.time_delta * pan_vec_no_navigation[2];
rv3d->dist += zoom_distance;
}
}
else {
/* dolly with Z */

View File

@@ -1048,6 +1048,9 @@ typedef enum eNdof_Navigation_Mode {
/**
* 3D mouse cap controls the movement of the view window
* and allows for flying through the scene.
*
* \note this also inverts navigation for for 2D views,
* since it's confusing for users when 2D/3D navigation is inverted, see: #144751.
*/
NDOF_NAVIGATION_MODE_FLY = 1,
/* TODO: implement "Target Camera Mode" and "Drone Mode" */

View File

@@ -6335,8 +6335,10 @@ static void rna_def_userdef_input(BlenderRNA *brna)
"FLY",
0,
"Fly",
"Enables using the 3D Mouse as if it is a camera. Push into the scene and the camera "
"moves forward into the scene. You are entering the scene as if flying around in it"},
"Enables using the 3D Mouse as if it is a camera. "
"Push into the scene and the camera moves forward into the scene. "
"You are entering the scene as if flying around in it. "
"This also inverts pan & zoom for 2D views"},
{0, nullptr, 0, nullptr, nullptr},
};