[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45604] trunk/blender/source/blender/ editors/space_view3d/view3d_edit.c: code cleanup: use axis_angle_to_quat() to simplify turntable view rotate code.
Campbell Barton
ideasman42 at gmail.com
Fri Apr 13 15:55:56 CEST 2012
Revision: 45604
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45604
Author: campbellbarton
Date: 2012-04-13 13:55:55 +0000 (Fri, 13 Apr 2012)
Log Message:
-----------
code cleanup: use axis_angle_to_quat() to simplify turntable view rotate code.
Modified Paths:
--------------
trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
Modified: trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_edit.c 2012-04-13 13:31:41 UTC (rev 45603)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c 2012-04-13 13:55:55 UTC (rev 45604)
@@ -671,15 +671,15 @@
}
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 @@
/* 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 @@
}
/* 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) {
More information about the Bf-blender-cvs
mailing list