3D View: use shortest angle between quaternions
authorCampbell Barton <ideasman42@gmail.com>
Tue, 19 Dec 2017 03:05:54 +0000 (14:05 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 19 Dec 2017 03:05:54 +0000 (14:05 +1100)
Gave incorrect smoothview speed changing between some axis and
axis locking.

source/blender/editors/space_view3d/view3d_view.c

index 0bccab626e609a577efdf291408890771b654fb5..85d21a13add70fdf6668ebd5066e66d32ecc7f2c 100644 (file)
@@ -271,7 +271,7 @@ void ED_view3d_smooth_view_ex(
                         * this means small rotations wont lag */
                        if (sview->quat && !sview->ofs && !sview->dist) {
                                /* scale the time allowed by the rotation */
-                               sms.time_allowed *= (double)angle_normalized_qtqt(sms.dst.quat, sms.src.quat) / M_PI; /* 180deg == 1.0 */
+                               sms.time_allowed *= (double)fabsf(angle_signed_normalized_qtqt(sms.dst.quat, sms.src.quat)) / M_PI; /* 180deg == 1.0 */
                        }
 
                        /* ensure it shows correct */
@@ -1076,7 +1076,7 @@ char ED_view3d_quat_to_axis_view(const float quat[4], const float epsilon)
        char view;
 
        for (view = RV3D_VIEW_FRONT; view <= RV3D_VIEW_BOTTOM; view++) {
-               if (angle_qtqt(quat, view3d_quat_axis[view - RV3D_VIEW_FRONT]) < epsilon) {
+               if (fabsf(angle_signed_qtqt(quat, view3d_quat_axis[view - RV3D_VIEW_FRONT])) < epsilon) {
                        return view;
                }
        }