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>2012-04-13 17:55:55 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-04-13 17:55:55 +0400
commit958e71e3753528a20df933f0ddad01d1613e154a (patch)
treec71d8c2cc87317c3a5bf94fa273bd1267f52efb4
parent0d9fa935812d2e4e9c6ef55311993697abde2f7f (diff)
code cleanup: use axis_angle_to_quat() to simplify turntable view rotate code.
-rw-r--r--source/blender/editors/space_view3d/view3d_edit.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c
index 4fdae8f8b24..42a44b25afa 100644
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@ -671,15 +671,15 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y)
}
else {
/* New turntable view code by John Aughey */
- float phi, q1[4];
+ float q1[4];
float m[3][3];
float m_inv[3][3];
- float xvec[3] = {1.0f, 0.0f, 0.0f};
- /* Sensitivity will control how fast the viewport rotates. 0.0035 was
+ const float zvec_global[3] = {0.0f, 0.0f, 1.0f};
+ /* Sensitivity will control how fast the viewport rotates. 0.007 was
* obtained experimentally by looking at viewport rotation sensitivities
* on other modeling programs. */
/* Perhaps this should be a configurable user parameter. */
- const float sensitivity = 0.0035f;
+ const float sensitivity = 0.007f;
/* Get the 3x3 matrix and its inverse from the quaternion */
quat_to_mat3(m, vod->viewquat);
@@ -687,12 +687,9 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y)
/* Determine the direction of the x vector (for rotating up and down) */
/* This can likely be computed directly from the quaternion. */
- mul_m3_v3(m_inv, xvec);
/* Perform the up/down rotation */
- phi = sensitivity * -(y - vod->oldy);
- q1[0] = cos(phi);
- mul_v3_v3fl(q1 + 1, xvec, sin(phi));
+ axis_angle_to_quat(q1, m_inv[0], sensitivity * -(y - vod->oldy));
mul_qt_qtqt(vod->viewquat, vod->viewquat, q1);
if (vod->use_dyn_ofs) {
@@ -703,10 +700,7 @@ static void viewrotate_apply(ViewOpsData *vod, int x, int y)
}
/* Perform the orbital rotation */
- phi = sensitivity * vod->reverse * (x - vod->oldx);
- q1[0] = cos(phi);
- q1[1] = q1[2] = 0.0;
- q1[3] = sin(phi);
+ axis_angle_to_quat(q1, zvec_global, sensitivity * vod->reverse * (x - vod->oldx));
mul_qt_qtqt(vod->viewquat, vod->viewquat, q1);
if (vod->use_dyn_ofs) {