From 694416701a009172f62b04d62970b384fbb21253 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Sat, 21 Jun 2014 15:42:10 +0200 Subject: [PATCH] Replaced C casts by C++ casts --- glm/gtx/quaternion.inl | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index 615989bc..0dc95b0f 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -41,7 +41,7 @@ namespace glm detail::tquat const & s2, T const & h) { - return mix(mix(q1, q2, h), mix(s1, s2, h), T(2) * (T(1) - h) * h); + return mix(mix(q1, q2, h), mix(s1, s2, h), static_cast(2) * (static_cast(1) - h) * h); } template @@ -53,7 +53,7 @@ namespace glm ) { detail::tquat invQuat = inverse(curr); - return exp((log(next + invQuat) + log(prev + invQuat)) / T(-4)) * curr; + return exp((log(next + invQuat) + log(prev + invQuat)) / static_cast(-4)) * curr; } template @@ -152,7 +152,7 @@ namespace glm detail::tquat const & q ) { - T w = static_cast(1.0) - q.x * q.x - q.y * q.y - q.z * q.z; + T w = static_cast(1) - q.x * q.x - q.y * q.y - q.z * q.z; if(w < T(0)) return T(0); else @@ -176,12 +176,12 @@ namespace glm T const & a ) { - if(a <= T(0)) return x; - if(a >= T(1)) return y; + if(a <= static_cast(0)) return x; + if(a >= static_cast(1)) return y; T fCos = dot(x, y); detail::tquat y2(y); //BUG!!! tquat y2; - if(fCos < T(0)) + if(fCos < static_cast(0)) { y2 = -y; fCos = -fCos; @@ -189,7 +189,7 @@ namespace glm //if(fCos > 1.0f) // problem T k0, k1; - if(fCos > T(0.9999)) + if(fCos > (static_cast(1) - epsilon())) { k0 = static_cast(1) - a; k1 = static_cast(0) + a; //BUG!!! 1.0f + a; @@ -199,8 +199,8 @@ namespace glm T fSin = sqrt(T(1) - fCos * fCos); T fAngle = atan(fSin, fCos); T fOneOverSin = static_cast(1) / fSin; - k0 = sin((T(1) - a) * fAngle) * fOneOverSin; - k1 = sin((T(0) + a) * fAngle) * fOneOverSin; + k0 = sin((static_cast(1) - a) * fAngle) * fOneOverSin; + k1 = sin((static_cast(0) + a) * fAngle) * fOneOverSin; } return detail::tquat( @@ -218,7 +218,7 @@ namespace glm T const & a ) { - return glm::normalize(x * (T(1) - a) + (y * a)); + return glm::normalize(x * (static_cast(1) - a) + (y * a)); } template @@ -231,7 +231,7 @@ namespace glm T cosTheta = dot(orig, dest); detail::tvec3 rotationAxis; - if(cosTheta < T(-1) + epsilon()) + if(cosTheta < static_cast(-1) + epsilon()) { // special case when vectors in opposite directions : // there is no "ideal" rotation axis @@ -249,11 +249,11 @@ namespace glm // Implementation from Stan Melax's Game Programming Gems 1 article rotationAxis = cross(orig, dest); - T s = sqrt((T(1) + cosTheta) * T(2)); + T s = sqrt((T(1) + cosTheta) * static_cast(2)); T invs = static_cast(1) / s; return detail::tquat( - s * T(0.5f), + s * static_cast(0.5f), rotationAxis.x * invs, rotationAxis.y * invs, rotationAxis.z * invs);