Переглянути джерело

std::hash specialization for glm::tdualquat

Thom de Villa 10 роки тому
батько
коміт
3b9e90c7b6
2 змінених файлів з 18 додано та 0 видалено
  1. 7 0
      glm/gtx/hash.hpp
  2. 11 0
      glm/gtx/hash.inl

+ 7 - 0
glm/gtx/hash.hpp

@@ -53,6 +53,7 @@
 #include "../gtc/vec1.hpp"
 
 #include "../gtc/quaternion.hpp"
+#include "../gtx/dual_quaternion.hpp"
 
 #include "../mat2x2.hpp"
 #include "../mat2x3.hpp"
@@ -98,6 +99,12 @@ namespace std
 		GLM_FUNC_DECL size_t operator()(const glm::tquat<T,P> &q) const;
 	};
 
+	template <typename T, glm::precision P>
+	struct hash<glm::tdualquat<T,P>>
+	{
+		GLM_FUNC_DECL size_t operator()(const glm::tdualquat<T,P> &q) const;
+	};
+
 	template <typename T, glm::precision P>
 	struct hash<glm::tmat2x2<T,P>>
 	{

+ 11 - 0
glm/gtx/hash.inl

@@ -108,6 +108,17 @@ namespace std
 		return seed;
 	}
 
+	template <typename T, glm::precision P>
+	GLM_FUNC_QUALIFIER size_t
+	hash<glm::tdualquat<T,P>>::operator()(const glm::tdualquat<T,P> &q) const
+	{
+		size_t seed = 0;
+		hash<glm::tquat<T,P>> hasher;
+		glm::detail::hash_combine(seed, hasher(q.real));
+		glm::detail::hash_combine(seed, hasher(q.dual));
+		return seed;
+	}
+
 	template <typename T, glm::precision P>
 	GLM_FUNC_QUALIFIER size_t
 	hash<glm::tmat2x2<T,P>>::operator()(const glm::tmat2x2<T,P> &m) const