From 1c5fd06c2d9732158a87f22f78c13c2e7fe1ae13 Mon Sep 17 00:00:00 2001 From: Christophe Riccio Date: Thu, 1 Sep 2016 22:46:21 +0200 Subject: [PATCH] Fixed cast and clean up --- glm/gtc/bitfield.inl | 8 +- glm/gtc/color_space.inl | 16 +-- glm/gtc/matrix_transform.inl | 219 +++++++++++------------------------ glm/gtx/quaternion.inl | 70 +++-------- glm/gtx/transform.inl | 19 +-- glm/gtx/transform2.inl | 86 +++++--------- 6 files changed, 129 insertions(+), 289 deletions(-) diff --git a/glm/gtc/bitfield.inl b/glm/gtc/bitfield.inl index af522bdf..490cfb32 100644 --- a/glm/gtc/bitfield.inl +++ b/glm/gtc/bitfield.inl @@ -231,7 +231,7 @@ namespace detail } template class vecIUType> - GLM_FUNC_QUALIFIER vecIUType mask(vecIUType const & v) + GLM_FUNC_QUALIFIER vecIUType mask(vecIUType const& v) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'mask' accepts only integer values"); @@ -266,7 +266,7 @@ namespace detail } template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldRotateLeft(vecType const & In, int Shift) + GLM_FUNC_QUALIFIER vecType bitfieldRotateLeft(vecType const& In, int Shift) { GLM_STATIC_ASSERT(std::numeric_limits::is_integer, "'bitfieldRotateLeft' accepts only integer values"); @@ -281,7 +281,7 @@ namespace detail } template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldFillOne(vecType const & Value, int FirstBit, int BitCount) + GLM_FUNC_QUALIFIER vecType bitfieldFillOne(vecType const& Value, int FirstBit, int BitCount) { return Value | static_cast(mask(BitCount) << FirstBit); } @@ -293,7 +293,7 @@ namespace detail } template class vecType> - GLM_FUNC_QUALIFIER vecType bitfieldFillZero(vecType const & Value, int FirstBit, int BitCount) + GLM_FUNC_QUALIFIER vecType bitfieldFillZero(vecType const& Value, int FirstBit, int BitCount) { return Value & static_cast(~(mask(BitCount) << FirstBit)); } diff --git a/glm/gtc/color_space.inl b/glm/gtc/color_space.inl index 662e6d39..3fe293b0 100644 --- a/glm/gtc/color_space.inl +++ b/glm/gtc/color_space.inl @@ -7,7 +7,7 @@ namespace detail template class vecType> struct compute_rgbToSrgb { - GLM_FUNC_QUALIFIER static vecType call(vecType const & ColorRGB, T GammaCorrection) + GLM_FUNC_QUALIFIER static vecType call(vecType const& ColorRGB, T GammaCorrection) { vecType const ClampedColor(clamp(ColorRGB, static_cast(0), static_cast(1))); @@ -21,7 +21,7 @@ namespace detail template struct compute_rgbToSrgb { - GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & ColorRGB, T GammaCorrection) + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& ColorRGB, T GammaCorrection) { return tvec4(compute_rgbToSrgb::call(tvec3(ColorRGB), GammaCorrection), ColorRGB.a); } @@ -30,7 +30,7 @@ namespace detail template class vecType> struct compute_srgbToRgb { - GLM_FUNC_QUALIFIER static vecType call(vecType const & ColorSRGB, T Gamma) + GLM_FUNC_QUALIFIER static vecType call(vecType const& ColorSRGB, T Gamma) { return mix( pow((ColorSRGB + static_cast(0.055)) * static_cast(0.94786729857819905213270142180095), vecType(Gamma)), @@ -42,7 +42,7 @@ namespace detail template struct compute_srgbToRgb { - GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const & ColorSRGB, T Gamma) + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& ColorSRGB, T Gamma) { return tvec4(compute_srgbToRgb::call(tvec3(ColorSRGB), Gamma), ColorSRGB.a); } @@ -50,25 +50,25 @@ namespace detail }//namespace detail template class vecType> - GLM_FUNC_QUALIFIER vecType convertLinearToSRGB(vecType const & ColorLinear) + GLM_FUNC_QUALIFIER vecType convertLinearToSRGB(vecType const& ColorLinear) { return detail::compute_rgbToSrgb::call(ColorLinear, static_cast(0.41666)); } template class vecType> - GLM_FUNC_QUALIFIER vecType convertLinearToSRGB(vecType const & ColorLinear, T Gamma) + GLM_FUNC_QUALIFIER vecType convertLinearToSRGB(vecType const& ColorLinear, T Gamma) { return detail::compute_rgbToSrgb::call(ColorLinear, static_cast(1) / Gamma); } template class vecType> - GLM_FUNC_QUALIFIER vecType convertSRGBToLinear(vecType const & ColorSRGB) + GLM_FUNC_QUALIFIER vecType convertSRGBToLinear(vecType const& ColorSRGB) { return detail::compute_srgbToRgb::call(ColorSRGB, static_cast(2.4)); } template class vecType> - GLM_FUNC_QUALIFIER vecType convertSRGBToLinear(vecType const & ColorSRGB, T Gamma) + GLM_FUNC_QUALIFIER vecType convertSRGBToLinear(vecType const& ColorSRGB, T Gamma) { return detail::compute_srgbToRgb::call(ColorSRGB, Gamma); } diff --git a/glm/gtc/matrix_transform.inl b/glm/gtc/matrix_transform.inl index 9801a2e1..dac55a4a 100644 --- a/glm/gtc/matrix_transform.inl +++ b/glm/gtc/matrix_transform.inl @@ -8,11 +8,7 @@ namespace glm { template - GLM_FUNC_QUALIFIER tmat4x4 translate - ( - tmat4x4 const & m, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tmat4x4 translate(tmat4x4 const & m, tvec3 const & v) { tmat4x4 Result(m); Result[3] = m[0] * v[0] + m[1] * v[1] + m[2] * v[2] + m[3]; @@ -20,12 +16,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 rotate - ( - tmat4x4 const & m, - T angle, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tmat4x4 rotate(tmat4x4 const & m, T angle, tvec3 const & v) { T const a = angle; T const c = cos(a); @@ -36,15 +27,15 @@ namespace glm tmat4x4 Rotate(uninitialize); Rotate[0][0] = c + temp[0] * axis[0]; - Rotate[0][1] = 0 + temp[0] * axis[1] + s * axis[2]; - Rotate[0][2] = 0 + temp[0] * axis[2] - s * axis[1]; + Rotate[0][1] = temp[0] * axis[1] + s * axis[2]; + Rotate[0][2] = temp[0] * axis[2] - s * axis[1]; - Rotate[1][0] = 0 + temp[1] * axis[0] - s * axis[2]; + Rotate[1][0] = temp[1] * axis[0] - s * axis[2]; Rotate[1][1] = c + temp[1] * axis[1]; - Rotate[1][2] = 0 + temp[1] * axis[2] + s * axis[0]; + Rotate[1][2] = temp[1] * axis[2] + s * axis[0]; - Rotate[2][0] = 0 + temp[2] * axis[0] + s * axis[1]; - Rotate[2][1] = 0 + temp[2] * axis[1] - s * axis[0]; + Rotate[2][0] = temp[2] * axis[0] + s * axis[1]; + Rotate[2][1] = temp[2] * axis[1] - s * axis[0]; Rotate[2][2] = c + temp[2] * axis[2]; tmat4x4 Result(uninitialize); @@ -56,12 +47,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 rotate_slow - ( - tmat4x4 const & m, - T angle, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tmat4x4 rotate_slow(tmat4x4 const & m, T angle, tvec3 const & v) { T const a = angle; T const c = cos(a); @@ -70,31 +56,27 @@ namespace glm tvec3 axis = normalize(v); - Result[0][0] = c + (1 - c) * axis.x * axis.x; - Result[0][1] = (1 - c) * axis.x * axis.y + s * axis.z; - Result[0][2] = (1 - c) * axis.x * axis.z - s * axis.y; - Result[0][3] = 0; + Result[0][0] = c + (static_cast(1) - c) * axis.x * axis.x; + Result[0][1] = (static_cast(1) - c) * axis.x * axis.y + s * axis.z; + Result[0][2] = (static_cast(1) - c) * axis.x * axis.z - s * axis.y; + Result[0][3] = static_cast(0); - Result[1][0] = (1 - c) * axis.y * axis.x - s * axis.z; - Result[1][1] = c + (1 - c) * axis.y * axis.y; - Result[1][2] = (1 - c) * axis.y * axis.z + s * axis.x; - Result[1][3] = 0; + Result[1][0] = (static_cast(1) - c) * axis.y * axis.x - s * axis.z; + Result[1][1] = c + (static_cast(1) - c) * axis.y * axis.y; + Result[1][2] = (static_cast(1) - c) * axis.y * axis.z + s * axis.x; + Result[1][3] = static_cast(0); - Result[2][0] = (1 - c) * axis.z * axis.x + s * axis.y; - Result[2][1] = (1 - c) * axis.z * axis.y - s * axis.x; - Result[2][2] = c + (1 - c) * axis.z * axis.z; - Result[2][3] = 0; + Result[2][0] = (static_cast(1) - c) * axis.z * axis.x + s * axis.y; + Result[2][1] = (static_cast(1) - c) * axis.z * axis.y - s * axis.x; + Result[2][2] = c + (static_cast(1) - c) * axis.z * axis.z; + Result[2][3] = static_cast(0); Result[3] = tvec4(0, 0, 0, 1); return m * Result; } template - GLM_FUNC_QUALIFIER tmat4x4 scale - ( - tmat4x4 const & m, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tmat4x4 scale(tmat4x4 const & m, tvec3 const & v) { tmat4x4 Result(uninitialize); Result[0] = m[0] * v[0]; @@ -105,11 +87,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 scale_slow - ( - tmat4x4 const & m, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tmat4x4 scale_slow(tmat4x4 const & m, tvec3 const & v) { tmat4x4 Result(T(1)); Result[0][0] = v.x; @@ -267,13 +245,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 perspective - ( - T fovy, - T aspect, - T zNear, - T zFar - ) + GLM_FUNC_QUALIFIER tmat4x4 perspective(T fovy, T aspect, T zNear, T zFar) { # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED return perspectiveLH(fovy, aspect, zNear, zFar); @@ -283,12 +255,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 perspectiveRH - ( - T fovy, - T aspect, - T zNear, T zFar - ) + GLM_FUNC_QUALIFIER tmat4x4 perspectiveRH(T fovy, T aspect, T zNear, T zFar) { assert(abs(aspect - std::numeric_limits::epsilon()) > static_cast(0)); @@ -311,12 +278,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 perspectiveLH - ( - T fovy, - T aspect, - T zNear, T zFar - ) + GLM_FUNC_QUALIFIER tmat4x4 perspectiveLH(T fovy, T aspect, T zNear, T zFar) { assert(abs(aspect - std::numeric_limits::epsilon()) > static_cast(0)); @@ -339,12 +301,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 perspectiveFov - ( - T fov, - T width, T height, - T zNear, T zFar - ) + GLM_FUNC_QUALIFIER tmat4x4 perspectiveFov(T fov, T width, T height, T zNear, T zFar) { # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED return perspectiveFovLH(fov, width, height, zNear, zFar); @@ -354,12 +311,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 perspectiveFovRH - ( - T fov, - T width, T height, - T zNear, T zFar - ) + GLM_FUNC_QUALIFIER tmat4x4 perspectiveFovRH(T fov, T width, T height, T zNear, T zFar) { assert(width > static_cast(0)); assert(height > static_cast(0)); @@ -386,12 +338,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 perspectiveFovLH - ( - T fov, - T width, T height, - T zNear, T zFar - ) + GLM_FUNC_QUALIFIER tmat4x4 perspectiveFovLH(T fov, T width, T height, T zNear, T zFar) { assert(width > static_cast(0)); assert(height > static_cast(0)); @@ -418,12 +365,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 infinitePerspective - ( - T fovy, - T aspect, - T zNear - ) + GLM_FUNC_QUALIFIER tmat4x4 infinitePerspective(T fovy, T aspect, T zNear) { # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED return infinitePerspectiveLH(fovy, aspect, zNear); @@ -433,68 +375,52 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 infinitePerspectiveRH - ( - T fovy, - T aspect, - T zNear - ) + GLM_FUNC_QUALIFIER tmat4x4 infinitePerspectiveRH(T fovy, T aspect, T zNear) { - T const range = tan(fovy / T(2)) * zNear; + T const range = tan(fovy / static_cast(2)) * zNear; T const left = -range * aspect; T const right = range * aspect; T const bottom = -range; T const top = range; - tmat4x4 Result(T(0)); - Result[0][0] = (T(2) * zNear) / (right - left); - Result[1][1] = (T(2) * zNear) / (top - bottom); - Result[2][2] = - T(1); - Result[2][3] = - T(1); - Result[3][2] = - T(2) * zNear; + tmat4x4 Result(static_cast(0)); + Result[0][0] = (static_cast(2) * zNear) / (right - left); + Result[1][1] = (static_cast(2) * zNear) / (top - bottom); + Result[2][2] = - static_cast(1); + Result[2][3] = - static_cast(1); + Result[3][2] = - static_cast(2) * zNear; return Result; } template - GLM_FUNC_QUALIFIER tmat4x4 infinitePerspectiveLH - ( - T fovy, - T aspect, - T zNear - ) + GLM_FUNC_QUALIFIER tmat4x4 infinitePerspectiveLH(T fovy, T aspect, T zNear) { - T const range = tan(fovy / T(2)) * zNear; + T const range = tan(fovy / static_cast(2)) * zNear; T const left = -range * aspect; T const right = range * aspect; T const bottom = -range; T const top = range; tmat4x4 Result(T(0)); - Result[0][0] = (T(2) * zNear) / (right - left); - Result[1][1] = (T(2) * zNear) / (top - bottom); - Result[2][2] = T(1); - Result[2][3] = T(1); - Result[3][2] = - T(2) * zNear; + Result[0][0] = (static_cast(2) * zNear) / (right - left); + Result[1][1] = (static_cast(2) * zNear) / (top - bottom); + Result[2][2] = static_cast(1); + Result[2][3] = static_cast(1); + Result[3][2] = - static_cast(2) * zNear; return Result; } // Infinite projection matrix: http://www.terathon.com/gdc07_lengyel.pdf template - GLM_FUNC_QUALIFIER tmat4x4 tweakedInfinitePerspective - ( - T fovy, - T aspect, - T zNear, - T ep - ) + GLM_FUNC_QUALIFIER tmat4x4 tweakedInfinitePerspective(T fovy, T aspect, T zNear, T ep) { - T const range = tan(fovy / T(2)) * zNear; + T const range = tan(fovy / static_cast(2)) * zNear; T const left = -range * aspect; T const right = range * aspect; T const bottom = -range; T const top = range; - tmat4x4 Result(T(0)); + tmat4x4 Result(static_cast(0)); Result[0][0] = (static_cast(2) * zNear) / (right - left); Result[1][1] = (static_cast(2) * zNear) / (top - bottom); Result[2][2] = ep - static_cast(1); @@ -504,12 +430,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 tweakedInfinitePerspective - ( - T fovy, - T aspect, - T zNear - ) + GLM_FUNC_QUALIFIER tmat4x4 tweakedInfinitePerspective(T fovy, T aspect, T zNear) { return tweakedInfinitePerspective(fovy, aspect, zNear, epsilon()); } @@ -523,16 +444,16 @@ namespace glm tvec4 const & viewport ) { - tvec4 tmp = tvec4(obj, T(1)); + tvec4 tmp = tvec4(obj, static_cast(1)); tmp = model * tmp; tmp = proj * tmp; tmp /= tmp.w; # if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - tmp.x = tmp.x * T(0.5) + T(0.5); - tmp.y = tmp.y * T(0.5) + T(0.5); + tmp.x = tmp.x * static_cast(0.5) + static_cast(0.5); + tmp.y = tmp.y * static_cast(0.5) + static_cast(0.5); # else - tmp = tmp * T(0.5) + T(0.5); + tmp = tmp * static_cast(0.5) + static_cast(0.5); # endif tmp[0] = tmp[0] * T(viewport[2]) + T(viewport[0]); tmp[1] = tmp[1] * T(viewport[3]) + T(viewport[1]); @@ -555,10 +476,10 @@ namespace glm tmp.x = (tmp.x - T(viewport[0])) / T(viewport[2]); tmp.y = (tmp.y - T(viewport[1])) / T(viewport[3]); # if GLM_DEPTH_CLIP_SPACE == GLM_DEPTH_ZERO_TO_ONE - tmp.x = tmp.x * T(2) - T(1); - tmp.y = tmp.y * T(2) - T(1); + tmp.x = tmp.x * static_cast(2) - static_cast(1); + tmp.y = tmp.y * static_cast(2) - static_cast(1); # else - tmp = tmp * T(2) - T(1); + tmp = tmp * static_cast(2) - static_cast(1); # endif tvec4 obj = Inverse * tmp; @@ -568,36 +489,26 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 pickMatrix - ( - tvec2 const & center, - tvec2 const & delta, - tvec4 const & viewport - ) + GLM_FUNC_QUALIFIER tmat4x4 pickMatrix(tvec2 const & center, tvec2 const & delta, tvec4 const & viewport) { - assert(delta.x > T(0) && delta.y > T(0)); - tmat4x4 Result(1.0f); + assert(delta.x > static_cast(0) && delta.y > static_cast(0)); + tmat4x4 Result(static_cast(1)); - if(!(delta.x > T(0) && delta.y > T(0))) + if(!(delta.x > static_cast(0) && delta.y > static_cast(0))) return Result; // Error tvec3 Temp( - (T(viewport[2]) - T(2) * (center.x - T(viewport[0]))) / delta.x, - (T(viewport[3]) - T(2) * (center.y - T(viewport[1]))) / delta.y, - T(0)); + (static_cast(viewport[2]) - static_cast(2) * (center.x - static_cast(viewport[0]))) / delta.x, + (static_cast(viewport[3]) - static_cast(2) * (center.y - static_cast(viewport[1]))) / delta.y, + static_cast(0)); // Translate and scale the picked region to the entire window Result = translate(Result, Temp); - return scale(Result, tvec3(T(viewport[2]) / delta.x, T(viewport[3]) / delta.y, T(1))); + return scale(Result, tvec3(static_cast(viewport[2]) / delta.x, static_cast(viewport[3]) / delta.y, static_cast(1))); } template - GLM_FUNC_QUALIFIER tmat4x4 lookAt - ( - tvec3 const & eye, - tvec3 const & center, - tvec3 const & up - ) + GLM_FUNC_QUALIFIER tmat4x4 lookAt(tvec3 const & eye, tvec3 const & center, tvec3 const & up) { # if GLM_COORDINATE_SYSTEM == GLM_LEFT_HANDED return lookAtLH(eye, center, up); diff --git a/glm/gtx/quaternion.inl b/glm/gtx/quaternion.inl index ba43c220..1a31e947 100644 --- a/glm/gtx/quaternion.inl +++ b/glm/gtx/quaternion.inl @@ -7,21 +7,13 @@ namespace glm { template - GLM_FUNC_QUALIFIER tvec3 cross - ( - tvec3 const & v, - tquat const & q - ) + GLM_FUNC_QUALIFIER tvec3 cross(tvec3 const& v, tquat const& q) { return inverse(q) * v; } template - GLM_FUNC_QUALIFIER tvec3 cross - ( - tquat const & q, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tvec3 cross(tquat const& q, tvec3 const& v) { return q * v; } @@ -51,25 +43,19 @@ namespace glm } template - GLM_FUNC_QUALIFIER tquat exp - ( - tquat const & q - ) + GLM_FUNC_QUALIFIER tquat exp(tquat const& q) { tvec3 u(q.x, q.y, q.z); - T Angle = glm::length(u); + T const Angle = glm::length(u); if (Angle < epsilon()) return tquat(); - tvec3 v(u / Angle); + tvec3 const v(u / Angle); return tquat(cos(Angle), sin(Angle) * v); } template - GLM_FUNC_QUALIFIER tquat log - ( - tquat const & q - ) + GLM_FUNC_QUALIFIER tquat log(tquat const& q) { tvec3 u(q.x, q.y, q.z); T Vec3Len = length(u); @@ -110,36 +96,25 @@ namespace glm T Angle = acos(x.w / magnitude); T NewAngle = Angle * y; T Div = sin(NewAngle) / sin(Angle); - T Mag = pow(magnitude, y-1); + T Mag = pow(magnitude, y - static_cast(1)); return tquat(cos(NewAngle) * magnitude * Mag, x.x * Div * Mag, x.y * Div * Mag, x.z * Div * Mag); } template - GLM_FUNC_QUALIFIER tvec3 rotate - ( - tquat const & q, - tvec3 const & v - ) + GLM_FUNC_QUALIFIER tvec3 rotate(tquat const& q, tvec3 const& v) { return q * v; } template - GLM_FUNC_QUALIFIER tvec4 rotate - ( - tquat const & q, - tvec4 const & v - ) + GLM_FUNC_QUALIFIER tvec4 rotate(tquat const& q, tvec4 const& v) { return q * v; } template - GLM_FUNC_QUALIFIER T extractRealComponent - ( - tquat const & q - ) + GLM_FUNC_QUALIFIER T extractRealComponent(tquat const& q) { T w = static_cast(1) - q.x * q.x - q.y * q.y - q.z * q.z; if(w < T(0)) @@ -149,21 +124,13 @@ namespace glm } template - GLM_FUNC_QUALIFIER T length2 - ( - tquat const & q - ) + GLM_FUNC_QUALIFIER T length2(tquat const& q) { return q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w; } template - GLM_FUNC_QUALIFIER tquat shortMix - ( - tquat const & x, - tquat const & y, - T const & a - ) + GLM_FUNC_QUALIFIER tquat shortMix(tquat const& x, tquat const& y, T const& a) { if(a <= static_cast(0)) return x; if(a >= static_cast(1)) return y; @@ -200,22 +167,13 @@ namespace glm } template - GLM_FUNC_QUALIFIER tquat fastMix - ( - tquat const & x, - tquat const & y, - T const & a - ) + GLM_FUNC_QUALIFIER tquat fastMix(tquat const& x, tquat const& y, T const & a) { return glm::normalize(x * (static_cast(1) - a) + (y * a)); } template - GLM_FUNC_QUALIFIER tquat rotation - ( - tvec3 const & orig, - tvec3 const & dest - ) + GLM_FUNC_QUALIFIER tquat rotation(tvec3 const& orig, tvec3 const& dest) { T cosTheta = dot(orig, dest); tvec3 rotationAxis; diff --git a/glm/gtx/transform.inl b/glm/gtx/transform.inl index fc228ce8..516d8661 100644 --- a/glm/gtx/transform.inl +++ b/glm/gtx/transform.inl @@ -4,28 +4,21 @@ namespace glm { template - GLM_FUNC_QUALIFIER tmat4x4 translate( - tvec3 const & v) + GLM_FUNC_QUALIFIER tmat4x4 translate(tvec3 const & v) { - return translate( - tmat4x4(1.0f), v); + return translate(tmat4x4(static_cast(1)), v); } template - GLM_FUNC_QUALIFIER tmat4x4 rotate( - T angle, - tvec3 const & v) + GLM_FUNC_QUALIFIER tmat4x4 rotate(T angle, tvec3 const & v) { - return rotate( - tmat4x4(1), angle, v); + return rotate(tmat4x4(static_cast(1)), angle, v); } template - GLM_FUNC_QUALIFIER tmat4x4 scale( - tvec3 const & v) + GLM_FUNC_QUALIFIER tmat4x4 scale(tvec3 const & v) { - return scale( - tmat4x4(1.0f), v); + return scale(tmat4x4(static_cast(1)), v); } }//namespace glm diff --git a/glm/gtx/transform2.inl b/glm/gtx/transform2.inl index 038bd956..b65bd3db 100644 --- a/glm/gtx/transform2.inl +++ b/glm/gtx/transform2.inl @@ -4,9 +4,7 @@ namespace glm { template - GLM_FUNC_QUALIFIER tmat3x3 shearX2D( - const tmat3x3& m, - T s) + GLM_FUNC_QUALIFIER tmat3x3 shearX2D(tmat3x3 const& m, T s) { tmat3x3 r(1); r[0][1] = s; @@ -14,9 +12,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat3x3 shearY2D( - const tmat3x3& m, - T s) + GLM_FUNC_QUALIFIER tmat3x3 shearY2D(tmat3x3 const& m, T s) { tmat3x3 r(1); r[1][0] = s; @@ -24,10 +20,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 shearX3D( - const tmat4x4& m, - T s, - T t) + GLM_FUNC_QUALIFIER tmat4x4 shearX3D(tmat4x4 const& m, T s, T t) { tmat4x4 r(1); r[1][0] = s; @@ -36,10 +29,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 shearY3D( - const tmat4x4& m, - T s, - T t) + GLM_FUNC_QUALIFIER tmat4x4 shearY3D(tmat4x4 const& m, T s, T t) { tmat4x4 r(1); r[0][1] = s; @@ -48,10 +38,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 shearZ3D( - const tmat4x4& m, - T s, - T t) + GLM_FUNC_QUALIFIER tmat4x4 shearZ3D(tmat4x4 const& m, T s, T t) { tmat4x4 r(1); r[0][2] = s; @@ -60,35 +47,31 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat3x3 reflect2D( - const tmat3x3& m, - const tvec3& normal) + GLM_FUNC_QUALIFIER tmat3x3 reflect2D(tmat3x3 const& m, tvec3 const& normal) { - tmat3x3 r(1); - r[0][0] = 1 - 2 * normal.x * normal.x; - r[0][1] = -2 * normal.x * normal.y; - r[1][0] = -2 * normal.x * normal.y; - r[1][1] = 1 - 2 * normal.y * normal.y; + tmat3x3 r(static_cast(1)); + r[0][0] = static_cast(1) - static_cast(2) * normal.x * normal.x; + r[0][1] = -static_cast(2) * normal.x * normal.y; + r[1][0] = -static_cast(2) * normal.x * normal.y; + r[1][1] = static_cast(1) - static_cast(2) * normal.y * normal.y; return m * r; } template - GLM_FUNC_QUALIFIER tmat4x4 reflect3D( - const tmat4x4& m, - const tvec3& normal) + GLM_FUNC_QUALIFIER tmat4x4 reflect3D(tmat4x4 const& m, tvec3 const& normal) { - tmat4x4 r(1); - r[0][0] = 1 - 2 * normal.x * normal.x; - r[0][1] = -2 * normal.x * normal.y; - r[0][2] = -2 * normal.x * normal.z; + tmat4x4 r(static_cast(1)); + r[0][0] = static_cast(1) - static_cast(2) * normal.x * normal.x; + r[0][1] = -static_cast(2) * normal.x * normal.y; + r[0][2] = -static_cast(2) * normal.x * normal.z; - r[1][0] = -2 * normal.x * normal.y; - r[1][1] = 1 - 2 * normal.y * normal.y; - r[1][2] = -2 * normal.y * normal.z; + r[1][0] = -static_cast(2) * normal.x * normal.y; + r[1][1] = static_cast(1) - static_cast(2) * normal.y * normal.y; + r[1][2] = -static_cast(2) * normal.y * normal.z; - r[2][0] = -2 * normal.x * normal.z; - r[2][1] = -2 * normal.y * normal.z; - r[2][2] = 1 - 2 * normal.z * normal.z; + r[2][0] = -static_cast(2) * normal.x * normal.z; + r[2][1] = -static_cast(2) * normal.y * normal.z; + r[2][2] = static_cast(1) - static_cast(2) * normal.z * normal.z; return m * r; } @@ -97,11 +80,11 @@ namespace glm const tmat3x3& m, const tvec3& normal) { - tmat3x3 r(1); - r[0][0] = 1 - normal.x * normal.x; + tmat3x3 r(static_cast(1)); + r[0][0] = static_cast(1) - normal.x * normal.x; r[0][1] = - normal.x * normal.y; r[1][0] = - normal.x * normal.y; - r[1][1] = 1 - normal.y * normal.y; + r[1][1] = static_cast(1) - normal.y * normal.y; return m * r; } @@ -110,26 +93,24 @@ namespace glm const tmat4x4& m, const tvec3& normal) { - tmat4x4 r(1); - r[0][0] = 1 - normal.x * normal.x; + tmat4x4 r(static_cast(1)); + r[0][0] = static_cast(1) - normal.x * normal.x; r[0][1] = - normal.x * normal.y; r[0][2] = - normal.x * normal.z; r[1][0] = - normal.x * normal.y; - r[1][1] = 1 - normal.y * normal.y; + r[1][1] = static_cast(1) - normal.y * normal.y; r[1][2] = - normal.y * normal.z; r[2][0] = - normal.x * normal.z; r[2][1] = - normal.y * normal.z; - r[2][2] = 1 - normal.z * normal.z; + r[2][2] = static_cast(1) - normal.z * normal.z; return m * r; } template - GLM_FUNC_QUALIFIER tmat4x4 scaleBias( - T scale, - T bias) + GLM_FUNC_QUALIFIER tmat4x4 scaleBias(T scale, T bias) { tmat4x4 result; - result[3] = tvec4(tvec3(bias), T(1)); + result[3] = tvec4(tvec3(bias), static_cast(1)); result[0][0] = scale; result[1][1] = scale; result[2][2] = scale; @@ -137,10 +118,7 @@ namespace glm } template - GLM_FUNC_QUALIFIER tmat4x4 scaleBias( - const tmat4x4& m, - T scale, - T bias) + GLM_FUNC_QUALIFIER tmat4x4 scaleBias(tmat4x4 const& m, T scale, T bias) { return m * scaleBias(scale, bias); }