2015-03-07 13:01:55 +00:00
|
|
|
/// @ref gtx_hash
|
|
|
|
/// @file glm/gtx/hash.inl
|
|
|
|
///
|
|
|
|
/// @see core (dependence)
|
|
|
|
///
|
|
|
|
/// @defgroup gtx_hash GLM_GTX_hash
|
|
|
|
/// @ingroup gtx
|
2016-05-23 20:55:49 +00:00
|
|
|
///
|
2015-03-07 13:04:56 +00:00
|
|
|
/// @brief Add std::hash support for glm types
|
2016-05-23 20:55:49 +00:00
|
|
|
///
|
2015-03-07 13:01:55 +00:00
|
|
|
/// <glm/gtx/hash.inl> need to be included to use these functionalities.
|
|
|
|
|
|
|
|
namespace glm {
|
|
|
|
namespace detail
|
|
|
|
{
|
|
|
|
GLM_INLINE void hash_combine(size_t &seed, size_t hash)
|
|
|
|
{
|
|
|
|
hash += 0x9e3779b9 + (seed << 6) + (seed >> 2);
|
|
|
|
seed ^= hash;
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 00:23:29 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::vec<1, T, P>>::operator()(glm::vec<1, T, P> const & v) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
hash<T> hasher;
|
|
|
|
return hasher(v.x);
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 00:23:29 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::vec<2, T, P>>::operator()(glm::vec<2, T, P> const & v) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
|
|
|
hash<T> hasher;
|
|
|
|
glm::detail::hash_combine(seed, hasher(v.x));
|
|
|
|
glm::detail::hash_combine(seed, hasher(v.y));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 00:23:29 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::vec<3, T, P>>::operator()(glm::vec<3, T, P> const & v) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
|
|
|
hash<T> hasher;
|
|
|
|
glm::detail::hash_combine(seed, hasher(v.x));
|
|
|
|
glm::detail::hash_combine(seed, hasher(v.y));
|
|
|
|
glm::detail::hash_combine(seed, hasher(v.z));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 00:23:29 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::vec<4, T, P>>::operator()(glm::vec<4, T, P> const & v) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
|
|
|
hash<T> hasher;
|
|
|
|
glm::detail::hash_combine(seed, hasher(v.x));
|
|
|
|
glm::detail::hash_combine(seed, hasher(v.y));
|
|
|
|
glm::detail::hash_combine(seed, hasher(v.z));
|
|
|
|
glm::detail::hash_combine(seed, hasher(v.w));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2015-08-31 20:50:24 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::tquat<T, P>>::operator()(glm::tquat<T,P> const & q) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
|
|
|
hash<T> hasher;
|
|
|
|
glm::detail::hash_combine(seed, hasher(q.x));
|
|
|
|
glm::detail::hash_combine(seed, hasher(q.y));
|
|
|
|
glm::detail::hash_combine(seed, hasher(q.z));
|
|
|
|
glm::detail::hash_combine(seed, hasher(q.w));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2015-08-31 20:50:24 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::tdualquat<T, P>>::operator()(glm::tdualquat<T, P> const & q) const
|
2015-07-24 15:58:15 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
2015-08-31 20:50:24 +00:00
|
|
|
hash<glm::tquat<T, P>> hasher;
|
2015-07-24 15:58:15 +00:00
|
|
|
glm::detail::hash_combine(seed, hasher(q.real));
|
|
|
|
glm::detail::hash_combine(seed, hasher(q.dual));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 15:00:25 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::mat<2, 2, T, P>>::operator()(glm::mat<2, 2, T, P> const& m) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
2016-12-30 00:23:29 +00:00
|
|
|
hash<glm::vec<2, T, P>> hasher;
|
2015-03-07 13:01:55 +00:00
|
|
|
glm::detail::hash_combine(seed, hasher(m[0]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[1]));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 15:00:25 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::mat<2, 3, T, P>>::operator()(glm::mat<2, 3, T, P> const& m) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
2016-12-30 00:23:29 +00:00
|
|
|
hash<glm::vec<3, T, P>> hasher;
|
2015-03-07 13:01:55 +00:00
|
|
|
glm::detail::hash_combine(seed, hasher(m[0]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[1]));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 15:00:25 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::mat<2, 4, T, P>>::operator()(glm::mat<2, 4, T, P> const& m) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
2016-12-30 00:23:29 +00:00
|
|
|
hash<glm::vec<4, T, P>> hasher;
|
2015-03-07 13:01:55 +00:00
|
|
|
glm::detail::hash_combine(seed, hasher(m[0]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[1]));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 15:00:25 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::mat<3, 2, T, P>>::operator()(glm::mat<3, 2, T, P> const& m) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
2016-12-30 00:23:29 +00:00
|
|
|
hash<glm::vec<2, T, P>> hasher;
|
2015-03-07 13:01:55 +00:00
|
|
|
glm::detail::hash_combine(seed, hasher(m[0]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[1]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[2]));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 15:00:25 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::mat<3, 3, T, P>>::operator()(glm::mat<3, 3, T, P> const& m) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
2016-12-30 00:23:29 +00:00
|
|
|
hash<glm::vec<3, T, P>> hasher;
|
2015-03-07 13:01:55 +00:00
|
|
|
glm::detail::hash_combine(seed, hasher(m[0]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[1]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[2]));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 15:00:25 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::mat<3, 4, T, P>>::operator()(glm::mat<3, 4, T, P> const& m) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
2016-12-30 00:23:29 +00:00
|
|
|
hash<glm::vec<4, T, P>> hasher;
|
2015-03-07 13:01:55 +00:00
|
|
|
glm::detail::hash_combine(seed, hasher(m[0]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[1]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[2]));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 15:00:25 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::mat<4, 2, T,P>>::operator()(glm::mat<4, 2, T,P> const & m) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
2016-12-30 00:23:29 +00:00
|
|
|
hash<glm::vec<2, T, P>> hasher;
|
2015-03-07 13:01:55 +00:00
|
|
|
glm::detail::hash_combine(seed, hasher(m[0]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[1]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[2]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[3]));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 15:00:25 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::mat<4, 3, T,P>>::operator()(glm::mat<4, 3, T,P> const & m) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
2016-12-30 00:23:29 +00:00
|
|
|
hash<glm::vec<3, T, P>> hasher;
|
2015-03-07 13:01:55 +00:00
|
|
|
glm::detail::hash_combine(seed, hasher(m[0]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[1]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[2]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[3]));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
|
2016-12-30 19:05:04 +00:00
|
|
|
template<typename T, glm::precision P>
|
2016-12-30 15:00:25 +00:00
|
|
|
GLM_FUNC_QUALIFIER size_t hash<glm::mat<4, 4, T,P>>::operator()(glm::mat<4, 4, T, P> const& m) const
|
2015-03-07 13:01:55 +00:00
|
|
|
{
|
|
|
|
size_t seed = 0;
|
2016-12-30 00:23:29 +00:00
|
|
|
hash<glm::vec<4, T, P>> hasher;
|
2015-03-07 13:01:55 +00:00
|
|
|
glm::detail::hash_combine(seed, hasher(m[0]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[1]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[2]));
|
|
|
|
glm::detail::hash_combine(seed, hasher(m[3]));
|
|
|
|
return seed;
|
|
|
|
}
|
|
|
|
}
|