Commit: ee59df521f2af10d6a34158a39bf21dd5ae847a3
Author: Jorge Bernal
Date:   Wed Dec 16 01:52:30 2015 +0100
Branches: master
https://developer.blender.org/rBee59df521f2af10d6a34158a39bf21dd5ae847a3

BGE clean up: use float version of trigonometric functions

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

M       intern/moto/include/MT_Matrix3x3.h
M       intern/moto/include/MT_Matrix3x3.inl
M       intern/moto/include/MT_Quaternion.h
M       intern/moto/include/MT_Quaternion.inl
M       intern/moto/include/MT_Vector2.inl
M       intern/moto/include/MT_Vector3.inl
M       intern/moto/include/MT_Vector4.inl
M       source/gameengine/GamePlayer/ghost/GPG_System.cpp
M       source/gameengine/Ketsji/KX_Camera.cpp
M       source/gameengine/Ketsji/KX_ConstraintActuator.cpp
M       source/gameengine/Ketsji/KX_Dome.cpp
M       source/gameengine/Ketsji/KX_OrientationInterpolator.cpp
M       source/gameengine/Ketsji/KX_TrackToActuator.cpp
M       
source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp

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

diff --git a/intern/moto/include/MT_Matrix3x3.h 
b/intern/moto/include/MT_Matrix3x3.h
index 8832fd5..6f965f5 100644
--- a/intern/moto/include/MT_Matrix3x3.h
+++ b/intern/moto/include/MT_Matrix3x3.h
@@ -151,12 +151,12 @@ public:
         **/
 
        void setEuler(const MT_Vector3& euler) {
-               MT_Scalar ci = cos(euler[0]); 
-               MT_Scalar cj = cos(euler[1]); 
-               MT_Scalar ch = cos(euler[2]);
-               MT_Scalar si = sin(euler[0]); 
-               MT_Scalar sj = sin(euler[1]); 
-               MT_Scalar sh = sin(euler[2]);
+               MT_Scalar ci = cosf(euler[0]);
+               MT_Scalar cj = cosf(euler[1]);
+               MT_Scalar ch = cosf(euler[2]);
+               MT_Scalar si = sinf(euler[0]);
+               MT_Scalar sj = sinf(euler[1]);
+               MT_Scalar sh = sinf(euler[2]);
                MT_Scalar cc = ci * ch; 
                MT_Scalar cs = ci * sh; 
                MT_Scalar sc = si * ch; 
@@ -170,19 +170,19 @@ public:
        void getEuler(MT_Scalar& yaw, MT_Scalar& pitch, MT_Scalar& roll) const
                {                       
                        if (m_el[2][0] != -1.0f && m_el[2][0] != 1.0f) {
-                               pitch = MT_Scalar(-asin(m_el[2][0]));
-                               yaw = MT_Scalar(atan2(m_el[2][1] / cos(pitch), 
m_el[2][2] / cos(pitch)));
-                               roll = MT_Scalar(atan2(m_el[1][0] / cos(pitch), 
m_el[0][0] / cos(pitch)));                              
+                               pitch = MT_Scalar(-asinf(m_el[2][0]));
+                               yaw = MT_Scalar(atan2f(m_el[2][1] / 
cosf(pitch), m_el[2][2] / cosf(pitch)));
+                               roll = MT_Scalar(atan2f(m_el[1][0] / 
cosf(pitch), m_el[0][0] / cosf(pitch)));
                        }
                        else {
                                roll = MT_Scalar(0);
                                if (m_el[2][0] == -1.0f) {
                                        pitch = (float)MT_PI / 2.0f;
-                                       yaw = MT_Scalar(atan2(m_el[0][1], 
m_el[0][2]));
+                                       yaw = MT_Scalar(atan2f(m_el[0][1], 
m_el[0][2]));
                                }
                                else {
                                        pitch = (float)-MT_PI / 2.0f;
-                                       yaw = MT_Scalar(atan2(m_el[0][1], 
m_el[0][2]));
+                                       yaw = MT_Scalar(atan2f(m_el[0][1], 
m_el[0][2]));
                                }
                        }
                }
diff --git a/intern/moto/include/MT_Matrix3x3.inl 
b/intern/moto/include/MT_Matrix3x3.inl
index 088c4b0..614e4f9 100644
--- a/intern/moto/include/MT_Matrix3x3.inl
+++ b/intern/moto/include/MT_Matrix3x3.inl
@@ -9,7 +9,7 @@ GEN_INLINE MT_Quaternion MT_Matrix3x3::getRotation() const {
     
     if (trace > 0.0f) 
     {
-        MT_Scalar s = sqrt(trace + MT_Scalar(1.0f));
+        MT_Scalar s = sqrtf(trace + MT_Scalar(1.0f));
         result[3] = s * MT_Scalar(0.5f);
         s = MT_Scalar(0.5f) / s;
         
@@ -28,7 +28,7 @@ GEN_INLINE MT_Quaternion MT_Matrix3x3::getRotation() const {
         int j = next[i];  
         int k = next[j];
         
-        MT_Scalar s = sqrt(m_el[i][i] - m_el[j][j] - m_el[k][k] + 
MT_Scalar(1.0f));
+        MT_Scalar s = sqrtf(m_el[i][i] - m_el[j][j] - m_el[k][k] + 
MT_Scalar(1.0f));
         
         result[i] = s * MT_Scalar(0.5f);
         
diff --git a/intern/moto/include/MT_Quaternion.h 
b/intern/moto/include/MT_Quaternion.h
index b7703fe..6aabb1f 100644
--- a/intern/moto/include/MT_Quaternion.h
+++ b/intern/moto/include/MT_Quaternion.h
@@ -70,18 +70,18 @@ public:
     void setRotation(const MT_Vector3& axis, MT_Scalar mt_angle) {
         MT_Scalar d = axis.length();
         MT_assert(!MT_fuzzyZero(d));
-        MT_Scalar s = sin(mt_angle * MT_Scalar(0.5f)) / d;
+        MT_Scalar s = sinf(mt_angle * MT_Scalar(0.5f)) / d;
         setValue(axis[0] * s, axis[1] * s, axis[2] * s, 
-                 cos(mt_angle * MT_Scalar(0.5f)));
+                 cosf(mt_angle * MT_Scalar(0.5f)));
     }
 
     void setEuler(MT_Scalar yaw, MT_Scalar pitch, MT_Scalar roll) {
-        MT_Scalar cosYaw = cos(yaw * MT_Scalar(0.5f));
-        MT_Scalar sinYaw = sin(yaw * MT_Scalar(0.5f));
-        MT_Scalar cosPitch = cos(pitch * MT_Scalar(0.5f));
-        MT_Scalar sinPitch = sin(pitch * MT_Scalar(0.5f));
-        MT_Scalar cosRoll = cos(roll * MT_Scalar(0.5f));
-        MT_Scalar sinRoll = sin(roll * MT_Scalar(0.5f));
+        MT_Scalar cosYaw = cosf(yaw * MT_Scalar(0.5f));
+        MT_Scalar sinYaw = sinf(yaw * MT_Scalar(0.5f));
+        MT_Scalar cosPitch = cosf(pitch * MT_Scalar(0.5f));
+        MT_Scalar sinPitch = sinf(pitch * MT_Scalar(0.5f));
+        MT_Scalar cosRoll = cosf(roll * MT_Scalar(0.5f));
+        MT_Scalar sinRoll = sinf(roll * MT_Scalar(0.5f));
         setValue(cosRoll * sinPitch * cosYaw + sinRoll * cosPitch * sinYaw,
                  cosRoll * cosPitch * sinYaw - sinRoll * sinPitch * cosYaw,
                  sinRoll * cosPitch * cosYaw - cosRoll * sinPitch * sinYaw,
diff --git a/intern/moto/include/MT_Quaternion.inl 
b/intern/moto/include/MT_Quaternion.inl
index dcd9910..8fe71b7 100644
--- a/intern/moto/include/MT_Quaternion.inl
+++ b/intern/moto/include/MT_Quaternion.inl
@@ -29,10 +29,10 @@ GEN_INLINE MT_Quaternion MT_Quaternion::inverse() const {
 //       pg. 124-132
 GEN_INLINE MT_Quaternion MT_Quaternion::random() {
     MT_Scalar x0 = MT_random();
-    MT_Scalar r1 = sqrt(MT_Scalar(1.0f) - x0), r2 = sqrt(x0);
+    MT_Scalar r1 = sqrtf(MT_Scalar(1.0f) - x0), r2 = sqrtf(x0);
     MT_Scalar t1 = (float)MT_2_PI * MT_random(), t2 = (float)MT_2_PI * 
MT_random();
-    MT_Scalar c1 = cos(t1), s1 = sin(t1);
-    MT_Scalar c2 = cos(t2), s2 = sin(t2);
+    MT_Scalar c1 = cosf(t1), s1 = sinf(t1);
+    MT_Scalar c2 = cosf(t2), s2 = sinf(t2);
     return MT_Quaternion(s1 * r1, c1 * r1, s2 * r2, c2 * r2);
 }
 
@@ -62,14 +62,14 @@ GEN_INLINE MT_Quaternion operator*(const MT_Vector3& w, 
const MT_Quaternion& q)
 
 GEN_INLINE MT_Scalar MT_Quaternion::angle(const MT_Quaternion& q) const 
 {
-       MT_Scalar s = sqrt(length2() * q.length2());
+       MT_Scalar s = sqrtf(length2() * q.length2());
        assert(s != MT_Scalar(0.0f));
        
        s = dot(q) / s;
        
        s = MT_clamp(s, -1.0f, 1.0f);
        
-       return acos(s);
+       return acosf(s);
 }
 
 GEN_INLINE MT_Quaternion MT_Quaternion::slerp(const MT_Quaternion& q, const 
MT_Scalar& t) const
@@ -82,10 +82,10 @@ GEN_INLINE MT_Quaternion MT_Quaternion::slerp(const 
MT_Quaternion& q, const MT_S
                s = -s;
        if ((1.0f - s) > 0.0001f)
        {
-               MT_Scalar theta = acos(s);
-               d = MT_Scalar(1.0f) / sin(theta);
-               s0 = sin((MT_Scalar(1.0f) - t) * theta);
-               s1 = sin(t * theta);
+               MT_Scalar theta = acosf(s);
+               d = MT_Scalar(1.0f) / sinf(theta);
+               s0 = sinf((MT_Scalar(1.0f) - t) * theta);
+               s1 = sinf(t * theta);
        }
        else
        {
diff --git a/intern/moto/include/MT_Vector2.inl 
b/intern/moto/include/MT_Vector2.inl
index c975558..ed16025 100644
--- a/intern/moto/include/MT_Vector2.inl
+++ b/intern/moto/include/MT_Vector2.inl
@@ -48,7 +48,7 @@ GEN_INLINE MT_Scalar MT_Vector2::dot(const MT_Vector2& vv) 
const {
 }
 
 GEN_INLINE MT_Scalar MT_Vector2::length2() const { return dot(*this); }
-GEN_INLINE MT_Scalar MT_Vector2::length() const { return sqrt(length2()); }
+GEN_INLINE MT_Scalar MT_Vector2::length() const { return sqrtf(length2()); }
 
 GEN_INLINE MT_Vector2 MT_Vector2::absolute() const {
     return MT_Vector2(MT_abs(m_co[0]), MT_abs(m_co[1]));
@@ -68,9 +68,9 @@ GEN_INLINE MT_Vector2 MT_Vector2::scaled(MT_Scalar xx, 
MT_Scalar yy) const {
 }
 
 GEN_INLINE MT_Scalar MT_Vector2::angle(const MT_Vector2& vv) const {
-    MT_Scalar s = sqrt(length2() * vv.length2());
+    MT_Scalar s = sqrtf(length2() * vv.length2());
     MT_assert(!MT_fuzzyZero(s));
-    return acos(dot(vv) / s);
+    return acosf(dot(vv) / s);
 }
 
 
diff --git a/intern/moto/include/MT_Vector3.inl 
b/intern/moto/include/MT_Vector3.inl
index 8a2328f..7994bf7 100644
--- a/intern/moto/include/MT_Vector3.inl
+++ b/intern/moto/include/MT_Vector3.inl
@@ -52,7 +52,7 @@ GEN_INLINE MT_Scalar MT_Vector3::dot(const MT_Vector3& v) 
const {
 }
 
 GEN_INLINE MT_Scalar MT_Vector3::length2() const { return dot(*this); }
-GEN_INLINE MT_Scalar MT_Vector3::length() const { return sqrt(length2()); }
+GEN_INLINE MT_Scalar MT_Vector3::length() const { return sqrtf(length2()); }
 
 GEN_INLINE MT_Vector3 MT_Vector3::absolute() const {
     return MT_Vector3(MT_abs(m_co[0]), MT_abs(m_co[1]), MT_abs(m_co[2]));
@@ -93,9 +93,9 @@ GEN_INLINE MT_Vector3 MT_Vector3::scaled(MT_Scalar xx, 
MT_Scalar yy, MT_Scalar z
 }
 
 GEN_INLINE MT_Scalar MT_Vector3::angle(const MT_Vector3& v) const {
-    MT_Scalar s = sqrt(length2() * v.length2());
+    MT_Scalar s = sqrtf(length2() * v.length2());
     MT_assert(!MT_fuzzyZero(s));
-    return acos(dot(v) / s);
+    return acosf(dot(v) / s);
 }
 
 GEN_INLINE MT_Vector3 MT_Vector3::cross(const MT_Vector3& v) const {
@@ -117,9 +117,9 @@ GEN_INLINE int MT_Vector3::closestAxis() const {
 
 GEN_INLINE MT_Vector3 MT_Vector3::random() {
     MT_Scalar z = MT_Scalar(2.0f) * MT_random() - MT_Scalar(1.0f);
-    MT_Scalar r = sqrt(MT_Scalar(1.0f) - z * z);
+    MT_Scalar r = sqrtf(MT_Scalar(1.0f) - z * z);
     MT_Scalar t = (float)MT_2_PI * MT_random();
-    return MT_Vector3(r * cos(t), r * sin(t), z);
+    return MT_Vector3(r * cosf(t), r * sinf(t), z);
 }
 
 GEN_INLINE MT_Scalar  MT_dot(const MT_Vector3& v1, const MT_Vector3& v2) { 
diff --git a/intern/moto/include/MT_Vector4.inl 
b/intern/moto/include/MT_Vector4.inl
index 1196745..5b6e676 100644
--- a/intern/moto/include/MT_Vector4.inl
+++ b/intern/moto/include/MT_Vector4.inl
@@ -48,7 +48,7 @@ GEN_INLINE MT_Scalar MT_Vector4::dot(const MT_Vector4& v) 
const {
 }
 
 GEN_INLINE MT_Scalar MT_Vector4::length2() const { return MT_dot(*this, 
*this); }
-GEN_INLINE MT_Scalar MT_Vector4::length() const { return sqrt(length2()); }
+GEN_INLINE MT_Scalar MT_Vector4::length() const { return sqrtf(length2()); }
 
 GEN_INLINE MT_Vector4 MT_Vector4::absolute() const {
     return MT_Vector4(MT_abs(m_co[0]), MT_abs(m_co[1]), MT_abs(m_co[2]), 
MT_abs(m_co[3]));
diff --git a/source/gameengine/GamePlayer/ghost/GPG_System.cpp 
b/source/gameengine/GamePlayer/ghost/GPG_System.cpp
index 6710572..669ab05 100644
--- a/source/gameengine/GamePlayer/ghost/GPG_System.cpp
+++ b/source/gameengine/GamePlayer/ghost/GPG_System.cpp
@@ -46,7 +46,7 @@ double GPG_System::GetTimeInSeconds()
 {
        GHOST_TInt64 millis = (GHOST_TInt64)m_system->getMilliSeconds();
        double time = (double)millis;
-       time /= 1000.0f;
+       time /= 1000.0;
        return time;
 }
 
diff --git a/source/gameengine/Ketsji/KX_Camera.cpp 
b/source/gameengine/Ketsji/KX_Camera.cpp
index 76c7b4a..6988d56 100644
--- a/source/gameengine/Ketsji/KX_Camera.cpp
+++ b/source/gameengine/Ketsji/KX_Camera.cpp
@@ -294,7 +294,7 @@ void KX_Camera::NormalizeClipPlanes()
        
        for (unsigned int p = 0; p < 6; p++)
        {
-               MT_Scalar factor = sqrt(m_planes[p][0]*m_planes[p][0] + 
m_planes[

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to