Reduced dependencies of GTX extensions. Removed some deprecated code.
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
#include "../detail/precision.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTC_epsilon extension included")
|
||||
@@ -56,18 +57,18 @@ namespace glm
|
||||
/// True if this expression is satisfied.
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
typename genType::bool_type epsilonEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
typename genType::value_type const & epsilon);
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL vecType<bool, P> epsilonEqual(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
T const & epsilon);
|
||||
|
||||
/// Returns the component-wise comparison of |x - y| < epsilon.
|
||||
/// True if this expression is satisfied.
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
typename genType::bool_type epsilonEqual(
|
||||
GLM_FUNC_DECL bool epsilonEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
genType const & epsilon);
|
||||
@@ -77,7 +78,7 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
typename genType::boolType epsilonNotEqual(
|
||||
GLM_FUNC_DECL typename genType::boolType epsilonNotEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
typename genType::value_type const & epsilon);
|
||||
@@ -87,7 +88,7 @@ namespace glm
|
||||
///
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
typename genType::boolType epsilonNotEqual(
|
||||
GLM_FUNC_DECL bool epsilonNotEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
genType const & epsilon);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
// Dependency:
|
||||
#include "quaternion.hpp"
|
||||
#include "../vector_relational.hpp"
|
||||
#include "../common.hpp"
|
||||
#include "../vec2.hpp"
|
||||
#include "../vec3.hpp"
|
||||
@@ -35,6 +36,7 @@
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER bool epsilonEqual
|
||||
(
|
||||
float const & x,
|
||||
@@ -45,6 +47,7 @@ namespace glm
|
||||
return abs(x - y) < epsilon;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER bool epsilonEqual
|
||||
(
|
||||
double const & x,
|
||||
@@ -55,6 +58,7 @@ namespace glm
|
||||
return abs(x - y) < epsilon;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
||||
(
|
||||
float const & x,
|
||||
@@ -65,6 +69,7 @@ namespace glm
|
||||
return abs(x - y) >= epsilon;
|
||||
}
|
||||
|
||||
template <>
|
||||
GLM_FUNC_QUALIFIER bool epsilonNotEqual
|
||||
(
|
||||
double const & x,
|
||||
@@ -75,170 +80,48 @@ namespace glm
|
||||
return abs(x - y) >= epsilon;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool, P> epsilonEqual
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
|
||||
(
|
||||
detail::tvec2<T, P> const & x,
|
||||
detail::tvec2<T, P> const & y,
|
||||
T const & epsilon)
|
||||
{
|
||||
return detail::tvec2<bool, P>(
|
||||
abs(x.x - y.x) < epsilon,
|
||||
abs(x.y - y.y) < epsilon);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool, P> epsilonEqual
|
||||
(
|
||||
detail::tvec2<T, P> const & x,
|
||||
detail::tvec2<T, P> const & y,
|
||||
detail::tvec2<T, P> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec2<bool, P>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool, P> epsilonEqual
|
||||
(
|
||||
detail::tvec3<T, P> const & x,
|
||||
detail::tvec3<T, P> const & y,
|
||||
T const & epsilon)
|
||||
{
|
||||
return detail::tvec3<bool, P>(
|
||||
abs(x.x - y.x) < epsilon,
|
||||
abs(x.y - y.y) < epsilon,
|
||||
abs(x.z - y.z) < epsilon);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool, P> epsilonEqual
|
||||
(
|
||||
detail::tvec3<T, P> const & x,
|
||||
detail::tvec3<T, P> const & y,
|
||||
detail::tvec3<T, P> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool, P>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y,
|
||||
abs(x.z - y.z) < epsilon.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> epsilonEqual
|
||||
(
|
||||
detail::tvec4<T, P> const & x,
|
||||
detail::tvec4<T, P> const & y,
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool, P>(
|
||||
abs(x.x - y.x) < epsilon,
|
||||
abs(x.y - y.y) < epsilon,
|
||||
abs(x.z - y.z) < epsilon,
|
||||
abs(x.w - y.w) < epsilon);
|
||||
return lessThan(abs(x - y), vecType<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> epsilonEqual
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonEqual
|
||||
(
|
||||
detail::tvec4<T, P> const & x,
|
||||
detail::tvec4<T, P> const & y,
|
||||
detail::tvec4<T, P> const & epsilon
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
vecType<T, P> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool, P>(
|
||||
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);
|
||||
return lessThan(abs(x - y), vecType<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool, P> epsilonNotEqual
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
|
||||
(
|
||||
detail::tvec2<T, P> const & x,
|
||||
detail::tvec2<T, P> const & y,
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec2<bool, P>(
|
||||
abs(x.x - y.x) >= epsilon,
|
||||
abs(x.y - y.y) >= epsilon);
|
||||
return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<bool, P> epsilonNotEqual
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER vecType<bool, P> epsilonNotEqual
|
||||
(
|
||||
detail::tvec2<T, P> const & x,
|
||||
detail::tvec2<T, P> const & y,
|
||||
detail::tvec2<T, P> const & epsilon
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y,
|
||||
vecType<T, P> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec2<bool, P>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool, P> epsilonNotEqual
|
||||
(
|
||||
detail::tvec3<T, P> const & x,
|
||||
detail::tvec3<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool, P>(
|
||||
abs(x.x - y.x) >= epsilon,
|
||||
abs(x.y - y.y) >= epsilon,
|
||||
abs(x.z - y.z) >= epsilon);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<bool, P> epsilonNotEqual
|
||||
(
|
||||
detail::tvec3<T, P> const & x,
|
||||
detail::tvec3<T, P> const & y,
|
||||
detail::tvec3<T, P> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec3<bool, P>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y,
|
||||
abs(x.z - y.z) >= epsilon.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> epsilonNotEqual
|
||||
(
|
||||
detail::tvec4<T, P> const & x,
|
||||
detail::tvec4<T, P> const & y,
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool, P>(
|
||||
abs(x.x - y.x) >= epsilon,
|
||||
abs(x.y - y.y) >= epsilon,
|
||||
abs(x.z - y.z) >= epsilon,
|
||||
abs(x.w - y.w) >= epsilon);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> epsilonNotEqual
|
||||
(
|
||||
detail::tvec4<T, P> const & x,
|
||||
detail::tvec4<T, P> const & y,
|
||||
detail::tvec4<T, P> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool, P>(
|
||||
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);
|
||||
return greaterThanEqual(abs(x - y), vecType<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
@@ -249,11 +132,8 @@ namespace glm
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool, P>(
|
||||
abs(x.x - y.x) < epsilon,
|
||||
abs(x.y - y.y) < epsilon,
|
||||
abs(x.z - y.z) < epsilon,
|
||||
abs(x.w - y.w) < epsilon);
|
||||
detail::tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
|
||||
return lessThan(abs(v), detail::tvec4<T, P>(epsilon));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
@@ -264,10 +144,7 @@ namespace glm
|
||||
T const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool, P>(
|
||||
abs(x.x - y.x) >= epsilon,
|
||||
abs(x.y - y.y) >= epsilon,
|
||||
abs(x.z - y.z) >= epsilon,
|
||||
abs(x.w - y.w) >= epsilon);
|
||||
detail::tvec4<T, P> v(x.x - y.x, x.y - y.y, x.z - y.z, x.w - y.w);
|
||||
return greaterThanEqual(abs(v), detail::tvec4<T, P>(epsilon));
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
@@ -36,15 +36,27 @@
|
||||
#include "../vector_relational.hpp"
|
||||
#include "../detail/_noise.hpp"
|
||||
|
||||
namespace glm
|
||||
namespace glm{
|
||||
namespace gtc
|
||||
{
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T, P> grad4(T const & j, detail::tvec4<T, P> const & ip)
|
||||
{
|
||||
detail::tvec3<T, P> pXYZ = floor(fract(detail::tvec3<T, P>(j) * detail::tvec3<T, P>(ip)) * T(7)) * ip[2] - T(1);
|
||||
T pW = static_cast<T>(1.5) - dot(abs(pXYZ), detail::tvec3<T, P>(1));
|
||||
detail::tvec4<T, P> s = detail::tvec4<T, P>(lessThan(detail::tvec4<T, P>(pXYZ, pW), detail::tvec4<T, P>(0.0)));
|
||||
pXYZ = pXYZ + (detail::tvec3<T, P>(s) * T(2) - T(1)) * s.w;
|
||||
return detail::tvec4<T, P>(pXYZ, pW);
|
||||
}
|
||||
}//namespace gtc
|
||||
|
||||
// Classic Perlin noise
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T perlin(detail::tvec2<T, P> const & Position)
|
||||
{
|
||||
detail::tvec4<T, P> Pi = glm::floor(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) + detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
|
||||
detail::tvec4<T, P> Pf = glm::fract(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) - detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
|
||||
Pi = mod(Pi, T(289)); // To avoid truncation effects in permutation
|
||||
Pi = mod(Pi, detail::tvec4<T, P>(289)); // To avoid truncation effects in permutation
|
||||
detail::tvec4<T, P> ix(Pi.x, Pi.z, Pi.x, Pi.z);
|
||||
detail::tvec4<T, P> iy(Pi.y, Pi.y, Pi.w, Pi.w);
|
||||
detail::tvec4<T, P> fx(Pf.x, Pf.z, Pf.x, Pf.z);
|
||||
@@ -229,8 +241,8 @@ namespace glm
|
||||
{
|
||||
detail::tvec4<T, P> Pi0 = floor(Position); // Integer part for indexing
|
||||
detail::tvec4<T, P> Pi1 = Pi0 + T(1); // Integer part + 1
|
||||
Pi0 = mod(Pi0, T(289));
|
||||
Pi1 = mod(Pi1, T(289));
|
||||
Pi0 = mod(Pi0, detail::tvec4<T, P>(289));
|
||||
Pi1 = mod(Pi1, detail::tvec4<T, P>(289));
|
||||
detail::tvec4<T, P> Pf0 = fract(Position); // Fractional part for interpolation
|
||||
detail::tvec4<T, P> Pf1 = Pf0 - T(1); // Fractional part - 1.0
|
||||
detail::tvec4<T, P> ix(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
||||
@@ -366,7 +378,7 @@ namespace glm
|
||||
detail::tvec4<T, P> Pi = floor(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) + detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
|
||||
detail::tvec4<T, P> Pf = fract(detail::tvec4<T, P>(Position.x, Position.y, Position.x, Position.y)) - detail::tvec4<T, P>(0.0, 0.0, 1.0, 1.0);
|
||||
Pi = mod(Pi, detail::tvec4<T, P>(rep.x, rep.y, rep.x, rep.y)); // To create noise with explicit period
|
||||
Pi = mod(Pi, T(289)); // To avoid truncation effects in permutation
|
||||
Pi = mod(Pi, detail::tvec4<T, P>(289)); // To avoid truncation effects in permutation
|
||||
detail::tvec4<T, P> ix(Pi.x, Pi.z, Pi.x, Pi.z);
|
||||
detail::tvec4<T, P> iy(Pi.y, Pi.y, Pi.w, Pi.w);
|
||||
detail::tvec4<T, P> fx(Pf.x, Pf.z, Pf.x, Pf.z);
|
||||
@@ -407,8 +419,8 @@ namespace glm
|
||||
{
|
||||
detail::tvec3<T, P> Pi0 = mod(floor(Position), rep); // Integer part, modulo period
|
||||
detail::tvec3<T, P> Pi1 = mod(Pi0 + detail::tvec3<T, P>(T(1)), rep); // Integer part + 1, mod period
|
||||
Pi0 = mod(Pi0, T(289));
|
||||
Pi1 = mod(Pi1, T(289));
|
||||
Pi0 = mod(Pi0, detail::tvec3<T, P>(289));
|
||||
Pi1 = mod(Pi1, detail::tvec3<T, P>(289));
|
||||
detail::tvec3<T, P> Pf0 = fract(Position); // Fractional part for interpolation
|
||||
detail::tvec3<T, P> Pf1 = Pf0 - detail::tvec3<T, P>(T(1)); // Fractional part - 1.0
|
||||
detail::tvec4<T, P> ix = detail::tvec4<T, P>(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
|
||||
@@ -630,15 +642,15 @@ namespace glm
|
||||
x12 = detail::tvec4<T, P>(detail::tvec2<T, P>(x12) - i1, x12.z, x12.w);
|
||||
|
||||
// Permutations
|
||||
i = mod(i, T(289)); // Avoid truncation effects in permutation
|
||||
i = mod(i, detail::tvec2<T, P>(289)); // Avoid truncation effects in permutation
|
||||
detail::tvec3<T, P> p = detail::permute(
|
||||
detail::permute(i.y + detail::tvec3<T, P>(T(0), i1.y, T(1)))
|
||||
+ i.x + detail::tvec3<T, P>(T(0), i1.x, T(1)));
|
||||
|
||||
detail::tvec3<T, P> m = max(T(0.5) - detail::tvec3<T, P>(
|
||||
dot(x0, x0),
|
||||
detail::tvec3<T, P> m = max(detail::tvec3<T, P>(0.5) - detail::tvec3<T, P>(
|
||||
dot(x0, x0),
|
||||
dot(detail::tvec2<T, P>(x12.x, x12.y), detail::tvec2<T, P>(x12.x, x12.y)),
|
||||
dot(detail::tvec2<T, P>(x12.z, x12.w), detail::tvec2<T, P>(x12.z, x12.w))), T(0));
|
||||
dot(detail::tvec2<T, P>(x12.z, x12.w), detail::tvec2<T, P>(x12.z, x12.w))), detail::tvec3<T, P>(0));
|
||||
m = m * m ;
|
||||
m = m * m ;
|
||||
|
||||
@@ -733,7 +745,7 @@ namespace glm
|
||||
p3 *= norm.w;
|
||||
|
||||
// Mix final noise value
|
||||
detail::tvec4<T, P> m = max(T(0.6) - detail::tvec4<T, P>(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), T(0));
|
||||
detail::tvec4<T, P> m = max(T(0.6) - detail::tvec4<T, P>(dot(x0, x0), dot(x1, x1), dot(x2, x2), dot(x3, x3)), detail::tvec4<T, P>(0));
|
||||
m = m * m;
|
||||
return T(42) * dot(m * m, detail::tvec4<T, P>(dot(p0, x0), dot(p1, x1), dot(p2, x2), dot(p3, x3)));
|
||||
}
|
||||
@@ -788,23 +800,23 @@ namespace glm
|
||||
detail::tvec4<T, P> x4 = x0 + C.w;
|
||||
|
||||
// Permutations
|
||||
i = mod(i, T(289));
|
||||
i = mod(i, detail::tvec4<T, P>(289));
|
||||
T j0 = detail::permute(detail::permute(detail::permute(detail::permute(i.w) + i.z) + i.y) + i.x);
|
||||
detail::tvec4<T, P> j1 = detail::permute(detail::permute(detail::permute(detail::permute(
|
||||
i.w + detail::tvec4<T, P>(i1.w, i2.w, i3.w, T(1)))
|
||||
+ i.z + detail::tvec4<T, P>(i1.z, i2.z, i3.z, T(1)))
|
||||
+ i.y + detail::tvec4<T, P>(i1.y, i2.y, i3.y, T(1)))
|
||||
+ i.x + detail::tvec4<T, P>(i1.x, i2.x, i3.x, T(1)));
|
||||
i.w + detail::tvec4<T, P>(i1.w, i2.w, i3.w, T(1))) +
|
||||
i.z + detail::tvec4<T, P>(i1.z, i2.z, i3.z, T(1))) +
|
||||
i.y + detail::tvec4<T, P>(i1.y, i2.y, i3.y, T(1))) +
|
||||
i.x + detail::tvec4<T, P>(i1.x, i2.x, i3.x, T(1)));
|
||||
|
||||
// Gradients: 7x7x6 points over a cube, mapped onto a 4-cross polytope
|
||||
// 7*7*6 = 294, which is close to the ring size 17*17 = 289.
|
||||
detail::tvec4<T, P> ip = detail::tvec4<T, P>(T(1) / T(294), T(1) / T(49), T(1) / T(7), T(0));
|
||||
|
||||
detail::tvec4<T, P> p0 = detail::grad4(j0, ip);
|
||||
detail::tvec4<T, P> p1 = detail::grad4(j1.x, ip);
|
||||
detail::tvec4<T, P> p2 = detail::grad4(j1.y, ip);
|
||||
detail::tvec4<T, P> p3 = detail::grad4(j1.z, ip);
|
||||
detail::tvec4<T, P> p4 = detail::grad4(j1.w, ip);
|
||||
detail::tvec4<T, P> p0 = gtc::grad4(j0, ip);
|
||||
detail::tvec4<T, P> p1 = gtc::grad4(j1.x, ip);
|
||||
detail::tvec4<T, P> p2 = gtc::grad4(j1.y, ip);
|
||||
detail::tvec4<T, P> p3 = gtc::grad4(j1.z, ip);
|
||||
detail::tvec4<T, P> p4 = gtc::grad4(j1.w, ip);
|
||||
|
||||
// Normalise gradients
|
||||
detail::tvec4<T, P> norm = detail::taylorInvSqrt(detail::tvec4<T, P>(dot(p0, p0), dot(p1, p1), dot(p2, p2), dot(p3, p3)));
|
||||
@@ -815,8 +827,8 @@ namespace glm
|
||||
p4 *= detail::taylorInvSqrt(dot(p4, p4));
|
||||
|
||||
// Mix contributions from the five corners
|
||||
detail::tvec3<T, P> m0 = max(T(0.6) - detail::tvec3<T, P>(dot(x0, x0), dot(x1, x1), dot(x2, x2)), T(0));
|
||||
detail::tvec2<T, P> m1 = max(T(0.6) - detail::tvec2<T, P>(dot(x3, x3), dot(x4, x4) ), T(0));
|
||||
detail::tvec3<T, P> m0 = max(T(0.6) - detail::tvec3<T, P>(dot(x0, x0), dot(x1, x1), dot(x2, x2)), detail::tvec3<T, P>(0));
|
||||
detail::tvec2<T, P> m1 = max(T(0.6) - detail::tvec2<T, P>(dot(x3, x3), dot(x4, x4) ), detail::tvec2<T, P>(0));
|
||||
m0 = m0 * m0;
|
||||
m1 = m1 * m1;
|
||||
return T(49) *
|
||||
|
||||
@@ -186,10 +186,10 @@ namespace detail
|
||||
/// Returns dot product of q1 and q2, i.e., q1[0] * q2[0] + q1[1] * q2[1] + ...
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename T, precision P>
|
||||
template <typename T, precision P, template <typename, precision> class quatType>
|
||||
GLM_FUNC_DECL T dot(
|
||||
detail::tquat<T, P> const & q1,
|
||||
detail::tquat<T, P> const & q2);
|
||||
quatType<T, P> const & x,
|
||||
quatType<T, P> const & y);
|
||||
|
||||
/// Spherical linear interpolation of two quaternions.
|
||||
/// The interpolation is oriented and the rotation is performed at constant speed.
|
||||
@@ -345,48 +345,60 @@ namespace detail
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename quatType>
|
||||
GLM_FUNC_DECL typename quatType::bool_type lessThan(quatType const & x, quatType const & y);
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> lessThan(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x <= y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename quatType>
|
||||
GLM_FUNC_DECL typename quatType::bool_type lessThanEqual(quatType const & x, quatType const & y);
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> lessThanEqual(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x > y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename quatType>
|
||||
GLM_FUNC_DECL typename quatType::bool_type greaterThan(quatType const & x, quatType const & y);
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> greaterThan(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x >= y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename quatType>
|
||||
GLM_FUNC_DECL typename quatType::bool_type greaterThanEqual(quatType const & x, quatType const & y);
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> greaterThanEqual(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x == y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename quatType>
|
||||
GLM_FUNC_DECL typename quatType::bool_type equal(quatType const & x, quatType const & y);
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> equal(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// Returns the component-wise comparison of result x != y.
|
||||
///
|
||||
/// @tparam quatType Floating-point quaternion types.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
template <typename quatType>
|
||||
GLM_FUNC_DECL typename quatType::bool_type notEqual(quatType const & x, quatType const & y);
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_DECL detail::tvec4<bool, P> notEqual(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y);
|
||||
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
||||
@@ -128,7 +128,9 @@ namespace detail
|
||||
)
|
||||
{
|
||||
detail::tvec3<T, P> w = cross(u, v);
|
||||
detail::tquat<T, P> q(T(1) + dot(u, v), w.x, w.y, w.z);
|
||||
T Dot = detail::compute_dot<detail::tvec3, T, P>::call(u, v);
|
||||
detail::tquat<T, P> q(T(1) + Dot, w.x, w.y, w.z);
|
||||
|
||||
*this = normalize(q);
|
||||
}
|
||||
|
||||
@@ -181,7 +183,28 @@ namespace detail
|
||||
assert(i >= 0 && i < this->length());
|
||||
return (&x)[i];
|
||||
}
|
||||
}//namespace detail
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> conjugate
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return detail::tquat<T, P>(q.w, -q.x, -q.y, -q.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> inverse
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return conjugate(q) / dot(q, q);
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
//////////////////////////////////////////////////////////////
|
||||
// tquat<valType> operators
|
||||
|
||||
@@ -240,7 +263,20 @@ namespace detail
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// tquat<valType> external operators
|
||||
// tquat<T, P> external functions
|
||||
|
||||
template <typename T, precision P>
|
||||
struct compute_dot<tquat, T, P>
|
||||
{
|
||||
static T call(tquat<T, P> const & x, tquat<T, P> const & y)
|
||||
{
|
||||
tvec4<T, P> tmp(x.x * y.x, x.y * y.y, x.z * y.z, x.w * y.w);
|
||||
return (tmp.x + tmp.y) + (tmp.z + tmp.w);
|
||||
}
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// tquat<T, P> external operators
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> operator-
|
||||
@@ -298,7 +334,7 @@ namespace detail
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return inverse(q) * v;
|
||||
return glm::inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
@@ -318,7 +354,7 @@ namespace detail
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return inverse(q) * v;
|
||||
return glm::inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
@@ -401,16 +437,6 @@ namespace detail
|
||||
return detail::tquat<T, P>(q.w * oneOverLen, q.x * oneOverLen, q.y * oneOverLen, q.z * oneOverLen);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T dot
|
||||
(
|
||||
detail::tquat<T, P> const & q1,
|
||||
detail::tquat<T, P> const & q2
|
||||
)
|
||||
{
|
||||
return q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> cross
|
||||
(
|
||||
@@ -587,24 +613,6 @@ namespace detail
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> conjugate
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return detail::tquat<T, P>(q.w, -q.x, -q.y, -q.z);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> inverse
|
||||
(
|
||||
detail::tquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return conjugate(q) / dot(q, q);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T, P> rotate
|
||||
(
|
||||
@@ -850,80 +858,79 @@ namespace detail
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER typename detail::tquat<T, P>::bool_type lessThan
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> lessThan
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
typename detail::tquat<T, P>::bool_type Result;
|
||||
for(int i = 0; i < x.length(); ++i)
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] < y[i];
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER typename detail::tquat<T, P>::bool_type lessThanEqual
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> lessThanEqual
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
typename detail::tquat<T, P>::bool_type Result;
|
||||
for(int i = 0; i < x.length(); ++i)
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] <= y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER typename detail::tquat<T, P>::bool_type greaterThan
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> greaterThan
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
typename detail::tquat<T, P>::bool_type Result;
|
||||
for(int i = 0; i < x.length(); ++i)
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] > y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER typename detail::tquat<T, P>::bool_type greaterThanEqual
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> greaterThanEqual
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
typename detail::tquat<T, P>::bool_type Result;
|
||||
for(int i = 0; i < x.length(); ++i)
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] >= y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER typename detail::tquat<T, P>::bool_type equal
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> equal
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
typename detail::tquat<T, P>::bool_type Result;
|
||||
for(int i = 0; i < x.length(); ++i)
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] == y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER typename detail::tquat<T, P>::bool_type notEqual
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool, P> notEqual
|
||||
(
|
||||
detail::tquat<T, P> const & x,
|
||||
detail::tquat<T, P> const & y
|
||||
)
|
||||
{
|
||||
typename detail::tquat<T, P>::bool_type Result;
|
||||
for(int i = 0; i < x.length(); ++i)
|
||||
detail::tvec4<bool, P> Result;
|
||||
for(length_t i = 0; i < x.length(); ++i)
|
||||
Result[i] = x[i] != y[i];
|
||||
return Result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user