[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30791] trunk/blender/source/blender: bugfix [#21754] Smooth view + repeeted view orbit results in slow orbiting .

Campbell Barton ideasman42 at gmail.com
Tue Jul 27 06:56:26 CEST 2010


Revision: 30791
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30791
Author:   campbellbarton
Date:     2010-07-27 06:56:24 +0200 (Tue, 27 Jul 2010)

Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/BLI_math_vector.h
    trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
    trunk/blender/source/blender/editors/space_view3d/view3d_view.c

Modified: trunk/blender/source/blender/blenlib/BLI_math_vector.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_vector.h	2010-07-27 04:02:09 UTC (rev 30790)
+++ trunk/blender/source/blender/blenlib/BLI_math_vector.h	2010-07-27 04:56:24 UTC (rev 30791)
@@ -126,6 +126,7 @@
 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                          */

Modified: trunk/blender/source/blender/blenlib/intern/math_vector_inline.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2010-07-27 04:02:09 UTC (rev 30790)
+++ trunk/blender/source/blender/blenlib/intern/math_vector_inline.c	2010-07-27 04:56:24 UTC (rev 30791)
@@ -409,6 +409,11 @@
 	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)

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_view.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_view.c	2010-07-27 04:02:09 UTC (rev 30790)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_view.c	2010-07-27 04:56:24 UTC (rev 30791)
@@ -219,38 +219,16 @@
 		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 @@
 				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;
 





More information about the Bf-blender-cvs mailing list