Fixed warnings

This commit is contained in:
Christophe Riccio 2017-08-07 14:56:45 +02:00
parent a41c4d83d2
commit 00e7908294
2 changed files with 61 additions and 68 deletions

View File

@ -562,25 +562,26 @@ namespace detail
template<typename T, precision P>
GLM_FUNC_QUALIFIER T roll(tquat<T, P> const & q)
{
return T(atan(T(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
return static_cast<T>(atan(static_cast<T>(2) * (q.x * q.y + q.w * q.z), q.w * q.w + q.x * q.x - q.y * q.y - q.z * q.z));
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER T pitch(tquat<T, P> const & q)
{
//return T(atan(T(2) * (q.y * q.z + q.w * q.x), q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z));
const T y = T(2) * (q.y * q.z + q.w * q.x);
const T y = static_cast<T>(2) * (q.y * q.z + q.w * q.x);
const T x = q.w * q.w - q.x * q.x - q.y * q.y + q.z * q.z;
if(y == T(0) && x == T(0)) //avoid atan2(0,0) - handle singularity - Matiis
return T(T(2)*atan(q.x,q.w));
return T(atan(y,x));
if(detail::compute_equal<T>::call(y, static_cast<T>(0)) && detail::compute_equal<T>::call(x, static_cast<T>(0))) //avoid atan2(0,0) - handle singularity - Matiis
return static_cast<T>(static_cast<T>(2) * atan(q.x,q.w));
return static_cast<T>(atan(y,x));
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER T yaw(tquat<T, P> const & q)
{
return asin(clamp(T(-2) * (q.x * q.z - q.w * q.y), T(-1), T(1)));
return asin(clamp(static_cast<T>(-2) * (q.x * q.z - q.w * q.y), static_cast<T>(-1), static_cast<T>(1)));
}
template<typename T, precision P>
@ -643,7 +644,7 @@ namespace detail
biggestIndex = 3;
}
T biggestVal = sqrt(fourBiggestSquaredMinus1 + T(1)) * T(0.5);
T biggestVal = sqrt(fourBiggestSquaredMinus1 + static_cast<T>(1)) * static_cast<T>(0.5);
T mult = static_cast<T>(0.25) / biggestVal;
tquat<T, P> Result;
@ -690,7 +691,7 @@ namespace detail
template<typename T, precision P>
GLM_FUNC_QUALIFIER T angle(tquat<T, P> const & x)
{
return acos(x.w) * T(2);
return acos(x.w) * static_cast<T>(2);
}
template<typename T, precision P>

View File

@ -6,40 +6,38 @@
namespace glm
{
template<typename T, precision P>
GLM_FUNC_QUALIFIER void axisAngle
(
mat<4, 4, T, P> const& mat,
vec<3, T, P> & axis,
T & angle
)
GLM_FUNC_QUALIFIER void axisAngle(mat<4, 4, T, P> const& mat, vec<3, T, P> & axis, T & angle)
{
T epsilon = (T)0.01;
T epsilon2 = (T)0.1;
T epsilon = static_cast<T>(0.01);
T epsilon2 = static_cast<T>(0.1);
if((abs(mat[1][0] - mat[0][1]) < epsilon) && (abs(mat[2][0] - mat[0][2]) < epsilon) && (abs(mat[2][1] - mat[1][2]) < epsilon))
{
if ((abs(mat[1][0] + mat[0][1]) < epsilon2) && (abs(mat[2][0] + mat[0][2]) < epsilon2) && (abs(mat[2][1] + mat[1][2]) < epsilon2) && (abs(mat[0][0] + mat[1][1] + mat[2][2] - (T)3.0) < epsilon2))
{
angle = (T)0.0;
axis.x = (T)1.0;
axis.y = (T)0.0;
axis.z = (T)0.0;
angle = static_cast<T>(0.0);
axis.x = static_cast<T>(1.0);
axis.y = static_cast<T>(0.0);
axis.z = static_cast<T>(0.0);
return;
}
angle = static_cast<T>(3.1415926535897932384626433832795);
T xx = (mat[0][0] + (T)1.0) * (T)0.5;
T yy = (mat[1][1] + (T)1.0) * (T)0.5;
T zz = (mat[2][2] + (T)1.0) * (T)0.5;
T xy = (mat[1][0] + mat[0][1]) * (T)0.25;
T xz = (mat[2][0] + mat[0][2]) * (T)0.25;
T yz = (mat[2][1] + mat[1][2]) * (T)0.25;
T xx = (mat[0][0] + static_cast<T>(1.0)) * static_cast<T>(0.5);
T yy = (mat[1][1] + static_cast<T>(1.0)) * static_cast<T>(0.5);
T zz = (mat[2][2] + static_cast<T>(1.0)) * static_cast<T>(0.5);
T xy = (mat[1][0] + mat[0][1]) * static_cast<T>(0.25);
T xz = (mat[2][0] + mat[0][2]) * static_cast<T>(0.25);
T yz = (mat[2][1] + mat[1][2]) * static_cast<T>(0.25);
if((xx > yy) && (xx > zz))
{
if (xx < epsilon) {
axis.x = (T)0.0;
axis.y = (T)0.7071;
axis.z = (T)0.7071;
} else {
if(xx < epsilon)
{
axis.x = static_cast<T>(0.0);
axis.y = static_cast<T>(0.7071);
axis.z = static_cast<T>(0.7071);
}
else
{
axis.x = sqrt(xx);
axis.y = xy / axis.x;
axis.z = xz / axis.x;
@ -47,11 +45,14 @@ namespace glm
}
else if (yy > zz)
{
if (yy < epsilon) {
axis.x = (T)0.7071;
axis.y = (T)0.0;
axis.z = (T)0.7071;
} else {
if(yy < epsilon)
{
axis.x = static_cast<T>(0.7071);
axis.y = static_cast<T>(0.0);
axis.z = static_cast<T>(0.7071);
}
else
{
axis.y = sqrt(yy);
axis.x = xy / axis.y;
axis.z = yz / axis.y;
@ -59,11 +60,14 @@ namespace glm
}
else
{
if (zz < epsilon) {
axis.x = (T)0.7071;
axis.y = (T)0.7071;
axis.z = (T)0.0;
} else {
if (zz < epsilon)
{
axis.x = static_cast<T>(0.7071);
axis.y = static_cast<T>(0.7071);
axis.z = static_cast<T>(0.0);
}
else
{
axis.z = sqrt(zz);
axis.x = xz / axis.z;
axis.y = yz / axis.z;
@ -73,9 +77,9 @@ namespace glm
}
T s = sqrt((mat[2][1] - mat[1][2]) * (mat[2][1] - mat[1][2]) + (mat[2][0] - mat[0][2]) * (mat[2][0] - mat[0][2]) + (mat[1][0] - mat[0][1]) * (mat[1][0] - mat[0][1]));
if (glm::abs(s) < T(0.001))
s = (T)1.0;
T const angleCos = (mat[0][0] + mat[1][1] + mat[2][2] - (T)1.0) * (T)0.5;
if (angleCos - static_cast<T>(1) < epsilon)
s = static_cast<T>(1);
T const angleCos = (mat[0][0] + mat[1][1] + mat[2][2] - static_cast<T>(1)) * static_cast<T>(0.5);
if(angleCos - static_cast<T>(1) < epsilon)
angle = pi<T>() * static_cast<T>(0.25);
else
angle = acos(angleCos);
@ -85,11 +89,7 @@ namespace glm
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER mat<4, 4, T, P> axisAngleMatrix
(
vec<3, T, P> const & axis,
T const angle
)
GLM_FUNC_QUALIFIER mat<4, 4, T, P> axisAngleMatrix(vec<3, T, P> const & axis, T const angle)
{
T c = cos(angle);
T s = sin(angle);
@ -97,32 +97,24 @@ namespace glm
vec<3, T, P> n = normalize(axis);
return mat<4, 4, T, P>(
t * n.x * n.x + c, t * n.x * n.y + n.z * s, t * n.x * n.z - n.y * s, T(0),
t * n.x * n.y - n.z * s, t * n.y * n.y + c, t * n.y * n.z + n.x * s, T(0),
t * n.x * n.z + n.y * s, t * n.y * n.z - n.x * s, t * n.z * n.z + c, T(0),
T(0), T(0), T(0), T(1));
t * n.x * n.x + c, t * n.x * n.y + n.z * s, t * n.x * n.z - n.y * s, static_cast<T>(0.0),
t * n.x * n.y - n.z * s, t * n.y * n.y + c, t * n.y * n.z + n.x * s, static_cast<T>(0.0),
t * n.x * n.z + n.y * s, t * n.y * n.z - n.x * s, t * n.z * n.z + c, static_cast<T>(0.0),
static_cast<T>(0.0), static_cast<T>(0.0), static_cast<T>(0.0), static_cast<T>(1.0));
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER mat<4, 4, T, P> extractMatrixRotation
(
mat<4, 4, T, P> const& m
)
GLM_FUNC_QUALIFIER mat<4, 4, T, P> extractMatrixRotation(mat<4, 4, T, P> const& m)
{
return mat<4, 4, T, P>(
m[0][0], m[0][1], m[0][2], 0.0,
m[1][0], m[1][1], m[1][2], 0.0,
m[2][0], m[2][1], m[2][2], 0.0,
0.0, 0.0, 0.0, 1.0);
m[0][0], m[0][1], m[0][2], static_cast<T>(0.0),
m[1][0], m[1][1], m[1][2], static_cast<T>(0.0),
m[2][0], m[2][1], m[2][2], static_cast<T>(0.0),
static_cast<T>(0.0), static_cast<T>(0.0), static_cast<T>(0.0), static_cast<T>(1.0));
}
template<typename T, precision P>
GLM_FUNC_QUALIFIER mat<4, 4, T, P> interpolate
(
mat<4, 4, T, P> const& m1,
mat<4, 4, T, P> const& m2,
T const delta
)
GLM_FUNC_QUALIFIER mat<4, 4, T, P> interpolate(mat<4, 4, T, P> const& m1, mat<4, 4, T, P> const& m2, T const delta)
{
mat<4, 4, T, P> m1rot = extractMatrixRotation(m1);
mat<4, 4, T, P> dltRotation = m2 * transpose(m1rot);