aboutsummaryrefslogtreecommitdiff
path: root/include/vector3d.h
diff options
context:
space:
mode:
authorRichard Try <bazrovstepan@gmail.com>2022-05-10 20:26:24 +0300
committerGitHub <noreply@github.com>2022-05-10 19:26:24 +0200
commit6928c7eb6f00a00df4efcf1a1ec8f2310609696b (patch)
tree18e265d0921511b2ab542f37dc217573008e5b9c /include/vector3d.h
parent372b3642bf524da2694cc09bdc8bdacb23f5fd0e (diff)
downloadirrlicht-6928c7eb6f00a00df4efcf1a1ec8f2310609696b.tar.xz
Add hash for vector2d and vector3d (#93)
Diffstat (limited to 'include/vector3d.h')
-rw-r--r--include/vector3d.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/vector3d.h b/include/vector3d.h
index 4dbc53b..ed910e9 100644
--- a/include/vector3d.h
+++ b/include/vector3d.h
@@ -7,6 +7,8 @@
#include "irrMath.h"
+#include <functional>
+
namespace irr
{
namespace core
@@ -466,5 +468,22 @@ namespace core
} // end namespace core
} // end namespace irr
+namespace std
+{
+
+template<class T>
+struct hash<irr::core::vector3d<T> >
+{
+ size_t operator()(const irr::core::vector3d<T>& vec) const
+ {
+ size_t h1 = hash<T>()(vec.X);
+ size_t h2 = hash<T>()(vec.Y);
+ size_t h3 = hash<T>()(vec.Z);
+ return (h1 << (5 * sizeof(h1)) | h1 >> (3 * sizeof(h1))) ^ (h2 << (2 * sizeof(h2)) | h2 >> (6 * sizeof(h2))) ^ h3;
+ }
+};
+
+}
+
#endif