mirror of
https://github.com/g-truc/glm.git
synced 2024-11-29 11:24:35 +00:00
Merge branch 'master' of https://github.com/g-truc/glm
This commit is contained in:
commit
5c5cfa5b66
@ -148,11 +148,25 @@ namespace detail
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER tquat<T, Q>::tquat(vec<3, T, Q> const& u, vec<3, T, Q> const& v)
|
||||
{
|
||||
vec<3, T, Q> const LocalW(cross(u, v));
|
||||
T Dot = detail::compute_dot<vec<3, T, Q>, T, detail::is_aligned<Q>::value>::call(u, v);
|
||||
tquat<T, Q> q(T(1) + Dot, LocalW.x, LocalW.y, LocalW.z);
|
||||
T norm_u_norm_v = sqrt(dot(u, u) * dot(v, v));
|
||||
T real_part = norm_u_norm_v + dot(u, v);
|
||||
vec<3, T, Q> t;
|
||||
|
||||
*this = normalize(q);
|
||||
if(real_part < static_cast<T>(1.e-6f) * norm_u_norm_v)
|
||||
{
|
||||
// If u and v are exactly opposite, rotate 180 degrees
|
||||
// around an arbitrary orthogonal axis. Axis normalisation
|
||||
// can happen later, when we normalise the quaternion.
|
||||
real_part = static_cast<T>(0);
|
||||
t = abs(u.x) > abs(u.z) ? vec<3, T, Q>(-u.y, u.x, static_cast<T>(0)) : vec<3, T, Q>(static_cast<T>(0), -u.z, u.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise, build quaternion the standard way.
|
||||
t = cross(u, v);
|
||||
}
|
||||
|
||||
*this = normalize(tquat<T, Q>(real_part, t.x, t.y, t.z));
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
|
@ -146,8 +146,8 @@ namespace glm
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fmin' only accept floating-point input");
|
||||
|
||||
if (isnan(y))
|
||||
return x;
|
||||
if (isnan(x))
|
||||
return y;
|
||||
if (isnan(y))
|
||||
return x;
|
||||
|
||||
@ -176,8 +176,8 @@ namespace glm
|
||||
{
|
||||
GLM_STATIC_ASSERT(std::numeric_limits<genType>::is_iec559, "'fmax' only accept floating-point input");
|
||||
|
||||
if (isnan(y))
|
||||
return x;
|
||||
if (isnan(x))
|
||||
return y;
|
||||
if (isnan(y))
|
||||
return x;
|
||||
|
||||
|
@ -44,94 +44,94 @@
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::vec<1, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::vec<1, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::vec<1, T, Q> const& v) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::vec<2, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::vec<2, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::vec<2, T, Q> const& v) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::vec<3, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::vec<3, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::vec<3, T, Q> const& v) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::vec<4, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::vec<4, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::vec<4, T, Q> const& v) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::tquat<T,P>>
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::tquat<T,Q>>
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::tquat<T, Q> const& q) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::tdualquat<T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::tdualquat<T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::tdualquat<T,P> const& q) const;
|
||||
GLM_FUNC_DECL size_t operator()(glm::tdualquat<T,Q> const& q) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::mat<2, 2, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::mat<2, 2, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<2, 2, T,P> const& m) const;
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<2, 2, T,Q> const& m) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::mat<2, 3, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::mat<2, 3, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<2, 3, T,P> const& m) const;
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<2, 3, T,Q> const& m) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::mat<2, 4, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::mat<2, 4, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<2, 4, T,P> const& m) const;
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<2, 4, T,Q> const& m) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::mat<3, 2, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::mat<3, 2, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<3, 2, T,P> const& m) const;
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<3, 2, T,Q> const& m) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::mat<3, 3, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::mat<3, 3, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<3, 3, T,P> const& m) const;
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<3, 3, T,Q> const& m) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::mat<3, 4, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::mat<3, 4, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<3, 4, T,P> const& m) const;
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<3, 4, T,Q> const& m) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::mat<4, 2, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::mat<4, 2, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<4, 2, T,P> const& m) const;
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<4, 2, T,Q> const& m) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::mat<4, 3, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::mat<4, 3, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<4, 3, T,P> const& m) const;
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<4, 3, T,Q> const& m) const;
|
||||
};
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
struct hash<glm::mat<4, 4, T,P> >
|
||||
template<typename T, glm::qualifier Q>
|
||||
struct hash<glm::mat<4, 4, T,Q> >
|
||||
{
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<4, 4, T,P> const& m) const;
|
||||
GLM_FUNC_DECL size_t operator()(glm::mat<4, 4, T,Q> const& m) const;
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
|
@ -22,14 +22,14 @@ namespace detail
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::vec<1, T, Q>>::operator()(glm::vec<1, T, Q> const& v) const
|
||||
{
|
||||
hash<T> hasher;
|
||||
return hasher(v.x);
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::vec<2, T, Q>>::operator()(glm::vec<2, T, Q> const& v) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
@ -39,7 +39,7 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::vec<3, T, Q>>::operator()(glm::vec<3, T, Q> const& v) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
@ -50,7 +50,7 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::vec<4, T, Q>>::operator()(glm::vec<4, T, Q> const& v) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
@ -62,8 +62,8 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::tquat<T, Q>>::operator()(glm::tquat<T,P> const& q) const
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::tquat<T, Q>>::operator()(glm::tquat<T,Q> const& q) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
hash<T> hasher;
|
||||
@ -74,7 +74,7 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::tdualquat<T, Q>>::operator()(glm::tdualquat<T, Q> const& q) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
@ -84,7 +84,7 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<2, 2, T, Q>>::operator()(glm::mat<2, 2, T, Q> const& m) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
@ -94,7 +94,7 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<2, 3, T, Q>>::operator()(glm::mat<2, 3, T, Q> const& m) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
@ -104,7 +104,7 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<2, 4, T, Q>>::operator()(glm::mat<2, 4, T, Q> const& m) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
@ -114,7 +114,7 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<3, 2, T, Q>>::operator()(glm::mat<3, 2, T, Q> const& m) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
@ -125,7 +125,7 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<3, 3, T, Q>>::operator()(glm::mat<3, 3, T, Q> const& m) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
@ -136,7 +136,7 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<3, 4, T, Q>>::operator()(glm::mat<3, 4, T, Q> const& m) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
@ -147,8 +147,8 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<4, 2, T,P>>::operator()(glm::mat<4, 2, T,P> const& m) const
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<4, 2, T,Q>>::operator()(glm::mat<4, 2, T,Q> const& m) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
hash<glm::vec<2, T, Q>> hasher;
|
||||
@ -159,8 +159,8 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<4, 3, T,P>>::operator()(glm::mat<4, 3, T,P> const& m) const
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<4, 3, T,Q>>::operator()(glm::mat<4, 3, T,Q> const& m) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
hash<glm::vec<3, T, Q>> hasher;
|
||||
@ -171,8 +171,8 @@ namespace std
|
||||
return seed;
|
||||
}
|
||||
|
||||
template<typename T, glm::qualifier P>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<4, 4, T,P>>::operator()(glm::mat<4, 4, T, Q> const& m) const
|
||||
template<typename T, glm::qualifier Q>
|
||||
GLM_FUNC_QUALIFIER size_t hash<glm::mat<4, 4, T,Q>>::operator()(glm::mat<4, 4, T, Q> const& m) const
|
||||
{
|
||||
size_t seed = 0;
|
||||
hash<glm::vec<4, T, Q>> hasher;
|
||||
|
@ -101,6 +101,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
|
||||
- Fixed documentation warnings
|
||||
- Fixed GLM_HAS_OPENMP when OpenMP is not enabled
|
||||
- Fixed Better follow GLSL min and max specification #372
|
||||
- Fixed quaternion constructor from two vectors special cases #469
|
||||
|
||||
#### Deprecation:
|
||||
- Requires Visual Studio 2013, GCC 4.7, Clang 3.4, Cuda 7, ICC 2013 or a C++11 compiler
|
||||
|
@ -225,16 +225,28 @@ int test_quat_mul()
|
||||
|
||||
int test_quat_two_axis_ctr()
|
||||
{
|
||||
int Error(0);
|
||||
int Error = 0;
|
||||
|
||||
glm::quat q1(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
||||
glm::vec3 v1 = q1 * glm::vec3(1, 0, 0);
|
||||
glm::quat const q1(glm::vec3(1, 0, 0), glm::vec3(0, 1, 0));
|
||||
glm::vec3 const v1 = q1 * glm::vec3(1, 0, 0);
|
||||
Error += glm::all(glm::epsilonEqual(v1, glm::vec3(0, 1, 0), 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::quat q2 = q1 * q1;
|
||||
glm::vec3 v2 = q2 * glm::vec3(1, 0, 0);
|
||||
glm::quat const q2 = q1 * q1;
|
||||
glm::vec3 const v2 = q2 * glm::vec3(1, 0, 0);
|
||||
Error += glm::all(glm::epsilonEqual(v2, glm::vec3(-1, 0, 0), 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::quat const q3(glm::vec3(1, 0, 0), glm::vec3(-1, 0, 0));
|
||||
glm::vec3 const v3 = q3 * glm::vec3(1, 0, 0);
|
||||
Error += glm::all(glm::epsilonEqual(v3, glm::vec3(-1, 0, 0), 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::quat const q4(glm::vec3(0, 1, 0), glm::vec3(0, -1, 0));
|
||||
glm::vec3 const v4 = q4 * glm::vec3(0, 1, 0);
|
||||
Error += glm::all(glm::epsilonEqual(v4, glm::vec3(0, -1, 0), 0.0001f)) ? 0 : 1;
|
||||
|
||||
glm::quat const q5(glm::vec3(0, 0, 1), glm::vec3(0, 0, -1));
|
||||
glm::vec3 const v5 = q5 * glm::vec3(0, 0, 1);
|
||||
Error += glm::all(glm::epsilonEqual(v5, glm::vec3(0, 0, -1), 0.0001f)) ? 0 : 1;
|
||||
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#define GLM_ENABLE_EXPERIMENTAL
|
||||
|
||||
#include <glm/gtx/extended_min_max.hpp>
|
||||
#include <glm/gtc/vec1.hpp>
|
||||
#include <glm/gtc/epsilon.hpp>
|
||||
@ -18,6 +19,9 @@ namespace fmin_
|
||||
glm::vec1 A0 = glm::fmin(glm::vec1(1), glm::vec1(Zero_f / 0.0f));
|
||||
Error += glm::epsilonEqual(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||
|
||||
glm::vec1 A1 = glm::fmin(glm::vec1(Zero_f / 0.0f), glm::vec1(1));
|
||||
Error += glm::epsilonEqual(A1.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||
|
||||
glm::vec2 B0 = glm::fmin(glm::vec2(1), glm::vec2(1));
|
||||
glm::vec2 B1 = glm::fmin(glm::vec2(1), 1.0f);
|
||||
bool B2 = glm::all(glm::equal(B0, B1));
|
||||
@ -47,6 +51,9 @@ namespace fmax_
|
||||
glm::vec1 A0 = glm::fmax(glm::vec1(1), glm::vec1(Zero_f / 0.0f));
|
||||
Error += glm::epsilonEqual(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||
|
||||
glm::vec1 A1 = glm::fmax(glm::vec1(Zero_f / 0.0f), glm::vec1(1));
|
||||
Error += glm::epsilonEqual(A0.x, 1.0f, glm::epsilon<float>()) ? 0 : 1;
|
||||
|
||||
glm::vec2 B0 = glm::fmax(glm::vec2(1), glm::vec2(1));
|
||||
glm::vec2 B1 = glm::fmax(glm::vec2(1), 1.0f);
|
||||
bool B2 = glm::all(glm::equal(B0, B1));
|
||||
|
Loading…
Reference in New Issue
Block a user