[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45606] trunk/blender/source/blender/ editors/space_view3d/view3d_edit.c: fix [#30728] Align View Restricts Further View Changes
Campbell Barton
ideasman42 at gmail.com
Fri Apr 13 17:15:13 CEST 2012
Revision: 45606
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45606
Author: campbellbarton
Date: 2012-04-13 15:15:13 +0000 (Fri, 13 Apr 2012)
Log Message:
-----------
fix [#30728] Align View Restricts Further View Changes
turntable rotation can get into gimbal lock.
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 14:18:33 UTC (rev 45605)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_edit.c 2012-04-13 15:15:13 UTC (rev 45606)
@@ -675,6 +675,8 @@
float m[3][3];
float m_inv[3][3];
const float zvec_global[3] = {0.0f, 0.0f, 1.0f};
+ float xaxis[3];
+
/* Sensitivity will control how fast the viewport rotates. 0.007 was
* obtained experimentally by looking at viewport rotation sensitivities
* on other modeling programs. */
@@ -685,11 +687,30 @@
quat_to_mat3(m, vod->viewquat);
invert_m3_m3(m_inv, m);
+ /* avoid gimble lock */
+#if 1
+ if (len_squared_v3v3(zvec_global, m_inv[2]) > 0.001f) {
+ float fac;
+ cross_v3_v3v3(xaxis, zvec_global, m_inv[2]);
+ if (dot_v3v3(xaxis, m_inv[0]) < 0) {
+ negate_v3(xaxis);
+ }
+ fac = angle_normalized_v3v3(zvec_global, m_inv[2]) / M_PI;
+ fac = fabsf(fac - 0.5f) * 2;
+ fac = fac * fac;
+ interp_v3_v3v3(xaxis, xaxis, m_inv[0], fac);
+ }
+ else
+#endif
+ {
+ copy_v3_v3(xaxis, m_inv[0]);
+ }
+
/* Determine the direction of the x vector (for rotating up and down) */
/* This can likely be computed directly from the quaternion. */
/* Perform the up/down rotation */
- axis_angle_to_quat(q1, m_inv[0], sensitivity * -(y - vod->oldy));
+ axis_angle_to_quat(q1, xaxis, sensitivity * -(y - vod->oldy));
mul_qt_qtqt(vod->viewquat, vod->viewquat, q1);
if (vod->use_dyn_ofs) {
More information about the Bf-blender-cvs
mailing list