Updated GTX_associated_min_max with vec1 support

master
Christophe Riccio ago%!(EXTRA string=11 years)
parent c2d542562e
commit d06db1133d
  1. 198
      glm/gtx/associated_min_max.hpp
  2. 739
      glm/gtx/associated_min_max.inl
  3. 1
      readme.txt

@ -22,7 +22,7 @@
/// ///
/// @ref gtx_associated_min_max /// @ref gtx_associated_min_max
/// @file glm/gtx/associated_min_max.hpp /// @file glm/gtx/associated_min_max.hpp
/// @date 2008-03-10 / 2011-06-07 /// @date 2008-03-10 / 2014-10-11
/// @author Christophe Riccio /// @author Christophe Riccio
/// ///
/// @see core (dependence) /// @see core (dependence)
@ -49,53 +49,177 @@ namespace glm
/// @addtogroup gtx_associated_min_max /// @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 /// @see gtx_associated_min_max
template<typename genTypeT, typename genTypeU> template<typename T, typename U, precision P>
GLM_FUNC_DECL genTypeU associatedMin( GLM_FUNC_DECL U associatedMin(T x, U a, T y, U b);
const genTypeT& x, const genTypeU& a,
const genTypeT& y, const genTypeU& b);
/// Min comparison between 3 variables /// Minimum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max /// @see gtx_associated_min_max
template<typename genTypeT, typename genTypeU> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL genTypeU associatedMin( GLM_FUNC_DECL tvec2<U, P> associatedMin(
const genTypeT& x, const genTypeU& a, vecType<T, P> const & x, vecType<U, P> const & a,
const genTypeT& y, const genTypeU& b, vecType<T, P> const & y, vecType<U, P> const & b);
const genTypeT& z, const genTypeU& c);
/// Min comparison between 4 variables /// Minimum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max /// @see gtx_associated_min_max
template<typename genTypeT, typename genTypeU> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL genTypeU associatedMin( GLM_FUNC_DECL vecType<U, P> associatedMin(
const genTypeT& x, const genTypeU& a, T x, const vecType<U, P>& a,
const genTypeT& y, const genTypeU& b, T y, const vecType<U, P>& b);
const genTypeT& z, const genTypeU& c,
const genTypeT& w, const genTypeU& d);
/// Max comparison between 2 variables /// Minimum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max /// @see gtx_associated_min_max
template<typename genTypeT, typename genTypeU> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL genTypeU associatedMax( GLM_FUNC_DECL vecType<U, P> associatedMin(
const genTypeT& x, const genTypeU& a, vecType<T, P> const & x, U a,
const genTypeT& y, const genTypeU& b); vecType<T, P> 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 /// @see gtx_associated_min_max
template<typename genTypeT, typename genTypeU> template<typename T, typename U>
GLM_FUNC_DECL genTypeU associatedMax( GLM_FUNC_DECL U associatedMin(
const genTypeT& x, const genTypeU& a, T x, U a,
const genTypeT& y, const genTypeU& b, T y, U b,
const genTypeT& z, const genTypeU& c); 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 /// @see gtx_associated_min_max
template<typename genTypeT, typename genTypeU> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL genTypeU associatedMax( GLM_FUNC_DECL vecType<U, P> associatedMin(
const genTypeT& x, const genTypeU& a, vecType<T, P> const & x, vecType<U, P> const & a,
const genTypeT& y, const genTypeU& b, vecType<T, P> const & y, vecType<U, P> const & b,
const genTypeT& z, const genTypeU& c, vecType<T, P> const & z, vecType<U, P> const & c);
const genTypeT& w, const genTypeU& d);
/// Minimum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U>
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<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<U, P> associatedMin(
vecType<T, P> const & x, vecType<U, P> const & a,
vecType<T, P> const & y, vecType<U, P> const & b,
vecType<T, P> const & z, vecType<U, P> const & c,
vecType<T, P> const & w, vecType<U, P> const & d);
/// Minimum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<U, P> associatedMin(
T x, vecType<U, P> const & a,
T y, vecType<U, P> const & b,
T z, vecType<U, P> const & c,
T w, vecType<U, P> const & d);
/// Minimum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<U, P> associatedMin(
vecType<T, P> const & x, U a,
vecType<T, P> const & y, U b,
vecType<T, P> const & z, U c,
vecType<T, P> const & w, U d);
/// Maximum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U>
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<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL tvec2<U, P> associatedMax(
vecType<T, P> const & x, vecType<U, P> const & a,
vecType<T, P> const & y, vecType<U, P> const & b);
/// Maximum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> associatedMax(
T x, vecType<U, P> const & a,
T y, vecType<U, P> const & b);
/// Maximum comparison between 2 variables and returns 2 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<U, P> associatedMax(
vecType<T, P> const & x, U a,
vecType<T, P> const & y, U b);
/// Maximum comparison between 3 variables and returns 3 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U>
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<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<U, P> associatedMax(
vecType<T, P> const & x, vecType<U, P> const & a,
vecType<T, P> const & y, vecType<U, P> const & b,
vecType<T, P> const & z, vecType<U, P> const & c);
/// Maximum comparison between 3 variables and returns 3 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<T, P> associatedMax(
T x, vecType<U, P> const & a,
T y, vecType<U, P> const & b,
T z, vecType<U, P> const & c);
/// Maximum comparison between 3 variables and returns 3 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<U, P> associatedMax(
vecType<T, P> const & x, U a,
vecType<T, P> const & y, U b,
vecType<T, P> const & z, U c);
/// Maximum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U>
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<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<U, P> associatedMax(
vecType<T, P> const & x, vecType<U, P> const & a,
vecType<T, P> const & y, vecType<U, P> const & b,
vecType<T, P> const & z, vecType<U, P> const & c,
vecType<T, P> const & w, vecType<U, P> const & d);
/// Maximum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<U, P> associatedMax(
T x, vecType<U, P> const & a,
T y, vecType<U, P> const & b,
T z, vecType<U, P> const & c,
T w, vecType<U, P> const & d);
/// Maximum comparison between 4 variables and returns 4 associated variable values
/// @see gtx_associated_min_max
template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_DECL vecType<U, P> associatedMax(
vecType<T, P> const & x, U a,
vecType<T, P> const & y, U b,
vecType<T, P> const & z, U c,
vecType<T, P> const & w, U d);
/// @} /// @}
} //namespace glm } //namespace glm

@ -2,7 +2,7 @@
// OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net) // OpenGL Mathematics Copyright (c) 2005 - 2014 G-Truc Creation (www.g-truc.net)
/////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2008-03-10 // Created : 2008-03-10
// Updated : 2008-03-15 // Updated : 2014-10-11
// Licence : This source is under MIT License // Licence : This source is under MIT License
// File : gtx_associated_min_max.inl // 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; return x < y ? a : b;
} }
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMin GLM_FUNC_QUALIFIER tvec2<U, P> associatedMin
( (
const tvec2<T, P>& x, const tvec2<U, P>& a, vecType<T, P> const & x, vecType<U, P> const & a,
const tvec2<T, P>& y, const tvec2<U, P>& b vecType<T, P> const & y, vecType<U, P> const & b
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMin
(
const tvec3<T, P>& x, const tvec3<U, P>& a,
const tvec3<T, P>& y, const tvec3<U, P>& b
) )
{ {
tvec3<U, P> Result(tvec3<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
Result[i] = x[i] < y[i] ? a[i] : b[i]; Result[i] = x[i] < y[i] ? a[i] : b[i];
return Result; return Result;
} }
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMin GLM_FUNC_QUALIFIER vecType<U, P> associatedMin
( (
const tvec4<T, P>& x, const tvec4<U, P>& a, T x, const vecType<U, P>& a,
const tvec4<T, P>& y, const tvec4<U, P>& b T y, const vecType<U, P>& b
) )
{ {
tvec4<U, P> Result(tvec4<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMin
(
T x, const tvec2<U, P>& a,
T y, const tvec2<U, P>& b
)
{
tvec2<U, P> Result(tvec2<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
Result[i] = x < y ? a[i] : b[i]; Result[i] = x < y ? a[i] : b[i];
return Result; return Result;
} }
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMin GLM_FUNC_QUALIFIER vecType<U, P> associatedMin
( (
T x, const tvec3<U, P>& a, vecType<T, P> const & x, U a,
T y, const tvec3<U, P>& b vecType<T, P> const & y, U b
) )
{ {
tvec3<U, P> Result(tvec3<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMin
(
T x, const tvec4<U, P>& a,
T y, const tvec4<U, P>& b
)
{
tvec4<U, P> Result(tvec4<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMin
(
tvec2<T, P> const & x, U a,
tvec2<T, P> const & y, U b
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMin
(
tvec3<T, P> const & x, U a,
tvec3<T, P> const & y, U b
)
{
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMin
(
const tvec4<T, P>& x, U a,
const tvec4<T, P>& y, U b
)
{
tvec4<U, P> Result(tvec4<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
Result[i] = x[i] < y[i] ? a : b; Result[i] = x[i] < y[i] ? a : b;
return Result; return Result;
@ -146,43 +68,15 @@ GLM_FUNC_QUALIFIER U associatedMin
return Result; return Result;
} }
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMin GLM_FUNC_QUALIFIER vecType<U, P> associatedMin
(
const tvec2<T, P>& x, const tvec2<U, P>& a,
const tvec2<T, P>& y, const tvec2<U, P>& b,
const tvec2<T, P>& z, const tvec2<U, P>& c
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMin
(
const tvec3<T, P>& x, const tvec3<U, P>& a,
const tvec3<T, P>& y, const tvec3<U, P>& b,
const tvec3<T, P>& z, const tvec3<U, P>& c
)
{
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMin
( (
const tvec4<T, P>& x, const tvec4<U, P>& a, vecType<T, P> const & x, vecType<U, P> const & a,
const tvec4<T, P>& y, const tvec4<U, P>& b, vecType<T, P> const & y, vecType<U, P> const & b,
const tvec4<T, P>& z, const tvec4<U, P>& c vecType<T, P> const & z, vecType<U, P> const & c
) )
{ {
tvec4<U, P> Result(tvec4<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) 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]); Result[i] = x[i] < y[i] ? (x[i] < z[i] ? a[i] : c[i]) : (y[i] < z[i] ? b[i] : c[i]);
return Result; return Result;
@ -207,60 +101,16 @@ GLM_FUNC_QUALIFIER U associatedMin
} }
// Min comparison between 4 variables // Min comparison between 4 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMin GLM_FUNC_QUALIFIER vecType<U, P> associatedMin
(
const tvec2<T, P>& x, const tvec2<U, P>& a,
const tvec2<T, P>& y, const tvec2<U, P>& b,
const tvec2<T, P>& z, const tvec2<U, P>& c,
const tvec2<T, P>& w, const tvec2<U, P>& d
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMin
(
const tvec3<T, P>& x, const tvec3<U, P>& a,
const tvec3<T, P>& y, const tvec3<U, P>& b,
const tvec3<T, P>& z, const tvec3<U, P>& c,
const tvec3<T, P>& w, const tvec3<U, P>& d
)
{
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMin
( (
const tvec4<T, P>& x, const tvec4<U, P>& a, vecType<T, P> const & x, vecType<U, P> const & a,
const tvec4<T, P>& y, const tvec4<U, P>& b, vecType<T, P> const & y, vecType<U, P> const & b,
const tvec4<T, P>& z, const tvec4<U, P>& c, vecType<T, P> const & z, vecType<U, P> const & c,
const tvec4<T, P>& w, const tvec4<U, P>& d vecType<T, P> const & w, vecType<U, P> const & d
) )
{ {
tvec4<U, P> Result(tvec4<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
{ {
T Test1 = min(x[i], y[i]); T Test1 = min(x[i], y[i]);
@ -273,19 +123,19 @@ GLM_FUNC_QUALIFIER tvec4<U, P> associatedMin
} }
// Min comparison between 4 variables // Min comparison between 4 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMin GLM_FUNC_QUALIFIER vecType<U, P> associatedMin
( (
T x, const tvec2<U, P>& a, T x, vecType<U, P> const & a,
T y, const tvec2<U, P>& b, T y, vecType<U, P> const & b,
T z, const tvec2<U, P>& c, T z, vecType<U, P> const & c,
T w, const tvec2<U, P>& d T w, vecType<U, P> const & d
) )
{ {
T Test1 = min(x, y); T Test1 = min(x, y);
T Test2 = min(z, w); T Test2 = min(z, w);
tvec2<U, P> Result(tvec2<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
{ {
U Result1 = x < y ? a[i] : b[i]; U Result1 = x < y ? a[i] : b[i];
@ -296,106 +146,16 @@ GLM_FUNC_QUALIFIER tvec2<U, P> associatedMin
} }
// Min comparison between 4 variables // Min comparison between 4 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMin GLM_FUNC_QUALIFIER vecType<U, P> associatedMin
( (
T x, const tvec3<U, P>& a, vecType<T, P> const & x, U a,
T y, const tvec3<U, P>& b, vecType<T, P> const & y, U b,
T z, const tvec3<U, P>& c, vecType<T, P> const & z, U c,
T w, const tvec3<U, P>& d vecType<T, P> const & w, U d
) )
{ {
T Test1 = min(x, y); vecType<U, P> Result(vecType<U, P>::_null);
T Test2 = min(z, w);
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMin
(
T x, const tvec4<U, P>& a,
T y, const tvec4<U, P>& b,
T z, const tvec4<U, P>& c,
T w, const tvec4<U, P>& d
)
{
T Test1 = min(x, y);
T Test2 = min(z, w);
tvec4<U, P> Result(tvec4<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMin
(
const tvec2<T, P>& x, U a,
const tvec2<T, P>& y, U b,
const tvec2<T, P>& z, U c,
const tvec2<T, P>& w, U d
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMin
(
const tvec3<T, P>& x, U a,
const tvec3<T, P>& y, U b,
const tvec3<T, P>& z, U c,
const tvec3<T, P>& w, U d
)
{
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMin
(
const tvec4<T, P>& x, U a,
const tvec4<T, P>& y, U b,
const tvec4<T, P>& z, U c,
const tvec4<T, P>& w, U d
)
{
tvec4<U, P> Result(tvec4<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
{ {
T Test1 = min(x[i], y[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 // Max comparison between 2 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMax GLM_FUNC_QUALIFIER tvec2<U, P> associatedMax
( (
const tvec2<T, P>& x, const tvec2<U, P>& a, vecType<T, P> const & x, vecType<U, P> const & a,
const tvec2<T, P>& y, const tvec2<U, P>& b vecType<T, P> const & y, vecType<U, P> const & b
) )
{ {
tvec2<U, P> Result(tvec2<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
Result[i] = x[i] > y[i] ? a[i] : b[i]; Result[i] = x[i] > y[i] ? a[i] : b[i];
return Result; return Result;
} }
// Max comparison between 2 variables // Max comparison between 2 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMax GLM_FUNC_QUALIFIER vecType<T, P> associatedMax
(
const tvec3<T, P>& x, const tvec3<U, P>& a,
const tvec3<T, P>& y, const tvec3<U, P>& b
)
{
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
(
const tvec4<T, P>& x, const tvec4<U, P>& a,
const tvec4<T, P>& y, const tvec4<U, P>& b
)
{
tvec4<U, P> Result(tvec4<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMax
( (
T x, const tvec2<U, P>& a, T x, vecType<U, P> const & a,
T y, const tvec2<U, P>& b T y, vecType<U, P> const & b
) )
{ {
tvec2<U, P> Result(tvec2<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
Result[i] = x > y ? a[i] : b[i]; Result[i] = x > y ? a[i] : b[i];
return Result; return Result;
} }
// Max comparison between 2 variables // Max comparison between 2 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMax GLM_FUNC_QUALIFIER vecType<U, P> associatedMax
( (
T x, const tvec3<U, P>& a, vecType<T, P> const & x, U a,
T y, const tvec3<U, P>& b vecType<T, P> const & y, U b
) )
{ {
tvec3<U, P> Result(tvec3<U, P>::_null); vecType<T, P> Result(vecType<T, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
(
T x, const tvec4<U, P>& a,
T y, const tvec4<U, P>& b
)
{
tvec4<U, P> Result(tvec4<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMax
(
const tvec2<T, P>& x, U a,
const tvec2<T, P>& y, U b
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMax
(
const tvec3<T, P>& x, U a,
const tvec3<T, P>& y, U b
)
{
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
(
const tvec4<T, P>& x, U a,
const tvec4<T, P>& y, U b
)
{
tvec4<U, P> Result(tvec4<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
Result[i] = x[i] > y[i] ? a : b; Result[i] = x[i] > y[i] ? a : b;
return Result; return Result;
@ -554,135 +230,45 @@ GLM_FUNC_QUALIFIER U associatedMax
} }
// Max comparison between 3 variables // Max comparison between 3 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMax GLM_FUNC_QUALIFIER vecType<U, P> associatedMax
(
const tvec2<T, P>& x, const tvec2<U, P>& a,
const tvec2<T, P>& y, const tvec2<U, P>& b,
const tvec2<T, P>& z, const tvec2<U, P>& c
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMax
( (
const tvec3<T, P>& x, const tvec3<U, P>& a, vecType<T, P> const & x, vecType<U, P> const & a,
const tvec3<T, P>& y, const tvec3<U, P>& b, vecType<T, P> const & y, vecType<U, P> const & b,
const tvec3<T, P>& z, const tvec3<U, P>& c vecType<T, P> const & z, vecType<U, P> const & c
) )
{ {
tvec3<U, P> Result(tvec3<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) 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]); Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a[i] : c[i]) : (y[i] > z[i] ? b[i] : c[i]);
return Result; return Result;
} }
// Max comparison between 3 variables // Max comparison between 3 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax GLM_FUNC_QUALIFIER vecType<T, P> associatedMax
( (
const tvec4<T, P>& x, const tvec4<U, P>& a, T x, vecType<U, P> const & a,
const tvec4<T, P>& y, const tvec4<U, P>& b, T y, vecType<U, P> const & b,
const tvec4<T, P>& z, const tvec4<U, P>& c T z, vecType<U, P> const & c
) )
{ {
tvec4<U, P> Result(tvec4<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMax
(
T x, const tvec2<U, P>& a,
T y, const tvec2<U, P>& b,
T z, const tvec2<U, P>& c
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMax
(
T x, const tvec3<U, P>& a,
T y, const tvec3<U, P>& b,
T z, const tvec3<U, P>& c
)
{
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
(
T x, const tvec4<U, P>& a,
T y, const tvec4<U, P>& b,
T z, const tvec4<U, P>& c
)
{
tvec4<U, P> Result(tvec4<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) 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]); Result[i] = x > y ? (x > z ? a[i] : c[i]) : (y > z ? b[i] : c[i]);
return Result; return Result;
} }
// Max comparison between 3 variables // Max comparison between 3 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMax GLM_FUNC_QUALIFIER vecType<U, P> associatedMax
(
const tvec2<T, P>& x, U a,
const tvec2<T, P>& y, U b,
const tvec2<T, P>& z, U c
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMax
( (
const tvec3<T, P>& x, U a, vecType<T, P> const & x, U a,
const tvec3<T, P>& y, U b, vecType<T, P> const & y, U b,
const tvec3<T, P>& z, U c vecType<T, P> const & z, U c
) )
{ {
tvec3<U, P> Result(tvec3<U, P>::_null); vecType<T, P> Result(vecType<T, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
(
const tvec4<T, P>& x, U a,
const tvec4<T, P>& y, U b,
const tvec4<T, P>& z, U c
)
{
tvec4<U, P> Result(tvec4<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) 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); Result[i] = x[i] > y[i] ? (x[i] > z[i] ? a : c) : (y[i] > z[i] ? b : c);
return Result; return Result;
@ -707,60 +293,16 @@ GLM_FUNC_QUALIFIER U associatedMax
} }
// Max comparison between 4 variables // Max comparison between 4 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMax GLM_FUNC_QUALIFIER vecType<U, P> associatedMax
(
const tvec2<T, P>& x, const tvec2<U, P>& a,
const tvec2<T, P>& y, const tvec2<U, P>& b,
const tvec2<T, P>& z, const tvec2<U, P>& c,
const tvec2<T, P>& w, const tvec2<U, P>& d
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMax
(
const tvec3<T, P>& x, const tvec3<U, P>& a,
const tvec3<T, P>& y, const tvec3<U, P>& b,
const tvec3<T, P>& z, const tvec3<U, P>& c,
const tvec3<T, P>& w, const tvec3<U, P>& d
)
{
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
( (
const tvec4<T, P>& x, const tvec4<U, P>& a, vecType<T, P> const & x, vecType<U, P> const & a,
const tvec4<T, P>& y, const tvec4<U, P>& b, vecType<T, P> const & y, vecType<U, P> const & b,
const tvec4<T, P>& z, const tvec4<U, P>& c, vecType<T, P> const & z, vecType<U, P> const & c,
const tvec4<T, P>& w, const tvec4<U, P>& d vecType<T, P> const & w, vecType<U, P> const & d
) )
{ {
tvec4<U, P> Result(tvec4<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
{ {
T Test1 = max(x[i], y[i]); T Test1 = max(x[i], y[i]);
@ -773,65 +315,19 @@ GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
} }
// Max comparison between 4 variables // Max comparison between 4 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMax GLM_FUNC_QUALIFIER vecType<U, P> associatedMax
(
T x, const tvec2<U, P>& a,
T y, const tvec2<U, P>& b,
T z, const tvec2<U, P>& c,
T w, const tvec2<U, P>& d
)
{
T Test1 = max(x, y);
T Test2 = max(z, w);
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMax
(
T x, const tvec3<U, P>& a,
T y, const tvec3<U, P>& b,
T z, const tvec3<U, P>& c,
T w, const tvec3<U, P>& d
)
{
T Test1 = max(x, y);
T Test2 = max(z, w);
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
( (
T x, const tvec4<U, P>& a, T x, vecType<U, P> const & a,
T y, const tvec4<U, P>& b, T y, vecType<U, P> const & b,
T z, const tvec4<U, P>& c, T z, vecType<U, P> const & c,
T w, const tvec4<U, P>& d T w, vecType<U, P> const & d
) )
{ {
T Test1 = max(x, y); T Test1 = max(x, y);
T Test2 = max(z, w); T Test2 = max(z, w);
tvec4<U, P> Result(tvec4<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
{ {
U Result1 = x > y ? a[i] : b[i]; U Result1 = x > y ? a[i] : b[i];
@ -842,60 +338,16 @@ GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
} }
// Max comparison between 4 variables // Max comparison between 4 variables
template<typename T, typename U, precision P> template<typename T, typename U, precision P, template <typename, precision> class vecType>
GLM_FUNC_QUALIFIER tvec2<U, P> associatedMax GLM_FUNC_QUALIFIER vecType<U, P> associatedMax
(
const tvec2<T, P>& x, U a,
const tvec2<T, P>& y, U b,
const tvec2<T, P>& z, U c,
const tvec2<T, P>& w, U d
)
{
tvec2<U, P> Result(tvec2<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec3<U, P> associatedMax
(
const tvec3<T, P>& x, U a,
const tvec3<T, P>& y, U b,
const tvec3<T, P>& z, U c,
const tvec3<T, P>& w, U d
)
{
tvec3<U, P> Result(tvec3<U, P>::_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<typename T, typename U, precision P>
GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
( (
const tvec4<T, P>& x, U a, vecType<T, P> const & x, U a,
const tvec4<T, P>& y, U b, vecType<T, P> const & y, U b,
const tvec4<T, P>& z, U c, vecType<T, P> const & z, U c,
const tvec4<T, P>& w, U d vecType<T, P> const & w, U d
) )
{ {
tvec4<U, P> Result(tvec4<U, P>::_null); vecType<U, P> Result(vecType<U, P>::_null);
for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i) for(detail::component_count_t i = 0; i < detail::component_count(Result); ++i)
{ {
T Test1 = max(x[i], y[i]); T Test1 = max(x[i], y[i]);
@ -906,5 +358,4 @@ GLM_FUNC_QUALIFIER tvec4<U, P> associatedMax
} }
return Result; return Result;
} }
}//namespace glm }//namespace glm

@ -63,6 +63,7 @@ GLM 0.9.6.0: 2014-XX-XX
- Added GLM_FORCE_SIZE_FUNC to replace .length() by .size() #245 - Added GLM_FORCE_SIZE_FUNC to replace .length() by .size() #245
- Fixed GTX_string_cast to support for integer types #249 - Fixed GTX_string_cast to support for integer types #249
- Removed GLM_FORCE_CUDA, Cuda is implicitly detected - Removed GLM_FORCE_CUDA, Cuda is implicitly detected
- Updated GTX_associated_min_max with vec1 support
================================================================================ ================================================================================
GLM 0.9.5.4: 2014-06-21 GLM 0.9.5.4: 2014-06-21

Loading…
Cancel
Save