From da060dad9938e5882e4f7b7bbf241b655f0054cb Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 27 Jul 2010 04:56:24 +0000 Subject: bugfix [#21754] Smooth view + repeeted view orbit results in slow orbiting. - original quat was not assigned yet so never gave a good result. - quat angle comparison as vector is wrong. --- source/blender/editors/space_view3d/view3d_view.c | 50 +++++++++++------------ 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'source/blender/editors/space_view3d/view3d_view.c') diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 6b1f5736f03..8ec226ef57e 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -219,38 +219,16 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo if (sms.new_lens != v3d->lens) changed = 1; - if ((sms.new_ofs[0]!=rv3d->ofs[0]) || - (sms.new_ofs[1]!=rv3d->ofs[1]) || - (sms.new_ofs[2]!=rv3d->ofs[2]) ) + if (!equals_v3v3(sms.new_ofs, rv3d->ofs)) changed = 1; - - if ((sms.new_quat[0]!=rv3d->viewquat[0]) || - (sms.new_quat[1]!=rv3d->viewquat[1]) || - (sms.new_quat[2]!=rv3d->viewquat[2]) || - (sms.new_quat[3]!=rv3d->viewquat[3]) ) + + if (!equals_v4v4(sms.new_quat, rv3d->viewquat)) changed = 1; /* The new view is different from the old one * so animate the view */ if (changed) { - - sms.time_allowed= (double)U.smooth_viewtx / 1000.0; - - /* if this is view rotation only - * we can decrease the time allowed by - * the angle between quats - * this means small rotations wont lag */ - if (quat && !ofs && !dist) { - float vec1[3], vec2[3]; - - copy_v3_v3(vec1, sms.new_quat); - copy_v3_v3(vec2, sms.orig_quat); - normalize_v3(vec1); - normalize_v3(vec2); - /* scale the time allowed by the rotation */ - sms.time_allowed *= angle_normalized_v3v3(vec1, vec2)/(M_PI/2); - } - + /* original values */ if (oldcamera) { sms.orig_dist= rv3d->dist; // below function does weird stuff with it... @@ -269,6 +247,26 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo rv3d->view= 0; } + sms.time_allowed= (double)U.smooth_viewtx / 1000.0; + + /* if this is view rotation only + * we can decrease the time allowed by + * the angle between quats + * this means small rotations wont lag */ + if (quat && !ofs && !dist) { + float vec1[3]={0,0,1}, vec2[3]= {0,0,1}; + float q1[4], q2[4]; + + invert_qt_qt(q1, sms.new_quat); + invert_qt_qt(q2, sms.orig_quat); + + mul_qt_v3(q1, vec1); + mul_qt_v3(q2, vec2); + + /* scale the time allowed by the rotation */ + sms.time_allowed *= angle_v3v3(vec1, vec2) / M_PI; /* 180deg == 1.0 */ + } + /* ensure it shows correct */ if(sms.to_camera) rv3d->persp= RV3D_PERSP; -- cgit v1.2.3