mirror of
https://github.com/g-truc/glm.git
synced 2024-11-26 18:24:35 +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
|
#ifndef glm_gtx_closest_point
|
||||||
#define glm_gtx_closest_point
|
#define glm_gtx_closest_point
|
||||||
|
|
||||||
namespace glm{
|
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
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
valType LineLength = distance(a, b);
|
template <typename valType>
|
||||||
detail::tvec3<valType> Vector = point - a;
|
GLM_FUNC_QUALIFIER detail::tvec3<valType> closestPointOnLine
|
||||||
detail::tvec3<valType> LineDirection = (b - a) / LineLength;
|
(
|
||||||
|
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
|
// Project Vector to LineDirection to get the distance of point from a
|
||||||
valType Distance = dot(Vector, LineDirection);
|
valType Distance = dot(Vector, LineDirection);
|
||||||
|
|
||||||
if(Distance <= valType(0)) return a;
|
|
||||||
if(Distance >= LineLength) return b;
|
|
||||||
return a + LineDirection * Distance;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(Distance <= valType(0)) return a;
|
||||||
|
if(Distance >= LineLength) return b;
|
||||||
|
return a + LineDirection * Distance;
|
||||||
|
}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
|
||||||
#endif//glm_gtx_closest_point
|
#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
|
// File : glm/gtx/color_space.inl
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
namespace glm
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor)
|
|
||||||
{
|
{
|
||||||
detail::tvec3<T> hsv = hsvColor;
|
template <typename T>
|
||||||
detail::tvec3<T> rgbColor;
|
GLM_FUNC_QUALIFIER detail::tvec3<T> rgbColor(const detail::tvec3<T>& hsvColor)
|
||||||
|
|
||||||
if(hsv.y == T(0))
|
|
||||||
// achromatic (grey)
|
|
||||||
rgbColor = detail::tvec3<T>(hsv.z);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
T sector = floor(hsv.x / T(60));
|
detail::tvec3<T> hsv = hsvColor;
|
||||||
T frac = (hsv.x / T(60)) - sector;
|
detail::tvec3<T> rgbColor;
|
||||||
// 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))
|
if(hsv.y == T(0))
|
||||||
{
|
// achromatic (grey)
|
||||||
default:
|
rgbColor = detail::tvec3<T>(hsv.z);
|
||||||
case 0:
|
else
|
||||||
rgbColor.r = hsv.z;
|
{
|
||||||
rgbColor.g = q;
|
T sector = floor(hsv.x / T(60));
|
||||||
rgbColor.b = o;
|
T frac = (hsv.x / T(60)) - sector;
|
||||||
break;
|
// factorial part of h
|
||||||
case 1:
|
T o = hsv.z * (T(1) - hsv.y);
|
||||||
rgbColor.r = p;
|
T p = hsv.z * (T(1) - hsv.y * frac);
|
||||||
rgbColor.g = hsv.z;
|
T q = hsv.z * (T(1) - hsv.y * (T(1) - frac));
|
||||||
rgbColor.b = o;
|
|
||||||
break;
|
switch(int(sector))
|
||||||
case 2:
|
{
|
||||||
rgbColor.r = o;
|
default:
|
||||||
rgbColor.g = hsv.z;
|
case 0:
|
||||||
rgbColor.b = q;
|
rgbColor.r = hsv.z;
|
||||||
break;
|
rgbColor.g = q;
|
||||||
case 3:
|
rgbColor.b = o;
|
||||||
rgbColor.r = o;
|
break;
|
||||||
rgbColor.g = p;
|
case 1:
|
||||||
rgbColor.b = hsv.z;
|
rgbColor.r = p;
|
||||||
break;
|
rgbColor.g = hsv.z;
|
||||||
case 4:
|
rgbColor.b = o;
|
||||||
rgbColor.r = q;
|
break;
|
||||||
rgbColor.g = o;
|
case 2:
|
||||||
rgbColor.b = hsv.z;
|
rgbColor.r = o;
|
||||||
break;
|
rgbColor.g = hsv.z;
|
||||||
case 5:
|
rgbColor.b = q;
|
||||||
rgbColor.r = hsv.z;
|
break;
|
||||||
rgbColor.g = o;
|
case 3:
|
||||||
rgbColor.b = p;
|
rgbColor.r = o;
|
||||||
break;
|
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>
|
hsv.z = Max;
|
||||||
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;
|
|
||||||
|
|
||||||
if(Max != T(0))
|
if(Max != T(0))
|
||||||
{
|
{
|
||||||
hsv.y = Delta / hsv.z;
|
hsv.y = Delta / hsv.z;
|
||||||
T h = T(0);
|
T h = T(0);
|
||||||
|
|
||||||
if(rgbColor.r == Max)
|
if(rgbColor.r == Max)
|
||||||
// between yellow & magenta
|
// between yellow & magenta
|
||||||
h = T(0) + T(60) * (rgbColor.g - rgbColor.b) / Delta;
|
h = T(0) + T(60) * (rgbColor.g - rgbColor.b) / Delta;
|
||||||
else if(rgbColor.g == Max)
|
else if(rgbColor.g == Max)
|
||||||
// between cyan & yellow
|
// between cyan & yellow
|
||||||
h = T(120) + T(60) * (rgbColor.b - rgbColor.r) / Delta;
|
h = T(120) + T(60) * (rgbColor.b - rgbColor.r) / Delta;
|
||||||
else
|
else
|
||||||
// between magenta & cyan
|
// between magenta & cyan
|
||||||
h = T(240) + T(60) * (rgbColor.r - rgbColor.g) / Delta;
|
h = T(240) + T(60) * (rgbColor.r - rgbColor.g) / Delta;
|
||||||
|
|
||||||
if(h < T(0))
|
if(h < T(0))
|
||||||
hsv.x = h + T(360);
|
hsv.x = h + T(360);
|
||||||
|
else
|
||||||
|
hsv.x = h;
|
||||||
|
}
|
||||||
else
|
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
|
detail::tvec3<T> rgbw = detail::tvec3<T>(T(0.2126), T(0.7152), T(0.0722));
|
||||||
hsv.y = T(0);
|
|
||||||
hsv.x = T(0);
|
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>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<T> saturation(const T s)
|
GLM_FUNC_QUALIFIER detail::tvec4<T> saturation(const T s, const detail::tvec4<T>& color)
|
||||||
{
|
{
|
||||||
detail::tvec3<T> rgbw = detail::tvec3<T>(T(0.2126), T(0.7152), T(0.0722));
|
return saturation(s) * color;
|
||||||
|
}
|
||||||
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 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
|
}//namespace glm
|
||||||
|
@ -7,59 +7,58 @@
|
|||||||
// File : glm/gtx/color_space_YCoCg.inl
|
// File : glm/gtx/color_space_YCoCg.inl
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
namespace glm
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg
|
|
||||||
(
|
|
||||||
detail::tvec3<valType> const & rgbColor
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
detail::tvec3<valType> result;
|
template <typename valType>
|
||||||
result.x/*Y */ = rgbColor.r / valType(4) + rgbColor.g / valType(2) + rgbColor.b / valType(4);
|
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCg
|
||||||
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);
|
detail::tvec3<valType> const & rgbColor
|
||||||
return result;
|
)
|
||||||
}
|
{
|
||||||
|
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>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCgR
|
GLM_FUNC_QUALIFIER detail::tvec3<valType> rgb2YCoCgR
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & rgbColor
|
detail::tvec3<valType> const & rgbColor
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tvec3<valType> result;
|
detail::tvec3<valType> result;
|
||||||
result.x/*Y */ = rgbColor.g / valType(2) + (rgbColor.r + rgbColor.b) / valType(4);
|
result.x/*Y */ = rgbColor.g / valType(2) + (rgbColor.r + rgbColor.b) / valType(4);
|
||||||
result.y/*Co*/ = rgbColor.r - rgbColor.b;
|
result.y/*Co*/ = rgbColor.r - rgbColor.b;
|
||||||
result.z/*Cg*/ = rgbColor.g - (rgbColor.r + rgbColor.b) / valType(2);
|
result.z/*Cg*/ = rgbColor.g - (rgbColor.r + rgbColor.b) / valType(2);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCg2rgb
|
GLM_FUNC_QUALIFIER detail::tvec3<valType> YCoCg2rgb
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & YCoCgColor
|
detail::tvec3<valType> const & YCoCgColor
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
detail::tvec3<valType> result;
|
detail::tvec3<valType> result;
|
||||||
result.r = YCoCgColor.x + YCoCgColor.y - YCoCgColor.z;
|
result.r = YCoCgColor.x + YCoCgColor.y - YCoCgColor.z;
|
||||||
result.g = YCoCgColor.x + YCoCgColor.z;
|
result.g = YCoCgColor.x + YCoCgColor.z;
|
||||||
result.b = YCoCgColor.x - YCoCgColor.y - YCoCgColor.z;
|
result.b = YCoCgColor.x - YCoCgColor.y - YCoCgColor.z;
|
||||||
return result;
|
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> 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
|
}//namespace glm
|
||||||
|
@ -7,131 +7,130 @@
|
|||||||
// File : glm/gtx/compatibility.inl
|
// File : glm/gtx/compatibility.inl
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
namespace glm
|
||||||
|
|
||||||
// isfinite
|
|
||||||
template <typename genType>
|
|
||||||
GLM_FUNC_QUALIFIER bool isfinite(
|
|
||||||
genType const & x)
|
|
||||||
{
|
{
|
||||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
// isfinite
|
||||||
return _finite(x);
|
template <typename genType>
|
||||||
#else//(GLM_COMPILER & GLM_COMPILER_GCC)
|
GLM_FUNC_QUALIFIER bool isfinite(
|
||||||
return std::isfinite(x) != 0;
|
genType const & x)
|
||||||
#endif
|
{
|
||||||
}
|
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||||
|
return _finite(x);
|
||||||
|
#else//(GLM_COMPILER & GLM_COMPILER_GCC)
|
||||||
|
return std::isfinite(x) != 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isfinite(
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> isfinite(
|
||||||
detail::tvec2<valType> const & x)
|
detail::tvec2<valType> const & x)
|
||||||
{
|
{
|
||||||
return detail::tvec2<bool>(
|
return detail::tvec2<bool>(
|
||||||
isfinite(x.x),
|
isfinite(x.x),
|
||||||
isfinite(x.y));
|
isfinite(x.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isfinite(
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> isfinite(
|
||||||
detail::tvec3<valType> const & x)
|
detail::tvec3<valType> const & x)
|
||||||
{
|
{
|
||||||
return detail::tvec3<bool>(
|
return detail::tvec3<bool>(
|
||||||
isfinite(x.x),
|
isfinite(x.x),
|
||||||
isfinite(x.y),
|
isfinite(x.y),
|
||||||
isfinite(x.z));
|
isfinite(x.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isfinite(
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> isfinite(
|
||||||
detail::tvec4<valType> const & x)
|
detail::tvec4<valType> const & x)
|
||||||
{
|
{
|
||||||
return detail::tvec4<bool>(
|
return detail::tvec4<bool>(
|
||||||
isfinite(x.x),
|
isfinite(x.x),
|
||||||
isfinite(x.y),
|
isfinite(x.y),
|
||||||
isfinite(x.z),
|
isfinite(x.z),
|
||||||
isfinite(x.w));
|
isfinite(x.w));
|
||||||
}
|
}
|
||||||
|
|
||||||
// isinf
|
// isinf
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER bool isinf(
|
GLM_FUNC_QUALIFIER bool isinf(
|
||||||
genType const & x)
|
genType const & x)
|
||||||
{
|
{
|
||||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||||
return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF;
|
return _fpclass(x) == _FPCLASS_NINF || _fpclass(x) == _FPCLASS_PINF;
|
||||||
#else
|
#else
|
||||||
return std::isinf(x) != 0;
|
return std::isinf(x) != 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isinf(
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> isinf(
|
||||||
detail::tvec2<valType> const & x)
|
detail::tvec2<valType> const & x)
|
||||||
{
|
{
|
||||||
return detail::tvec2<bool>(
|
return detail::tvec2<bool>(
|
||||||
isinf(x.x),
|
isinf(x.x),
|
||||||
isinf(x.y));
|
isinf(x.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isinf(
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> isinf(
|
||||||
detail::tvec3<valType> const & x)
|
detail::tvec3<valType> const & x)
|
||||||
{
|
{
|
||||||
return detail::tvec3<bool>(
|
return detail::tvec3<bool>(
|
||||||
isinf(x.x),
|
isinf(x.x),
|
||||||
isinf(x.y),
|
isinf(x.y),
|
||||||
isinf(x.z));
|
isinf(x.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> isinf(
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> isinf(
|
||||||
detail::tvec4<valType> const & x)
|
detail::tvec4<valType> const & x)
|
||||||
{
|
{
|
||||||
return detail::tvec4<bool>(
|
return detail::tvec4<bool>(
|
||||||
isinf(x.x),
|
isinf(x.x),
|
||||||
isinf(x.y),
|
isinf(x.y),
|
||||||
isinf(x.z),
|
isinf(x.z),
|
||||||
isinf(x.w));
|
isinf(x.w));
|
||||||
}
|
}
|
||||||
|
|
||||||
// isnan
|
// isnan
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER bool isnan(genType const & x)
|
GLM_FUNC_QUALIFIER bool isnan(genType const & x)
|
||||||
{
|
{
|
||||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||||
return _isnan(x);
|
return _isnan(x);
|
||||||
#else
|
#else
|
||||||
return std::isnan(x) != 0;
|
return std::isnan(x) != 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> isnan(
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> isnan(
|
||||||
detail::tvec2<valType> const & x)
|
detail::tvec2<valType> const & x)
|
||||||
{
|
{
|
||||||
return detail::tvec2<bool>(
|
return detail::tvec2<bool>(
|
||||||
isnan(x.x),
|
isnan(x.x),
|
||||||
isnan(x.y));
|
isnan(x.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> isnan(
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> isnan(
|
||||||
detail::tvec3<valType> const & x)
|
detail::tvec3<valType> const & x)
|
||||||
{
|
{
|
||||||
return detail::tvec3<bool>(
|
return detail::tvec3<bool>(
|
||||||
isnan(x.x),
|
isnan(x.x),
|
||||||
isnan(x.y),
|
isnan(x.y),
|
||||||
isnan(x.z));
|
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::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
|
}//namespace glm
|
||||||
|
@ -7,42 +7,41 @@
|
|||||||
// File : gtx_component_wise.inl
|
// File : gtx_component_wise.inl
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
namespace glm
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
|
|
||||||
{
|
{
|
||||||
typename genType::size_type result = typename genType::value_type(0);
|
template <typename genType>
|
||||||
for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
|
GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
|
||||||
result += v[i];
|
{
|
||||||
return result;
|
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>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v)
|
GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v)
|
||||||
{
|
{
|
||||||
typename genType::value_type result = typename genType::value_type(1);
|
typename genType::value_type result = typename genType::value_type(1);
|
||||||
for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
|
for(typename genType::size_type i = 0; i < genType::value_size(); ++i)
|
||||||
result *= v[i];
|
result *= v[i];
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v)
|
GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v)
|
||||||
{
|
{
|
||||||
typename genType::value_type result = typename genType::value_type(v[0]);
|
typename genType::value_type result = typename genType::value_type(v[0]);
|
||||||
for(typename genType::size_type i = 1; i < genType::value_size(); ++i)
|
for(typename genType::size_type i = 1; i < genType::value_size(); ++i)
|
||||||
result = min(result, v[i]);
|
result = min(result, v[i]);
|
||||||
return result;
|
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 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
|
}//namespace glm
|
||||||
|
@ -20,773 +20,8 @@
|
|||||||
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
/// THE SOFTWARE.
|
/// THE SOFTWARE.
|
||||||
///
|
///
|
||||||
/// @ref gtc_half_float
|
/// @ref gtx_constants
|
||||||
/// @file glm/gtc/half_float.inl
|
/// @file glm/gtx/constants.inl
|
||||||
/// @date 2009-04-29 / 2011-06-05
|
/// @date 2011-10-14 / 2011-10-14
|
||||||
/// @author Christophe Riccio
|
/// @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
|
// File : glm/gtx/epsilon.inl
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
namespace glm
|
||||||
|
|
||||||
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 equalEpsilon
|
||||||
|
(
|
||||||
|
genType const & x,
|
||||||
|
genType const & y,
|
||||||
|
genType const & epsilon
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return abs(x - y) < epsilon;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename genType>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER bool notEqualEpsilon
|
GLM_FUNC_QUALIFIER bool notEqualEpsilon
|
||||||
(
|
(
|
||||||
genType const & x,
|
genType const & x,
|
||||||
genType const & y,
|
genType const & y,
|
||||||
genType const & epsilon
|
genType const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return abs(x - y) >= epsilon;
|
return abs(x - y) >= epsilon;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec2<valType> const & x,
|
detail::tvec2<valType> const & x,
|
||||||
detail::tvec2<valType> const & y,
|
detail::tvec2<valType> const & y,
|
||||||
valType const & epsilon)
|
valType const & epsilon)
|
||||||
{
|
{
|
||||||
return detail::tvec2<bool>(
|
return detail::tvec2<bool>(
|
||||||
abs(x.x - y.x) < epsilon,
|
abs(x.x - y.x) < epsilon,
|
||||||
abs(x.y - y.y) < epsilon);
|
abs(x.y - y.y) < epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & x,
|
detail::tvec3<valType> const & x,
|
||||||
detail::tvec3<valType> const & y,
|
detail::tvec3<valType> const & y,
|
||||||
valType const & epsilon)
|
valType const & epsilon)
|
||||||
{
|
{
|
||||||
return detail::tvec3<bool>(
|
return detail::tvec3<bool>(
|
||||||
abs(x.x - y.x) < epsilon,
|
abs(x.x - y.x) < epsilon,
|
||||||
abs(x.y - y.y) < epsilon,
|
abs(x.y - y.y) < epsilon,
|
||||||
abs(x.z - y.z) < epsilon);
|
abs(x.z - y.z) < epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec4<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tvec4<valType> const & y,
|
detail::tvec4<valType> const & y,
|
||||||
valType const & epsilon
|
valType const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec4<bool>(
|
return detail::tvec4<bool>(
|
||||||
abs(x.x - y.x) < epsilon,
|
abs(x.x - y.x) < epsilon,
|
||||||
abs(x.y - y.y) < epsilon,
|
abs(x.y - y.y) < epsilon,
|
||||||
abs(x.z - y.z) < epsilon,
|
abs(x.z - y.z) < epsilon,
|
||||||
abs(x.w - y.w) < epsilon);
|
abs(x.w - y.w) < epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec2<valType> const & x,
|
detail::tvec2<valType> const & x,
|
||||||
detail::tvec2<valType> const & y,
|
detail::tvec2<valType> const & y,
|
||||||
valType const & epsilon
|
valType const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec2<bool>(
|
return detail::tvec2<bool>(
|
||||||
abs(x.x - y.x) >= epsilon,
|
abs(x.x - y.x) >= epsilon,
|
||||||
abs(x.y - y.y) >= epsilon);
|
abs(x.y - y.y) >= epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & x,
|
detail::tvec3<valType> const & x,
|
||||||
detail::tvec3<valType> const & y,
|
detail::tvec3<valType> const & y,
|
||||||
valType const & epsilon
|
valType const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec3<bool>(
|
return detail::tvec3<bool>(
|
||||||
abs(x.x - y.x) >= epsilon,
|
abs(x.x - y.x) >= epsilon,
|
||||||
abs(x.y - y.y) >= epsilon,
|
abs(x.y - y.y) >= epsilon,
|
||||||
abs(x.z - y.z) >= epsilon);
|
abs(x.z - y.z) >= epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec4<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tvec4<valType> const & y,
|
detail::tvec4<valType> const & y,
|
||||||
valType const & epsilon
|
valType const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec4<bool>(
|
return detail::tvec4<bool>(
|
||||||
abs(x.x - y.x) >= epsilon,
|
abs(x.x - y.x) >= epsilon,
|
||||||
abs(x.y - y.y) >= epsilon,
|
abs(x.y - y.y) >= epsilon,
|
||||||
abs(x.z - y.z) >= epsilon,
|
abs(x.z - y.z) >= epsilon,
|
||||||
abs(x.w - y.w) >= epsilon);
|
abs(x.w - y.w) >= epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> equalEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec2<valType> const & x,
|
detail::tvec2<valType> const & x,
|
||||||
detail::tvec2<valType> const & y,
|
detail::tvec2<valType> const & y,
|
||||||
detail::tvec2<valType> const & epsilon
|
detail::tvec2<valType> const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec2<bool>(
|
return detail::tvec2<bool>(
|
||||||
abs(x.x - y.x) < epsilon.x,
|
abs(x.x - y.x) < epsilon.x,
|
||||||
abs(x.y - y.y) < epsilon.y);
|
abs(x.y - y.y) < epsilon.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> equalEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & x,
|
detail::tvec3<valType> const & x,
|
||||||
detail::tvec3<valType> const & y,
|
detail::tvec3<valType> const & y,
|
||||||
detail::tvec3<valType> const & epsilon
|
detail::tvec3<valType> const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec3<bool>(
|
return detail::tvec3<bool>(
|
||||||
abs(x.x - y.x) < epsilon.x,
|
abs(x.x - y.x) < epsilon.x,
|
||||||
abs(x.y - y.y) < epsilon.y,
|
abs(x.y - y.y) < epsilon.y,
|
||||||
abs(x.z - y.z) < epsilon.z);
|
abs(x.z - y.z) < epsilon.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec4<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tvec4<valType> const & y,
|
detail::tvec4<valType> const & y,
|
||||||
detail::tvec4<valType> const & epsilon
|
detail::tvec4<valType> const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec4<bool>(
|
return detail::tvec4<bool>(
|
||||||
abs(x.x - y.x) < epsilon.x,
|
abs(x.x - y.x) < epsilon.x,
|
||||||
abs(x.y - y.y) < epsilon.y,
|
abs(x.y - y.y) < epsilon.y,
|
||||||
abs(x.z - y.z) < epsilon.z,
|
abs(x.z - y.z) < epsilon.z,
|
||||||
abs(x.w - y.w) < epsilon.w);
|
abs(x.w - y.w) < epsilon.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> equalEpsilon
|
||||||
(
|
(
|
||||||
detail::tquat<valType> const & x,
|
detail::tquat<valType> const & x,
|
||||||
detail::tquat<valType> const & y,
|
detail::tquat<valType> const & y,
|
||||||
detail::tquat<valType> const & epsilon
|
detail::tquat<valType> const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec4<bool>(
|
return detail::tvec4<bool>(
|
||||||
abs(x.x - y.x) < epsilon.x,
|
abs(x.x - y.x) < epsilon.x,
|
||||||
abs(x.y - y.y) < epsilon.y,
|
abs(x.y - y.y) < epsilon.y,
|
||||||
abs(x.z - y.z) < epsilon.z,
|
abs(x.z - y.z) < epsilon.z,
|
||||||
abs(x.w - y.w) < epsilon.w);
|
abs(x.w - y.w) < epsilon.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec2<bool> notEqualEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec2<valType> const & x,
|
detail::tvec2<valType> const & x,
|
||||||
detail::tvec2<valType> const & y,
|
detail::tvec2<valType> const & y,
|
||||||
detail::tvec2<valType> const & epsilon
|
detail::tvec2<valType> const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec2<bool>(
|
return detail::tvec2<bool>(
|
||||||
abs(x.x - y.x) >= epsilon.x,
|
abs(x.x - y.x) >= epsilon.x,
|
||||||
abs(x.y - y.y) >= epsilon.y);
|
abs(x.y - y.y) >= epsilon.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec3<bool> notEqualEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & x,
|
detail::tvec3<valType> const & x,
|
||||||
detail::tvec3<valType> const & y,
|
detail::tvec3<valType> const & y,
|
||||||
detail::tvec3<valType> const & epsilon
|
detail::tvec3<valType> const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec3<bool>(
|
return detail::tvec3<bool>(
|
||||||
abs(x.x - y.x) >= epsilon.x,
|
abs(x.x - y.x) >= epsilon.x,
|
||||||
abs(x.y - y.y) >= epsilon.y,
|
abs(x.y - y.y) >= epsilon.y,
|
||||||
abs(x.z - y.z) >= epsilon.z);
|
abs(x.z - y.z) >= epsilon.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
GLM_FUNC_QUALIFIER detail::tvec4<bool> notEqualEpsilon
|
||||||
(
|
(
|
||||||
detail::tvec4<valType> const & x,
|
detail::tvec4<valType> const & x,
|
||||||
detail::tvec4<valType> const & y,
|
detail::tvec4<valType> const & y,
|
||||||
detail::tvec4<valType> const & epsilon
|
detail::tvec4<valType> const & epsilon
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tvec4<bool>(
|
return detail::tvec4<bool>(
|
||||||
abs(x.x - y.x) >= epsilon.x,
|
abs(x.x - y.x) >= epsilon.x,
|
||||||
abs(x.y - y.y) >= epsilon.y,
|
abs(x.y - y.y) >= epsilon.y,
|
||||||
abs(x.z - y.z) >= epsilon.z,
|
abs(x.z - y.z) >= epsilon.z,
|
||||||
abs(x.w - y.w) >= epsilon.w);
|
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::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
|
}//namespace glm
|
||||||
|
@ -7,239 +7,238 @@
|
|||||||
// File : glm/gtx/euler_angles.inl
|
// File : glm/gtx/euler_angles.inl
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
namespace glm
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
|
|
||||||
(
|
|
||||||
valType const & angleX
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
valType cosX = glm::cos(angleX);
|
template <typename valType>
|
||||||
valType sinX = glm::sin(angleX);
|
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleX
|
||||||
|
(
|
||||||
|
valType const & angleX
|
||||||
|
)
|
||||||
|
{
|
||||||
|
valType cosX = glm::cos(angleX);
|
||||||
|
valType sinX = glm::sin(angleX);
|
||||||
|
|
||||||
return detail::tmat4x4<valType>(
|
return detail::tmat4x4<valType>(
|
||||||
valType(1), valType(0), valType(0), valType(0),
|
valType(1), valType(0), valType(0), valType(0),
|
||||||
valType(0), cosX, sinX, valType(0),
|
valType(0), cosX, sinX, valType(0),
|
||||||
valType(0),-sinX, cosX, valType(0),
|
valType(0),-sinX, cosX, valType(0),
|
||||||
valType(0), valType(0), valType(0), valType(1));
|
valType(0), valType(0), valType(0), valType(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleY
|
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleY
|
||||||
(
|
(
|
||||||
valType const & angleY
|
valType const & angleY
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType cosY = glm::cos(angleY);
|
valType cosY = glm::cos(angleY);
|
||||||
valType sinY = glm::sin(angleY);
|
valType sinY = glm::sin(angleY);
|
||||||
|
|
||||||
return detail::tmat4x4<valType>(
|
return detail::tmat4x4<valType>(
|
||||||
cosY, valType(0), sinY, valType(0),
|
cosY, valType(0), sinY, valType(0),
|
||||||
valType(0), valType(1), valType(0), valType(0),
|
valType(0), valType(1), valType(0), valType(0),
|
||||||
-sinY, valType(0), cosY, valType(0),
|
-sinY, valType(0), cosY, valType(0),
|
||||||
valType(0), valType(0), valType(0), valType(1));
|
valType(0), valType(0), valType(0), valType(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZ
|
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZ
|
||||||
(
|
(
|
||||||
valType const & angleZ
|
valType const & angleZ
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType cosZ = glm::cos(angleZ);
|
valType cosZ = glm::cos(angleZ);
|
||||||
valType sinZ = glm::sin(angleZ);
|
valType sinZ = glm::sin(angleZ);
|
||||||
|
|
||||||
return detail::tmat4x4<valType>(
|
return detail::tmat4x4<valType>(
|
||||||
cosZ, sinZ, valType(0), valType(0),
|
cosZ, sinZ, valType(0), valType(0),
|
||||||
-sinZ, cosZ, valType(0), valType(0),
|
-sinZ, cosZ, valType(0), valType(0),
|
||||||
valType(0), valType(0), valType(1), valType(0),
|
valType(0), valType(0), valType(1), valType(0),
|
||||||
valType(0), valType(0), valType(0), valType(1));
|
valType(0), valType(0), valType(0), valType(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXY
|
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXY
|
||||||
(
|
(
|
||||||
valType const & angleX,
|
valType const & angleX,
|
||||||
valType const & angleY
|
valType const & angleY
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType cosX = glm::cos(angleX);
|
valType cosX = glm::cos(angleX);
|
||||||
valType sinX = glm::sin(angleX);
|
valType sinX = glm::sin(angleX);
|
||||||
valType cosY = glm::cos(angleY);
|
valType cosY = glm::cos(angleY);
|
||||||
valType sinY = glm::sin(angleY);
|
valType sinY = glm::sin(angleY);
|
||||||
|
|
||||||
return detail::tmat4x4<valType>(
|
return detail::tmat4x4<valType>(
|
||||||
cosY, -sinX * sinY, cosX * sinY, valType(0),
|
cosY, -sinX * sinY, cosX * sinY, valType(0),
|
||||||
valType(0), cosX, sinX, valType(0),
|
valType(0), cosX, sinX, valType(0),
|
||||||
-sinY , -sinX * cosY, cosX * cosY, valType(0),
|
-sinY , -sinX * cosY, cosX * cosY, valType(0),
|
||||||
valType(0), valType(0), valType(0), valType(1));
|
valType(0), valType(0), valType(0), valType(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYX
|
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYX
|
||||||
(
|
(
|
||||||
valType const & angleY,
|
valType const & angleY,
|
||||||
valType const & angleX
|
valType const & angleX
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType cosX = glm::cos(angleX);
|
valType cosX = glm::cos(angleX);
|
||||||
valType sinX = glm::sin(angleX);
|
valType sinX = glm::sin(angleX);
|
||||||
valType cosY = glm::cos(angleY);
|
valType cosY = glm::cos(angleY);
|
||||||
valType sinY = glm::sin(angleY);
|
valType sinY = glm::sin(angleY);
|
||||||
|
|
||||||
return detail::tmat4x4<valType>(
|
return detail::tmat4x4<valType>(
|
||||||
cosY, valType(0), sinY, valType(0),
|
cosY, valType(0), sinY, valType(0),
|
||||||
-sinX * sinY, cosX, sinX * cosY, valType(0),
|
-sinX * sinY, cosX, sinX * cosY, valType(0),
|
||||||
-cosX * sinY, -sinX, cosX * cosY, valType(0),
|
-cosX * sinY, -sinX, cosX * cosY, valType(0),
|
||||||
valType(0), valType(0), valType(0), valType(1));
|
valType(0), valType(0), valType(0), valType(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXZ
|
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleXZ
|
||||||
(
|
(
|
||||||
valType const & angleX,
|
valType const & angleX,
|
||||||
valType const & angleZ
|
valType const & angleZ
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return eulerAngleX(angleX) * eulerAngleZ(angleZ);
|
return eulerAngleX(angleX) * eulerAngleZ(angleZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZX
|
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleZX
|
||||||
(
|
(
|
||||||
valType const & angleZ,
|
valType const & angleZ,
|
||||||
valType const & angleX
|
valType const & angleX
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return eulerAngleZ(angleZ) * eulerAngleX(angleX);
|
return eulerAngleZ(angleZ) * eulerAngleX(angleX);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYXZ
|
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> eulerAngleYXZ
|
||||||
(
|
(
|
||||||
valType const & yaw,
|
valType const & yaw,
|
||||||
valType const & pitch,
|
valType const & pitch,
|
||||||
valType const & roll
|
valType const & roll
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType tmp_ch = glm::cos(yaw);
|
valType tmp_ch = glm::cos(yaw);
|
||||||
valType tmp_sh = glm::sin(yaw);
|
valType tmp_sh = glm::sin(yaw);
|
||||||
valType tmp_cp = glm::cos(pitch);
|
valType tmp_cp = glm::cos(pitch);
|
||||||
valType tmp_sp = glm::sin(pitch);
|
valType tmp_sp = glm::sin(pitch);
|
||||||
valType tmp_cb = glm::cos(roll);
|
valType tmp_cb = glm::cos(roll);
|
||||||
valType tmp_sb = glm::sin(roll);
|
valType tmp_sb = glm::sin(roll);
|
||||||
|
|
||||||
detail::tmat4x4<valType> Result;
|
detail::tmat4x4<valType> Result;
|
||||||
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
|
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
|
||||||
Result[0][1] = tmp_sb * tmp_cp;
|
Result[0][1] = tmp_sb * tmp_cp;
|
||||||
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
|
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
|
||||||
Result[0][3] = valType(0);
|
Result[0][3] = valType(0);
|
||||||
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
|
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
|
||||||
Result[1][1] = tmp_cb * tmp_cp;
|
Result[1][1] = tmp_cb * tmp_cp;
|
||||||
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
|
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
|
||||||
Result[1][3] = valType(0);
|
Result[1][3] = valType(0);
|
||||||
Result[2][0] = tmp_sh * tmp_cp;
|
Result[2][0] = tmp_sh * tmp_cp;
|
||||||
Result[2][1] = -tmp_sp;
|
Result[2][1] = -tmp_sp;
|
||||||
Result[2][2] = tmp_ch * tmp_cp;
|
Result[2][2] = tmp_ch * tmp_cp;
|
||||||
Result[2][3] = valType(0);
|
Result[2][3] = valType(0);
|
||||||
Result[3][0] = valType(0);
|
Result[3][0] = valType(0);
|
||||||
Result[3][1] = valType(0);
|
Result[3][1] = valType(0);
|
||||||
Result[3][2] = valType(0);
|
Result[3][2] = valType(0);
|
||||||
Result[3][3] = valType(1);
|
Result[3][3] = valType(1);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> yawPitchRoll
|
GLM_FUNC_QUALIFIER detail::tmat4x4<valType> yawPitchRoll
|
||||||
(
|
(
|
||||||
valType const & yaw,
|
valType const & yaw,
|
||||||
valType const & pitch,
|
valType const & pitch,
|
||||||
valType const & roll
|
valType const & roll
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType tmp_ch = glm::cos(yaw);
|
valType tmp_ch = glm::cos(yaw);
|
||||||
valType tmp_sh = glm::sin(yaw);
|
valType tmp_sh = glm::sin(yaw);
|
||||||
valType tmp_cp = glm::cos(pitch);
|
valType tmp_cp = glm::cos(pitch);
|
||||||
valType tmp_sp = glm::sin(pitch);
|
valType tmp_sp = glm::sin(pitch);
|
||||||
valType tmp_cb = glm::cos(roll);
|
valType tmp_cb = glm::cos(roll);
|
||||||
valType tmp_sb = glm::sin(roll);
|
valType tmp_sb = glm::sin(roll);
|
||||||
|
|
||||||
detail::tmat4x4<valType> Result;
|
detail::tmat4x4<valType> Result;
|
||||||
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
|
Result[0][0] = tmp_ch * tmp_cb + tmp_sh * tmp_sp * tmp_sb;
|
||||||
Result[0][1] = tmp_sb * tmp_cp;
|
Result[0][1] = tmp_sb * tmp_cp;
|
||||||
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
|
Result[0][2] = -tmp_sh * tmp_cb + tmp_ch * tmp_sp * tmp_sb;
|
||||||
Result[0][3] = valType(0);
|
Result[0][3] = valType(0);
|
||||||
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
|
Result[1][0] = -tmp_ch * tmp_sb + tmp_sh * tmp_sp * tmp_cb;
|
||||||
Result[1][1] = tmp_cb * tmp_cp;
|
Result[1][1] = tmp_cb * tmp_cp;
|
||||||
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
|
Result[1][2] = tmp_sb * tmp_sh + tmp_ch * tmp_sp * tmp_cb;
|
||||||
Result[1][3] = valType(0);
|
Result[1][3] = valType(0);
|
||||||
Result[2][0] = tmp_sh * tmp_cp;
|
Result[2][0] = tmp_sh * tmp_cp;
|
||||||
Result[2][1] = -tmp_sp;
|
Result[2][1] = -tmp_sp;
|
||||||
Result[2][2] = tmp_ch * tmp_cp;
|
Result[2][2] = tmp_ch * tmp_cp;
|
||||||
Result[2][3] = valType(0);
|
Result[2][3] = valType(0);
|
||||||
Result[3][0] = valType(0);
|
Result[3][0] = valType(0);
|
||||||
Result[3][1] = valType(0);
|
Result[3][1] = valType(0);
|
||||||
Result[3][2] = valType(0);
|
Result[3][2] = valType(0);
|
||||||
Result[3][3] = valType(1);
|
Result[3][3] = valType(1);
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> orientate2
|
GLM_FUNC_QUALIFIER detail::tmat2x2<valType> orientate2
|
||||||
(
|
(
|
||||||
valType const & angle
|
valType const & angle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType c = glm::cos(angle);
|
valType c = glm::cos(angle);
|
||||||
valType s = glm::sin(angle);
|
valType s = glm::sin(angle);
|
||||||
|
|
||||||
detail::tmat2x2<valType> Result;
|
detail::tmat2x2<valType> Result;
|
||||||
Result[0][0] = c;
|
Result[0][0] = c;
|
||||||
Result[0][1] = s;
|
Result[0][1] = s;
|
||||||
Result[1][0] = -s;
|
Result[1][0] = -s;
|
||||||
Result[1][1] = c;
|
Result[1][1] = c;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
|
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
|
||||||
(
|
(
|
||||||
valType const & angle
|
valType const & angle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
valType c = glm::cos(angle);
|
valType c = glm::cos(angle);
|
||||||
valType s = glm::sin(angle);
|
valType s = glm::sin(angle);
|
||||||
|
|
||||||
detail::tmat3x3<valType> Result;
|
detail::tmat3x3<valType> Result;
|
||||||
Result[0][0] = c;
|
Result[0][0] = c;
|
||||||
Result[0][1] = s;
|
Result[0][1] = s;
|
||||||
Result[0][2] = 0.0f;
|
Result[0][2] = 0.0f;
|
||||||
Result[1][0] = -s;
|
Result[1][0] = -s;
|
||||||
Result[1][1] = c;
|
Result[1][1] = c;
|
||||||
Result[1][2] = 0.0f;
|
Result[1][2] = 0.0f;
|
||||||
Result[2][0] = 0.0f;
|
Result[2][0] = 0.0f;
|
||||||
Result[2][1] = 0.0f;
|
Result[2][1] = 0.0f;
|
||||||
Result[2][2] = 1.0f;
|
Result[2][2] = 1.0f;
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
|
GLM_FUNC_QUALIFIER detail::tmat3x3<valType> orientate3
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & angles
|
detail::tvec3<valType> const & angles
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return detail::tmat3x3<valType>(yawPitchRoll(angles.x, angles.y, angles.z));
|
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::tmat4x4<valType> orientate4
|
||||||
|
(
|
||||||
|
detail::tvec3<valType> const & angles
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return yawPitchRoll(angles.z, angles.x, angles.y);
|
||||||
|
}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
@ -7,50 +7,49 @@
|
|||||||
// File : glm/gtx/extend.inl
|
// File : glm/gtx/extend.inl
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
namespace glm
|
||||||
|
|
||||||
template <typename genType>
|
|
||||||
genType extend
|
|
||||||
(
|
|
||||||
genType const & Origin,
|
|
||||||
genType const & Source,
|
|
||||||
genType const & Distance
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
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>
|
template <typename valType>
|
||||||
detail::tvec2<valType> extend
|
detail::tvec2<valType> extend
|
||||||
(
|
(
|
||||||
detail::tvec2<valType> const & Origin,
|
detail::tvec2<valType> const & Origin,
|
||||||
detail::tvec2<valType> const & Source,
|
detail::tvec2<valType> const & Source,
|
||||||
valType const & Distance
|
valType const & Distance
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return Origin + (Source - Origin) * Distance;
|
return Origin + (Source - Origin) * Distance;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename valType>
|
template <typename valType>
|
||||||
detail::tvec3<valType> extend
|
detail::tvec3<valType> extend
|
||||||
(
|
(
|
||||||
detail::tvec3<valType> const & Origin,
|
detail::tvec3<valType> const & Origin,
|
||||||
detail::tvec3<valType> const & Source,
|
detail::tvec3<valType> const & Source,
|
||||||
valType const & Distance
|
valType const & Distance
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return Origin + (Source - Origin) * 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::tvec4<valType> extend
|
||||||
|
(
|
||||||
|
detail::tvec4<valType> const & Origin,
|
||||||
|
detail::tvec4<valType> const & Source,
|
||||||
|
valType const & Distance
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return Origin + (Source - Origin) * Distance;
|
||||||
|
}
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
@ -54,17 +54,17 @@ namespace glm
|
|||||||
|
|
||||||
//! Faster than the common pow function but less accurate.
|
//! Faster than the common pow function but less accurate.
|
||||||
//! From GLM_GTX_fast_exponential extension.
|
//! From GLM_GTX_fast_exponential extension.
|
||||||
template <typename valType>
|
template <typename genType>
|
||||||
valType fastPow(
|
genType fastPow(
|
||||||
valType const & x,
|
genType const & x,
|
||||||
valType const & y);
|
genType const & y);
|
||||||
|
|
||||||
//! Faster than the common pow function but less accurate.
|
//! Faster than the common pow function but less accurate.
|
||||||
//! From GLM_GTX_fast_exponential extension.
|
//! From GLM_GTX_fast_exponential extension.
|
||||||
template <typename T, typename U>
|
template <typename genTypeT, typename genTypeU>
|
||||||
T fastPow(
|
genType fastPow(
|
||||||
const T& x,
|
genTypeT const & x,
|
||||||
const U& y);
|
genTypeU const & y);
|
||||||
|
|
||||||
//! Faster than the common exp function but less accurate.
|
//! Faster than the common exp function but less accurate.
|
||||||
//! From GLM_GTX_fast_exponential extension.
|
//! From GLM_GTX_fast_exponential extension.
|
||||||
|
@ -7,284 +7,144 @@
|
|||||||
// File : glm/gtx/fast_exponential.inl
|
// File : glm/gtx/fast_exponential.inl
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
namespace glm{
|
#include "../core/_vectorize.hpp"
|
||||||
|
|
||||||
// fastPow:
|
namespace glm
|
||||||
template <typename T>
|
|
||||||
GLM_FUNC_QUALIFIER T fastPow(const T x, const T y)
|
|
||||||
{
|
{
|
||||||
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>
|
VECTORIZE_VEC_VEC(fastPow)
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow(
|
GLM_FUNC_QUALIFIER T fastPow(const T x, int y)
|
||||||
const detail::tvec3<T>& x,
|
{
|
||||||
const detail::tvec3<T>& y)
|
T f = T(1);
|
||||||
{
|
for(int i = 0; i < y; ++i)
|
||||||
return detail::tvec3<T>(
|
f *= x;
|
||||||
fastPow(x.x, y.x),
|
return f;
|
||||||
fastPow(x.y, y.y),
|
}
|
||||||
fastPow(x.z, y.z));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
|
GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow(
|
||||||
const detail::tvec4<T>& x,
|
const detail::tvec2<T>& x,
|
||||||
const detail::tvec4<T>& y)
|
const detail::tvec2<int>& y)
|
||||||
{
|
{
|
||||||
return detail::tvec4<T>(
|
return detail::tvec2<T>(
|
||||||
fastPow(x.x, y.x),
|
fastPow(x.x, y.x),
|
||||||
fastPow(x.y, y.y),
|
fastPow(x.y, y.y));
|
||||||
fastPow(x.z, y.z),
|
}
|
||||||
fastPow(x.w, y.w));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER T fastPow(const T x, int y)
|
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow(
|
||||||
{
|
const detail::tvec3<T>& x,
|
||||||
T f = T(1);
|
const detail::tvec3<int>& y)
|
||||||
for(int i = 0; i < y; ++i)
|
{
|
||||||
f *= x;
|
return detail::tvec3<T>(
|
||||||
return f;
|
fastPow(x.x, y.x),
|
||||||
}
|
fastPow(x.y, y.y),
|
||||||
|
fastPow(x.z, y.z));
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> fastPow(
|
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
|
||||||
const detail::tvec2<T>& x,
|
const detail::tvec4<T>& x,
|
||||||
const detail::tvec2<int>& y)
|
const detail::tvec4<int>& y)
|
||||||
{
|
{
|
||||||
return detail::tvec2<T>(
|
return detail::tvec4<T>(
|
||||||
fastPow(x.x, y.x),
|
fastPow(x.x, y.x),
|
||||||
fastPow(x.y, y.y));
|
fastPow(x.y, y.y),
|
||||||
}
|
fastPow(x.z, y.z),
|
||||||
|
fastPow(x.w, y.w));
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
// fastExp
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> fastPow(
|
// Note: This function provides accurate results only for value between -1 and 1, else avoid it.
|
||||||
const detail::tvec3<T>& x,
|
template <typename T>
|
||||||
const detail::tvec3<int>& y)
|
GLM_FUNC_QUALIFIER T fastExp(const T x)
|
||||||
{
|
{
|
||||||
return detail::tvec3<T>(
|
// This has a better looking and same performance in release mode than the following code. However, in debug mode it's slower.
|
||||||
fastPow(x.x, y.x),
|
// return 1.0f + x * (1.0f + x * 0.5f * (1.0f + x * 0.3333333333f * (1.0f + x * 0.25 * (1.0f + x * 0.2f))));
|
||||||
fastPow(x.y, y.y),
|
T x2 = x * x;
|
||||||
fastPow(x.z, y.z));
|
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>
|
for(int i = 0; i < int(IntegerPart); ++i)
|
||||||
GLM_FUNC_QUALIFIER detail::tvec4<T> fastPow(
|
z *= e;
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
// fastExp
|
const float x2 = FloatPart * FloatPart;
|
||||||
// Note: This function provides accurate results only for value between -1 and 1, else avoid it.
|
const float x3 = x2 * FloatPart;
|
||||||
template <typename T>
|
const float x4 = x3 * FloatPart;
|
||||||
GLM_FUNC_QUALIFIER T fastExp(const T x)
|
const float x5 = x4 * FloatPart;
|
||||||
{
|
return z * (1.0f + FloatPart + (x2 * 0.5f) + (x3 * 0.1666666667f) + (x4 * 0.041666667f) + (x5 * 0.008333333333f));
|
||||||
// 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;
|
|
||||||
|
|
||||||
for(int i = 0; i < int(IntegerPart); ++i)
|
// Increase accuracy on number bigger that 1 and smaller than -1 but it's not enough for high and negative numbers
|
||||||
z *= e;
|
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;
|
VECTORIZE_VEC(fastExp)
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increase accuracy on number bigger that 1 and smaller than -1 but it's not enough for high and negative numbers
|
// fastLog
|
||||||
GLM_FUNC_QUALIFIER float fastExp(float x)
|
template <typename genType>
|
||||||
{
|
GLM_FUNC_QUALIFIER genType fastLog(genType const & 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))));
|
return std::log(x);
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
/* Slower than the VC7.1 function...
|
||||||
GLM_FUNC_QUALIFIER detail::tvec3<T> fastExp(
|
GLM_FUNC_QUALIFIER float fastLog(float x)
|
||||||
const detail::tvec3<T>& x)
|
{
|
||||||
{
|
float y1 = (x - 1.0f) / (x + 1.0f);
|
||||||
return detail::tvec3<T>(
|
float y2 = y1 * y1;
|
||||||
fastExp(x.x),
|
return 2.0f * y1 * (1.0f + y2 * (0.3333333333f + y2 * (0.2f + y2 * 0.1428571429f)));
|
||||||
fastExp(x.y),
|
}
|
||||||
fastExp(x.z));
|
*/
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC(fastLog)
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
// fastLog
|
//fastExp2, ln2 = 0.69314718055994530941723212145818f
|
||||||
template <typename T>
|
template <typename genType>
|
||||||
GLM_FUNC_QUALIFIER T fastLog(const T x)
|
GLM_FUNC_QUALIFIER genType fastExp2(genType const & x)
|
||||||
{
|
{
|
||||||
return std::log(x);
|
return fastExp(0.69314718055994530941723212145818f * x);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Slower than the VC7.1 function...
|
VECTORIZE_VEC(fastExp2)
|
||||||
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>
|
// fastLog2, ln2 = 0.69314718055994530941723212145818f
|
||||||
GLM_FUNC_QUALIFIER detail::tvec2<T> fastLog(
|
template <typename genType>
|
||||||
const detail::tvec2<T>& x)
|
GLM_FUNC_QUALIFIER genType fastLog2(genType const & x)
|
||||||
{
|
{
|
||||||
return detail::tvec2<T>(
|
return fastLog(x) / 0.69314718055994530941723212145818f;
|
||||||
fastLog(x.x),
|
}
|
||||||
fastLog(x.y));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
VECTORIZE_VEC(fastLog2)
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace glm
|
}//namespace glm
|
||||||
|
Loading…
Reference in New Issue
Block a user