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:
authorCampbell Barton <ideasman42@gmail.com>2014-02-18 16:51:11 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-02-18 16:55:58 +0400
commitdcdb4eaf9cce1f3ff84bbe221ebafd20c2371541 (patch)
tree794f2700130434d78435166532f0b813e0a0b3f7 /source/blender/editors/space_view3d
parent13553876ba3e18f49c2199d9c21f53ff2d8b2e41 (diff)
NDOF: Fix for fly/walk mode ignoring axis invert options
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c68
-rw-r--r--source/blender/editors/space_view3d/view3d_fly.c10
-rw-r--r--source/blender/editors/space_view3d/view3d_intern.h2
-rw-r--r--source/blender/editors/space_view3d/view3d_walk.c10
4 files changed, 34 insertions, 56 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 0c4e2bd541a..bcf09621748 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -1151,20 +1151,6 @@ void VIEW3D_OT_rotate(wmOperatorType *ot)
#define NDOF_HAS_TRANSLATE ((!view3d_operator_offset_lock_check(C, op)) && !is_zero_v3(ndof->tvec))
#define NDOF_HAS_ROTATE (((rv3d->viewlock & RV3D_LOCKED) == 0) && !is_zero_v3(ndof->rvec))
-float ndof_to_axis_angle(const struct wmNDOFMotionData *ndof, float axis[3])
-{
- return ndof->dt * normalize_v3_v3(axis, ndof->rvec);
-}
-
-void ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4])
-{
- float axis[3];
- float angle;
-
- angle = ndof_to_axis_angle(ndof, axis);
- axis_angle_to_quat(q, axis, angle);
-}
-
/**
* Zoom and pan in the same function since sometimes zoom is interpreted as dolly (pan forward).
*
@@ -1182,9 +1168,7 @@ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof, ScrArea *s
return;
}
- pan_vec[0] = ndof->tvec[0] * ((U.ndof_flag & NDOF_PANX_INVERT_AXIS) ? -1.0f : 1.0f);
- pan_vec[1] = ndof->tvec[1] * ((U.ndof_flag & NDOF_PANY_INVERT_AXIS) ? -1.0f : 1.0f);
- pan_vec[2] = ndof->tvec[2] * ((U.ndof_flag & NDOF_PANZ_INVERT_AXIS) ? -1.0f : 1.0f);
+ WM_event_ndof_pan_get(ndof, pan_vec, false);
if (has_zoom) {
/* zoom with Z */
@@ -1195,14 +1179,11 @@ static void view3d_ndof_pan_zoom(const struct wmNDOFMotionData *ndof, ScrArea *s
* proportional to arclength = radius * angle
*/
- /* tune these until everything feels right */
- const float zoom_sensitivity = 1.f;
-
pan_vec[2] = 0.0f;
/* "zoom in" or "translate"? depends on zoom mode in user settings? */
- if (ndof->tz) {
- float zoom_distance = zoom_sensitivity * rv3d->dist * dt * ndof->tz;
+ if (ndof->tvec[2]) {
+ float zoom_distance = rv3d->dist * dt * ndof->tvec[2];
if (U.ndof_flag & NDOF_ZOOM_INVERT)
zoom_distance = -zoom_distance;
@@ -1242,7 +1223,6 @@ static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof, RegionView3D
/* optional, can be NULL*/
ViewOpsData *vod)
{
- const float rot_sensitivity = 1.0f;
float view_inv[4];
BLI_assert((rv3d->viewlock & RV3D_LOCKED) == 0);
@@ -1254,26 +1234,26 @@ static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof, RegionView3D
invert_qt_qt(view_inv, rv3d->viewquat);
if (U.ndof_flag & NDOF_TURNTABLE) {
+ float rot[3];
/* turntable view code by John Aughey, adapted for 3D mouse by [mce] */
- float angle, rot[4];
+ float angle, quat[4];
float xvec[3] = {1, 0, 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) */
mul_qt_v3(view_inv, xvec);
/* Perform the up/down rotation */
- angle = rot_sensitivity * dt * ndof->rx;
- if (U.ndof_flag & NDOF_TILT_INVERT_AXIS)
- angle = -angle;
- rot[0] = cosf(angle);
- mul_v3_v3fl(rot + 1, xvec, sin(angle));
- mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
+ angle = dt * rot[0];
+ quat[0] = cosf(angle);
+ mul_v3_v3fl(quat + 1, xvec, sin(angle));
+ mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, quat);
/* Perform the orbital rotation */
- angle = rot_sensitivity * dt * ndof->ry;
- if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS)
- angle = -angle;
+ angle = dt * rot[1];
/* update the onscreen doo-dad */
rv3d->rot_angle = angle;
@@ -1281,21 +1261,17 @@ static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof, RegionView3D
rv3d->rot_axis[1] = 0;
rv3d->rot_axis[2] = 1;
- rot[0] = cosf(angle);
- rot[1] = rot[2] = 0.0;
- rot[3] = sinf(angle);
- mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
+ quat[0] = cosf(angle);
+ quat[1] = 0.0f;
+ quat[2] = 0.0f;
+ quat[3] = sinf(angle);
+ mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, quat);
}
else {
- float rot[4];
+ float quat[4];
float axis[3];
- float angle = rot_sensitivity * ndof_to_axis_angle(ndof, axis);
-
- if (U.ndof_flag & NDOF_ROLL_INVERT_AXIS) axis[2] = -axis[2];
- if (U.ndof_flag & NDOF_TILT_INVERT_AXIS) axis[0] = -axis[0];
- if (U.ndof_flag & NDOF_ROTATE_INVERT_AXIS) axis[1] = -axis[1];
-
+ float angle = WM_event_ndof_to_axis_angle(ndof, axis);
/* transform rotation axis from view to world coordinates */
mul_qt_v3(view_inv, axis);
@@ -1304,10 +1280,10 @@ static void view3d_ndof_orbit(const struct wmNDOFMotionData *ndof, RegionView3D
rv3d->rot_angle = angle;
copy_v3_v3(rv3d->rot_axis, axis);
- axis_angle_to_quat(rot, axis, angle);
+ axis_angle_to_quat(quat, axis, angle);
/* apply rotation */
- mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
+ mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, quat);
}
/* rotate around custom center */
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index 813404a5bf9..4933e004855 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -959,19 +959,21 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly)
if (do_translate) {
float speed = 10.0f; /* blender units per second */
- float trans[3];
+ float trans[3], trans_orig_y;
/* ^^ this is ok for default cube scene, but should scale with.. something */
if (fly->use_precision)
speed *= 0.2f;
- mul_v3_v3fl(trans, ndof->tvec, speed * dt);
+ WM_event_ndof_pan_get(ndof, trans, false);
+ mul_v3_fl(trans, speed * dt);
+ trans_orig_y = trans[1];
/* transform motion from view to world coordinates */
mul_qt_v3(view_inv, trans);
if (flag & NDOF_FLY_HELICOPTER) {
/* replace world z component with device y (yes it makes sense) */
- trans[2] = speed * dt * ndof->tvec[1];
+ trans[2] = trans_orig_y;
}
if (rv3d->persp == RV3D_CAMOB) {
@@ -997,7 +999,7 @@ static int flyApply_ndof(bContext *C, FlyInfo *fly)
float rotation[4];
float axis[3];
- float angle = turn_sensitivity * ndof_to_axis_angle(ndof, axis);
+ float angle = turn_sensitivity * WM_event_ndof_to_axis_angle(ndof, axis);
if (fabsf(angle) > 0.0001f) {
do_rotate = true;
diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h
index 0317775f62b..86b1891074d 100644
--- a/source/blender/editors/space_view3d/view3d_intern.h
+++ b/source/blender/editors/space_view3d/view3d_intern.h
@@ -106,8 +106,6 @@ void VIEW3D_OT_clear_render_border(struct wmOperatorType *ot);
void VIEW3D_OT_zoom_border(struct wmOperatorType *ot);
void view3d_boxview_copy(ScrArea *sa, ARegion *ar);
-void ndof_to_quat(const struct wmNDOFMotionData *ndof, float q[4]);
-float ndof_to_axis_angle(const struct wmNDOFMotionData *ndof, float axis[3]);
/* view3d_fly.c */
void view3d_keymap(struct wmKeyConfig *keyconf);
diff --git a/source/blender/editors/space_view3d/view3d_walk.c b/source/blender/editors/space_view3d/view3d_walk.c
index 426a9a69f07..b49e26241b8 100644
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@ -1239,19 +1239,21 @@ static int walkApply_ndof(bContext *C, WalkInfo *walk)
if (do_translate) {
float speed = 10.0f; /* blender units per second */
- float trans[3];
+ float trans[3], trans_orig_y;
/* ^^ this is ok for default cube scene, but should scale with.. something */
if (walk->is_slow)
speed *= 0.2f;
- mul_v3_v3fl(trans, ndof->tvec, speed * dt);
+ WM_event_ndof_pan_get(ndof, trans, false);
+ mul_v3_fl(trans, speed * dt);
+ trans_orig_y = trans[1];
/* transform motion from view to world coordinates */
mul_qt_v3(view_inv, trans);
if (flag & NDOF_FLY_HELICOPTER) {
/* replace world z component with device y (yes it makes sense) */
- trans[2] = speed * dt * ndof->tvec[1];
+ trans[2] = trans_orig_y;
}
if (rv3d->persp == RV3D_CAMOB) {
@@ -1277,7 +1279,7 @@ static int walkApply_ndof(bContext *C, WalkInfo *walk)
float rotation[4];
float axis[3];
- float angle = turn_sensitivity * ndof_to_axis_angle(ndof, axis);
+ float angle = turn_sensitivity * WM_event_ndof_to_axis_angle(ndof, axis);
if (fabsf(angle) > 0.0001f) {
do_rotate = true;