Deprecated degrees, display a message for each function using it.

This commit is contained in:
Christophe Riccio 2013-12-26 18:58:44 +01:00
parent 36de7ea9e9
commit 1909f512e7
8 changed files with 36 additions and 6 deletions

View File

@ -75,6 +75,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
T a = angle;
#else
# pragma message("GLM: rotate function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T a = radians(angle);
#endif
T c = cos(a);
@ -116,6 +117,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
T const a = angle;
#else
# pragma message("GLM: rotate_slow function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const a = radians(angle);
#endif
T c = cos(a);
@ -248,6 +250,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
valType const rad = fovy;
#else
# pragma message("GLM: perspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
valType const rad = glm::radians(fovy);
#endif
@ -279,6 +282,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
valType rad = fov;
#else
# pragma message("GLM: perspectiveFov function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
valType rad = glm::radians(fov);
#endif
valType h = glm::cos(valType(0.5) * rad) / glm::sin(valType(0.5) * rad);
@ -304,6 +308,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
T const range = tan(fovy / T(2)) * zNear;
#else
# pragma message("GLM: infinitePerspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const range = tan(radians(fovy / T(2))) * zNear;
#endif
T left = -range * aspect;
@ -331,6 +336,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
T range = tan(fovy / T(2)) * zNear;
#else
# pragma message("GLM: tweakedInfinitePerspective function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T range = tan(radians(fovy / T(2))) * zNear;
#endif
T left = -range * aspect;

View File

@ -617,7 +617,7 @@ namespace detail
GLM_FUNC_QUALIFIER detail::tquat<T, P> rotate
(
detail::tquat<T, P> const & q,
typename detail::tquat<T, P>::T const & angle,
typename detail::tquat<T, P>::value_type const & angle,
detail::tvec3<T, P> const & v
)
{
@ -636,6 +636,7 @@ namespace detail
#ifdef GLM_FORCE_RADIANS
T const AngleRad(angle);
#else
# pragma message("GLM: rotate function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const AngleRad = radians(angle);
#endif
T const Sin = sin(AngleRad * T(0.5));
@ -662,6 +663,7 @@ namespace detail
#ifdef GLM_FORCE_RADIANS
return T(atan2(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));
#else
# pragma message("GLM: roll function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return glm::degrees(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));
#endif
}
@ -675,6 +677,7 @@ namespace detail
#ifdef GLM_FORCE_RADIANS
return T(atan2(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));
#else
# pragma message("GLM: pitch function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return glm::degrees(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));
#endif
}
@ -688,6 +691,7 @@ namespace detail
#ifdef GLM_FORCE_RADIANS
return asin(T(-2) * (q.x * q.z - q.w * q.y));
#else
# pragma message("GLM: yaw function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return glm::degrees(asin(T(-2) * (q.x * q.z - q.w * q.y)));
#endif
}
@ -817,6 +821,7 @@ namespace detail
#ifdef GLM_FORCE_RADIANS
return acos(x.w) * T(2);
#else
# pragma message("GLM: angle function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return glm::degrees(acos(x.w) * T(2));
#endif
}
@ -846,6 +851,7 @@ namespace detail
#ifdef GLM_FORCE_RADIANS
T const a(angle);
#else
# pragma message("GLM: angleAxis function taking degrees as a parameter is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const a(glm::radians(angle));
#endif
T s = glm::sin(a * T(0.5));

View File

@ -25,6 +25,7 @@ namespace glm
atan(tmp.x, tmp.z), // longitude
xz_dist); // xz distance
#else
# pragma message("GLM: polar function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return detail::tvec3<T, P>(
degrees(atan(xz_dist, tmp.y)), // latitude
degrees(atan(tmp.x, tmp.z)), // longitude
@ -42,6 +43,7 @@ namespace glm
T const latitude(polar.x);
T const longitude(polar.y);
#else
# pragma message("GLM: euclidean function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const latitude(radians(polar.x));
T const longitude(radians(polar.y));
#endif

View File

@ -39,6 +39,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
T a = angle;
#else
# pragma message("GLM: rotateNormalizedAxis function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T a = radians(angle);
#endif
T c = cos(a);
@ -82,6 +83,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
T const AngleRad(angle);
#else
# pragma message("GLM: rotateNormalizedAxis function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const AngleRad = radians(angle);
#endif
T const Sin = sin(AngleRad * T(0.5));

View File

@ -21,6 +21,7 @@ namespace glm
T const Cos(cos(angle));
T const Sin(sin(angle));
#else
# pragma message("GLM: rotate function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const Cos = cos(radians(angle));
T const Sin = sin(radians(angle));
#endif
@ -75,6 +76,7 @@ namespace glm
T const Cos(cos(angle));
T const Sin(sin(angle));
#else
# pragma message("GLM: rotateX function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const Cos = cos(radians(angle));
T const Sin = sin(radians(angle));
#endif
@ -97,6 +99,7 @@ namespace glm
T const Cos(cos(angle));
T const Sin(sin(angle));
#else
# pragma message("GLM: rotateY function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const Cos(cos(radians(angle)));
T const Sin(sin(radians(angle)));
#endif
@ -119,6 +122,7 @@ namespace glm
T const Cos(cos(angle));
T const Sin(sin(angle));
#else
# pragma message("GLM: rotateZ function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const Cos(cos(radians(angle)));
T const Sin(sin(radians(angle)));
#endif
@ -141,6 +145,7 @@ namespace glm
T const Cos(cos(angle));
T const Sin(sin(angle));
#else
# pragma message("GLM: rotateX function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const Cos(cos(radians(angle)));
T const Sin(sin(radians(angle)));
#endif
@ -163,6 +168,7 @@ namespace glm
T const Cos(cos(angle));
T const Sin(sin(angle));
#else
# pragma message("GLM: rotateX function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const Cos(cos(radians(angle)));
T const Sin(sin(radians(angle)));
#endif
@ -185,6 +191,7 @@ namespace glm
T const Cos(cos(angle));
T const Sin(sin(angle));
#else
# pragma message("GLM: rotateZ function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const Cos(cos(radians(angle)));
T const Sin(sin(radians(angle)));
#endif
@ -208,6 +215,7 @@ namespace glm
# ifdef GLM_FORCE_RADIANS
T Angle = acos(dot(Normal, Up));
# else
# pragma message("GLM: rotateZ function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T Angle = degrees(acos(dot(Normal, Up)));
# endif
return rotate(Angle, RotationAxis);

View File

@ -584,15 +584,16 @@ GLM_FUNC_QUALIFIER detail::fquatSIMD angleAxisSIMD
#ifdef GLM_FORCE_RADIANS
float a(angle);
#else
# pragma message("GLM: rotateZ function taking degrees as parameters is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
float a(glm::radians(angle));
#endif
float s = glm::sin(a * 0.5f);
return _mm_set_ps(
glm::cos(a * 0.5f),
v.z * s,
v.y * s,
v.x * s);
return _mm_set_ps(
glm::cos(a * 0.5f),
v.z * s,
v.y * s,
v.x * s);
}
GLM_FUNC_QUALIFIER detail::fquatSIMD angleAxisSIMD

View File

@ -23,6 +23,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
return Angle;
#else
# pragma message("GLM: angle function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return degrees(Angle);
#endif
}
@ -41,6 +42,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
return Angle;
#else
# pragma message("GLM: angle function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
return degrees(Angle);
#endif
}
@ -60,6 +62,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
T const Angle(acos(Dot));
#else
# pragma message("GLM: orientedAngle function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const Angle(degrees(acos(Dot)));
#endif
detail::tvec2<T, P> const TransformedVector(glm::rotate(x, Angle));
@ -84,6 +87,7 @@ namespace glm
#ifdef GLM_FORCE_RADIANS
T const Angle(acos(Dot));
#else
# pragma message("GLM: orientedAngle function returning degrees is deprecated. #define GLM_FORCE_RADIANS before including GLM headers to remove this message.")
T const Angle(degrees(acos(Dot)));
#endif

View File

@ -40,6 +40,7 @@ http://glm.g-truc.net/glm.pdf
GLM 0.9.5.1: 2014-XX-XX
--------------------------------------------------------------------------------
- Fixed angle and orientedAngle that sometimes return NaN values (#145)
- Deprecated degrees for function parameters and display a message.
================================================================================
GLM 0.9.5.0: 2013-12-25