[Bf-blender-cvs] [89a3e4d] master: Cleanup: redundant normalize in expmap_to_quat

Campbell Barton noreply at git.blender.org
Sat Apr 4 05:47:02 CEST 2015


Commit: 89a3e4deffde3f3a20fad22cf95f368153d3da32
Author: Campbell Barton
Date:   Sat Apr 4 14:45:54 2015 +1100
Branches: master
https://developer.blender.org/rB89a3e4deffde3f3a20fad22cf95f368153d3da32

Cleanup: redundant normalize in expmap_to_quat

===================================================================

M	source/blender/blenlib/intern/math_rotation.c
M	source/blender/editors/space_view3d/view3d_fly.c

===================================================================

diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c
index 3d5d47b..7706e8e 100644
--- a/source/blender/blenlib/intern/math_rotation.c
+++ b/source/blender/blenlib/intern/math_rotation.c
@@ -1043,11 +1043,12 @@ void expmap_to_quat(float r[4], const float expmap[3])
 	float angle;
 
 	/* Obtain axis/angle representation. */
-	angle = normalize_v3_v3(axis, expmap);
-	angle = angle_wrap_rad(angle);
-
-	/* Convert to quaternion. */
-	axis_angle_to_quat(r, axis, angle);
+	if (LIKELY((angle = normalize_v3_v3(axis, expmap)) != 0.0f)) {
+		axis_angle_normalized_to_quat(r, axis, angle_wrap_rad(angle));
+	}
+	else {
+		unit_qt(r);
+	}
 }
 
 /******************************** XYZ Eulers *********************************/
diff --git a/source/blender/editors/space_view3d/view3d_fly.c b/source/blender/editors/space_view3d/view3d_fly.c
index da77c4f..a3dfd62 100644
--- a/source/blender/editors/space_view3d/view3d_fly.c
+++ b/source/blender/editors/space_view3d/view3d_fly.c
@@ -806,7 +806,7 @@ static int flyApply(bContext *C, FlyInfo *fly)
 					copy_v3_fl3(upvec, 1.0f, 0.0f, 0.0f);
 					mul_m3_v3(mat, upvec);
 					/* Rotate about the relative up vec */
-					axis_angle_to_quat(tmp_quat, upvec, (float)moffset[1] * time_redraw * -FLY_ROTATE_FAC);
+					axis_angle_to_quat(tmp_quat, upvec, moffset[1] * time_redraw * -FLY_ROTATE_FAC);
 					mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
 
 					if (fly->xlock != FLY_AXISLOCK_STATE_OFF)
@@ -836,7 +836,7 @@ static int flyApply(bContext *C, FlyInfo *fly)
 					}
 
 					/* Rotate about the relative up vec */
-					axis_angle_to_quat(tmp_quat, upvec, (float)moffset[0] * time_redraw * FLY_ROTATE_FAC);
+					axis_angle_to_quat(tmp_quat, upvec, moffset[0] * time_redraw * FLY_ROTATE_FAC);
 					mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
 
 					if (fly->xlock != FLY_AXISLOCK_STATE_OFF)




More information about the Bf-blender-cvs mailing list