diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-07-27 08:56:24 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-07-27 08:56:24 +0400 |
commit | da060dad9938e5882e4f7b7bbf241b655f0054cb (patch) | |
tree | a1f7f394aef6d0fc81f5b5a770a45b59ace76ef1 /source | |
parent | db6f1f52a713323cf852a908de64a3ee6f066076 (diff) |
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.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_math_vector.h | 1 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_vector_inline.c | 5 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 50 |
3 files changed, 30 insertions, 26 deletions
diff --git a/source/blender/blenlib/BLI_math_vector.h b/source/blender/blenlib/BLI_math_vector.h index 02d5fb27dc9..15135e08225 100644 --- a/source/blender/blenlib/BLI_math_vector.h +++ b/source/blender/blenlib/BLI_math_vector.h @@ -126,6 +126,7 @@ MINLINE int compare_v3v3(float a[3], float b[3], float limit); MINLINE int compare_len_v3v3(float a[3], float b[3], float limit); MINLINE int compare_v4v4(float a[4], float b[4], float limit); +MINLINE int equals_v4v4(float a[4], float b[4]); /********************************** Angles ***********************************/ /* - angle with 2 arguments is angle between vector */ diff --git a/source/blender/blenlib/intern/math_vector_inline.c b/source/blender/blenlib/intern/math_vector_inline.c index fa8d1a30269..84d96d1d22a 100644 --- a/source/blender/blenlib/intern/math_vector_inline.c +++ b/source/blender/blenlib/intern/math_vector_inline.c @@ -409,6 +409,11 @@ MINLINE int equals_v3v3(float *v1, float *v2) return ((v1[0]==v2[0]) && (v1[1]==v2[1]) && (v1[2]==v2[2])); } +MINLINE int equals_v4v4(float *v1, float *v2) +{ + return ((v1[0]==v2[0]) && (v1[1]==v2[1]) && (v1[2]==v2[2]) && (v1[3]==v2[3])); +} + MINLINE int compare_v3v3(float *v1, float *v2, float limit) { if(fabs(v1[0]-v2[0])<limit) 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; |