diff options
author | Jorge Bernal <jbernalmartinez@gmail.com> | 2015-12-16 03:52:30 +0300 |
---|---|---|
committer | Jorge Bernal <jbernalmartinez@gmail.com> | 2015-12-16 03:53:48 +0300 |
commit | ee59df521f2af10d6a34158a39bf21dd5ae847a3 (patch) | |
tree | f48810bfb9d6df03542517d575d61b46b3584d89 | |
parent | 0c19a043e8198018ae794145fc4f1e78d5f00923 (diff) |
BGE clean up: use float version of trigonometric functions
-rw-r--r-- | intern/moto/include/MT_Matrix3x3.h | 22 | ||||
-rw-r--r-- | intern/moto/include/MT_Matrix3x3.inl | 4 | ||||
-rw-r--r-- | intern/moto/include/MT_Quaternion.h | 16 | ||||
-rw-r--r-- | intern/moto/include/MT_Quaternion.inl | 18 | ||||
-rw-r--r-- | intern/moto/include/MT_Vector2.inl | 6 | ||||
-rw-r--r-- | intern/moto/include/MT_Vector3.inl | 10 | ||||
-rw-r--r-- | intern/moto/include/MT_Vector4.inl | 2 | ||||
-rw-r--r-- | source/gameengine/GamePlayer/ghost/GPG_System.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Camera.cpp | 2 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_ConstraintActuator.cpp | 8 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_Dome.cpp | 10 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_OrientationInterpolator.cpp | 12 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_TrackToActuator.cpp | 12 | ||||
-rw-r--r-- | source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp | 2 |
14 files changed, 63 insertions, 63 deletions
diff --git a/intern/moto/include/MT_Matrix3x3.h b/intern/moto/include/MT_Matrix3x3.h index 8832fd56bf4..6f965f59069 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 088c4b098c8..614e4f93a81 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 b7703fe57d6..6aabb1f2ed4 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 dcd991096ea..8fe71b7b214 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 c975558b770..ed16025e733 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 8a2328fa295..7994bf7c55c 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 1196745e4be..5b6e6766416 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 6710572d843..669ab0532d9 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 76c7b4a222c..6988d563808 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[p][1]*m_planes[p][1] + m_planes[p][2]*m_planes[p][2]); + MT_Scalar factor = sqrtf(m_planes[p][0]*m_planes[p][0] + m_planes[p][1]*m_planes[p][1] + m_planes[p][2]*m_planes[p][2]); if (!MT_fuzzyZero(factor)) m_planes[p] /= factor; } diff --git a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp index 8f15955fba6..27c074393b4 100644 --- a/source/gameengine/Ketsji/KX_ConstraintActuator.cpp +++ b/source/gameengine/Ketsji/KX_ConstraintActuator.cpp @@ -96,10 +96,10 @@ KX_ConstraintActuator::KX_ConstraintActuator(SCA_IObject *gameobj, m_refDirection[2] /= len; m_refDirVector /= len; } - m_minimumBound = cos(minBound); - m_maximumBound = cos(maxBound); - m_minimumSine = sin(minBound); - m_maximumSine = sin(maxBound); + m_minimumBound = cosf(minBound); + m_maximumBound = cosf(maxBound); + m_minimumSine = sinf(minBound); + m_maximumSine = sinf(maxBound); } break; default: diff --git a/source/gameengine/Ketsji/KX_Dome.cpp b/source/gameengine/Ketsji/KX_Dome.cpp index 08cdc108c64..818a46531c9 100644 --- a/source/gameengine/Ketsji/KX_Dome.cpp +++ b/source/gameengine/Ketsji/KX_Dome.cpp @@ -1476,9 +1476,9 @@ void KX_Dome::CalculateCameraOrientation() * Uses 6 cameras for angles up to 360deg */ int i; - float deg45 = MT_PI / 4; - MT_Scalar c = cos(deg45); - MT_Scalar s = sin(deg45); + float deg45 = MT_PI / 4.0f; + MT_Scalar c = cosf(deg45); + MT_Scalar s = sinf(deg45); if (m_angle <= 180 && (m_mode == DOME_FISHEYE || m_mode == DOME_TRUNCATED_FRONT @@ -1575,8 +1575,8 @@ void KX_Dome::CalculateCameraOrientation() if (m_tilt) { float tiltdeg = ((m_tilt % 360) * 2 * MT_PI) / 360; - c = cos(tiltdeg); - s = sin(tiltdeg); + c = cosf(tiltdeg); + s = sinf(tiltdeg); MT_Matrix3x3 tilt_mat = MT_Matrix3x3( 1.0f, 0.0f, 0.0f, diff --git a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp index d2468d0317d..bcaa1e60e92 100644 --- a/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp +++ b/source/gameengine/Ketsji/KX_OrientationInterpolator.cpp @@ -39,12 +39,12 @@ void KX_OrientationInterpolator::Execute(float currentTime) const MT_Vector3 eul(m_ipos[0]->GetValue(currentTime), m_ipos[1]->GetValue(currentTime), m_ipos[2]->GetValue(currentTime)); - MT_Scalar ci = cos(eul[0]); - MT_Scalar cj = cos(eul[1]); - MT_Scalar ch = cos(eul[2]); - MT_Scalar si = sin(eul[0]); - MT_Scalar sj = sin(eul[1]); - MT_Scalar sh = sin(eul[2]); + MT_Scalar ci = cosf(eul[0]); + MT_Scalar cj = cosf(eul[1]); + MT_Scalar ch = cosf(eul[2]); + MT_Scalar si = sinf(eul[0]); + MT_Scalar sj = sinf(eul[1]); + MT_Scalar sh = sinf(eul[2]); MT_Scalar cc = ci*ch; MT_Scalar cs = ci*sh; MT_Scalar sc = si*ch; diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 651cc473640..74902ab20ee 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -92,12 +92,12 @@ static MT_Matrix3x3 EulToMat3(float eul[3]) MT_Matrix3x3 mat; float ci, cj, ch, si, sj, sh, cc, cs, sc, ss; - ci = cos(eul[0]); - cj = cos(eul[1]); - ch = cos(eul[2]); - si = sin(eul[0]); - sj = sin(eul[1]); - sh = sin(eul[2]); + ci = cosf(eul[0]); + cj = cosf(eul[1]); + ch = cosf(eul[2]); + si = sinf(eul[0]); + sj = sinf(eul[1]); + sh = sinf(eul[2]); cc = ci*ch; cs = ci*sh; sc = si*ch; diff --git a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp index 604b6a6b59b..84dbfff74b0 100644 --- a/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp +++ b/source/gameengine/Rasterizer/RAS_OpenGLRasterizer/RAS_OpenGLRasterizer.cpp @@ -404,7 +404,7 @@ void RAS_OpenGLRasterizer::FlushDebugShapes(SCA_IScene *scene) for (int j = 0; j<n; j++) { MT_Scalar theta = j*(float)M_PI*2/n; - MT_Vector3 pos(cos(theta) * rad, sin(theta) * rad, 0.0f); + MT_Vector3 pos(cosf(theta) * rad, sinf(theta) * rad, 0.0f); pos = pos*tr; pos += debugShapes[i].m_pos; const MT_Scalar* posPtr = &pos.x(); |