mirror of
https://github.com/g-truc/glm.git
synced 2024-11-23 01:14:34 +00:00
Vectorize and reformat
This commit is contained in:
parent
bc15b98730
commit
86be6440e3
1264
glm/gtx/bit.inl
1264
glm/gtx/bit.inl
File diff suppressed because it is too large
Load Diff
@ -10,28 +10,27 @@
|
||||
#ifndef glm_gtx_closest_point
|
||||
#define glm_gtx_closest_point
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine
|
||||
(
|
||||
detail::tvec3<valType> const & point,
|
||||
detail::tvec3<valType> const & a,
|
||||
detail::tvec3<valType> const & b
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
valType LineLength = distance(a, b);
|
||||
detail::tvec3<valType> Vector = point - a;
|
||||
detail::tvec3<valType> LineDirection = (b - a) / LineLength;
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine
|
||||
(
|
||||
detail::tvec3<valType> const & point,
|
||||
detail::tvec3<valType> const & a,
|
||||
detail::tvec3<valType> const & b
|
||||
)
|
||||
{
|
||||
valType LineLength = distance(a, b);
|
||||
detail::tvec3<valType> Vector = point - a;
|
||||
detail::tvec3<valType> LineDirection = (b - a) / LineLength;
|
||||
|
||||
// Project Vector to LineDirection to get the distance of point from a
|
||||
valType Distance = dot(Vector, LineDirection);
|
||||
|
||||
if(Distance <= valType(0)) return a;
|
||||
if(Distance >= LineLength) return b;
|
||||
return a + LineDirection * Distance;
|
||||
}
|
||||
// Project Vector to LineDirection to get the distance of point from a
|
||||
valType Distance = dot(Vector, LineDirection);
|
||||
|
||||
if(Distance <= valType(0)) return a;
|
||||
if(Distance >= LineLength) return b;
|
||||
return a + LineDirection * Distance;
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
#endif//glm_gtx_closest_point
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -7,144 +7,143 @@
|
||||
// File : glm/gtx/color_space.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor)
|
||||
namespace glm
|
||||
{
|
||||
detail::tvec3<T> hsv = hsvColor;
|
||||
detail::tvec3<T> rgbColor;
|
||||
|
||||
if(hsv.y == T(0))
|
||||
// achromatic (grey)
|
||||
rgbColor = detail::tvec3<T>(hsv.z);
|
||||
else
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor)
|
||||
{
|
||||
T sector = floor(hsv.x / T(60));
|
||||
T frac = (hsv.x / T(60)) - sector;
|
||||
// factorial part of h
|
||||
T o = hsv.z * (T(1) - hsv.y);
|
||||
T p = hsv.z * (T(1) - hsv.y * frac);
|
||||
T q = hsv.z * (T(1) - hsv.y * (T(1) - frac));
|
||||
detail::tvec3<T> hsv = hsvColor;
|
||||
detail::tvec3<T> rgbColor;
|
||||
|
||||
switch(int(sector))
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
rgbColor.r = hsv.z;
|
||||
rgbColor.g = q;
|
||||
rgbColor.b = o;
|
||||
break;
|
||||
case 1:
|
||||
rgbColor.r = p;
|
||||
rgbColor.g = hsv.z;
|
||||
rgbColor.b = o;
|
||||
break;
|
||||
case 2:
|
||||
rgbColor.r = o;
|
||||
rgbColor.g = hsv.z;
|
||||
rgbColor.b = q;
|
||||
break;
|
||||
case 3:
|
||||
rgbColor.r = o;
|
||||
rgbColor.g = p;
|
||||
rgbColor.b = hsv.z;
|
||||
break;
|
||||
case 4:
|
||||
rgbColor.r = q;
|
||||
rgbColor.g = o;
|
||||
rgbColor.b = hsv.z;
|
||||
break;
|
||||
case 5:
|
||||
rgbColor.r = hsv.z;
|
||||
rgbColor.g = o;
|
||||
rgbColor.b = p;
|
||||
break;
|
||||
}
|
||||
if(hsv.y == T(0))
|
||||
// achromatic (grey)
|
||||
rgbColor = detail::tvec3<T>(hsv.z);
|
||||
else
|
||||
{
|
||||
T sector = floor(hsv.x / T(60));
|
||||
T frac = (hsv.x / T(60)) - sector;
|
||||
// factorial part of h
|
||||
T o = hsv.z * (T(1) - hsv.y);
|
||||
T p = hsv.z * (T(1) - hsv.y * frac);
|
||||
T q = hsv.z * (T(1) - hsv.y * (T(1) - frac));
|
||||
|
||||
switch(int(sector))
|
||||
{
|
||||
default:
|
||||
case 0:
|
||||
rgbColor.r = hsv.z;
|
||||
rgbColor.g = q;
|
||||
rgbColor.b = o;
|
||||
break;
|
||||
case 1:
|
||||
rgbColor.r = p;
|
||||
rgbColor.g = hsv.z;
|
||||
rgbColor.b = o;
|
||||
break;
|
||||
case 2:
|
||||
rgbColor.r = o;
|
||||
rgbColor.g = hsv.z;
|
||||
rgbColor.b = q;
|
||||
break;
|
||||
case 3:
|
||||
rgbColor.r = o;
|
||||
rgbColor.g = p;
|
||||
rgbColor.b = hsv.z;
|
||||
break;
|
||||
case 4:
|
||||
rgbColor.r = q;
|
||||
rgbColor.g = o;
|
||||
rgbColor.b = hsv.z;
|
||||
break;
|
||||
case 5:
|
||||
rgbColor.r = hsv.z;
|
||||
rgbColor.g = o;
|
||||
rgbColor.b = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return rgbColor;
|
||||
}
|
||||
|
||||
return rgbColor;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> hsvColor(const detail::tvec3<T>& rgbColor)
|
||||
{
|
||||
detail::tvec3<T> hsv = rgbColor;
|
||||
float Min = min(min(rgbColor.r, rgbColor.g), rgbColor.b);
|
||||
float Max = max(max(rgbColor.r, rgbColor.g), rgbColor.b);
|
||||
float Delta = Max - Min;
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> hsvColor(const detail::tvec3<T>& rgbColor)
|
||||
{
|
||||
detail::tvec3<T> hsv = rgbColor;
|
||||
float Min = min(min(rgbColor.r, rgbColor.g), rgbColor.b);
|
||||
float Max = max(max(rgbColor.r, rgbColor.g), rgbColor.b);
|
||||
float Delta = Max - Min;
|
||||
|
||||
hsv.z = Max;
|
||||
hsv.z = Max;
|
||||
|
||||
if(Max != T(0))
|
||||
{
|
||||
hsv.y = Delta / hsv.z;
|
||||
T h = T(0);
|
||||
if(Max != T(0))
|
||||
{
|
||||
hsv.y = Delta / hsv.z;
|
||||
T h = T(0);
|
||||
|
||||
if(rgbColor.r == Max)
|
||||
// between yellow & magenta
|
||||
h = T(0) + T(60) * (rgbColor.g - rgbColor.b) / Delta;
|
||||
else if(rgbColor.g == Max)
|
||||
// between cyan & yellow
|
||||
h = T(120) + T(60) * (rgbColor.b - rgbColor.r) / Delta;
|
||||
else
|
||||
// between magenta & cyan
|
||||
h = T(240) + T(60) * (rgbColor.r - rgbColor.g) / Delta;
|
||||
if(rgbColor.r == Max)
|
||||
// between yellow & magenta
|
||||
h = T(0) + T(60) * (rgbColor.g - rgbColor.b) / Delta;
|
||||
else if(rgbColor.g == Max)
|
||||
// between cyan & yellow
|
||||
h = T(120) + T(60) * (rgbColor.b - rgbColor.r) / Delta;
|
||||
else
|
||||
// between magenta & cyan
|
||||
h = T(240) + T(60) * (rgbColor.r - rgbColor.g) / Delta;
|
||||
|
||||
if(h < T(0))
|
||||
hsv.x = h + T(360);
|
||||
if(h < T(0))
|
||||
hsv.x = h + T(360);
|
||||
else
|
||||
hsv.x = h;
|
||||
}
|
||||
else
|
||||
hsv.x = h;
|
||||
{
|
||||
// If r = g = b = 0 then s = 0, h is undefined
|
||||
hsv.y = T(0);
|
||||
hsv.x = T(0);
|
||||
}
|
||||
|
||||
return hsv;
|
||||
}
|
||||
else
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> saturation(const T s)
|
||||
{
|
||||
// If r = g = b = 0 then s = 0, h is undefined
|
||||
hsv.y = T(0);
|
||||
hsv.x = T(0);
|
||||
detail::tvec3<T> rgbw = detail::tvec3<T>(T(0.2126), T(0.7152), T(0.0722));
|
||||
|
||||
T col0 = (T(1) - s) * rgbw.r;
|
||||
T col1 = (T(1) - s) * rgbw.g;
|
||||
T col2 = (T(1) - s) * rgbw.b;
|
||||
|
||||
detail::tmat4x4<T> result(T(1));
|
||||
result[0][0] = col0 + s;
|
||||
result[0][1] = col0;
|
||||
result[0][2] = col0;
|
||||
result[1][0] = col1;
|
||||
result[1][1] = col1 + s;
|
||||
result[1][2] = col1;
|
||||
result[2][0] = col2;
|
||||
result[2][1] = col2;
|
||||
result[2][2] = col2 + s;
|
||||
return result;
|
||||
}
|
||||
|
||||
return hsv;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> saturation(const T s, const detail::tvec3<T>& color)
|
||||
{
|
||||
return detail::tvec3<T>(saturation(s) * detail::tvec4<T>(color, T(0)));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> saturation(const T s)
|
||||
{
|
||||
detail::tvec3<T> rgbw = detail::tvec3<T>(T(0.2126), T(0.7152), T(0.0722));
|
||||
|
||||
T col0 = (T(1) - s) * rgbw.r;
|
||||
T col1 = (T(1) - s) * rgbw.g;
|
||||
T col2 = (T(1) - s) * rgbw.b;
|
||||
|
||||
detail::tmat4x4<T> result(T(1));
|
||||
result[0][0] = col0 + s;
|
||||
result[0][1] = col0;
|
||||
result[0][2] = col0;
|
||||
result[1][0] = col1;
|
||||
result[1][1] = col1 + s;
|
||||
result[1][2] = col1;
|
||||
result[2][0] = col2;
|
||||
result[2][1] = col2;
|
||||
result[2][2] = col2 + s;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> saturation(const T s, const detail::tvec3<T>& color)
|
||||
{
|
||||
return detail::tvec3<T>(saturation(s) * detail::tvec4<T>(color, T(0)));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> saturation(const T s, const detail::tvec4<T>& color)
|
||||
{
|
||||
return saturation(s) * color;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T luminosity(const detail::tvec3<T>& color)
|
||||
{
|
||||
const detail::tvec3<T> tmp = detail::tvec3<T>(0.33, 0.59, 0.11);
|
||||
return dot(color, tmp);
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> saturation(const T s, const detail::tvec4<T>& color)
|
||||
{
|
||||
return saturation(s) * color;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T luminosity(const detail::tvec3<T>& color)
|
||||
{
|
||||
const detail::tvec3<T> tmp = detail::tvec3<T>(0.33, 0.59, 0.11);
|
||||
return dot(color, tmp);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,59 +7,58 @@
|
||||
// File : glm/gtx/color_space_YCoCg.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg
|
||||
(
|
||||
detail::tvec3<valType> const & rgbColor
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
detail::tvec3<valType> result;
|
||||
result.x/*Y */ = rgbColor.r / valType(4) + rgbColor.g / valType(2) + rgbColor.b / valType(4);
|
||||
result.y/*Co*/ = rgbColor.r / valType(2) + rgbColor.g * valType(0) - rgbColor.b / valType(2);
|
||||
result.z/*Cg*/ = - rgbColor.r / valType(4) + rgbColor.g / valType(2) - rgbColor.b / valType(4);
|
||||
return result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg
|
||||
(
|
||||
detail::tvec3<valType> const & rgbColor
|
||||
)
|
||||
{
|
||||
detail::tvec3<valType> result;
|
||||
result.x/*Y */ = rgbColor.r / valType(4) + rgbColor.g / valType(2) + rgbColor.b / valType(4);
|
||||
result.y/*Co*/ = rgbColor.r / valType(2) + rgbColor.g * valType(0) - rgbColor.b / valType(2);
|
||||
result.z/*Cg*/ = - rgbColor.r / valType(4) + rgbColor.g / valType(2) - rgbColor.b / valType(4);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCgR
|
||||
(
|
||||
detail::tvec3<valType> const & rgbColor
|
||||
)
|
||||
{
|
||||
detail::tvec3<valType> result;
|
||||
result.x/*Y */ = rgbColor.g / valType(2) + (rgbColor.r + rgbColor.b) / valType(4);
|
||||
result.y/*Co*/ = rgbColor.r - rgbColor.b;
|
||||
result.z/*Cg*/ = rgbColor.g - (rgbColor.r + rgbColor.b) / valType(2);
|
||||
return result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCgR
|
||||
(
|
||||
detail::tvec3<valType> const & rgbColor
|
||||
)
|
||||
{
|
||||
detail::tvec3<valType> result;
|
||||
result.x/*Y */ = rgbColor.g / valType(2) + (rgbColor.r + rgbColor.b) / valType(4);
|
||||
result.y/*Co*/ = rgbColor.r - rgbColor.b;
|
||||
result.z/*Cg*/ = rgbColor.g - (rgbColor.r + rgbColor.b) / valType(2);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCg2rgb
|
||||
(
|
||||
detail::tvec3<valType> const & YCoCgColor
|
||||
)
|
||||
{
|
||||
detail::tvec3<valType> result;
|
||||
result.r = YCoCgColor.x + YCoCgColor.y - YCoCgColor.z;
|
||||
result.g = YCoCgColor.x + YCoCgColor.z;
|
||||
result.b = YCoCgColor.x - YCoCgColor.y - YCoCgColor.z;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCgR2rgb
|
||||
(
|
||||
detail::tvec3<valType> const & YCoCgRColor
|
||||
)
|
||||
{
|
||||
detail::tvec3<valType> result;
|
||||
valType tmp = YCoCgRColor.x - (YCoCgRColor.z / valType(2));
|
||||
result.g = YCoCgRColor.z + tmp;
|
||||
result.b = tmp - (YCoCgRColor.y / valType(2));
|
||||
result.r = result.b + YCoCgRColor.y;
|
||||
return result;
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCg2rgb
|
||||
(
|
||||
detail::tvec3<valType> const & YCoCgColor
|
||||
)
|
||||
{
|
||||
detail::tvec3<valType> result;
|
||||
result.r = YCoCgColor.x + YCoCgColor.y - YCoCgColor.z;
|
||||
result.g = YCoCgColor.x + YCoCgColor.z;
|
||||
result.b = YCoCgColor.x - YCoCgColor.y - YCoCgColor.z;
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCgR2rgb
|
||||
(
|
||||
detail::tvec3<valType> const & YCoCgRColor
|
||||
)
|
||||
{
|
||||
detail::tvec3<valType> result;
|
||||
valType tmp = YCoCgRColor.x - (YCoCgRColor.z / valType(2));
|
||||
result.g = YCoCgRColor.z + tmp;
|
||||
result.b = tmp - (YCoCgRColor.y / valType(2));
|
||||
result.r = result.b + YCoCgRColor.y;
|
||||
return result;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,131 +7,130 @@
|
||||
// File : glm/gtx/compatibility.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
// isfinite
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isfinite(
|
||||
genType const & x)
|
||||
namespace glm
|
||||
{
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
return _finite(x);
|
||||
#else//(GLM_COMPILER & GLM_COMPILER_GCC)
|
||||
return std::isfinite(x) != 0;
|
||||
#endif
|
||||
}
|
||||
// isfinite
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isfinite(
|
||||
genType const & x)
|
||||
{
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
return _finite(x);
|
||||
#else//(GLM_COMPILER & GLM_COMPILER_GCC)
|
||||
return std::isfinite(x) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isfinite(
|
||||
detail::tvec2<valType> const & x)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
isfinite(x.x),
|
||||
isfinite(x.y));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isfinite(
|
||||
detail::tvec2<valType> const & x)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
isfinite(x.x),
|
||||
isfinite(x.y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isfinite(
|
||||
detail::tvec3<valType> const & x)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
isfinite(x.x),
|
||||
isfinite(x.y),
|
||||
isfinite(x.z));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isfinite(
|
||||
detail::tvec3<valType> const & x)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
isfinite(x.x),
|
||||
isfinite(x.y),
|
||||
isfinite(x.z));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isfinite(
|
||||
detail::tvec4<valType> const & x)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
isfinite(x.x),
|
||||
isfinite(x.y),
|
||||
isfinite(x.z),
|
||||
isfinite(x.w));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isfinite(
|
||||
detail::tvec4<valType> const & x)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
isfinite(x.x),
|
||||
isfinite(x.y),
|
||||
isfinite(x.z),
|
||||
isfinite(x.w));
|
||||
}
|
||||
|
||||
// isinf
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isinf(
|
||||
genType const & x)
|
||||
{
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF;
|
||||
#else
|
||||
return std::isinf(x) != 0;
|
||||
#endif
|
||||
}
|
||||
// isinf
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isinf(
|
||||
genType const & x)
|
||||
{
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF;
|
||||
#else
|
||||
return std::isinf(x) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isinf(
|
||||
detail::tvec2<valType> const & x)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
isinf(x.x),
|
||||
isinf(x.y));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isinf(
|
||||
detail::tvec2<valType> const & x)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
isinf(x.x),
|
||||
isinf(x.y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isinf(
|
||||
detail::tvec3<valType> const & x)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
isinf(x.x),
|
||||
isinf(x.y),
|
||||
isinf(x.z));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isinf(
|
||||
detail::tvec3<valType> const & x)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
isinf(x.x),
|
||||
isinf(x.y),
|
||||
isinf(x.z));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isinf(
|
||||
detail::tvec4<valType> const & x)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
isinf(x.x),
|
||||
isinf(x.y),
|
||||
isinf(x.z),
|
||||
isinf(x.w));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isinf(
|
||||
detail::tvec4<valType> const & x)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
isinf(x.x),
|
||||
isinf(x.y),
|
||||
isinf(x.z),
|
||||
isinf(x.w));
|
||||
}
|
||||
|
||||
// isnan
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isnan(genType const & x)
|
||||
{
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
return _isnan(x);
|
||||
#else
|
||||
return std::isnan(x) != 0;
|
||||
#endif
|
||||
}
|
||||
// isnan
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isnan(genType const & x)
|
||||
{
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
return _isnan(x);
|
||||
#else
|
||||
return std::isnan(x) != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isnan(
|
||||
detail::tvec2<valType> const & x)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
isnan(x.x),
|
||||
isnan(x.y));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isnan(
|
||||
detail::tvec2<valType> const & x)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
isnan(x.x),
|
||||
isnan(x.y));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isnan(
|
||||
detail::tvec3<valType> const & x)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
isnan(x.x),
|
||||
isnan(x.y),
|
||||
isnan(x.z));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isnan(
|
||||
detail::tvec4<valType> const & x)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
isnan(x.x),
|
||||
isnan(x.y),
|
||||
isnan(x.z),
|
||||
isnan(x.w));
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isnan(
|
||||
detail::tvec3<valType> const & x)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
isnan(x.x),
|
||||
isnan(x.y),
|
||||
isnan(x.z));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isnan(
|
||||
detail::tvec4<valType> const & x)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
isnan(x.x),
|
||||
isnan(x.y),
|
||||
isnan(x.z),
|
||||
isnan(x.w));
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,42 +7,41 @@
|
||||
// File : gtx_component_wise.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
|
||||
namespace glm
|
||||
{
|
||||
typename genType::size_type result = typename genType::value_type(0);
|
||||
for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
|
||||
result += v[i];
|
||||
return result;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
|
||||
{
|
||||
typename genType::size_type result = typename genType::value_type(0);
|
||||
for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
|
||||
result += v[i];
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v)
|
||||
{
|
||||
typename genType::value_type result = typename genType::value_type(1);
|
||||
for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
|
||||
result *= v[i];
|
||||
return result;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v)
|
||||
{
|
||||
typename genType::value_type result = typename genType::value_type(1);
|
||||
for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
|
||||
result *= v[i];
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v)
|
||||
{
|
||||
typename genType::value_type result = typename genType::value_type(v[0]);
|
||||
for(typename genType::size_type i = 1; i < genType::value_size(); ++i)
|
||||
result = min(result, v[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v)
|
||||
{
|
||||
typename genType::value_type result = typename genType::value_type(v[0]);
|
||||
for(typename genType::size_type i = 1; i < genType::value_size(); ++i)
|
||||
result = max(result, v[i]);
|
||||
return result;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v)
|
||||
{
|
||||
typename genType::value_type result = typename genType::value_type(v[0]);
|
||||
for(typename genType::size_type i = 1; i < genType::value_size(); ++i)
|
||||
result = min(result, v[i]);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v)
|
||||
{
|
||||
typename genType::value_type result = typename genType::value_type(v[0]);
|
||||
for(typename genType::size_type i = 1; i < genType::value_size(); ++i)
|
||||
result = max(result, v[i]);
|
||||
return result;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -20,773 +20,8 @@
|
||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
/// THE SOFTWARE.
|
||||
///
|
||||
/// @ref gtc_half_float
|
||||
/// @file glm/gtc/half_float.inl
|
||||
/// @date 2009-04-29 / 2011-06-05
|
||||
/// @ref gtx_constants
|
||||
/// @file glm/gtx/constants.inl
|
||||
/// @date 2011-10-14 / 2011-10-14
|
||||
/// @author Christophe Riccio
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../core/_detail.hpp"
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename genIType>
|
||||
GLM_FUNC_QUALIFIER genIType mask
|
||||
(
|
||||
genIType const & count
|
||||
)
|
||||
{
|
||||
return ((genIType(1) << (count)) - genIType(1));
|
||||
}
|
||||
|
||||
template <typename valIType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valIType> mask
|
||||
(
|
||||
detail::tvec2<valIType> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valIType>(
|
||||
mask(count[0]),
|
||||
mask(count[1]));
|
||||
}
|
||||
|
||||
template <typename valIType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valIType> mask
|
||||
(
|
||||
detail::tvec3<valIType> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valIType>(
|
||||
mask(count[0]),
|
||||
mask(count[1]),
|
||||
mask(count[2]));
|
||||
}
|
||||
|
||||
template <typename valIType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valIType> mask
|
||||
(
|
||||
detail::tvec4<valIType> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec4<valIType>(
|
||||
mask(count[0]),
|
||||
mask(count[1]),
|
||||
mask(count[2]),
|
||||
mask(count[3]));
|
||||
}
|
||||
|
||||
// extractField
|
||||
template <typename genIType>
|
||||
GLM_FUNC_QUALIFIER genIType extractField
|
||||
(
|
||||
half const & value,
|
||||
genIType const & first,
|
||||
genIType const & count
|
||||
)
|
||||
{
|
||||
assert(first + count < sizeof(half));
|
||||
return (value._data() << first) >> ((sizeof(half) << 3) - count);
|
||||
}
|
||||
|
||||
template <typename genIType>
|
||||
GLM_FUNC_QUALIFIER genIType extractField
|
||||
(
|
||||
float const & value,
|
||||
genIType const & first,
|
||||
genIType const & count
|
||||
)
|
||||
{
|
||||
assert(first + count < sizeof(float));
|
||||
return (detail::uif32(value).i << first) >> ((sizeof(float) << 3) - count);
|
||||
}
|
||||
|
||||
template <typename genIType>
|
||||
GLM_FUNC_QUALIFIER genIType extractField
|
||||
(
|
||||
double const & value,
|
||||
genIType const & first,
|
||||
genIType const & count
|
||||
)
|
||||
{
|
||||
assert(first + count < sizeof(double));
|
||||
return (detail::uif64(value).i << first) >> ((sizeof(double) << genIType(3)) - count);
|
||||
}
|
||||
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER genIUType extractField
|
||||
(
|
||||
genIUType const & Value,
|
||||
sizeType const & First,
|
||||
sizeType const & Count
|
||||
)
|
||||
{
|
||||
sizeType GenSize = sizeof(genIUType) << 3;
|
||||
|
||||
assert(First + Count <= GenSize);
|
||||
|
||||
genIUType ShiftLeft = Count ? Value << (GenSize - (Count + First)) : 0;
|
||||
genIUType ShiftBack = ShiftLeft >> genIUType(GenSize - Count);
|
||||
|
||||
return ShiftBack;
|
||||
}
|
||||
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
|
||||
(
|
||||
detail::tvec2<genIUType> const & value,
|
||||
sizeType const & first,
|
||||
sizeType const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec2<genIUType>(
|
||||
extractField(value[0], first, count),
|
||||
extractField(value[1], first, count));
|
||||
}
|
||||
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
|
||||
(
|
||||
detail::tvec3<genIUType> const & value,
|
||||
sizeType const & first,
|
||||
sizeType const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec3<genIUType>(
|
||||
extractField(value[0], first, count),
|
||||
extractField(value[1], first, count),
|
||||
extractField(value[2], first, count));
|
||||
}
|
||||
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
|
||||
(
|
||||
detail::tvec4<genIUType> const & value,
|
||||
sizeType const & first,
|
||||
sizeType const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec4<genIUType>(
|
||||
extractField(value[0], first, count),
|
||||
extractField(value[1], first, count),
|
||||
extractField(value[2], first, count),
|
||||
extractField(value[3], first, count));
|
||||
}
|
||||
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
|
||||
(
|
||||
detail::tvec2<genIUType> const & value,
|
||||
detail::tvec2<sizeType> const & first,
|
||||
detail::tvec2<sizeType> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec2<genIUType>(
|
||||
extractField(value[0], first[0], count[0]),
|
||||
extractField(value[1], first[1], count[1]));
|
||||
}
|
||||
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
|
||||
(
|
||||
detail::tvec3<genIUType> const & value,
|
||||
detail::tvec3<sizeType> const & first,
|
||||
detail::tvec3<sizeType> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec3<genIUType>(
|
||||
extractField(value[0], first[0], count[0]),
|
||||
extractField(value[1], first[1], count[1]),
|
||||
extractField(value[2], first[2], count[2]));
|
||||
}
|
||||
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
|
||||
(
|
||||
detail::tvec4<genIUType> const & value,
|
||||
detail::tvec4<sizeType> const & first,
|
||||
detail::tvec4<sizeType> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec4<genIUType>(
|
||||
extractField(value[0], first[0], count[0]),
|
||||
extractField(value[1], first[1], count[1]),
|
||||
extractField(value[2], first[2], count[2]),
|
||||
extractField(value[3], first[3], count[3]));
|
||||
}
|
||||
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<genIUType> extractField
|
||||
(
|
||||
genIUType const & value,
|
||||
detail::tvec2<sizeType> const & first,
|
||||
detail::tvec2<sizeType> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec2<genIUType>(
|
||||
extractField(value, first[0], count[0]),
|
||||
extractField(value, first[1], count[1]));
|
||||
}
|
||||
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<genIUType> extractField
|
||||
(
|
||||
genIUType const & value,
|
||||
detail::tvec3<sizeType> const & first,
|
||||
detail::tvec3<sizeType> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec3<genIUType>(
|
||||
extractField(value, first[0], count[0]),
|
||||
extractField(value, first[1], count[1]),
|
||||
extractField(value, first[2], count[2]));
|
||||
}
|
||||
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<genIUType> extractField
|
||||
(
|
||||
genIUType const & value,
|
||||
detail::tvec4<sizeType> const & first,
|
||||
detail::tvec4<sizeType> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec4<genIUType>(
|
||||
extractField(value, first[0], count[0]),
|
||||
extractField(value, first[1], count[1]),
|
||||
extractField(value, first[2], count[2]),
|
||||
extractField(value, first[3], count[3]));
|
||||
}
|
||||
|
||||
// lowestBit
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER int lowestBit
|
||||
(
|
||||
genType const & Value
|
||||
)
|
||||
{
|
||||
assert(Value != genType(0)); // not valid call
|
||||
|
||||
genType Bit;
|
||||
for(Bit = genType(0); !(Value & (1 << Bit)); ++Bit){}
|
||||
return Bit;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<int> lowestBit
|
||||
(
|
||||
detail::tvec2<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec2<int>(
|
||||
lowestBit(value[0]),
|
||||
lowestBit(value[1]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<int> lowestBit
|
||||
(
|
||||
detail::tvec3<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec3<int>(
|
||||
lowestBit(value[0]),
|
||||
lowestBit(value[1]),
|
||||
lowestBit(value[2]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<int> lowestBit
|
||||
(
|
||||
detail::tvec4<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec4<int>(
|
||||
lowestBit(value[0]),
|
||||
lowestBit(value[1]),
|
||||
lowestBit(value[2]),
|
||||
lowestBit(value[3]));
|
||||
}
|
||||
|
||||
// highestBit
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER int highestBit
|
||||
(
|
||||
genType const & value
|
||||
)
|
||||
{
|
||||
assert(value != genType(0)); // not valid call
|
||||
|
||||
genType bit = genType(-1);
|
||||
for(genType tmp = value; tmp; tmp >>= 1, ++bit){}
|
||||
return bit;
|
||||
}
|
||||
|
||||
//template <>
|
||||
//GLM_FUNC_QUALIFIER int highestBit<int>
|
||||
//(
|
||||
// int value
|
||||
//)
|
||||
//{
|
||||
// int bit = -1;
|
||||
// for(int tmp = value; tmp; tmp >>= 1, ++bit);
|
||||
// return bit;
|
||||
//}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<int> highestBit
|
||||
(
|
||||
detail::tvec2<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec2<int>(
|
||||
highestBit(value[0]),
|
||||
highestBit(value[1]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<int> highestBit
|
||||
(
|
||||
detail::tvec3<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec3<int>(
|
||||
highestBit(value[0]),
|
||||
highestBit(value[1]),
|
||||
highestBit(value[2]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<int> highestBit
|
||||
(
|
||||
detail::tvec4<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec4<int>(
|
||||
highestBit(value[0]),
|
||||
highestBit(value[1]),
|
||||
highestBit(value[2]),
|
||||
highestBit(value[3]));
|
||||
}
|
||||
|
||||
// highestBitValue
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType highestBitValue
|
||||
(
|
||||
genType const & value
|
||||
)
|
||||
{
|
||||
genType tmp = value;
|
||||
genType result = genType(0);
|
||||
while(tmp)
|
||||
{
|
||||
result = (tmp & (~tmp + 1)); // grab lowest bit
|
||||
tmp &= ~result; // clear lowest bit
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<int> highestBitValue
|
||||
(
|
||||
detail::tvec2<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec2<int>(
|
||||
highestBitValue(value[0]),
|
||||
highestBitValue(value[1]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<int> highestBitValue
|
||||
(
|
||||
detail::tvec3<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec3<int>(
|
||||
highestBitValue(value[0]),
|
||||
highestBitValue(value[1]),
|
||||
highestBitValue(value[2]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<int> highestBitValue
|
||||
(
|
||||
detail::tvec4<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec4<int>(
|
||||
highestBitValue(value[0]),
|
||||
highestBitValue(value[1]),
|
||||
highestBitValue(value[2]),
|
||||
highestBitValue(value[3]));
|
||||
}
|
||||
|
||||
// isPowerOfTwo
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool isPowerOfTwo(genType const & Value)
|
||||
{
|
||||
//detail::If<std::numeric_limits<genType>::is_signed>::apply(abs, Value);
|
||||
//return !(Value & (Value - 1));
|
||||
|
||||
// For old complier?
|
||||
genType Result = Value;
|
||||
if(std::numeric_limits<genType>::is_signed)
|
||||
Result = abs(Result);
|
||||
return !(Result & (Result - 1));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isPowerOfTwo
|
||||
(
|
||||
detail::tvec2<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
isPowerOfTwo(value[0]),
|
||||
isPowerOfTwo(value[1]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isPowerOfTwo
|
||||
(
|
||||
detail::tvec3<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
isPowerOfTwo(value[0]),
|
||||
isPowerOfTwo(value[1]),
|
||||
isPowerOfTwo(value[2]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isPowerOfTwo
|
||||
(
|
||||
detail::tvec4<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
isPowerOfTwo(value[0]),
|
||||
isPowerOfTwo(value[1]),
|
||||
isPowerOfTwo(value[2]),
|
||||
isPowerOfTwo(value[3]));
|
||||
}
|
||||
|
||||
// powerOfTwoAbove
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType powerOfTwoAbove(genType const & value)
|
||||
{
|
||||
return isPowerOfTwo(value) ? value : highestBitValue(value) << 1;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoAbove
|
||||
(
|
||||
detail::tvec2<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
powerOfTwoAbove(value[0]),
|
||||
powerOfTwoAbove(value[1]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoAbove
|
||||
(
|
||||
detail::tvec3<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
powerOfTwoAbove(value[0]),
|
||||
powerOfTwoAbove(value[1]),
|
||||
powerOfTwoAbove(value[2]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoAbove
|
||||
(
|
||||
detail::tvec4<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
powerOfTwoAbove(value[0]),
|
||||
powerOfTwoAbove(value[1]),
|
||||
powerOfTwoAbove(value[2]),
|
||||
powerOfTwoAbove(value[3]));
|
||||
}
|
||||
|
||||
// powerOfTwoBelow
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType powerOfTwoBelow
|
||||
(
|
||||
genType const & value
|
||||
)
|
||||
{
|
||||
return isPowerOfTwo(value) ? value : highestBitValue(value);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoBelow
|
||||
(
|
||||
detail::tvec2<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
powerOfTwoBelow(value[0]),
|
||||
powerOfTwoBelow(value[1]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoBelow
|
||||
(
|
||||
detail::tvec3<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
powerOfTwoBelow(value[0]),
|
||||
powerOfTwoBelow(value[1]),
|
||||
powerOfTwoBelow(value[2]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoBelow
|
||||
(
|
||||
detail::tvec4<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
powerOfTwoBelow(value[0]),
|
||||
powerOfTwoBelow(value[1]),
|
||||
powerOfTwoBelow(value[2]),
|
||||
powerOfTwoBelow(value[3]));
|
||||
}
|
||||
|
||||
// powerOfTwoNearest
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType powerOfTwoNearest
|
||||
(
|
||||
genType const & value
|
||||
)
|
||||
{
|
||||
if(isPowerOfTwo(value))
|
||||
return value;
|
||||
|
||||
genType prev = highestBitValue(value);
|
||||
genType next = prev << 1;
|
||||
return (next - value) < (value - prev) ? next : prev;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> powerOfTwoNearest
|
||||
(
|
||||
detail::tvec2<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
powerOfTwoNearest(value[0]),
|
||||
powerOfTwoNearest(value[1]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> powerOfTwoNearest
|
||||
(
|
||||
detail::tvec3<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
powerOfTwoNearest(value[0]),
|
||||
powerOfTwoNearest(value[1]),
|
||||
powerOfTwoNearest(value[2]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> powerOfTwoNearest
|
||||
(
|
||||
detail::tvec4<valType> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
powerOfTwoNearest(value[0]),
|
||||
powerOfTwoNearest(value[1]),
|
||||
powerOfTwoNearest(value[2]),
|
||||
powerOfTwoNearest(value[3]));
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType bitRevert(genType const & In)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRevert' only accept integer values");
|
||||
|
||||
genType Out = 0;
|
||||
std::size_t BitSize = sizeof(genType) * 8;
|
||||
for(std::size_t i = 0; i < BitSize; ++i)
|
||||
if(In & (genType(1) << i))
|
||||
Out |= genType(1) << (BitSize - 1 - i);
|
||||
return Out;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRevert
|
||||
(
|
||||
detail::tvec2<valType> const & Value
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
bitRevert(Value[0]),
|
||||
bitRevert(Value[1]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRevert
|
||||
(
|
||||
detail::tvec3<valType> const & Value
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
bitRevert(Value[0]),
|
||||
bitRevert(Value[1]),
|
||||
bitRevert(Value[2]));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRevert
|
||||
(
|
||||
detail::tvec4<valType> const & Value
|
||||
)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
bitRevert(Value[0]),
|
||||
bitRevert(Value[1]),
|
||||
bitRevert(Value[2]),
|
||||
bitRevert(Value[3]));
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType bitRotateRight(genType const & In, std::size_t Shift)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateRight' only accept integer values");
|
||||
|
||||
std::size_t BitSize = sizeof(genType) * 8;
|
||||
return (In << Shift) | (In >> (BitSize - Shift));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRotateRight
|
||||
(
|
||||
detail::tvec2<valType> const & Value,
|
||||
std::size_t Shift
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
bitRotateRight(Value[0], Shift),
|
||||
bitRotateRight(Value[1], Shift));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRotateRight
|
||||
(
|
||||
detail::tvec3<valType> const & Value,
|
||||
std::size_t Shift
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
bitRotateRight(Value[0], Shift),
|
||||
bitRotateRight(Value[1], Shift),
|
||||
bitRotateRight(Value[2], Shift));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRotateRight
|
||||
(
|
||||
detail::tvec4<valType> const & Value,
|
||||
std::size_t Shift
|
||||
)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
bitRotateRight(Value[0], Shift),
|
||||
bitRotateRight(Value[1], Shift),
|
||||
bitRotateRight(Value[2], Shift),
|
||||
bitRotateRight(Value[3], Shift));
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType bitRotateLeft(genType const & In, std::size_t Shift)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_integer, "'bitRotateLeft' only accept integer values");
|
||||
|
||||
std::size_t BitSize = sizeof(genType) * 8;
|
||||
return (In >> Shift) | (In << (BitSize - Shift));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<valType> bitRotateLeft
|
||||
(
|
||||
detail::tvec2<valType> const & Value,
|
||||
std::size_t Shift
|
||||
)
|
||||
{
|
||||
return detail::tvec2<valType>(
|
||||
bitRotateLeft(Value[0], Shift),
|
||||
bitRotateLeft(Value[1], Shift));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> bitRotateLeft
|
||||
(
|
||||
detail::tvec3<valType> const & Value,
|
||||
std::size_t Shift
|
||||
)
|
||||
{
|
||||
return detail::tvec3<valType>(
|
||||
bitRotateLeft(Value[0], Shift),
|
||||
bitRotateLeft(Value[1], Shift),
|
||||
bitRotateLeft(Value[2], Shift));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<valType> bitRotateLeft
|
||||
(
|
||||
detail::tvec4<valType> const & Value,
|
||||
std::size_t Shift
|
||||
)
|
||||
{
|
||||
return detail::tvec4<valType>(
|
||||
bitRotateLeft(Value[0], Shift),
|
||||
bitRotateLeft(Value[1], Shift),
|
||||
bitRotateLeft(Value[2], Shift),
|
||||
bitRotateLeft(Value[3], Shift));
|
||||
}
|
||||
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType fillBitfieldWithOne
|
||||
(
|
||||
genIUType const & Value,
|
||||
int const & FromBit,
|
||||
int const & ToBit
|
||||
)
|
||||
{
|
||||
assert(FromBit <= ToBit);
|
||||
assert(ToBit <= sizeof(genIUType) * std::size_t(8));
|
||||
|
||||
genIUType Result = Value;
|
||||
for(std::size_t i = 0; i <= ToBit; ++i)
|
||||
Result |= (1 << i);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename genIUType>
|
||||
GLM_FUNC_QUALIFIER genIUType fillBitfieldWithZero
|
||||
(
|
||||
genIUType const & Value,
|
||||
int const & FromBit,
|
||||
int const & ToBit
|
||||
)
|
||||
{
|
||||
assert(FromBit <= ToBit);
|
||||
assert(ToBit <= sizeof(genIUType) * std::size_t(8));
|
||||
|
||||
genIUType Result = Value;
|
||||
for(std::size_t i = 0; i <= ToBit; ++i)
|
||||
Result &= ~(1 << i);
|
||||
return Result;
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
@ -7,224 +7,223 @@
|
||||
// File : glm/gtx/epsilon.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool equalEpsilon
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
genType const & epsilon
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
return abs(x - y) < epsilon;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool equalEpsilon
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
genType const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(x - y) < epsilon;
|
||||
}
|
||||
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool notEqualEpsilon
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
genType const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(x - y) >= epsilon;
|
||||
}
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER bool notEqualEpsilon
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
genType const & epsilon
|
||||
)
|
||||
{
|
||||
return abs(x - y) >= epsilon;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y,
|
||||
valType const & epsilon)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
abs(x.x - y.x) < epsilon,
|
||||
abs(x.y - y.y) < epsilon);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y,
|
||||
valType const & epsilon)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
abs(x.x - y.x) < epsilon,
|
||||
abs(x.y - y.y) < epsilon);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y,
|
||||
valType const & epsilon)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(x.x - y.x) < epsilon,
|
||||
abs(x.y - y.y) < epsilon,
|
||||
abs(x.z - y.z) < epsilon);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y,
|
||||
valType const & epsilon)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(x.x - y.x) < epsilon,
|
||||
abs(x.y - y.y) < epsilon,
|
||||
abs(x.z - y.z) < epsilon);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y,
|
||||
valType const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) < epsilon,
|
||||
abs(x.y - y.y) < epsilon,
|
||||
abs(x.z - y.z) < epsilon,
|
||||
abs(x.w - y.w) < epsilon);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y,
|
||||
valType const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) < epsilon,
|
||||
abs(x.y - y.y) < epsilon,
|
||||
abs(x.z - y.z) < epsilon,
|
||||
abs(x.w - y.w) < epsilon);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y,
|
||||
valType const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
abs(x.x - y.x) >= epsilon,
|
||||
abs(x.y - y.y) >= epsilon);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y,
|
||||
valType const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
abs(x.x - y.x) >= epsilon,
|
||||
abs(x.y - y.y) >= epsilon);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y,
|
||||
valType const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(x.x - y.x) >= epsilon,
|
||||
abs(x.y - y.y) >= epsilon,
|
||||
abs(x.z - y.z) >= epsilon);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y,
|
||||
valType const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(x.x - y.x) >= epsilon,
|
||||
abs(x.y - y.y) >= epsilon,
|
||||
abs(x.z - y.z) >= epsilon);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y,
|
||||
valType const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) >= epsilon,
|
||||
abs(x.y - y.y) >= epsilon,
|
||||
abs(x.z - y.z) >= epsilon,
|
||||
abs(x.w - y.w) >= epsilon);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y,
|
||||
valType const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) >= epsilon,
|
||||
abs(x.y - y.y) >= epsilon,
|
||||
abs(x.z - y.z) >= epsilon,
|
||||
abs(x.w - y.w) >= epsilon);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y,
|
||||
detail::tvec2<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y,
|
||||
detail::tvec2<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y,
|
||||
detail::tvec3<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y,
|
||||
abs(x.z - y.z) < epsilon.z);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y,
|
||||
detail::tvec3<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y,
|
||||
abs(x.z - y.z) < epsilon.z);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y,
|
||||
detail::tvec4<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y,
|
||||
abs(x.z - y.z) < epsilon.z,
|
||||
abs(x.w - y.w) < epsilon.w);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y,
|
||||
detail::tvec4<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y,
|
||||
abs(x.z - y.z) < epsilon.z,
|
||||
abs(x.w - y.w) < epsilon.w);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
||||
(
|
||||
detail::tquat<valType> const & x,
|
||||
detail::tquat<valType> const & y,
|
||||
detail::tquat<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y,
|
||||
abs(x.z - y.z) < epsilon.z,
|
||||
abs(x.w - y.w) < epsilon.w);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
||||
(
|
||||
detail::tquat<valType> const & x,
|
||||
detail::tquat<valType> const & y,
|
||||
detail::tquat<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y,
|
||||
abs(x.z - y.z) < epsilon.z,
|
||||
abs(x.w - y.w) < epsilon.w);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y,
|
||||
detail::tvec2<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec2<valType> const & x,
|
||||
detail::tvec2<valType> const & y,
|
||||
detail::tvec2<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec2<bool>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y,
|
||||
detail::tvec3<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y,
|
||||
abs(x.z - y.z) >= epsilon.z);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec3<valType> const & x,
|
||||
detail::tvec3<valType> const & y,
|
||||
detail::tvec3<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y,
|
||||
abs(x.z - y.z) >= epsilon.z);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y,
|
||||
detail::tvec4<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y,
|
||||
abs(x.z - y.z) >= epsilon.z,
|
||||
abs(x.w - y.w) >= epsilon.w);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tquat<valType> const & x,
|
||||
detail::tquat<valType> const & y,
|
||||
detail::tquat<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y,
|
||||
abs(x.z - y.z) >= epsilon.z,
|
||||
abs(x.w - y.w) >= epsilon.w);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tvec4<valType> const & x,
|
||||
detail::tvec4<valType> const & y,
|
||||
detail::tvec4<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y,
|
||||
abs(x.z - y.z) >= epsilon.z,
|
||||
abs(x.w - y.w) >= epsilon.w);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
||||
(
|
||||
detail::tquat<valType> const & x,
|
||||
detail::tquat<valType> const & y,
|
||||
detail::tquat<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y,
|
||||
abs(x.z - y.z) >= epsilon.z,
|
||||
abs(x.w - y.w) >= epsilon.w);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,239 +7,238 @@
|
||||
// File : glm/gtx/euler_angles.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
|
||||
(
|
||||
valType const & angleX
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
valType cosX = glm::cos(angleX);
|
||||
valType sinX = glm::sin(angleX);
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
|
||||
(
|
||||
valType const & angleX
|
||||
)
|
||||
{
|
||||
valType cosX = glm::cos(angleX);
|
||||
valType sinX = glm::sin(angleX);
|
||||
|
||||
return detail::tmat4x4<valType>(
|
||||
valType(1), valType(0), valType(0), valType(0),
|
||||
valType(0), cosX, sinX, valType(0),
|
||||
valType(0),-sinX, cosX, valType(0),
|
||||
valType(0), valType(0), valType(0), valType(1));
|
||||
}
|
||||
return detail::tmat4x4<valType>(
|
||||
valType(1), valType(0), valType(0), valType(0),
|
||||
valType(0), cosX, sinX, valType(0),
|
||||
valType(0),-sinX, cosX, valType(0),
|
||||
valType(0), valType(0), valType(0), valType(1));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleY
|
||||
(
|
||||
valType const & angleY
|
||||
)
|
||||
{
|
||||
valType cosY = glm::cos(angleY);
|
||||
valType sinY = glm::sin(angleY);
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleY
|
||||
(
|
||||
valType const & angleY
|
||||
)
|
||||
{
|
||||
valType cosY = glm::cos(angleY);
|
||||
valType sinY = glm::sin(angleY);
|
||||
|
||||
return detail::tmat4x4<valType>(
|
||||
cosY, valType(0), sinY, valType(0),
|
||||
valType(0), valType(1), valType(0), valType(0),
|
||||
-sinY, valType(0), cosY, valType(0),
|
||||
valType(0), valType(0), valType(0), valType(1));
|
||||
}
|
||||
return detail::tmat4x4<valType>(
|
||||
cosY, valType(0), sinY, valType(0),
|
||||
valType(0), valType(1), valType(0), valType(0),
|
||||
-sinY, valType(0), cosY, valType(0),
|
||||
valType(0), valType(0), valType(0), valType(1));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZ
|
||||
(
|
||||
valType const & angleZ
|
||||
)
|
||||
{
|
||||
valType cosZ = glm::cos(angleZ);
|
||||
valType sinZ = glm::sin(angleZ);
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZ
|
||||
(
|
||||
valType const & angleZ
|
||||
)
|
||||
{
|
||||
valType cosZ = glm::cos(angleZ);
|
||||
valType sinZ = glm::sin(angleZ);
|
||||
|
||||
return detail::tmat4x4<valType>(
|
||||
cosZ, sinZ, valType(0), valType(0),
|
||||
-sinZ, cosZ, valType(0), valType(0),
|
||||
valType(0), valType(0), valType(1), valType(0),
|
||||
valType(0), valType(0), valType(0), valType(1));
|
||||
}
|
||||
return detail::tmat4x4<valType>(
|
||||
cosZ, sinZ, valType(0), valType(0),
|
||||
-sinZ, cosZ, valType(0), valType(0),
|
||||
valType(0), valType(0), valType(1), valType(0),
|
||||
valType(0), valType(0), valType(0), valType(1));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXY
|
||||
(
|
||||
valType const & angleX,
|
||||
valType const & angleY
|
||||
)
|
||||
{
|
||||
valType cosX = glm::cos(angleX);
|
||||
valType sinX = glm::sin(angleX);
|
||||
valType cosY = glm::cos(angleY);
|
||||
valType sinY = glm::sin(angleY);
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXY
|
||||
(
|
||||
valType const & angleX,
|
||||
valType const & angleY
|
||||
)
|
||||
{
|
||||
valType cosX = glm::cos(angleX);
|
||||
valType sinX = glm::sin(angleX);
|
||||
valType cosY = glm::cos(angleY);
|
||||
valType sinY = glm::sin(angleY);
|
||||
|
||||
return detail::tmat4x4<valType>(
|
||||
cosY, -sinX * sinY, cosX * sinY, valType(0),
|
||||
valType(0), cosX, sinX, valType(0),
|
||||
-sinY , -sinX * cosY, cosX * cosY, valType(0),
|
||||
valType(0), valType(0), valType(0), valType(1));
|
||||
}
|
||||
return detail::tmat4x4<valType>(
|
||||
cosY, -sinX * sinY, cosX * sinY, valType(0),
|
||||
valType(0), cosX, sinX, valType(0),
|
||||
-sinY , -sinX * cosY, cosX * cosY, valType(0),
|
||||
valType(0), valType(0), valType(0), valType(1));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYX
|
||||
(
|
||||
valType const & angleY,
|
||||
valType const & angleX
|
||||
)
|
||||
{
|
||||
valType cosX = glm::cos(angleX);
|
||||
valType sinX = glm::sin(angleX);
|
||||
valType cosY = glm::cos(angleY);
|
||||
valType sinY = glm::sin(angleY);
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYX
|
||||
(
|
||||
valType const & angleY,
|
||||
valType const & angleX
|
||||
)
|
||||
{
|
||||
valType cosX = glm::cos(angleX);
|
||||
valType sinX = glm::sin(angleX);
|
||||
valType cosY = glm::cos(angleY);
|
||||
valType sinY = glm::sin(angleY);
|
||||
|
||||
return detail::tmat4x4<valType>(
|
||||
cosY, valType(0), sinY, valType(0),
|
||||
-sinX * sinY, cosX, sinX * cosY, valType(0),
|
||||
-cosX * sinY, -sinX, cosX * cosY, valType(0),
|
||||
valType(0), valType(0), valType(0), valType(1));
|
||||
}
|
||||
return detail::tmat4x4<valType>(
|
||||
cosY, valType(0), sinY, valType(0),
|
||||
-sinX * sinY, cosX, sinX * cosY, valType(0),
|
||||
-cosX * sinY, -sinX, cosX * cosY, valType(0),
|
||||
valType(0), valType(0), valType(0), valType(1));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXZ
|
||||
(
|
||||
valType const & angleX,
|
||||
valType const & angleZ
|
||||
)
|
||||
{
|
||||
return eulerAngleX(angleX) * eulerAngleZ(angleZ);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXZ
|
||||
(
|
||||
valType const & angleX,
|
||||
valType const & angleZ
|
||||
)
|
||||
{
|
||||
return eulerAngleX(angleX) * eulerAngleZ(angleZ);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZX
|
||||
(
|
||||
valType const & angleZ,
|
||||
valType const & angleX
|
||||
)
|
||||
{
|
||||
return eulerAngleZ(angleZ) * eulerAngleX(angleX);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZX
|
||||
(
|
||||
valType const & angleZ,
|
||||
valType const & angleX
|
||||
)
|
||||
{
|
||||
return eulerAngleZ(angleZ) * eulerAngleX(angleX);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYXZ
|
||||
(
|
||||
valType const & yaw,
|
||||
valType const & pitch,
|
||||
valType const & roll
|
||||
)
|
||||
{
|
||||
valType tmp_ch = glm::cos(yaw);
|
||||
valType tmp_sh = glm::sin(yaw);
|
||||
valType tmp_cp = glm::cos(pitch);
|
||||
valType tmp_sp = glm::sin(pitch);
|
||||
valType tmp_cb = glm::cos(roll);
|
||||
valType tmp_sb = glm::sin(roll);
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYXZ
|
||||
(
|
||||
valType const & yaw,
|
||||
valType const & pitch,
|
||||
valType const & roll
|
||||
)
|
||||
{
|
||||
valType tmp_ch = glm::cos(yaw);
|
||||
valType tmp_sh = glm::sin(yaw);
|
||||
valType tmp_cp = glm::cos(pitch);
|
||||
valType tmp_sp = glm::sin(pitch);
|
||||
valType tmp_cb = glm::cos(roll);
|
||||
valType tmp_sb = glm::sin(roll);
|
||||
|
||||
detail::tmat4x4<valType> Result;
|
||||
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
|
||||
Result[0][1] = tmp_sb * tmp_cp;
|
||||
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
|
||||
Result[0][3] = valType(0);
|
||||
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
|
||||
Result[1][1] = tmp_cb * tmp_cp;
|
||||
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
|
||||
Result[1][3] = valType(0);
|
||||
Result[2][0] = tmp_sh * tmp_cp;
|
||||
Result[2][1] = -tmp_sp;
|
||||
Result[2][2] = tmp_ch * tmp_cp;
|
||||
Result[2][3] = valType(0);
|
||||
Result[3][0] = valType(0);
|
||||
Result[3][1] = valType(0);
|
||||
Result[3][2] = valType(0);
|
||||
Result[3][3] = valType(1);
|
||||
return Result;
|
||||
}
|
||||
detail::tmat4x4<valType> Result;
|
||||
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
|
||||
Result[0][1] = tmp_sb * tmp_cp;
|
||||
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
|
||||
Result[0][3] = valType(0);
|
||||
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
|
||||
Result[1][1] = tmp_cb * tmp_cp;
|
||||
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
|
||||
Result[1][3] = valType(0);
|
||||
Result[2][0] = tmp_sh * tmp_cp;
|
||||
Result[2][1] = -tmp_sp;
|
||||
Result[2][2] = tmp_ch * tmp_cp;
|
||||
Result[2][3] = valType(0);
|
||||
Result[3][0] = valType(0);
|
||||
Result[3][1] = valType(0);
|
||||
Result[3][2] = valType(0);
|
||||
Result[3][3] = valType(1);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> yawPitchRoll
|
||||
(
|
||||
valType const & yaw,
|
||||
valType const & pitch,
|
||||
valType const & roll
|
||||
)
|
||||
{
|
||||
valType tmp_ch = glm::cos(yaw);
|
||||
valType tmp_sh = glm::sin(yaw);
|
||||
valType tmp_cp = glm::cos(pitch);
|
||||
valType tmp_sp = glm::sin(pitch);
|
||||
valType tmp_cb = glm::cos(roll);
|
||||
valType tmp_sb = glm::sin(roll);
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> yawPitchRoll
|
||||
(
|
||||
valType const & yaw,
|
||||
valType const & pitch,
|
||||
valType const & roll
|
||||
)
|
||||
{
|
||||
valType tmp_ch = glm::cos(yaw);
|
||||
valType tmp_sh = glm::sin(yaw);
|
||||
valType tmp_cp = glm::cos(pitch);
|
||||
valType tmp_sp = glm::sin(pitch);
|
||||
valType tmp_cb = glm::cos(roll);
|
||||
valType tmp_sb = glm::sin(roll);
|
||||
|
||||
detail::tmat4x4<valType> Result;
|
||||
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
|
||||
Result[0][1] = tmp_sb * tmp_cp;
|
||||
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
|
||||
Result[0][3] = valType(0);
|
||||
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
|
||||
Result[1][1] = tmp_cb * tmp_cp;
|
||||
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
|
||||
Result[1][3] = valType(0);
|
||||
Result[2][0] = tmp_sh * tmp_cp;
|
||||
Result[2][1] = -tmp_sp;
|
||||
Result[2][2] = tmp_ch * tmp_cp;
|
||||
Result[2][3] = valType(0);
|
||||
Result[3][0] = valType(0);
|
||||
Result[3][1] = valType(0);
|
||||
Result[3][2] = valType(0);
|
||||
Result[3][3] = valType(1);
|
||||
return Result;
|
||||
}
|
||||
detail::tmat4x4<valType> Result;
|
||||
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
|
||||
Result[0][1] = tmp_sb * tmp_cp;
|
||||
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
|
||||
Result[0][3] = valType(0);
|
||||
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
|
||||
Result[1][1] = tmp_cb * tmp_cp;
|
||||
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
|
||||
Result[1][3] = valType(0);
|
||||
Result[2][0] = tmp_sh * tmp_cp;
|
||||
Result[2][1] = -tmp_sp;
|
||||
Result[2][2] = tmp_ch * tmp_cp;
|
||||
Result[2][3] = valType(0);
|
||||
Result[3][0] = valType(0);
|
||||
Result[3][1] = valType(0);
|
||||
Result[3][2] = valType(0);
|
||||
Result[3][3] = valType(1);
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> orientate2
|
||||
(
|
||||
valType const & angle
|
||||
)
|
||||
{
|
||||
valType c = glm::cos(angle);
|
||||
valType s = glm::sin(angle);
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> orientate2
|
||||
(
|
||||
valType const & angle
|
||||
)
|
||||
{
|
||||
valType c = glm::cos(angle);
|
||||
valType s = glm::sin(angle);
|
||||
|
||||
detail::tmat2x2<valType> Result;
|
||||
Result[0][0] = c;
|
||||
Result[0][1] = s;
|
||||
Result[1][0] = -s;
|
||||
Result[1][1] = c;
|
||||
return Result;
|
||||
}
|
||||
detail::tmat2x2<valType> Result;
|
||||
Result[0][0] = c;
|
||||
Result[0][1] = s;
|
||||
Result[1][0] = -s;
|
||||
Result[1][1] = c;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
|
||||
(
|
||||
valType const & angle
|
||||
)
|
||||
{
|
||||
valType c = glm::cos(angle);
|
||||
valType s = glm::sin(angle);
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
|
||||
(
|
||||
valType const & angle
|
||||
)
|
||||
{
|
||||
valType c = glm::cos(angle);
|
||||
valType s = glm::sin(angle);
|
||||
|
||||
detail::tmat3x3<valType> Result;
|
||||
Result[0][0] = c;
|
||||
Result[0][1] = s;
|
||||
Result[0][2] = 0.0f;
|
||||
Result[1][0] = -s;
|
||||
Result[1][1] = c;
|
||||
Result[1][2] = 0.0f;
|
||||
Result[2][0] = 0.0f;
|
||||
Result[2][1] = 0.0f;
|
||||
Result[2][2] = 1.0f;
|
||||
return Result;
|
||||
}
|
||||
detail::tmat3x3<valType> Result;
|
||||
Result[0][0] = c;
|
||||
Result[0][1] = s;
|
||||
Result[0][2] = 0.0f;
|
||||
Result[1][0] = -s;
|
||||
Result[1][1] = c;
|
||||
Result[1][2] = 0.0f;
|
||||
Result[2][0] = 0.0f;
|
||||
Result[2][1] = 0.0f;
|
||||
Result[2][2] = 1.0f;
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
|
||||
(
|
||||
detail::tvec3<valType> const & angles
|
||||
)
|
||||
{
|
||||
return detail::tmat3x3<valType>(yawPitchRoll(angles.x, angles.y, angles.z));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> orientate4
|
||||
(
|
||||
detail::tvec3<valType> const & angles
|
||||
)
|
||||
{
|
||||
return yawPitchRoll(angles.z, angles.x, angles.y);
|
||||
}
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
|
||||
(
|
||||
detail::tvec3<valType> const & angles
|
||||
)
|
||||
{
|
||||
return detail::tmat3x3<valType>(yawPitchRoll(angles.x, angles.y, angles.z));
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> orientate4
|
||||
(
|
||||
detail::tvec3<valType> const & angles
|
||||
)
|
||||
{
|
||||
return yawPitchRoll(angles.z, angles.x, angles.y);
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -7,50 +7,49 @@
|
||||
// File : glm/gtx/extend.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
|
||||
template <typename genType>
|
||||
genType extend
|
||||
(
|
||||
genType const & Origin,
|
||||
genType const & Source,
|
||||
genType const & Distance
|
||||
)
|
||||
namespace glm
|
||||
{
|
||||
return Origin + (Source - Origin) * Distance;
|
||||
}
|
||||
template <typename genType>
|
||||
genType extend
|
||||
(
|
||||
genType const & Origin,
|
||||
genType const & Source,
|
||||
genType const & Distance
|
||||
)
|
||||
{
|
||||
return Origin + (Source - Origin) * Distance;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
detail::tvec2<valType> extend
|
||||
(
|
||||
detail::tvec2<valType> const & Origin,
|
||||
detail::tvec2<valType> const & Source,
|
||||
valType const & Distance
|
||||
)
|
||||
{
|
||||
return Origin + (Source - Origin) * Distance;
|
||||
}
|
||||
template <typename valType>
|
||||
detail::tvec2<valType> extend
|
||||
(
|
||||
detail::tvec2<valType> const & Origin,
|
||||
detail::tvec2<valType> const & Source,
|
||||
valType const & Distance
|
||||
)
|
||||
{
|
||||
return Origin + (Source - Origin) * Distance;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
detail::tvec3<valType> extend
|
||||
(
|
||||
detail::tvec3<valType> const & Origin,
|
||||
detail::tvec3<valType> const & Source,
|
||||
valType const & Distance
|
||||
)
|
||||
{
|
||||
return Origin + (Source - Origin) * Distance;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
detail::tvec4<valType> extend
|
||||
(
|
||||
detail::tvec4<valType> const & Origin,
|
||||
detail::tvec4<valType> const & Source,
|
||||
valType const & Distance
|
||||
)
|
||||
{
|
||||
return Origin + (Source - Origin) * Distance;
|
||||
}
|
||||
template <typename valType>
|
||||
detail::tvec3<valType> extend
|
||||
(
|
||||
detail::tvec3<valType> const & Origin,
|
||||
detail::tvec3<valType> const & Source,
|
||||
valType const & Distance
|
||||
)
|
||||
{
|
||||
return Origin + (Source - Origin) * Distance;
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
detail::tvec4<valType> extend
|
||||
(
|
||||
detail::tvec4<valType> const & Origin,
|
||||
detail::tvec4<valType> const & Source,
|
||||
valType const & Distance
|
||||
)
|
||||
{
|
||||
return Origin + (Source - Origin) * Distance;
|
||||
}
|
||||
}//namespace glm
|
||||
|
@ -54,17 +54,17 @@ namespace glm
|
||||
|
||||
//! Faster than the common pow function but less accurate.
|
||||
//! From GLM_GTX_fast_exponential extension.
|
||||
template <typename valType>
|
||||
valType fastPow(
|
||||
valType const & x,
|
||||
valType const & y);
|
||||
template <typename genType>
|
||||
genType fastPow(
|
||||
genType const & x,
|
||||
genType const & y);
|
||||
|
||||
//! Faster than the common pow function but less accurate.
|
||||
//! From GLM_GTX_fast_exponential extension.
|
||||
template <typename T, typename U>
|
||||
T fastPow(
|
||||
const T& x,
|
||||
const U& y);
|
||||
template <typename genTypeT, typename genTypeU>
|
||||
genType fastPow(
|
||||
genTypeT const & x,
|
||||
genTypeU const & y);
|
||||
|
||||
//! Faster than the common exp function but less accurate.
|
||||
//! From GLM_GTX_fast_exponential extension.
|
||||
|
@ -7,284 +7,144 @@
|
||||
// File : glm/gtx/fast_exponential.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace glm{
|
||||
#include "../core/_vectorize.hpp"
|
||||
|
||||
// fastPow:
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T fastPow(const T x, const T y)
|
||||
namespace glm
|
||||
{
|
||||
return exp(y * log(x));
|
||||
}
|
||||
// fastPow:
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastPow(genType const & x, genType const & y)
|
||||
{
|
||||
return exp(y * log(x));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow(
|
||||
const detail::tvec2<T>& x,
|
||||
const detail::tvec2<T>& y)
|
||||
{
|
||||
return detail::tvec2<T>(
|
||||
fastPow(x.x, y.x),
|
||||
fastPow(x.y, y.y));
|
||||
}
|
||||
VECTORIZE_VEC_VEC(fastPow)
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow(
|
||||
const detail::tvec3<T>& x,
|
||||
const detail::tvec3<T>& y)
|
||||
{
|
||||
return detail::tvec3<T>(
|
||||
fastPow(x.x, y.x),
|
||||
fastPow(x.y, y.y),
|
||||
fastPow(x.z, y.z));
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T fastPow(const T x, int y)
|
||||
{
|
||||
T f = T(1);
|
||||
for(int i = 0; i < y; ++i)
|
||||
f *= x;
|
||||
return f;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
|
||||
const detail::tvec4<T>& x,
|
||||
const detail::tvec4<T>& y)
|
||||
{
|
||||
return detail::tvec4<T>(
|
||||
fastPow(x.x, y.x),
|
||||
fastPow(x.y, y.y),
|
||||
fastPow(x.z, y.z),
|
||||
fastPow(x.w, y.w));
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow(
|
||||
const detail::tvec2<T>& x,
|
||||
const detail::tvec2<int>& y)
|
||||
{
|
||||
return detail::tvec2<T>(
|
||||
fastPow(x.x, y.x),
|
||||
fastPow(x.y, y.y));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T fastPow(const T x, int y)
|
||||
{
|
||||
T f = T(1);
|
||||
for(int i = 0; i < y; ++i)
|
||||
f *= x;
|
||||
return f;
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow(
|
||||
const detail::tvec3<T>& x,
|
||||
const detail::tvec3<int>& y)
|
||||
{
|
||||
return detail::tvec3<T>(
|
||||
fastPow(x.x, y.x),
|
||||
fastPow(x.y, y.y),
|
||||
fastPow(x.z, y.z));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow(
|
||||
const detail::tvec2<T>& x,
|
||||
const detail::tvec2<int>& y)
|
||||
{
|
||||
return detail::tvec2<T>(
|
||||
fastPow(x.x, y.x),
|
||||
fastPow(x.y, y.y));
|
||||
}
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
|
||||
const detail::tvec4<T>& x,
|
||||
const detail::tvec4<int>& y)
|
||||
{
|
||||
return detail::tvec4<T>(
|
||||
fastPow(x.x, y.x),
|
||||
fastPow(x.y, y.y),
|
||||
fastPow(x.z, y.z),
|
||||
fastPow(x.w, y.w));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow(
|
||||
const detail::tvec3<T>& x,
|
||||
const detail::tvec3<int>& y)
|
||||
{
|
||||
return detail::tvec3<T>(
|
||||
fastPow(x.x, y.x),
|
||||
fastPow(x.y, y.y),
|
||||
fastPow(x.z, y.z));
|
||||
}
|
||||
// fastExp
|
||||
// Note: This function provides accurate results only for value between -1 and 1, else avoid it.
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T fastExp(const T x)
|
||||
{
|
||||
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
|
||||
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
|
||||
T x2 = x * x;
|
||||
T x3 = x2 * x;
|
||||
T x4 = x3 * x;
|
||||
T x5 = x4 * x;
|
||||
return T(1) + x + (x2 * T(0.5)) + (x3 * T(0.1666666667)) + (x4 * T(0.041666667)) + (x5 * T(0.008333333333));
|
||||
}
|
||||
/* // Try to handle all values of float... but often shower than std::exp, glm::floor and the loop kill the performance
|
||||
GLM_FUNC_QUALIFIER float fastExp(float x)
|
||||
{
|
||||
const float e = 2.718281828f;
|
||||
const float IntegerPart = floor(x);
|
||||
const float FloatPart = x - IntegerPart;
|
||||
float z = 1.f;
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
|
||||
const detail::tvec4<T>& x,
|
||||
const detail::tvec4<int>& y)
|
||||
{
|
||||
return detail::tvec4<T>(
|
||||
fastPow(x.x, y.x),
|
||||
fastPow(x.y, y.y),
|
||||
fastPow(x.z, y.z),
|
||||
fastPow(x.w, y.w));
|
||||
}
|
||||
for(int i = 0; i < int(IntegerPart); ++i)
|
||||
z *= e;
|
||||
|
||||
// fastExp
|
||||
// Note: This function provides accurate results only for value between -1 and 1, else avoid it.
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T fastExp(const T x)
|
||||
{
|
||||
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
|
||||
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
|
||||
T x2 = x * x;
|
||||
T x3 = x2 * x;
|
||||
T x4 = x3 * x;
|
||||
T x5 = x4 * x;
|
||||
return T(1) + x + (x2 * T(0.5)) + (x3 * T(0.1666666667)) + (x4 * T(0.041666667)) + (x5 * T(0.008333333333));
|
||||
}
|
||||
/* // Try to handle all values of float... but often shower than std::exp, glm::floor and the loop kill the performance
|
||||
GLM_FUNC_QUALIFIER float fastExp(float x)
|
||||
{
|
||||
const float e = 2.718281828f;
|
||||
const float IntegerPart = floor(x);
|
||||
const float FloatPart = x - IntegerPart;
|
||||
float z = 1.f;
|
||||
const float x2 = FloatPart * FloatPart;
|
||||
const float x3 = x2 * FloatPart;
|
||||
const float x4 = x3 * FloatPart;
|
||||
const float x5 = x4 * FloatPart;
|
||||
return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f));
|
||||
}
|
||||
|
||||
for(int i = 0; i < int(IntegerPart); ++i)
|
||||
z *= e;
|
||||
// Increase accuracy on number bigger that 1 and smaller than -1 but it's not enough for high and negative numbers
|
||||
GLM_FUNC_QUALIFIER float fastExp(float x)
|
||||
{
|
||||
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
|
||||
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
|
||||
float x2 = x * x;
|
||||
float x3 = x2 * x;
|
||||
float x4 = x3 * x;
|
||||
float x5 = x4 * x;
|
||||
float x6 = x5 * x;
|
||||
float x7 = x6 * x;
|
||||
float x8 = x7 * x;
|
||||
return 1.0f + x + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)+ (x6 * 0.00138888888888f) + (x7 * 0.000198412698f) + (x8 * 0.0000248015873f);;
|
||||
}
|
||||
*/
|
||||
|
||||
const float x2 = FloatPart * FloatPart;
|
||||
const float x3 = x2 * FloatPart;
|
||||
const float x4 = x3 * FloatPart;
|
||||
const float x5 = x4 * FloatPart;
|
||||
return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f));
|
||||
}
|
||||
VECTORIZE_VEC(fastExp)
|
||||
|
||||
// Increase accuracy on number bigger that 1 and smaller than -1 but it's not enough for high and negative numbers
|
||||
GLM_FUNC_QUALIFIER float fastExp(float x)
|
||||
{
|
||||
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
|
||||
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
|
||||
float x2 = x * x;
|
||||
float x3 = x2 * x;
|
||||
float x4 = x3 * x;
|
||||
float x5 = x4 * x;
|
||||
float x6 = x5 * x;
|
||||
float x7 = x6 * x;
|
||||
float x8 = x7 * x;
|
||||
return 1.0f + x + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f)+ (x6 * 0.00138888888888f) + (x7 * 0.000198412698f) + (x8 * 0.0000248015873f);;
|
||||
}
|
||||
*/
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> fastExp(
|
||||
const detail::tvec2<T>& x)
|
||||
{
|
||||
return detail::tvec2<T>(
|
||||
fastExp(x.x),
|
||||
fastExp(x.y));
|
||||
}
|
||||
// fastLog
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastLog(genType const & x)
|
||||
{
|
||||
return std::log(x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp(
|
||||
const detail::tvec3<T>& x)
|
||||
{
|
||||
return detail::tvec3<T>(
|
||||
fastExp(x.x),
|
||||
fastExp(x.y),
|
||||
fastExp(x.z));
|
||||
}
|
||||
/* Slower than the VC7.1 function...
|
||||
GLM_FUNC_QUALIFIER float fastLog(float x)
|
||||
{
|
||||
float y1 = (x - 1.0f) / (x + 1.0f);
|
||||
float y2 = y1 * y1;
|
||||
return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f)));
|
||||
}
|
||||
*/
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> fastExp(
|
||||
const detail::tvec4<T>& x)
|
||||
{
|
||||
return detail::tvec4<T>(
|
||||
fastExp(x.x),
|
||||
fastExp(x.y),
|
||||
fastExp(x.z),
|
||||
fastExp(x.w));
|
||||
}
|
||||
VECTORIZE_VEC(fastLog)
|
||||
|
||||
// fastLog
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T fastLog(const T x)
|
||||
{
|
||||
return std::log(x);
|
||||
}
|
||||
//fastExp2, ln2 = 0.69314718055994530941723212145818f
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastExp2(genType const & x)
|
||||
{
|
||||
return fastExp(0.69314718055994530941723212145818f * x);
|
||||
}
|
||||
|
||||
/* Slower than the VC7.1 function...
|
||||
GLM_FUNC_QUALIFIER float fastLog(float x)
|
||||
{
|
||||
float y1 = (x - 1.0f) / (x + 1.0f);
|
||||
float y2 = y1 * y1;
|
||||
return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f)));
|
||||
}
|
||||
*/
|
||||
VECTORIZE_VEC(fastExp2)
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog(
|
||||
const detail::tvec2<T>& x)
|
||||
{
|
||||
return detail::tvec2<T>(
|
||||
fastLog(x.x),
|
||||
fastLog(x.y));
|
||||
}
|
||||
// fastLog2, ln2 = 0.69314718055994530941723212145818f
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType fastLog2(genType const & x)
|
||||
{
|
||||
return fastLog(x) / 0.69314718055994530941723212145818f;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> fastLog(
|
||||
const detail::tvec3<T>& x)
|
||||
{
|
||||
return detail::tvec3<T>(
|
||||
fastLog(x.x),
|
||||
fastLog(x.y),
|
||||
fastLog(x.z));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> fastLog(
|
||||
const detail::tvec4<T>& x)
|
||||
{
|
||||
return detail::tvec4<T>(
|
||||
fastLog(x.x),
|
||||
fastLog(x.y),
|
||||
fastLog(x.z),
|
||||
fastLog(x.w));
|
||||
}
|
||||
|
||||
//fastExp2, ln2 = 0.69314718055994530941723212145818f
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T fastExp2(const T x)
|
||||
{
|
||||
return fastExp(0.69314718055994530941723212145818f * x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> fastExp2(
|
||||
const detail::tvec2<T>& x)
|
||||
{
|
||||
return detail::tvec2<T>(
|
||||
fastExp2(x.x),
|
||||
fastExp2(x.y));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp2(
|
||||
const detail::tvec3<T>& x)
|
||||
{
|
||||
return detail::tvec3<T>(
|
||||
fastExp2(x.x),
|
||||
fastExp2(x.y),
|
||||
fastExp2(x.z));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> fastExp2(
|
||||
const detail::tvec4<T>& x)
|
||||
{
|
||||
return detail::tvec4<T>(
|
||||
fastExp2(x.x),
|
||||
fastExp2(x.y),
|
||||
fastExp2(x.z),
|
||||
fastExp2(x.w));
|
||||
}
|
||||
|
||||
// fastLog2, ln2 = 0.69314718055994530941723212145818f
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T fastLog2(const T x)
|
||||
{
|
||||
return fastLog(x) / 0.69314718055994530941723212145818f;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog2(
|
||||
const detail::tvec2<T>& x)
|
||||
{
|
||||
return detail::tvec2<T>(
|
||||
fastLog2(x.x),
|
||||
fastLog2(x.y));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T> fastLog2(
|
||||
const detail::tvec3<T>& x)
|
||||
{
|
||||
return detail::tvec3<T>(
|
||||
fastLog2(x.x),
|
||||
fastLog2(x.y),
|
||||
fastLog2(x.z));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T> fastLog2(
|
||||
const detail::tvec4<T>& x)
|
||||
{
|
||||
return detail::tvec4<T>(
|
||||
fastLog2(x.x),
|
||||
fastLog2(x.y),
|
||||
fastLog2(x.z),
|
||||
fastLog2(x.w));
|
||||
}
|
||||
VECTORIZE_VEC(fastLog2)
|
||||
|
||||
}//namespace glm
|
||||
|
Loading…
Reference in New Issue
Block a user