diff --git a/glm/gtx/associated_min_max.hpp b/glm/gtx/associated_min_max.hpp index 23f37ca9..a5ffd8df 100644 --- a/glm/gtx/associated_min_max.hpp +++ b/glm/gtx/associated_min_max.hpp @@ -22,7 +22,7 @@ /// /// @ref gtx_associated_min_max /// @file glm/gtx/associated_min_max.hpp -/// @date 2008-03-10 / 2011-06-07 +/// @date 2008-03-10 / 2014-10-11 /// @author Christophe Riccio /// /// @see core (dependence) @@ -49,53 +49,177 @@ namespace glm /// @addtogroup gtx_associated_min_max /// @{ - /// Min comparison between 2 variables + /// Minimum comparison between 2 variables and returns 2 associated variable values /// @see gtx_associated_min_max - template - GLM_FUNC_DECL genTypeU associatedMin( - const genTypeT& x, const genTypeU& a, - const genTypeT& y, const genTypeU& b); + template + GLM_FUNC_DECL U associatedMin(T x, U a, T y, U b); - /// Min comparison between 3 variables + /// Minimum comparison between 2 variables and returns 2 associated variable values /// @see gtx_associated_min_max - template - GLM_FUNC_DECL genTypeU associatedMin( - const genTypeT& x, const genTypeU& a, - const genTypeT& y, const genTypeU& b, - const genTypeT& z, const genTypeU& c); + template class vecType> + GLM_FUNC_DECL tvec2 associatedMin( + vecType const & x, vecType const & a, + vecType const & y, vecType const & b); - /// Min comparison between 4 variables + /// Minimum comparison between 2 variables and returns 2 associated variable values /// @see gtx_associated_min_max - template - GLM_FUNC_DECL genTypeU associatedMin( - const genTypeT& x, const genTypeU& a, - const genTypeT& y, const genTypeU& b, - const genTypeT& z, const genTypeU& c, - const genTypeT& w, const genTypeU& d); + template class vecType> + GLM_FUNC_DECL vecType associatedMin( + T x, const vecType& a, + T y, const vecType& b); - /// Max comparison between 2 variables + /// Minimum comparison between 2 variables and returns 2 associated variable values /// @see gtx_associated_min_max - template - GLM_FUNC_DECL genTypeU associatedMax( - const genTypeT& x, const genTypeU& a, - const genTypeT& y, const genTypeU& b); + template class vecType> + GLM_FUNC_DECL vecType associatedMin( + vecType const & x, U a, + vecType const & y, U b); - /// Max comparison between 3 variables + /// Minimum comparison between 3 variables and returns 3 associated variable values /// @see gtx_associated_min_max - template - GLM_FUNC_DECL genTypeU associatedMax( - const genTypeT& x, const genTypeU& a, - const genTypeT& y, const genTypeU& b, - const genTypeT& z, const genTypeU& c); + template + GLM_FUNC_DECL U associatedMin( + T x, U a, + T y, U b, + T z, U c); - /// Max comparison between 4 variables + /// Minimum comparison between 3 variables and returns 3 associated variable values /// @see gtx_associated_min_max - template - GLM_FUNC_DECL genTypeU associatedMax( - const genTypeT& x, const genTypeU& a, - const genTypeT& y, const genTypeU& b, - const genTypeT& z, const genTypeU& c, - const genTypeT& w, const genTypeU& d); + template class vecType> + GLM_FUNC_DECL vecType associatedMin( + vecType const & x, vecType const & a, + vecType const & y, vecType const & b, + vecType const & z, vecType const & c); + + /// Minimum comparison between 4 variables and returns 4 associated variable values + /// @see gtx_associated_min_max + template + GLM_FUNC_DECL U associatedMin( + T x, U a, + T y, U b, + T z, U c, + T w, U d); + + /// Minimum comparison between 4 variables and returns 4 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMin( + vecType const & x, vecType const & a, + vecType const & y, vecType const & b, + vecType const & z, vecType const & c, + vecType const & w, vecType const & d); + + /// Minimum comparison between 4 variables and returns 4 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMin( + T x, vecType const & a, + T y, vecType const & b, + T z, vecType const & c, + T w, vecType const & d); + + /// Minimum comparison between 4 variables and returns 4 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMin( + vecType const & x, U a, + vecType const & y, U b, + vecType const & z, U c, + vecType const & w, U d); + + /// Maximum comparison between 2 variables and returns 2 associated variable values + /// @see gtx_associated_min_max + template + GLM_FUNC_DECL U associatedMax(T x, U a, T y, U b); + + /// Maximum comparison between 2 variables and returns 2 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL tvec2 associatedMax( + vecType const & x, vecType const & a, + vecType const & y, vecType const & b); + + /// Maximum comparison between 2 variables and returns 2 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMax( + T x, vecType const & a, + T y, vecType const & b); + + /// Maximum comparison between 2 variables and returns 2 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMax( + vecType const & x, U a, + vecType const & y, U b); + + /// Maximum comparison between 3 variables and returns 3 associated variable values + /// @see gtx_associated_min_max + template + GLM_FUNC_DECL U associatedMax( + T x, U a, + T y, U b, + T z, U c); + + /// Maximum comparison between 3 variables and returns 3 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMax( + vecType const & x, vecType const & a, + vecType const & y, vecType const & b, + vecType const & z, vecType const & c); + + /// Maximum comparison between 3 variables and returns 3 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMax( + T x, vecType const & a, + T y, vecType const & b, + T z, vecType const & c); + + /// Maximum comparison between 3 variables and returns 3 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMax( + vecType const & x, U a, + vecType const & y, U b, + vecType const & z, U c); + + /// Maximum comparison between 4 variables and returns 4 associated variable values + /// @see gtx_associated_min_max + template + GLM_FUNC_DECL U associatedMax( + T x, U a, + T y, U b, + T z, U c, + T w, U d); + + /// Maximum comparison between 4 variables and returns 4 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMax( + vecType const & x, vecType const & a, + vecType const & y, vecType const & b, + vecType const & z, vecType const & c, + vecType const & w, vecType const & d); + + /// Maximum comparison between 4 variables and returns 4 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMax( + T x, vecType const & a, + T y, vecType const & b, + T z, vecType const & c, + T w, vecType const & d); + + /// Maximum comparison between 4 variables and returns 4 associated variable values + /// @see gtx_associated_min_max + template class vecType> + GLM_FUNC_DECL vecType associatedMax( + vecType const & x, U a, + vecType const & y, U b, + vecType const & z, U c, + vecType const & w, U d); /// @} } //namespace glm diff --git a/glm/gtx/associated_min_max.inl b/glm/gtx/associated_min_max.inl index cbb60c79..028cdd66 100644 --- a/glm/gtx/associated_min_max.inl +++ b/glm/gtx/associated_min_max.inl @@ -2,7 +2,7 @@ // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) /////////////////////////////////////////////////////////////////////////////////////////////////// // Created : 2008-03-10 -// Updated : 2008-03-15 +// Updated : 2014-10-11 // Licence : This source is under MIT License // File : gtx_associated_min_max.inl /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -16,118 +16,40 @@ GLM_FUNC_QUALIFIER U associatedMin(T x, U a, T y, U b) return x < y ? a : b; } -template +template class vecType> GLM_FUNC_QUALIFIER tvec2 associatedMin ( - const tvec2& x, const tvec2& a, - const tvec2& y, const tvec2& b + vecType const & x, vecType const & a, + vecType const & y, vecType const & b ) { - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) Result[i] = x[i] < y[i] ? a[i] : b[i]; return Result; } -template -GLM_FUNC_QUALIFIER tvec3 associatedMin +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMin ( - const tvec3& x, const tvec3& a, - const tvec3& y, const tvec3& b + T x, const vecType& a, + T y, const vecType& b ) { - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] < y[i] ? a[i] : b[i]; - return Result; -} - -template -GLM_FUNC_QUALIFIER tvec4 associatedMin -( - const tvec4& x, const tvec4& a, - const tvec4& y, const tvec4& b -) -{ - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] < y[i] ? a[i] : b[i]; - return Result; -} - -template -GLM_FUNC_QUALIFIER tvec2 associatedMin -( - T x, const tvec2& a, - T y, const tvec2& b -) -{ - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) Result[i] = x < y ? a[i] : b[i]; return Result; } -template -GLM_FUNC_QUALIFIER tvec3 associatedMin +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMin ( - T x, const tvec3& a, - T y, const tvec3& b + vecType const & x, U a, + vecType const & y, U b ) { - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x < y ? a[i] : b[i]; - return Result; -} - -template -GLM_FUNC_QUALIFIER tvec4 associatedMin -( - T x, const tvec4& a, - T y, const tvec4& b -) -{ - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x < y ? a[i] : b[i]; - return Result; -} - -template -GLM_FUNC_QUALIFIER tvec2 associatedMin -( - tvec2 const & x, U a, - tvec2 const & y, U b -) -{ - tvec2 Result(tvec2::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] < y[i] ? a : b; - return Result; -} - -template -GLM_FUNC_QUALIFIER tvec3 associatedMin -( - tvec3 const & x, U a, - tvec3 const & y, U b -) -{ - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] < y[i] ? a : b; - return Result; -} - -template -GLM_FUNC_QUALIFIER tvec4 associatedMin -( - const tvec4& x, U a, - const tvec4& y, U b -) -{ - tvec4 Result(tvec4::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) Result[i] = x[i] < y[i] ? a : b; return Result; @@ -146,43 +68,15 @@ GLM_FUNC_QUALIFIER U associatedMin return Result; } -template -GLM_FUNC_QUALIFIER tvec2 associatedMin +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMin ( - const tvec2& x, const tvec2& a, - const tvec2& y, const tvec2& b, - const tvec2& z, const tvec2& c + vecType const & x, vecType const & a, + vecType const & y, vecType const & b, + vecType const & z, vecType const & c ) { - tvec2 Result(tvec2::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); - return Result; -} - -template -GLM_FUNC_QUALIFIER tvec3 associatedMin -( - const tvec3& x, const tvec3& a, - const tvec3& y, const tvec3& b, - const tvec3& z, const tvec3& c -) -{ - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); - return Result; -} - -template -GLM_FUNC_QUALIFIER tvec4 associatedMin -( - const tvec4& x, const tvec4& a, - const tvec4& y, const tvec4& b, - const tvec4& z, const tvec4& c -) -{ - tvec4 Result(tvec4::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]); return Result; @@ -207,16 +101,16 @@ GLM_FUNC_QUALIFIER U associatedMin } // Min comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMin +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMin ( - const tvec2& x, const tvec2& a, - const tvec2& y, const tvec2& b, - const tvec2& z, const tvec2& c, - const tvec2& w, const tvec2& d + vecType const & x, vecType const & a, + vecType const & y, vecType const & b, + vecType const & z, vecType const & c, + vecType const & w, vecType const & d ) { - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) { T Test1 = min(x[i], y[i]); @@ -229,63 +123,19 @@ GLM_FUNC_QUALIFIER tvec2 associatedMin } // Min comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMin +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMin ( - const tvec3& x, const tvec3& a, - const tvec3& y, const tvec3& b, - const tvec3& z, const tvec3& c, - const tvec3& w, const tvec3& d -) -{ - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - T Test1 = min(x[i], y[i]); - T Test2 = min(z[i], w[i]); - U Result1 = x[i] < y[i] ? a[i] : b[i]; - U Result2 = z[i] < w[i] ? c[i] : d[i]; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; -} - -// Min comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMin -( - const tvec4& x, const tvec4& a, - const tvec4& y, const tvec4& b, - const tvec4& z, const tvec4& c, - const tvec4& w, const tvec4& d -) -{ - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - T Test1 = min(x[i], y[i]); - T Test2 = min(z[i], w[i]); - U Result1 = x[i] < y[i] ? a[i] : b[i]; - U Result2 = z[i] < w[i] ? c[i] : d[i]; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; -} - -// Min comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMin -( - T x, const tvec2& a, - T y, const tvec2& b, - T z, const tvec2& c, - T w, const tvec2& d + T x, vecType const & a, + T y, vecType const & b, + T z, vecType const & c, + T w, vecType const & d ) { T Test1 = min(x, y); T Test2 = min(z, w); - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) { U Result1 = x < y ? a[i] : b[i]; @@ -296,106 +146,16 @@ GLM_FUNC_QUALIFIER tvec2 associatedMin } // Min comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMin +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMin ( - T x, const tvec3& a, - T y, const tvec3& b, - T z, const tvec3& c, - T w, const tvec3& d + vecType const & x, U a, + vecType const & y, U b, + vecType const & z, U c, + vecType const & w, U d ) { - T Test1 = min(x, y); - T Test2 = min(z, w); - - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - U Result1 = x < y ? a[i] : b[i]; - U Result2 = z < w ? c[i] : d[i]; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; -} - -// Min comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMin -( - T x, const tvec4& a, - T y, const tvec4& b, - T z, const tvec4& c, - T w, const tvec4& d -) -{ - T Test1 = min(x, y); - T Test2 = min(z, w); - - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - U Result1 = x < y ? a[i] : b[i]; - U Result2 = z < w ? c[i] : d[i]; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; -} - -// Min comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMin -( - const tvec2& x, U a, - const tvec2& y, U b, - const tvec2& z, U c, - const tvec2& w, U d -) -{ - tvec2 Result(tvec2::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - T Test1 = min(x[i], y[i]); - T Test2 = min(z[i], w[i]);; - U Result1 = x[i] < y[i] ? a : b; - U Result2 = z[i] < w[i] ? c : d; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; -} - -// Min comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMin -( - const tvec3& x, U a, - const tvec3& y, U b, - const tvec3& z, U c, - const tvec3& w, U d -) -{ - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - T Test1 = min(x[i], y[i]); - T Test2 = min(z[i], w[i]);; - U Result1 = x[i] < y[i] ? a : b; - U Result2 = z[i] < w[i] ? c : d; - Result[i] = Test1 < Test2 ? Result1 : Result2; - } - return Result; -} - -// Min comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMin -( - const tvec4& x, U a, - const tvec4& y, U b, - const tvec4& z, U c, - const tvec4& w, U d -) -{ - tvec4 Result(tvec4::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) { T Test1 = min(x[i], y[i]); @@ -415,126 +175,42 @@ GLM_FUNC_QUALIFIER U associatedMax(T x, U a, T y, U b) } // Max comparison between 2 variables -template +template class vecType> GLM_FUNC_QUALIFIER tvec2 associatedMax ( - const tvec2& x, const tvec2& a, - const tvec2& y, const tvec2& b + vecType const & x, vecType const & a, + vecType const & y, vecType const & b ) { - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) Result[i] = x[i] > y[i] ? a[i] : b[i]; return Result; } // Max comparison between 2 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMax +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMax ( - const tvec3& x, const tvec3& a, - const tvec3& y, const tvec3& b + T x, vecType const & a, + T y, vecType const & b ) { - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] > y[i] ? a[i] : b[i]; - return Result; -} - -// Max comparison between 2 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMax -( - const tvec4& x, const tvec4& a, - const tvec4& y, const tvec4& b -) -{ - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] > y[i] ? a[i] : b[i]; - return Result; -} - -// Max comparison between 2 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMax -( - T x, const tvec2& a, - T y, const tvec2& b -) -{ - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) Result[i] = x > y ? a[i] : b[i]; return Result; } // Max comparison between 2 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMax +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMax ( - T x, const tvec3& a, - T y, const tvec3& b + vecType const & x, U a, + vecType const & y, U b ) { - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x > y ? a[i] : b[i]; - return Result; -} - -// Max comparison between 2 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMax -( - T x, const tvec4& a, - T y, const tvec4& b -) -{ - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x > y ? a[i] : b[i]; - return Result; -} - -// Max comparison between 2 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMax -( - const tvec2& x, U a, - const tvec2& y, U b -) -{ - tvec2 Result(tvec2::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] > y[i] ? a : b; - return Result; -} - -// Max comparison between 2 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMax -( - const tvec3& x, U a, - const tvec3& y, U b -) -{ - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] > y[i] ? a : b; - return Result; -} - -// Max comparison between 2 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMax -( - const tvec4& x, U a, - const tvec4& y, U b -) -{ - tvec4 Result(tvec4::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) Result[i] = x[i] > y[i] ? a : b; return Result; @@ -554,135 +230,45 @@ GLM_FUNC_QUALIFIER U associatedMax } // Max comparison between 3 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMax +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMax ( - const tvec2& x, const tvec2& a, - const tvec2& y, const tvec2& b, - const tvec2& z, const tvec2& c + vecType const & x, vecType const & a, + vecType const & y, vecType const & b, + vecType const & z, vecType const & c ) { - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); return Result; } // Max comparison between 3 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMax +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMax ( - const tvec3& x, const tvec3& a, - const tvec3& y, const tvec3& b, - const tvec3& z, const tvec3& c + T x, vecType const & a, + T y, vecType const & b, + T z, vecType const & c ) { - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); - return Result; -} - -// Max comparison between 3 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMax -( - const tvec4& x, const tvec4& a, - const tvec4& y, const tvec4& b, - const tvec4& z, const tvec4& c -) -{ - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]); - return Result; -} - -// Max comparison between 3 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMax -( - T x, const tvec2& a, - T y, const tvec2& b, - T z, const tvec2& c -) -{ - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); return Result; } // Max comparison between 3 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMax +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMax ( - T x, const tvec3& a, - T y, const tvec3& b, - T z, const tvec3& c + vecType const & x, U a, + vecType const & y, U b, + vecType const & z, U c ) { - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); - return Result; -} - -// Max comparison between 3 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMax -( - T x, const tvec4& a, - T y, const tvec4& b, - T z, const tvec4& c -) -{ - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]); - return Result; -} - -// Max comparison between 3 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMax -( - const tvec2& x, U a, - const tvec2& y, U b, - const tvec2& z, U c -) -{ - tvec2 Result(tvec2::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); - return Result; -} - -// Max comparison between 3 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMax -( - const tvec3& x, U a, - const tvec3& y, U b, - const tvec3& z, U c -) -{ - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); - return Result; -} - -// Max comparison between 3 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMax -( - const tvec4& x, U a, - const tvec4& y, U b, - const tvec4& z, U c -) -{ - tvec4 Result(tvec4::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c); return Result; @@ -707,16 +293,16 @@ GLM_FUNC_QUALIFIER U associatedMax } // Max comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMax +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMax ( - const tvec2& x, const tvec2& a, - const tvec2& y, const tvec2& b, - const tvec2& z, const tvec2& c, - const tvec2& w, const tvec2& d + vecType const & x, vecType const & a, + vecType const & y, vecType const & b, + vecType const & z, vecType const & c, + vecType const & w, vecType const & d ) { - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) { T Test1 = max(x[i], y[i]); @@ -729,63 +315,19 @@ GLM_FUNC_QUALIFIER tvec2 associatedMax } // Max comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMax +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMax ( - const tvec3& x, const tvec3& a, - const tvec3& y, const tvec3& b, - const tvec3& z, const tvec3& c, - const tvec3& w, const tvec3& d -) -{ - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - T Test1 = max(x[i], y[i]); - T Test2 = max(z[i], w[i]); - U Result1 = x[i] > y[i] ? a[i] : b[i]; - U Result2 = z[i] > w[i] ? c[i] : d[i]; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; -} - -// Max comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMax -( - const tvec4& x, const tvec4& a, - const tvec4& y, const tvec4& b, - const tvec4& z, const tvec4& c, - const tvec4& w, const tvec4& d -) -{ - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - T Test1 = max(x[i], y[i]); - T Test2 = max(z[i], w[i]); - U Result1 = x[i] > y[i] ? a[i] : b[i]; - U Result2 = z[i] > w[i] ? c[i] : d[i]; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; -} - -// Max comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMax -( - T x, const tvec2& a, - T y, const tvec2& b, - T z, const tvec2& c, - T w, const tvec2& d + T x, vecType const & a, + T y, vecType const & b, + T z, vecType const & c, + T w, vecType const & d ) { T Test1 = max(x, y); T Test2 = max(z, w); - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) { U Result1 = x > y ? a[i] : b[i]; @@ -796,62 +338,16 @@ GLM_FUNC_QUALIFIER tvec2 associatedMax } // Max comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMax +template class vecType> +GLM_FUNC_QUALIFIER vecType associatedMax ( - T x, const tvec3& a, - T y, const tvec3& b, - T z, const tvec3& c, - T w, const tvec3& d + vecType const & x, U a, + vecType const & y, U b, + vecType const & z, U c, + vecType const & w, U d ) { - T Test1 = max(x, y); - T Test2 = max(z, w); - - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - U Result1 = x > y ? a[i] : b[i]; - U Result2 = z > w ? c[i] : d[i]; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; -} - -// Max comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMax -( - T x, const tvec4& a, - T y, const tvec4& b, - T z, const tvec4& c, - T w, const tvec4& d -) -{ - T Test1 = max(x, y); - T Test2 = max(z, w); - - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - U Result1 = x > y ? a[i] : b[i]; - U Result2 = z > w ? c[i] : d[i]; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; -} - -// Max comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec2 associatedMax -( - const tvec2& x, U a, - const tvec2& y, U b, - const tvec2& z, U c, - const tvec2& w, U d -) -{ - tvec2 Result(tvec2::_null); + vecType Result(vecType::_null); for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) { T Test1 = max(x[i], y[i]); @@ -862,49 +358,4 @@ GLM_FUNC_QUALIFIER tvec2 associatedMax } return Result; } - -// Max comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec3 associatedMax -( - const tvec3& x, U a, - const tvec3& y, U b, - const tvec3& z, U c, - const tvec3& w, U d -) -{ - tvec3 Result(tvec3::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - T Test1 = max(x[i], y[i]); - T Test2 = max(z[i], w[i]);; - U Result1 = x[i] > y[i] ? a : b; - U Result2 = z[i] > w[i] ? c : d; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; -} - -// Max comparison between 4 variables -template -GLM_FUNC_QUALIFIER tvec4 associatedMax -( - const tvec4& x, U a, - const tvec4& y, U b, - const tvec4& z, U c, - const tvec4& w, U d -) -{ - tvec4 Result(tvec4::_null); - for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) - { - T Test1 = max(x[i], y[i]); - T Test2 = max(z[i], w[i]);; - U Result1 = x[i] > y[i] ? a : b; - U Result2 = z[i] > w[i] ? c : d; - Result[i] = Test1 > Test2 ? Result1 : Result2; - } - return Result; -} - }//namespace glm diff --git a/readme.txt b/readme.txt index 2d854def..3453fb3f 100644 --- a/readme.txt +++ b/readme.txt @@ -63,6 +63,7 @@ GLM 0.9.6.0: 2014-XX-XX - Added GLM_FORCE_SIZE_FUNC to replace .length() by .size() #245 - Fixed GTX_string_cast to support for integer types #249 - Removed GLM_FORCE_CUDA, Cuda is implicitly detected +- Updated GTX_associated_min_max with vec1 support ================================================================================ GLM 0.9.5.4: 2014-06-21