Fix NDOF orbit turntable direction when upside-down

In NDOF's turntable mode, direction of rotating around Z axis should be
inverted when the view is "upside-down".

Co-authored-by: Kamil Galik <kgalik@3dconnexion.com>

Ref: !129970
This commit is contained in:
Campbell Barton
2025-01-28 16:09:47 +11:00
parent 001c3b0d4b
commit a2b5cb5863

View File

@@ -175,21 +175,29 @@ static void view3d_ndof_orbit(const wmNDOFMotionData *ndof,
/* Turntable view code adapted for 3D mouse use. */
float angle, quat[4];
float xvec[3] = {1, 0, 0};
float yvec[3] = {0, 1, 0};
/* only use XY, ignore Z */
WM_event_ndof_rotate_get(ndof, rot);
/* Determine the direction of the x vector (for rotating up and down) */
/* Determine the direction of the X vector (for rotating up and down). */
mul_qt_v3(view_inv, xvec);
/* Determine the direction of the Y vector (to check if the view is upside down). */
mul_qt_v3(view_inv, yvec);
/* Perform the up/down rotation */
angle = ndof->dt * rot[0];
axis_angle_to_quat(quat, xvec, angle);
mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, quat);
/* Perform the orbital rotation */
/* Perform the Z rotation. */
angle = ndof->dt * rot[1];
/* Flip the turntable angle when the view is upside down. */
if (yvec[2] < 0.0f) {
angle *= -1.0f;
}
/* Update the onscreen axis-angle indicator. */
rv3d->rot_angle = angle;
rv3d->rot_axis[0] = 0;