From 32a4365ea947a91dfd920db58fdaa89bd1ce24f1 Mon Sep 17 00:00:00 2001 From: Nathan Bowhay Date: Thu, 12 Feb 2015 11:00:25 -0800 Subject: [PATCH] Optimized code Since floating point division is the most expensive operation, it was optimized. --- Engine/source/math/mQuat.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Engine/source/math/mQuat.cpp b/Engine/source/math/mQuat.cpp index 29180d837..d2b1a6ae6 100644 --- a/Engine/source/math/mQuat.cpp +++ b/Engine/source/math/mQuat.cpp @@ -60,12 +60,12 @@ QuatF& QuatF::set( const EulerF & e ) z = cysz*cx - sycz*sx; */ // Assuming the angles are in radians. - F32 c1 = mCos(e.y/2.0f); - F32 s1 = mSin(e.y/2.0f); - F32 c2 = mCos(e.z/2.0f); - F32 s2 = mSin(e.z/2.0f); - F32 c3 = mCos(e.x/2.0f); - F32 s3 = mSin(e.x/2.0f); + F32 c1 = mCos(e.y * 0.5f); + F32 s1 = mSin(e.y * 0.5f); + F32 c2 = mCos(e.z * 0.5f); + F32 s2 = mSin(e.z * 0.5f); + F32 c3 = mCos(e.x * 0.5f); + F32 s3 = mSin(e.x * 0.5f); F32 c1c2 = c1*c2; F32 s1s2 = s1*s2; w =c1c2*c3 - s1s2*s3;