mirror of
https://github.com/g-truc/glm.git
synced 2025-04-10 07:18:54 +00:00
Reduced dependencies of GTX extensions. Removed some deprecated code.
This commit is contained in:
parent
950eaa45cb
commit
9f8112f93a
24 changed files with 347 additions and 757 deletions
|
@ -123,15 +123,6 @@ namespace detail
|
|||
return (t * t * t) * (t * (t * T(6) - T(15)) + T(10));
|
||||
}
|
||||
*/
|
||||
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 detail
|
||||
}//namespace glm
|
||||
|
||||
|
|
|
@ -29,6 +29,10 @@
|
|||
#ifndef GLM_CORE_DETAIL_INCLUDED
|
||||
#define GLM_CORE_DETAIL_INCLUDED
|
||||
|
||||
#include "type_vec2.hpp"
|
||||
#include "type_vec3.hpp"
|
||||
#include "type_vec4.hpp"
|
||||
|
||||
#define VECTORIZE2_VEC(func) \
|
||||
template <typename T, precision P> \
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T, P> func( \
|
||||
|
|
|
@ -147,7 +147,7 @@ namespace glm
|
|||
template <typename genType>
|
||||
GLM_FUNC_DECL genType mod(
|
||||
genType const & x,
|
||||
typename genType::T const & y);
|
||||
typename genType::value_type const & y);
|
||||
|
||||
/// Returns the fractional part of x and sets i to the integer
|
||||
/// part (as a whole number floating point value). Both the
|
||||
|
@ -177,7 +177,7 @@ namespace glm
|
|||
template <typename genType>
|
||||
GLM_FUNC_DECL genType min(
|
||||
genType const & x,
|
||||
typename genType::T const & y);
|
||||
typename genType::value_type const & y);
|
||||
|
||||
/// Returns y if x < y; otherwise, it returns x.
|
||||
///
|
||||
|
@ -193,7 +193,7 @@ namespace glm
|
|||
template <typename genType>
|
||||
GLM_FUNC_DECL genType max(
|
||||
genType const & x,
|
||||
typename genType::T const & y);
|
||||
typename genType::value_type const & y);
|
||||
|
||||
/// Returns min(max(x, minVal), maxVal) for each component in x
|
||||
/// using the floating-point values minVal and maxVal.
|
||||
|
@ -211,8 +211,8 @@ namespace glm
|
|||
template <typename genType, precision P>
|
||||
GLM_FUNC_DECL genType clamp(
|
||||
genType const & x,
|
||||
typename genType::T const & minVal,
|
||||
typename genType::T const & maxVal);
|
||||
typename genType::value_type const & minVal,
|
||||
typename genType::value_type const & maxVal);
|
||||
|
||||
/// If genTypeU is a floating scalar or vector:
|
||||
/// Returns x * (1.0 - a) + y * a, i.e., the linear blend of
|
||||
|
@ -302,8 +302,8 @@ namespace glm
|
|||
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL genType smoothstep(
|
||||
typename genType::T const & edge0,
|
||||
typename genType::T const & edge1,
|
||||
typename genType::value_type const & edge0,
|
||||
typename genType::value_type const & edge1,
|
||||
genType const & x);
|
||||
|
||||
/// Returns true if x holds a NaN (not a number)
|
||||
|
|
|
@ -64,6 +64,17 @@ namespace glm
|
|||
genType const & p0,
|
||||
genType const & p1);
|
||||
|
||||
/// Returns the dot product of x and y, i.e., result = x * y.
|
||||
///
|
||||
/// @tparam genType Floating-point vector types.
|
||||
///
|
||||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_DECL T dot(
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y);
|
||||
/*
|
||||
/// Returns the dot product of x and y, i.e., result = x * y.
|
||||
///
|
||||
/// @tparam genType Floating-point vector types.
|
||||
|
@ -71,10 +82,10 @@ namespace glm
|
|||
/// @see <a href="http://www.opengl.org/sdk/docs/manglsl/xhtml/dot.xml">GLSL dot man page</a>
|
||||
/// @see <a href="http://www.opengl.org/registry/doc/GLSLangSpec.4.20.8.pdf">GLSL 4.20.8 specification, section 8.5 Geometric Functions</a>
|
||||
template <typename genType>
|
||||
GLM_FUNC_DECL typename genType::value_type dot(
|
||||
GLM_FUNC_DECL genType dot(
|
||||
genType const & x,
|
||||
genType const & y);
|
||||
|
||||
*/
|
||||
/// Returns the cross product of x and y.
|
||||
///
|
||||
/// @tparam valType Floating-point scalar types.
|
||||
|
|
|
@ -31,8 +31,43 @@
|
|||
#include "type_vec4.hpp"
|
||||
#include "type_float.hpp"
|
||||
|
||||
namespace glm
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
template <template <class, precision> class vecType, typename T, precision P>
|
||||
struct compute_dot{};
|
||||
|
||||
template <typename T, precision P>
|
||||
struct compute_dot<detail::tvec2, T, P>
|
||||
{
|
||||
static T call(detail::tvec2<T, P> const & x, detail::tvec2<T, P> const & y)
|
||||
{
|
||||
detail::tvec2<T, P> tmp(x * y);
|
||||
return tmp.x + tmp.y;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, precision P>
|
||||
struct compute_dot<detail::tvec3, T, P>
|
||||
{
|
||||
static T call(detail::tvec3<T, P> const & x, detail::tvec3<T, P> const & y)
|
||||
{
|
||||
detail::tvec3<T, P> tmp(x * y);
|
||||
return tmp.x + tmp.y + tmp.z;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, precision P>
|
||||
struct compute_dot<detail::tvec4, T, P>
|
||||
{
|
||||
static T call(detail::tvec4<T, P> const & x, detail::tvec4<T, P> const & y)
|
||||
{
|
||||
detail::tvec4<T, P> tmp(x * y);
|
||||
return (tmp.x + tmp.y) + (tmp.z + tmp.w);
|
||||
}
|
||||
};
|
||||
}//namespace detail
|
||||
|
||||
// length
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType length
|
||||
|
@ -123,41 +158,35 @@ namespace glm
|
|||
}
|
||||
|
||||
// dot
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType dot
|
||||
GLM_FUNC_QUALIFIER float dot
|
||||
(
|
||||
genType const & x,
|
||||
genType const & y
|
||||
float const & x,
|
||||
float const & y
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'dot' only accept floating-point inputs");
|
||||
|
||||
return x * y;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER double dot
|
||||
(
|
||||
double const & x,
|
||||
double const & y
|
||||
)
|
||||
{
|
||||
return x * y;
|
||||
}
|
||||
|
||||
template <typename T, precision P, template <typename, precision> class vecType>
|
||||
GLM_FUNC_QUALIFIER T dot
|
||||
(
|
||||
detail::tvec2<T, P> const & x,
|
||||
detail::tvec2<T, P> const & y
|
||||
vecType<T, P> const & x,
|
||||
vecType<T, P> const & y
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' only accept floating-point inputs");
|
||||
|
||||
return x.x * y.x + x.y * y.y;
|
||||
return detail::compute_dot<vecType, T, P>::call(x, y);
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T dot
|
||||
(
|
||||
detail::tvec3<T, P> const & x,
|
||||
detail::tvec3<T, P> const & y
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' only accept floating-point inputs");
|
||||
|
||||
return x.x * y.x + x.y * y.y + x.z * y.z;
|
||||
}
|
||||
/* // SSE3
|
||||
GLM_FUNC_QUALIFIER float dot(const tvec4<float>& x, const tvec4<float>& y)
|
||||
{
|
||||
|
@ -175,18 +204,6 @@ namespace glm
|
|||
return Result;
|
||||
}
|
||||
*/
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER T dot
|
||||
(
|
||||
detail::tvec4<T, P> const & x,
|
||||
detail::tvec4<T, P> const & y
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<T>::is_iec559, "'dot' only accept floating-point inputs");
|
||||
|
||||
return x.x * y.x + x.y * y.y + x.z * y.z + x.w * y.w;
|
||||
}
|
||||
|
||||
// cross
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> cross
|
||||
|
|
|
@ -29,8 +29,20 @@
|
|||
#include "../detail/_noise.hpp"
|
||||
#include "./func_common.hpp"
|
||||
|
||||
namespace glm
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
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 detail
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER T noise1(T const & x)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -39,8 +39,10 @@
|
|||
#ifndef GLM_GTX_bit
|
||||
#define GLM_GTX_bit
|
||||
|
||||
// Dependency:
|
||||
#include "../glm.hpp"
|
||||
// Dependencies
|
||||
#include "../detail/type_int.hpp"
|
||||
#include "../detail/setup.hpp"
|
||||
#include <cstddef>
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTX_bit extension included")
|
||||
|
@ -54,71 +56,52 @@ namespace glm
|
|||
/// Build a mask of 'count' bits
|
||||
/// @see gtx_bit
|
||||
template <typename genIType>
|
||||
genIType mask(genIType const & count);
|
||||
|
||||
/// Component wise extraction of bit fields.
|
||||
/// genType and genIType could be a scalar or a vector.
|
||||
/// @see gtx_bit
|
||||
template <typename genIUType, typename sizeType>
|
||||
GLM_DEPRECATED genIUType extractField(
|
||||
genIUType const & v,
|
||||
sizeType const & first,
|
||||
sizeType const & count);
|
||||
|
||||
//! Find the lowest bit set to 1 in a integer variable.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
GLM_DEPRECATED int lowestBit(genType const & value);
|
||||
|
||||
//! Find the highest bit set to 1 in a integer variable.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
GLM_DEPRECATED int highestBit(genType const & value);
|
||||
GLM_FUNC_DECL genIType mask(genIType const & count);
|
||||
|
||||
//! Find the highest bit set to 1 in a integer variable and return its value.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
genType highestBitValue(genType const & value);
|
||||
GLM_FUNC_DECL genType highestBitValue(genType const & value);
|
||||
|
||||
//! Return true if the value is a power of two number.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
bool isPowerOfTwo(genType const & value);
|
||||
GLM_FUNC_DECL bool isPowerOfTwo(genType const & value);
|
||||
|
||||
//! Return the power of two number which value is just higher the input value.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
genType powerOfTwoAbove(genType const & value);
|
||||
GLM_FUNC_DECL genType powerOfTwoAbove(genType const & value);
|
||||
|
||||
//! Return the power of two number which value is just lower the input value.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
genType powerOfTwoBelow(genType const & value);
|
||||
GLM_FUNC_DECL genType powerOfTwoBelow(genType const & value);
|
||||
|
||||
//! Return the power of two number which value is the closet to the input value.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
genType powerOfTwoNearest(genType const & value);
|
||||
GLM_FUNC_DECL genType powerOfTwoNearest(genType const & value);
|
||||
|
||||
//! Revert all bits of any integer based type.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
GLM_DEPRECATED genType bitRevert(genType const & value);
|
||||
GLM_DEPRECATED GLM_FUNC_DECL genType bitRevert(genType const & value);
|
||||
|
||||
//! Rotate all bits to the right.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
genType bitRotateRight(genType const & In, std::size_t Shift);
|
||||
GLM_FUNC_DECL genType bitRotateRight(genType const & In, std::size_t Shift);
|
||||
|
||||
//! Rotate all bits to the left.
|
||||
/// @see gtx_bit
|
||||
template <typename genType>
|
||||
genType bitRotateLeft(genType const & In, std::size_t Shift);
|
||||
GLM_FUNC_DECL genType bitRotateLeft(genType const & In, std::size_t Shift);
|
||||
|
||||
//! Set to 1 a range of bits.
|
||||
/// @see gtx_bit
|
||||
template <typename genIUType>
|
||||
genIUType fillBitfieldWithOne(
|
||||
GLM_FUNC_DECL genIUType fillBitfieldWithOne(
|
||||
genIUType const & Value,
|
||||
int const & FromBit,
|
||||
int const & ToBit);
|
||||
|
@ -126,7 +109,7 @@ namespace glm
|
|||
//! Set to 0 a range of bits.
|
||||
/// @see gtx_bit
|
||||
template <typename genIUType>
|
||||
genIUType fillBitfieldWithZero(
|
||||
GLM_FUNC_DECL genIUType fillBitfieldWithZero(
|
||||
genIUType const & Value,
|
||||
int const & FromBit,
|
||||
int const & ToBit);
|
||||
|
@ -136,112 +119,112 @@ namespace glm
|
|||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
int16 bitfieldInterleave(int8 x, int8 y);
|
||||
GLM_FUNC_DECL int16 bitfieldInterleave(int8 x, int8 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
uint16 bitfieldInterleave(uint8 x, uint8 y);
|
||||
GLM_FUNC_DECL uint16 bitfieldInterleave(uint8 x, uint8 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
int32 bitfieldInterleave(int16 x, int16 y);
|
||||
GLM_FUNC_DECL int32 bitfieldInterleave(int16 x, int16 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
uint32 bitfieldInterleave(uint16 x, uint16 y);
|
||||
GLM_FUNC_DECL uint32 bitfieldInterleave(uint16 x, uint16 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
int64 bitfieldInterleave(int32 x, int32 y);
|
||||
GLM_FUNC_DECL int64 bitfieldInterleave(int32 x, int32 y);
|
||||
|
||||
/// Interleaves the bits of x and y.
|
||||
/// The first bit is the first bit of x followed by the first bit of y.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
uint64 bitfieldInterleave(uint32 x, uint32 y);
|
||||
GLM_FUNC_DECL uint64 bitfieldInterleave(uint32 x, uint32 y);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
int32 bitfieldInterleave(int8 x, int8 y, int8 z);
|
||||
GLM_FUNC_DECL int32 bitfieldInterleave(int8 x, int8 y, int8 z);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z);
|
||||
GLM_FUNC_DECL uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
int64 bitfieldInterleave(int16 x, int16 y, int16 z);
|
||||
GLM_FUNC_DECL int64 bitfieldInterleave(int16 x, int16 y, int16 z);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z);
|
||||
GLM_FUNC_DECL uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
int64 bitfieldInterleave(int32 x, int32 y, int32 z);
|
||||
GLM_FUNC_DECL int64 bitfieldInterleave(int32 x, int32 y, int32 z);
|
||||
|
||||
/// Interleaves the bits of x, y and z.
|
||||
/// The first bit is the first bit of x followed by the first bit of y and the first bit of z.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
uint64 bitfieldInterleave(uint32 x, uint32 y, uint32 z);
|
||||
GLM_FUNC_DECL uint64 bitfieldInterleave(uint32 x, uint32 y, uint32 z);
|
||||
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
int32 bitfieldInterleave(int8 x, int8 y, int8 z, int8 w);
|
||||
GLM_FUNC_DECL int32 bitfieldInterleave(int8 x, int8 y, int8 z, int8 w);
|
||||
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z, uint8 w);
|
||||
GLM_FUNC_DECL uint32 bitfieldInterleave(uint8 x, uint8 y, uint8 z, uint8 w);
|
||||
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
int64 bitfieldInterleave(int16 x, int16 y, int16 z, int16 w);
|
||||
GLM_FUNC_DECL int64 bitfieldInterleave(int16 x, int16 y, int16 z, int16 w);
|
||||
|
||||
/// Interleaves the bits of x, y, z and w.
|
||||
/// The first bit is the first bit of x followed by the first bit of y, the first bit of z and finally the first bit of w.
|
||||
/// The other bits are interleaved following the previous sequence.
|
||||
///
|
||||
/// @see gtx_bit
|
||||
uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z, uint16 w);
|
||||
GLM_FUNC_DECL uint64 bitfieldInterleave(uint16 x, uint16 y, uint16 z, uint16 w);
|
||||
|
||||
/// @}
|
||||
} //namespace glm
|
||||
|
|
271
glm/gtx/bit.inl
271
glm/gtx/bit.inl
|
@ -2,11 +2,13 @@
|
|||
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Created : 2007-03-14
|
||||
// Updated : 2008-11-14
|
||||
// Updated : 2013-12-25
|
||||
// Licence : This source is under MIT License
|
||||
// File : glm/gtx/bit.inl
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "../detail/_vectorize.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <typename genIType>
|
||||
|
@ -20,273 +22,6 @@ namespace glm
|
|||
|
||||
VECTORIZE_VEC(mask)
|
||||
|
||||
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 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 T, precision P, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T, P> extractField
|
||||
(
|
||||
detail::tvec2<T, P> const & value,
|
||||
sizeType const & first,
|
||||
sizeType const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec2<T, P>(
|
||||
extractField(value[0], first, count),
|
||||
extractField(value[1], first, count));
|
||||
}
|
||||
|
||||
template <typename T, precision P, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> extractField
|
||||
(
|
||||
detail::tvec3<T, P> const & value,
|
||||
sizeType const & first,
|
||||
sizeType const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec3<T, P>(
|
||||
extractField(value[0], first, count),
|
||||
extractField(value[1], first, count),
|
||||
extractField(value[2], first, count));
|
||||
}
|
||||
|
||||
template <typename T, precision P, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T, P> extractField
|
||||
(
|
||||
detail::tvec4<T, P> const & value,
|
||||
sizeType const & first,
|
||||
sizeType const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec4<T, P>(
|
||||
extractField(value[0], first, count),
|
||||
extractField(value[1], first, count),
|
||||
extractField(value[2], first, count),
|
||||
extractField(value[3], first, count));
|
||||
}
|
||||
|
||||
template <typename T, precision P, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T, P> extractField
|
||||
(
|
||||
detail::tvec2<T, P> const & value,
|
||||
detail::tvec2<sizeType, P> const & first,
|
||||
detail::tvec2<sizeType, P> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec2<T, P>(
|
||||
extractField(value[0], first[0], count[0]),
|
||||
extractField(value[1], first[1], count[1]));
|
||||
}
|
||||
|
||||
template <typename T, precision P, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> extractField
|
||||
(
|
||||
detail::tvec3<T, P> const & value,
|
||||
detail::tvec3<sizeType, P> const & first,
|
||||
detail::tvec3<sizeType, P> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec3<T, P>(
|
||||
extractField(value[0], first[0], count[0]),
|
||||
extractField(value[1], first[1], count[1]),
|
||||
extractField(value[2], first[2], count[2]));
|
||||
}
|
||||
|
||||
template <typename T, precision P, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T, P> extractField
|
||||
(
|
||||
detail::tvec4<T, P> const & value,
|
||||
detail::tvec4<sizeType, P> const & first,
|
||||
detail::tvec4<sizeType, P> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec4<T, P>(
|
||||
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 T, precision P, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<T, P> extractField
|
||||
(
|
||||
T const & value,
|
||||
detail::tvec2<sizeType, P> const & first,
|
||||
detail::tvec2<sizeType, P> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec2<T, P>(
|
||||
extractField(value, first[0], count[0]),
|
||||
extractField(value, first[1], count[1]));
|
||||
}
|
||||
|
||||
template <typename T, precision P, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<T, P> extractField
|
||||
(
|
||||
T const & value,
|
||||
detail::tvec3<sizeType, P> const & first,
|
||||
detail::tvec3<sizeType, P> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec3<T, P>(
|
||||
extractField(value, first[0], count[0]),
|
||||
extractField(value, first[1], count[1]),
|
||||
extractField(value, first[2], count[2]));
|
||||
}
|
||||
|
||||
template <typename T, precision P, typename sizeType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<T, P> extractField
|
||||
(
|
||||
T const & value,
|
||||
detail::tvec4<sizeType, P> const & first,
|
||||
detail::tvec4<sizeType, P> const & count
|
||||
)
|
||||
{
|
||||
return detail::tvec4<T, P>(
|
||||
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 T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<int, P> lowestBit
|
||||
(
|
||||
detail::tvec2<T, P> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec2<int, P>(
|
||||
lowestBit(value[0]),
|
||||
lowestBit(value[1]));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<int, P> lowestBit
|
||||
(
|
||||
detail::tvec3<T, P> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec3<int, P>(
|
||||
lowestBit(value[0]),
|
||||
lowestBit(value[1]),
|
||||
lowestBit(value[2]));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<int, P> lowestBit
|
||||
(
|
||||
detail::tvec4<T, P> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec4<int, P>(
|
||||
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 T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<int, P> highestBit
|
||||
(
|
||||
detail::tvec2<T, P> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec2<int, P>(
|
||||
highestBit(value[0]),
|
||||
highestBit(value[1]));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec3<int, P> highestBit
|
||||
(
|
||||
detail::tvec3<T, P> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec3<int, P>(
|
||||
highestBit(value[0]),
|
||||
highestBit(value[1]),
|
||||
highestBit(value[2]));
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<int, P> highestBit
|
||||
(
|
||||
detail::tvec4<T, P> const & value
|
||||
)
|
||||
{
|
||||
return detail::tvec4<int, P>(
|
||||
highestBit(value[0]),
|
||||
highestBit(value[1]),
|
||||
highestBit(value[2]),
|
||||
highestBit(value[3]));
|
||||
}
|
||||
|
||||
// highestBitValue
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER genType highestBitValue
|
||||
|
|
|
@ -191,7 +191,7 @@ namespace detail
|
|||
detail::tdualquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return inverse(q) * v;
|
||||
return glm::inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
|
@ -211,7 +211,7 @@ namespace detail
|
|||
detail::tdualquat<T, P> const & q
|
||||
)
|
||||
{
|
||||
return inverse(q) * v;
|
||||
return glm::inverse(q) * v;
|
||||
}
|
||||
|
||||
template <typename T, precision P>
|
||||
|
|
|
@ -38,9 +38,8 @@
|
|||
#ifndef GLM_GTX_raw_data
|
||||
#define GLM_GTX_raw_data
|
||||
|
||||
// Dependency:
|
||||
#include "../glm.hpp"
|
||||
#include "../gtc/type_precision.hpp"
|
||||
// Dependencies
|
||||
#include "../detail/setup.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(GLM_EXT_INCLUDED))
|
||||
# pragma message("GLM: GLM_GTX_raw_data extension included")
|
||||
|
@ -53,19 +52,19 @@ namespace glm
|
|||
|
||||
//! Type for byte numbers.
|
||||
//! From GLM_GTX_raw_data extension.
|
||||
typedef uint8 byte;
|
||||
typedef detail::uint8 byte;
|
||||
|
||||
//! Type for word numbers.
|
||||
//! From GLM_GTX_raw_data extension.
|
||||
typedef uint16 word;
|
||||
typedef detail::uint16 word;
|
||||
|
||||
//! Type for dword numbers.
|
||||
//! From GLM_GTX_raw_data extension.
|
||||
typedef uint32 dword;
|
||||
typedef detail::uint32 dword;
|
||||
|
||||
//! Type for qword numbers.
|
||||
//! From GLM_GTX_raw_data extension.
|
||||
typedef uint64 qword;
|
||||
typedef detail::uint64 qword;
|
||||
|
||||
/// @}
|
||||
}// namespace glm
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
#if(GLM_ARCH != GLM_ARCH_PURE)
|
||||
|
||||
#if(GLM_ARCH & GLM_ARCH_SSE2)
|
||||
# include "../core/intrinsic_matrix.hpp"
|
||||
# include "../detail/intrinsic_matrix.hpp"
|
||||
# include "../gtx/simd_vec4.hpp"
|
||||
#else
|
||||
# error "GLM: GLM_GTX_simd_mat4 requires compiler support of SSE2 through intrinsics"
|
||||
|
@ -127,7 +127,7 @@ namespace detail
|
|||
fmat4x4SIMD operator+ (fmat4x4SIMD const & m, float const & s);
|
||||
fmat4x4SIMD operator+ (float const & s, fmat4x4SIMD const & m);
|
||||
fmat4x4SIMD operator+ (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
|
||||
|
||||
|
||||
fmat4x4SIMD operator- (fmat4x4SIMD const & m, float const & s);
|
||||
fmat4x4SIMD operator- (float const & s, fmat4x4SIMD const & m);
|
||||
fmat4x4SIMD operator- (fmat4x4SIMD const & m1, fmat4x4SIMD const & m2);
|
||||
|
|
|
@ -88,7 +88,7 @@ GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD
|
|||
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD & fmat4x4SIMD::operator[]
|
||||
(
|
||||
length i
|
||||
length_t i
|
||||
)
|
||||
{
|
||||
assert(i < this->length());
|
||||
|
@ -98,7 +98,7 @@ GLM_FUNC_QUALIFIER fvec4SIMD & fmat4x4SIMD::operator[]
|
|||
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD const & fmat4x4SIMD::operator[]
|
||||
(
|
||||
length i
|
||||
length_t i
|
||||
) const
|
||||
{
|
||||
assert(i < this->length());
|
||||
|
@ -424,37 +424,44 @@ GLM_FUNC_QUALIFIER fmat4x4SIMD operator/
|
|||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD operator/
|
||||
(
|
||||
const fmat4x4SIMD &m,
|
||||
fvec4SIMD const & v
|
||||
)
|
||||
GLM_FUNC_QUALIFIER detail::fmat4x4SIMD inverse(detail::fmat4x4SIMD const & m)
|
||||
{
|
||||
return inverse(m) * v;
|
||||
detail::fmat4x4SIMD result;
|
||||
detail::sse_inverse_ps(&m[0].Data, &result[0].Data);
|
||||
return result;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD operator/
|
||||
(
|
||||
fvec4SIMD const & v,
|
||||
const fmat4x4SIMD &m
|
||||
const fmat4x4SIMD & m,
|
||||
fvec4SIMD const & v
|
||||
)
|
||||
{
|
||||
return v * inverse(m);
|
||||
return inverse(m) * v;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD operator/
|
||||
(
|
||||
fvec4SIMD const & v,
|
||||
const fmat4x4SIMD &m
|
||||
)
|
||||
{
|
||||
return v * inverse(m);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator/
|
||||
(
|
||||
const fmat4x4SIMD &m1,
|
||||
const fmat4x4SIMD &m2
|
||||
const fmat4x4SIMD &m1,
|
||||
const fmat4x4SIMD &m2
|
||||
)
|
||||
{
|
||||
__m128 result[4];
|
||||
__m128 inv[4];
|
||||
__m128 result[4];
|
||||
__m128 inv[4];
|
||||
|
||||
sse_inverse_ps(&m2.Data[0].Data, inv);
|
||||
sse_mul_ps(&m1.Data[0].Data, inv, result);
|
||||
|
||||
return fmat4x4SIMD(result);
|
||||
return fmat4x4SIMD(result);
|
||||
}
|
||||
|
||||
|
||||
|
@ -566,11 +573,4 @@ GLM_FUNC_QUALIFIER float determinant(detail::fmat4x4SIMD const & m)
|
|||
return Result;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::fmat4x4SIMD inverse(detail::fmat4x4SIMD const & m)
|
||||
{
|
||||
detail::fmat4x4SIMD result;
|
||||
detail::sse_inverse_ps(&m[0].Data, &result[0].Data);
|
||||
return result;
|
||||
}
|
||||
|
||||
}//namespace glm
|
||||
|
|
|
@ -44,9 +44,9 @@
|
|||
#if(GLM_ARCH != GLM_ARCH_PURE)
|
||||
|
||||
#if(GLM_ARCH & GLM_ARCH_SSE2)
|
||||
# include "../core/intrinsic_common.hpp"
|
||||
# include "../core/intrinsic_geometric.hpp"
|
||||
# include "../core/intrinsic_integer.hpp"
|
||||
# include "../detail/intrinsic_common.hpp"
|
||||
# include "../detail/intrinsic_geometric.hpp"
|
||||
# include "../detail/intrinsic_integer.hpp"
|
||||
#else
|
||||
# error "GLM: GLM_GTX_simd_vec4 requires compiler support of SSE2 through intrinsics"
|
||||
#endif
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <glm/gtc/type_precision.hpp>
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
#include <glm/packing.hpp>
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define GLM_MESSAGES
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include <iostream>
|
||||
|
||||
int test_compiler()
|
||||
|
@ -227,8 +227,28 @@ int test_operators()
|
|||
return (S && !R) ? 0 : 1;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct vec
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
template <template <typename> class C, typename T>
|
||||
struct Class
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct Class<vec, T>
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
//Class<vec, float> C;
|
||||
|
||||
int Error = 0;
|
||||
|
||||
Error += test_cpp_version();
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
// File : test/gtc/epsilon.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/gtc/constants.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
|
||||
int test_defined()
|
||||
{
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
// File : test/gtc/quaternion.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/quaternion.hpp>
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
|
||||
int test_quat_angle()
|
||||
{
|
||||
|
|
|
@ -9,12 +9,11 @@
|
|||
|
||||
#include <emmintrin.h>
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtc/type_precision.hpp>
|
||||
#include <glm/gtx/bit.hpp>
|
||||
#include <glm/gtc/type_precision.hpp>
|
||||
|
||||
#if(GLM_ARCH != GLM_ARCH_PURE)
|
||||
# include <glm/core/intrinsic_integer.hpp>
|
||||
# include <glm/detail/intrinsic_integer.hpp>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
@ -29,96 +28,6 @@ enum result
|
|||
STATIC_ASSERT
|
||||
};
|
||||
|
||||
namespace extractField
|
||||
{
|
||||
template <typename genType, typename sizeType>
|
||||
struct type
|
||||
{
|
||||
genType Value;
|
||||
sizeType BitFirst;
|
||||
sizeType BitCount;
|
||||
genType Return;
|
||||
result Result;
|
||||
};
|
||||
|
||||
typedef type<glm::uint64, glm::uint> typeU64;
|
||||
|
||||
#if(((GLM_COMPILER & GLM_COMPILER_GCC) == GLM_COMPILER_GCC) && (GLM_COMPILER < GLM_COMPILER_GCC44))
|
||||
typeU64 const Data64[] =
|
||||
{
|
||||
{0xffffffffffffffffLLU, 8, 0, 0x0000000000000000LLU, SUCCESS},
|
||||
{0x0000000000000000LLU, 0,64, 0x0000000000000000LLU, SUCCESS},
|
||||
{0xffffffffffffffffLLU, 0,64, 0xffffffffffffffffLLU, SUCCESS},
|
||||
{0x0f0f0f0f0f0f0f0fLLU, 0,64, 0x0f0f0f0f0f0f0f0fLLU, SUCCESS},
|
||||
{0x0000000000000000LLU, 8, 0, 0x0000000000000000LLU, SUCCESS},
|
||||
{0x8000000000000000LLU,63, 1, 0x0000000000000001LLU, SUCCESS},
|
||||
{0x7fffffffffffffffLLU,63, 1, 0x0000000000000000LLU, SUCCESS},
|
||||
{0x0000000000000300LLU, 8, 8, 0x0000000000000003LLU, SUCCESS},
|
||||
{0x000000000000ff00LLU, 8, 8, 0x00000000000000ffLLU, SUCCESS},
|
||||
{0xfffffffffffffff0LLU, 0, 5, 0x0000000000000010LLU, SUCCESS},
|
||||
{0x00000000000000ffLLU, 1, 3, 0x0000000000000007LLU, SUCCESS},
|
||||
{0x00000000000000ffLLU, 0, 3, 0x0000000000000007LLU, SUCCESS},
|
||||
{0x0000000000000000LLU, 0, 2, 0x0000000000000000LLU, SUCCESS},
|
||||
{0xffffffffffffffffLLU, 0, 8, 0x00000000000000ffLLU, SUCCESS},
|
||||
{0xffffffff00000000LLU,32,32, 0x00000000ffffffffLLU, SUCCESS},
|
||||
{0xfffffffffffffff0LLU, 0, 8, 0x0000000000000000LLU, FAIL},
|
||||
{0xffffffffffffffffLLU,32,32, 0x0000000000000000LLU, FAIL},
|
||||
//{0xffffffffffffffffLLU,64, 1, 0x0000000000000000LLU, ASSERT}, // Throw an assert
|
||||
//{0xffffffffffffffffLLU, 0,65, 0x0000000000000000LLU, ASSERT}, // Throw an assert
|
||||
//{0xffffffffffffffffLLU,33,32, 0x0000000000000000LLU, ASSERT}, // Throw an assert
|
||||
};
|
||||
#else
|
||||
typeU64 const Data64[] =
|
||||
{
|
||||
{0xffffffffffffffff, 8, 0, 0x0000000000000000, SUCCESS},
|
||||
{0x0000000000000000, 0,64, 0x0000000000000000, SUCCESS},
|
||||
{0xffffffffffffffff, 0,64, 0xffffffffffffffff, SUCCESS},
|
||||
{0x0f0f0f0f0f0f0f0f, 0,64, 0x0f0f0f0f0f0f0f0f, SUCCESS},
|
||||
{0x0000000000000000, 8, 0, 0x0000000000000000, SUCCESS},
|
||||
{0x8000000000000000,63, 1, 0x0000000000000001, SUCCESS},
|
||||
{0x7fffffffffffffff,63, 1, 0x0000000000000000, SUCCESS},
|
||||
{0x0000000000000300, 8, 8, 0x0000000000000003, SUCCESS},
|
||||
{0x000000000000ff00, 8, 8, 0x00000000000000ff, SUCCESS},
|
||||
{0xfffffffffffffff0, 0, 5, 0x0000000000000010, SUCCESS},
|
||||
{0x00000000000000ff, 1, 3, 0x0000000000000007, SUCCESS},
|
||||
{0x00000000000000ff, 0, 3, 0x0000000000000007, SUCCESS},
|
||||
{0x0000000000000000, 0, 2, 0x0000000000000000, SUCCESS},
|
||||
{0xffffffffffffffff, 0, 8, 0x00000000000000ff, SUCCESS},
|
||||
{0xffffffff00000000,32,32, 0x00000000ffffffff, SUCCESS},
|
||||
{0xfffffffffffffff0, 0, 8, 0x0000000000000000, FAIL},
|
||||
{0xffffffffffffffff,32,32, 0x0000000000000000, FAIL},
|
||||
//{0xffffffffffffffff,64, 1, 0x0000000000000000, ASSERT}, // Throw an assert
|
||||
//{0xffffffffffffffff, 0,65, 0x0000000000000000, ASSERT}, // Throw an assert
|
||||
//{0xffffffffffffffff,33,32, 0x0000000000000000, ASSERT}, // Throw an assert
|
||||
};
|
||||
#endif
|
||||
|
||||
int test()
|
||||
{
|
||||
glm::uint32 count = sizeof(Data64) / sizeof(typeU64);
|
||||
|
||||
for(glm::uint32 i = 0; i < count; ++i)
|
||||
{
|
||||
glm::uint64 Return = glm::extractField(
|
||||
Data64[i].Value,
|
||||
Data64[i].BitFirst,
|
||||
Data64[i].BitCount);
|
||||
|
||||
bool Compare = Data64[i].Return == Return;
|
||||
|
||||
if(Data64[i].Result == SUCCESS && Compare)
|
||||
continue;
|
||||
else if(Data64[i].Result == FAIL && !Compare)
|
||||
continue;
|
||||
|
||||
std::cout << "glm::extractfield test fail on test " << i << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}//extractField
|
||||
|
||||
namespace bitRevert
|
||||
{
|
||||
template <typename genType>
|
||||
|
@ -596,7 +505,6 @@ int main()
|
|||
Error += ::bitfieldInterleave3::test();
|
||||
Error += ::bitfieldInterleave4::test();
|
||||
Error += ::bitfieldInterleave::test();
|
||||
Error += ::extractField::test();
|
||||
Error += ::bitRevert::test();
|
||||
|
||||
return Error;
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
// File : test/gtc/gtc_dual_quaternion.cpp
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <glm/gtx/dual_quaternion.hpp>
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
#include <glm/gtx/euler_angles.hpp>
|
||||
#include <glm/vector_relational.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue