Fixed merge
This commit is contained in:
@@ -445,6 +445,13 @@ namespace detail
|
||||
# define GLM_RESTRICT __declspec(restrict)
|
||||
# define GLM_RESTRICT_VAR __restrict
|
||||
# define GLM_CONSTEXPR
|
||||
#elif(GLM_COMPILER & GLM_COMPILER_INTEL)
|
||||
# define GLM_DEPRECATED
|
||||
# define GLM_ALIGN(x) __declspec(align(x))
|
||||
# define GLM_ALIGNED_STRUCT(x) __declspec(align(x)) struct
|
||||
# define GLM_RESTRICT
|
||||
# define GLM_RESTRICT_VAR __restrict
|
||||
# define GLM_CONSTEXPR
|
||||
#elif((GLM_COMPILER & (GLM_COMPILER_GCC | GLM_COMPILER_LLVM_GCC)) && (GLM_COMPILER >= GLM_COMPILER_GCC31))
|
||||
# define GLM_DEPRECATED __attribute__((__deprecated__))
|
||||
# define GLM_ALIGN(x) __attribute__((aligned(x)))
|
||||
|
||||
@@ -278,8 +278,8 @@ namespace glm
|
||||
/// you would want a threshold function with a smooth
|
||||
/// transition. This is equivalent to:
|
||||
/// genType t;
|
||||
/// t = clamp ((x <EFBFBD> edge0) / (edge1 <EFBFBD> edge0), 0, 1);
|
||||
/// return t * t * (3 <EFBFBD> 2 * t);
|
||||
/// t = clamp ((x - edge0) / (edge1 - edge0), 0, 1);
|
||||
/// return t * t * (3 - 2 * t);
|
||||
/// Results are undefined if edge0 >= edge1.
|
||||
///
|
||||
/// @tparam genType Floating-point scalar or vector types.
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace detail
|
||||
//// Only valid if (INT_MIN <= x-y <= INT_MAX)
|
||||
//// min(x,y)
|
||||
//r = y + ((x - y) & ((x - y) >> (sizeof(int) *
|
||||
//CHAR_BIT <EFBFBD> 1)));
|
||||
//CHAR_BIT - 1)));
|
||||
//// max(x,y)
|
||||
//r = x - ((x - y) & ((x - y) >> (sizeof(int) *
|
||||
//CHAR_BIT - 1)));
|
||||
@@ -615,7 +615,7 @@ namespace detail
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'mix' only accept floating-point inputs");
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'step' only accept floating-point inputs");
|
||||
|
||||
return x < edge ? genType(0) : genType(1);
|
||||
}
|
||||
@@ -707,7 +707,7 @@ namespace detail
|
||||
genType const & x
|
||||
)
|
||||
{
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'mix' only accept floating-point inputs");
|
||||
GLM_STATIC_ASSERT(detail::type<genType>::is_float, "'smoothstep' only accept floating-point inputs");
|
||||
|
||||
genType tmp = clamp((x - edge0) / (edge1 - edge0), genType(0), genType(1));
|
||||
return tmp * tmp * (genType(3) - genType(2) * tmp);
|
||||
@@ -811,6 +811,8 @@ namespace detail
|
||||
# else
|
||||
return std::isnan(x);
|
||||
# endif
|
||||
# elif(GLM_COMPILER & GLM_COMPILER_CUDA)
|
||||
return isnan(x) != 0;
|
||||
# else
|
||||
return std::isnan(x);
|
||||
# endif
|
||||
@@ -866,6 +868,9 @@ namespace detail
|
||||
# else
|
||||
return std::isinf(x);
|
||||
# endif
|
||||
# elif(GLM_COMPILER & GLM_COMPILER_CUDA)
|
||||
// http://developer.download.nvidia.com/compute/cuda/4_2/rel/toolkit/docs/online/group__CUDA__MATH__DOUBLE_g13431dd2b40b51f9139cbb7f50c18fab.html#g13431dd2b40b51f9139cbb7f50c18fab
|
||||
return isinf(double(x)) != 0;
|
||||
# else
|
||||
return std::isinf(x);
|
||||
# endif
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace glm
|
||||
/// returning them in the least significant bits of the result.
|
||||
/// For unsigned data types, the most significant bits of the
|
||||
/// result will be set to zero. For signed data types, the
|
||||
/// most significant bits will be set to the value of bit offset + base <EFBFBD> 1.
|
||||
/// most significant bits will be set to the value of bit offset + base - 1.
|
||||
///
|
||||
/// If bits is zero, the result will be zero. The result will be
|
||||
/// undefined if offset or bits is negative, or if the sum of
|
||||
@@ -125,7 +125,7 @@ namespace glm
|
||||
/// Returns the insertion the bits least-significant bits of insert into base.
|
||||
///
|
||||
/// The result will have bits [offset, offset + bits - 1] taken
|
||||
/// from bits [0, bits <EFBFBD> 1] of insert, and all other bits taken
|
||||
/// from bits [0, bits - 1] of insert, and all other bits taken
|
||||
/// directly from the corresponding bits of base. If bits is
|
||||
/// zero, the result will simply be base. The result will be
|
||||
/// undefined if offset or bits is negative, or if the sum of
|
||||
|
||||
@@ -136,12 +136,42 @@ namespace glm
|
||||
|
||||
GLM_FUNC_QUALIFIER double packDouble2x32(detail::tvec2<detail::uint32> const & v)
|
||||
{
|
||||
return *(double*)&v;
|
||||
struct uint32_pair
|
||||
{
|
||||
detail::uint32 x;
|
||||
detail::uint32 y;
|
||||
};
|
||||
|
||||
union helper
|
||||
{
|
||||
uint32_pair input;
|
||||
double output;
|
||||
} Helper;
|
||||
|
||||
Helper.input.x = v.x;
|
||||
Helper.input.y = v.y;
|
||||
|
||||
return Helper.output;
|
||||
//return *(double*)&v;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tvec2<uint> unpackDouble2x32(double const & v)
|
||||
{
|
||||
return *(detail::tvec2<uint>*)&v;
|
||||
struct uint32_pair
|
||||
{
|
||||
detail::uint32 x;
|
||||
detail::uint32 y;
|
||||
};
|
||||
|
||||
union helper
|
||||
{
|
||||
double input;
|
||||
uint32_pair output;
|
||||
} Helper;
|
||||
|
||||
Helper.input = v;
|
||||
|
||||
return detail::tvec2<uint>(Helper.output.x, Helper.output.y);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER uint packHalf2x16(detail::tvec2<float> const & v)
|
||||
|
||||
@@ -62,7 +62,7 @@ namespace detail{
|
||||
static const ieee754_QNAN absMask;
|
||||
static const __m128 GLM_VAR_USED abs4Mask = _mm_set_ps1(absMask.f);
|
||||
|
||||
static const __m128 GLM_VAR_USED _epi32_sign_mask = _mm_castsi128_ps(_mm_set1_epi32(0x80000000));
|
||||
static const __m128 GLM_VAR_USED _epi32_sign_mask = _mm_castsi128_ps(_mm_set1_epi32(static_cast<int>(0x80000000)));
|
||||
//static const __m128 GLM_VAR_USED _epi32_inv_sign_mask = _mm_castsi128_ps(_mm_set1_epi32(0x7FFFFFFF));
|
||||
//static const __m128 GLM_VAR_USED _epi32_mant_mask = _mm_castsi128_ps(_mm_set1_epi32(0x7F800000));
|
||||
//static const __m128 GLM_VAR_USED _epi32_inv_mant_mask = _mm_castsi128_ps(_mm_set1_epi32(0x807FFFFF));
|
||||
|
||||
@@ -46,7 +46,7 @@ GLM_FUNC_QUALIFIER matType sse_comp_mul_ps
|
||||
out[3] = _mm_mul_ps(in1[3], in2[3]);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER void sse_add_ps(__m128 in1[4], __m128 in2[4], __m128 out[4])
|
||||
GLM_FUNC_QUALIFIER void sse_add_ps(__m128 const in1[4], __m128 const in2[4], __m128 out[4])
|
||||
{
|
||||
{
|
||||
out[0] = _mm_add_ps(in1[0], in2[0]);
|
||||
@@ -56,7 +56,7 @@ GLM_FUNC_QUALIFIER void sse_add_ps(__m128 in1[4], __m128 in2[4], __m128 out[4])
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER void sse_sub_ps(__m128 in1[4], __m128 in2[4], __m128 out[4])
|
||||
GLM_FUNC_QUALIFIER void sse_sub_ps(__m128 const in1[4], __m128 const in2[4], __m128 out[4])
|
||||
{
|
||||
{
|
||||
out[0] = _mm_sub_ps(in1[0], in2[0]);
|
||||
@@ -66,7 +66,7 @@ GLM_FUNC_QUALIFIER void sse_sub_ps(__m128 in1[4], __m128 in2[4], __m128 out[4])
|
||||
}
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER __m128 sse_mul_ps(__m128 m[4], __m128 v)
|
||||
GLM_FUNC_QUALIFIER __m128 sse_mul_ps(__m128 const m[4], __m128 v)
|
||||
{
|
||||
__m128 v0 = _mm_shuffle_ps(v, v, _MM_SHUFFLE(0, 0, 0, 0));
|
||||
__m128 v1 = _mm_shuffle_ps(v, v, _MM_SHUFFLE(1, 1, 1, 1));
|
||||
@@ -85,7 +85,7 @@ GLM_FUNC_QUALIFIER __m128 sse_mul_ps(__m128 m[4], __m128 v)
|
||||
return a2;
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER __m128 sse_mul_ps(__m128 v, __m128 m[4])
|
||||
GLM_FUNC_QUALIFIER __m128 sse_mul_ps(__m128 v, __m128 const m[4])
|
||||
{
|
||||
__m128 i0 = m[0];
|
||||
__m128 i1 = m[1];
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#define GLM_VERSION_MAJOR 0
|
||||
#define GLM_VERSION_MINOR 9
|
||||
#define GLM_VERSION_PATCH 4
|
||||
#define GLM_VERSION_REVISION 0
|
||||
#define GLM_VERSION_REVISION 2
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// Platform
|
||||
@@ -536,6 +536,13 @@
|
||||
# define GLM_ARCH GLM_ARCH_PURE
|
||||
#endif
|
||||
|
||||
// With MinGW-W64, including intrinsic headers before intrin.h will produce some errors. The problem is
|
||||
// that windows.h (and maybe other headers) will silently include intrin.h, which of course causes problems.
|
||||
// To fix, we just explicitly include intrin.h here.
|
||||
#if defined(__MINGW32__) && (GLM_ARCH != GLM_ARCH_PURE)
|
||||
# include <intrin.h>
|
||||
#endif
|
||||
|
||||
//#if(GLM_ARCH != GLM_ARCH_PURE)
|
||||
#if(GLM_ARCH & GLM_ARCH_AVX2)
|
||||
# include <immintrin.h>
|
||||
|
||||
@@ -155,7 +155,7 @@ namespace detail
|
||||
// We convert f to a half zero.
|
||||
//
|
||||
|
||||
return 0;
|
||||
return hdata(s);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -57,11 +57,11 @@ namespace glm
|
||||
/// Returns the component-wise compare of |x - y| < epsilon.
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
typename genType::boolType epsilonEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
typename genType::value_type const & epsilon);
|
||||
|
||||
typename genType::boolType epsilonEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
typename genType::value_type const & epsilon);
|
||||
|
||||
/// Returns the component-wise compare of |x - y| < epsilon.
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
@@ -73,11 +73,11 @@ namespace glm
|
||||
/// Returns the component-wise compare of |x - y| < epsilon.
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
typename genType::boolType epsilonNotEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
typename genType::value_type const & epsilon);
|
||||
|
||||
typename genType::boolType epsilonNotEqual(
|
||||
genType const & x,
|
||||
genType const & y,
|
||||
typename genType::value_type const & epsilon);
|
||||
|
||||
/// Returns the component-wise compare of |x - y| >= epsilon.
|
||||
/// @see gtc_epsilon
|
||||
template <typename genType>
|
||||
|
||||
@@ -269,21 +269,6 @@ namespace glm
|
||||
abs(x.w - y.w) < epsilon);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonEqual
|
||||
(
|
||||
detail::tquat<valType> const & x,
|
||||
detail::tquat<valType> const & y,
|
||||
detail::tquat<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) < epsilon.x,
|
||||
abs(x.y - y.y) < epsilon.y,
|
||||
abs(x.z - y.z) < epsilon.z,
|
||||
abs(x.w - y.w) < epsilon.w);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
||||
(
|
||||
@@ -298,19 +283,4 @@ namespace glm
|
||||
abs(x.z - y.z) >= epsilon,
|
||||
abs(x.w - y.w) >= epsilon);
|
||||
}
|
||||
|
||||
template <typename valType>
|
||||
GLM_FUNC_QUALIFIER detail::tvec4<bool> epsilonNotEqual
|
||||
(
|
||||
detail::tquat<valType> const & x,
|
||||
detail::tquat<valType> const & y,
|
||||
detail::tquat<valType> const & epsilon
|
||||
)
|
||||
{
|
||||
return detail::tvec4<bool>(
|
||||
abs(x.x - y.x) >= epsilon.x,
|
||||
abs(x.y - y.y) >= epsilon.y,
|
||||
abs(x.z - y.z) >= epsilon.z,
|
||||
abs(x.w - y.w) >= epsilon.w);
|
||||
}
|
||||
}//namespace glm
|
||||
|
||||
@@ -87,8 +87,8 @@ namespace glm
|
||||
///
|
||||
/// @param m Input matrix multiplied by this rotation matrix.
|
||||
/// @param angle Rotation angle expressed in radians if GLM_FORCE_RADIANS is define or degrees otherwise.
|
||||
/// @param axis Rotation axis.
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @param axis Rotation axis, recommanded to be normalized.
|
||||
/// @tparam T Value type used to build the matrix. Supported: half, float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see gtx_transform
|
||||
/// @see - rotate(T angle, T x, T y, T z)
|
||||
@@ -143,7 +143,7 @@ namespace glm
|
||||
/// @param top
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
/// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top, T const & zNear, T const & zFar)
|
||||
/// @see - glm::ortho(T const & left, T const & right, T const & bottom, T const & top, T const & zNear, T const & zFar)
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> ortho(
|
||||
T const & left,
|
||||
@@ -209,7 +209,7 @@ namespace glm
|
||||
/// @param near
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> infinitePerspective(
|
||||
T fovy, T aspect, T near);
|
||||
|
||||
@@ -220,7 +220,7 @@ namespace glm
|
||||
/// @param near
|
||||
/// @tparam T Value type used to build the matrix. Currently supported: half (not recommanded), float or double.
|
||||
/// @see gtc_matrix_transform
|
||||
template <typename T>
|
||||
template <typename T>
|
||||
detail::tmat4x4<T> tweakedInfinitePerspective(
|
||||
T fovy, T aspect, T near);
|
||||
|
||||
|
||||
@@ -236,7 +236,13 @@ namespace glm
|
||||
valType const & zFar
|
||||
)
|
||||
{
|
||||
valType range = tan(radians(fovy / valType(2))) * zNear;
|
||||
#ifdef GLM_FORCE_RADIANS
|
||||
valType const rad = fovy;
|
||||
#else
|
||||
valType const rad = glm::radians(fovy);
|
||||
#endif
|
||||
|
||||
valType range = tan(radians(rad / valType(2))) * zNear;
|
||||
valType left = -range * aspect;
|
||||
valType right = range * aspect;
|
||||
valType bottom = -range;
|
||||
|
||||
@@ -22,12 +22,13 @@
|
||||
///
|
||||
/// @ref gtc_quaternion
|
||||
/// @file glm/gtc/quaternion.hpp
|
||||
/// @date 2009-05-21 / 2011-06-05
|
||||
/// @date 2009-05-21 / 2012-12-20
|
||||
/// @author Christophe Riccio
|
||||
///
|
||||
/// @see core (dependence)
|
||||
/// @see gtc_half_float (dependence)
|
||||
///
|
||||
/// @see gtc_constants (dependence)
|
||||
///
|
||||
/// @defgroup gtc_quaternion GLM_GTC_quaternion
|
||||
/// @ingroup gtc
|
||||
///
|
||||
@@ -42,6 +43,7 @@
|
||||
// Dependency:
|
||||
#include "../glm.hpp"
|
||||
#include "../gtc/half_float.hpp"
|
||||
#include "../gtc/constants.hpp"
|
||||
|
||||
#if(defined(GLM_MESSAGES) && !defined(glm_ext))
|
||||
# pragma message("GLM: GLM_GTC_quaternion extension included")
|
||||
@@ -169,15 +171,50 @@ namespace detail
|
||||
detail::tquat<T> const & q1,
|
||||
detail::tquat<T> const & q2);
|
||||
|
||||
/// Returns a SLERP interpolated quaternion of x and y according a.
|
||||
/// Spherical linear interpolation of two quaternions.
|
||||
/// The interpolation is oriented and the rotation is performed at constant speed.
|
||||
/// For short path spherical linear interpolation, use the slerp function.
|
||||
///
|
||||
/// @param x A quaternion
|
||||
/// @param y A quaternion
|
||||
/// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
/// @see - slerp(detail::tquat<T> const & x, detail::tquat<T> const & y, T const & a)
|
||||
template <typename T>
|
||||
detail::tquat<T> mix(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a);
|
||||
|
||||
|
||||
/// Linear interpolation of two quaternions.
|
||||
/// The interpolation is oriented.
|
||||
///
|
||||
/// @param x A quaternion
|
||||
/// @param y A quaternion
|
||||
/// @param a Interpolation factor. The interpolation is defined in the range [0, 1].
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
template <typename T>
|
||||
detail::tquat<T> lerp(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a);
|
||||
|
||||
/// Spherical linear interpolation of two quaternions.
|
||||
/// The interpolation always take the short path and the rotation is performed at constant speed.
|
||||
///
|
||||
/// @param x A quaternion
|
||||
/// @param y A quaternion
|
||||
/// @param a Interpolation factor. The interpolation is defined beyond the range [0, 1].
|
||||
/// @tparam T Value type used to build the quaternion. Supported: half, float or double.
|
||||
/// @see gtc_quaternion
|
||||
template <typename T>
|
||||
detail::tquat<T> slerp(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a);
|
||||
|
||||
/// Returns the q conjugate.
|
||||
///
|
||||
/// @see gtc_quaternion
|
||||
|
||||
@@ -443,6 +443,7 @@ namespace detail
|
||||
return normalize(beta * x + alpha * y);
|
||||
}
|
||||
*/
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> mix
|
||||
(
|
||||
@@ -451,8 +452,77 @@ namespace detail
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
T angle = acos(dot(x, y));
|
||||
return (glm::sin((T(1) - a) * angle) * x + glm::sin(a * angle) * y) / glm::sin(angle);
|
||||
T cosTheta = dot(x, y);
|
||||
|
||||
// Perform a linear interpolation when cosTheta is close to 1 to avoid side effect of sin(angle) becoming a zero denominator
|
||||
if(cosTheta > T(1) - epsilon<T>())
|
||||
{
|
||||
// Linear interpolation
|
||||
return detail::tquat<T>(
|
||||
mix(x.w, y.w, a),
|
||||
mix(x.x, y.x, a),
|
||||
mix(x.y, y.y, a),
|
||||
mix(x.z, y.z, a));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Essential Mathematics, page 467
|
||||
T angle = acos(cosTheta);
|
||||
return (sin((T(1) - a) * angle) * x + sin(a * angle) * y) / sin(angle);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> lerp
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
// Lerp is only defined in [0, 1]
|
||||
assert(a >= T(0));
|
||||
assert(a <= T(1));
|
||||
|
||||
return x * (T(1) - a) + (y * a);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
GLM_FUNC_QUALIFIER detail::tquat<T> slerp
|
||||
(
|
||||
detail::tquat<T> const & x,
|
||||
detail::tquat<T> const & y,
|
||||
T const & a
|
||||
)
|
||||
{
|
||||
detail::tquat<T> z = y;
|
||||
|
||||
T cosTheta = dot(x, y);
|
||||
|
||||
// If cosTheta < 0, the interpolation will take the long way around the sphere.
|
||||
// To fix this, one quat must be negated.
|
||||
if (cosTheta < T(0))
|
||||
{
|
||||
z = -y;
|
||||
cosTheta = -cosTheta;
|
||||
}
|
||||
|
||||
// Perform a linear interpolation when cosTheta is close to 1 to avoid side effect of sin(angle) becoming a zero denominator
|
||||
if(cosTheta > T(1) - epsilon<T>())
|
||||
{
|
||||
// Linear interpolation
|
||||
return detail::tquat<T>(
|
||||
mix(x.w, y.w, a),
|
||||
mix(x.x, y.x, a),
|
||||
mix(x.y, y.y, a),
|
||||
mix(x.z, y.z, a));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Essential Mathematics, page 467
|
||||
T angle = acos(cosTheta);
|
||||
return (sin((T(1) - a) * angle) * x + sin(a * angle) * z) / sin(angle);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@@ -592,7 +662,7 @@ namespace detail
|
||||
typename detail::tquat<T>::value_type fourYSquaredMinus1 = m[1][1] - m[0][0] - m[2][2];
|
||||
typename detail::tquat<T>::value_type fourZSquaredMinus1 = m[2][2] - m[0][0] - m[1][1];
|
||||
typename detail::tquat<T>::value_type fourWSquaredMinus1 = m[0][0] + m[1][1] + m[2][2];
|
||||
|
||||
|
||||
int biggestIndex = 0;
|
||||
typename detail::tquat<T>::value_type fourBiggestSquaredMinus1 = fourWSquaredMinus1;
|
||||
if(fourXSquaredMinus1 > fourBiggestSquaredMinus1)
|
||||
@@ -641,6 +711,10 @@ namespace detail
|
||||
Result.y = (m[1][2] + m[2][1]) * mult;
|
||||
Result.z = biggestVal;
|
||||
break;
|
||||
|
||||
default: // Silence a -Wswitch-default warning in GCC. Should never actually get here. Assert is just for sanity.
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -36,8 +36,10 @@
|
||||
#include <cmath>
|
||||
#include <cfloat>
|
||||
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4127)
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable : 4127)
|
||||
#endif
|
||||
|
||||
typedef union
|
||||
{
|
||||
@@ -186,7 +188,9 @@ namespace detail
|
||||
}//namespace detail
|
||||
}//namespace glm
|
||||
|
||||
#pragma warning(pop)
|
||||
#if(GLM_COMPILER & GLM_COMPILER_VC)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#if((GLM_COMPILER & GLM_COMPILER_VC) || ((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_PLATFORM & GLM_PLATFORM_WINDOWS)))
|
||||
# define GLM_NEXT_AFTER_FLT(x, toward) glm::detail::nextafterf((x), (toward))
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace glm
|
||||
template <typename genType>
|
||||
GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
|
||||
{
|
||||
typename genType::size_type result = typename genType::value_type(0);
|
||||
typename genType::value_type result = typename genType::value_type(0);
|
||||
for(typename genType::size_type i = 0; i < v.length(); ++i)
|
||||
result += v[i];
|
||||
return result;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
/// @defgroup gtx_norm GLM_GTX_norm
|
||||
/// @ingroup gtx
|
||||
///
|
||||
/// @brief Various way to compute vector norms.
|
||||
/// @brief Various ways to compute vector norms.
|
||||
///
|
||||
/// <glm/gtx/norm.hpp> need to be included to use these functionalities.
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -91,6 +91,8 @@ namespace detail
|
||||
fvec4SIMD const & v3);
|
||||
explicit fmat4x4SIMD(
|
||||
tmat4x4<float> const & m);
|
||||
explicit fmat4x4SIMD(
|
||||
__m128 const in[4]);
|
||||
|
||||
// Conversions
|
||||
//template <typename U>
|
||||
|
||||
@@ -26,7 +26,14 @@ GLM_FUNC_QUALIFIER fmat4x4SIMD::size_type fmat4x4SIMD::row_size()
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD()
|
||||
{}
|
||||
{
|
||||
#ifndef GLM_SIMD_ENABLE_DEFAULT_INIT
|
||||
this->Data[0] = fvec4SIMD(1.0f, 0, 0, 0);
|
||||
this->Data[1] = fvec4SIMD(0, 1.0f, 0, 0);
|
||||
this->Data[2] = fvec4SIMD(0, 0, 1.0f, 0);
|
||||
this->Data[3] = fvec4SIMD(0, 0, 0, 1.0f);
|
||||
#endif
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD(float const & s)
|
||||
{
|
||||
@@ -75,6 +82,17 @@ GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD
|
||||
this->Data[3] = fvec4SIMD(m[3]);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD::fmat4x4SIMD
|
||||
(
|
||||
__m128 const in[4]
|
||||
)
|
||||
{
|
||||
this->Data[0] = in[0];
|
||||
this->Data[1] = in[1];
|
||||
this->Data[2] = in[2];
|
||||
this->Data[3] = in[3];
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Accesses
|
||||
|
||||
@@ -84,7 +102,7 @@ GLM_FUNC_QUALIFIER fvec4SIMD & fmat4x4SIMD::operator[]
|
||||
)
|
||||
{
|
||||
assert(
|
||||
i >= fmat4x4SIMD::size_type(0) &&
|
||||
//i >= fmat4x4SIMD::size_type(0) &&
|
||||
i < fmat4x4SIMD::col_size());
|
||||
|
||||
return this->Data[i];
|
||||
@@ -96,7 +114,7 @@ GLM_FUNC_QUALIFIER fvec4SIMD const & fmat4x4SIMD::operator[]
|
||||
) const
|
||||
{
|
||||
assert(
|
||||
i >= fmat4x4SIMD::size_type(0) &&
|
||||
//i >= fmat4x4SIMD::size_type(0) &&
|
||||
i < fmat4x4SIMD::col_size());
|
||||
|
||||
return this->Data[i];
|
||||
@@ -232,6 +250,274 @@ GLM_FUNC_QUALIFIER fmat4x4SIMD & fmat4x4SIMD::operator-- ()
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Binary operators
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator+
|
||||
(
|
||||
const fmat4x4SIMD &m,
|
||||
float const & s
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
m[0] + s,
|
||||
m[1] + s,
|
||||
m[2] + s,
|
||||
m[3] + s
|
||||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator+
|
||||
(
|
||||
float const & s,
|
||||
const fmat4x4SIMD &m
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
m[0] + s,
|
||||
m[1] + s,
|
||||
m[2] + s,
|
||||
m[3] + s
|
||||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator+
|
||||
(
|
||||
const fmat4x4SIMD &m1,
|
||||
const fmat4x4SIMD &m2
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
m1[0] + m2[0],
|
||||
m1[1] + m2[1],
|
||||
m1[2] + m2[2],
|
||||
m1[3] + m2[3]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator-
|
||||
(
|
||||
const fmat4x4SIMD &m,
|
||||
float const & s
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
m[0] - s,
|
||||
m[1] - s,
|
||||
m[2] - s,
|
||||
m[3] - s
|
||||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator-
|
||||
(
|
||||
float const & s,
|
||||
const fmat4x4SIMD &m
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
s - m[0],
|
||||
s - m[1],
|
||||
s - m[2],
|
||||
s - m[3]
|
||||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator-
|
||||
(
|
||||
const fmat4x4SIMD &m1,
|
||||
const fmat4x4SIMD &m2
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
m1[0] - m2[0],
|
||||
m1[1] - m2[1],
|
||||
m1[2] - m2[2],
|
||||
m1[3] - m2[3]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator*
|
||||
(
|
||||
const fmat4x4SIMD &m,
|
||||
float const & s
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
m[0] * s,
|
||||
m[1] * s,
|
||||
m[2] * s,
|
||||
m[3] * s
|
||||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator*
|
||||
(
|
||||
float const & s,
|
||||
const fmat4x4SIMD &m
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
m[0] * s,
|
||||
m[1] * s,
|
||||
m[2] * s,
|
||||
m[3] * s
|
||||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD operator*
|
||||
(
|
||||
const fmat4x4SIMD &m,
|
||||
fvec4SIMD const & v
|
||||
)
|
||||
{
|
||||
return sse_mul_ps(&m.Data[0].Data, v.Data);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD operator*
|
||||
(
|
||||
fvec4SIMD const & v,
|
||||
const fmat4x4SIMD &m
|
||||
)
|
||||
{
|
||||
return sse_mul_ps(v.Data, &m.Data[0].Data);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator*
|
||||
(
|
||||
const fmat4x4SIMD &m1,
|
||||
const fmat4x4SIMD &m2
|
||||
)
|
||||
{
|
||||
fmat4x4SIMD result;
|
||||
sse_mul_ps(&m1.Data[0].Data, &m2.Data[0].Data, &result.Data[0].Data);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator/
|
||||
(
|
||||
const fmat4x4SIMD &m,
|
||||
float const & s
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
m[0] / s,
|
||||
m[1] / s,
|
||||
m[2] / s,
|
||||
m[3] / s
|
||||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD operator/
|
||||
(
|
||||
float const & s,
|
||||
const fmat4x4SIMD &m
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
s / m[0],
|
||||
s / m[1],
|
||||
s / m[2],
|
||||
s / m[3]
|
||||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD operator/
|
||||
(
|
||||
const fmat4x4SIMD &m,
|
||||
fvec4SIMD const & v
|
||||
)
|
||||
{
|
||||
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
|
||||
)
|
||||
{
|
||||
__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);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Unary constant operators
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD const operator-
|
||||
(
|
||||
fmat4x4SIMD const & m
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
-m[0],
|
||||
-m[1],
|
||||
-m[2],
|
||||
-m[3]
|
||||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD const operator--
|
||||
(
|
||||
fmat4x4SIMD const & m,
|
||||
int
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
m[0] - 1.0f,
|
||||
m[1] - 1.0f,
|
||||
m[2] - 1.0f,
|
||||
m[3] - 1.0f
|
||||
);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER fmat4x4SIMD const operator++
|
||||
(
|
||||
fmat4x4SIMD const & m,
|
||||
int
|
||||
)
|
||||
{
|
||||
return detail::fmat4x4SIMD
|
||||
(
|
||||
m[0] + 1.0f,
|
||||
m[1] + 1.0f,
|
||||
m[2] + 1.0f,
|
||||
m[3] + 1.0f
|
||||
);
|
||||
}
|
||||
|
||||
}//namespace detail
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::tmat4x4<float> mat4_cast
|
||||
|
||||
@@ -54,6 +54,14 @@
|
||||
# pragma message("GLM: GLM_GTX_simd_vec4 extension included")
|
||||
#endif
|
||||
|
||||
|
||||
// Warning silencer for nameless struct/union.
|
||||
#if (GLM_COMPILER & GLM_COMPILER_VC)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4201) // warning C4201: nonstandard extension used : nameless struct/union
|
||||
#endif
|
||||
|
||||
|
||||
namespace glm{
|
||||
namespace detail
|
||||
{
|
||||
@@ -69,7 +77,15 @@ namespace detail
|
||||
typedef fvec4SIMD type;
|
||||
typedef tvec4<bool> bool_type;
|
||||
|
||||
__m128 Data;
|
||||
#ifdef GLM_SIMD_ENABLE_XYZW_UNION
|
||||
union
|
||||
{
|
||||
__m128 Data;
|
||||
struct {float x, y, z, w;};
|
||||
};
|
||||
#else
|
||||
__m128 Data;
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////
|
||||
// Implicit basic constructors
|
||||
@@ -289,8 +305,8 @@ namespace detail
|
||||
//! you would want a threshold function with a smooth
|
||||
//! transition. This is equivalent to:
|
||||
//! genType t;
|
||||
//! t = clamp ((x <EFBFBD> edge0) / (edge1 <EFBFBD> edge0), 0, 1);
|
||||
//! return t * t * (3 <EFBFBD> 2 * t);
|
||||
//! t = clamp ((x - edge0) / (edge1 - edge0), 0, 1);
|
||||
//! return t * t * (3 - 2 * t);
|
||||
//! Results are undefined if edge0 >= edge1.
|
||||
//! (From GLM_GTX_simd_vec4 extension, common function)
|
||||
detail::fvec4SIMD smoothstep(
|
||||
@@ -490,6 +506,12 @@ namespace detail
|
||||
|
||||
#include "simd_vec4.inl"
|
||||
|
||||
|
||||
#if (GLM_COMPILER & GLM_COMPILER_VC)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
|
||||
#endif//(GLM_ARCH != GLM_ARCH_PURE)
|
||||
|
||||
#endif//GLM_GTX_simd_vec4
|
||||
|
||||
@@ -20,6 +20,9 @@ struct mask
|
||||
// Implicit basic constructors
|
||||
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD()
|
||||
#ifdef GLM_SIMD_ENABLE_DEFAULT_INIT
|
||||
: Data(_mm_set_ps(0.0f, 0.0f, 0.0f, 0.0f))
|
||||
#endif
|
||||
{}
|
||||
|
||||
GLM_FUNC_QUALIFIER fvec4SIMD::fvec4SIMD(__m128 const & Data) :
|
||||
@@ -449,7 +452,7 @@ GLM_FUNC_QUALIFIER detail::fvec4SIMD mix
|
||||
{
|
||||
__m128 Sub0 = _mm_sub_ps(y.Data, x.Data);
|
||||
__m128 Mul0 = _mm_mul_ps(a.Data, Sub0);
|
||||
return _mm_mul_ps(x.Data, Mul0);
|
||||
return _mm_add_ps(x.Data, Mul0);
|
||||
}
|
||||
|
||||
GLM_FUNC_QUALIFIER detail::fvec4SIMD step
|
||||
|
||||
Reference in New Issue
Block a user