\r
#include "irrMath.h"\r
\r
+#include <functional>\r
+\r
namespace irr\r
{\r
namespace core\r
vector3d(T nx, T ny, T nz) : X(nx), Y(ny), Z(nz) {}\r
//! Constructor with the same value for all elements\r
explicit vector3d(T n) : X(n), Y(n), Z(n) {}\r
- //! Copy constructor\r
- vector3d(const vector3d<T>& other) : X(other.X), Y(other.Y), Z(other.Z) {}\r
\r
// operators\r
\r
vector3d<T> operator-() const { return vector3d<T>(-X, -Y, -Z); }\r
\r
- vector3d<T>& operator=(const vector3d<T>& other) { X = other.X; Y = other.Y; Z = other.Z; return *this; }\r
-\r
vector3d<T> operator+(const vector3d<T>& other) const { return vector3d<T>(X + other.X, Y + other.Y, Z + other.Z); }\r
vector3d<T>& operator+=(const vector3d<T>& other) { X+=other.X; Y+=other.Y; Z+=other.Z; return *this; }\r
vector3d<T> operator+(const T val) const { return vector3d<T>(X + val, Y + val, Z + val); }\r
\r
vector3d<T> operator/(const vector3d<T>& other) const { return vector3d<T>(X / other.X, Y / other.Y, Z / other.Z); }\r
vector3d<T>& operator/=(const vector3d<T>& other) { X/=other.X; Y/=other.Y; Z/=other.Z; return *this; }\r
- vector3d<T> operator/(const T v) const { T i=(T)1.0/v; return vector3d<T>(X * i, Y * i, Z * i); }\r
- vector3d<T>& operator/=(const T v) { T i=(T)1.0/v; X*=i; Y*=i; Z*=i; return *this; }\r
+ vector3d<T> operator/(const T v) const { return vector3d<T>(X/v, Y/v, Z/v); }\r
+ vector3d<T>& operator/=(const T v) { X/=v; Y/=v; Z/=v; return *this; }\r
\r
T& operator [](u32 index)\r
{\r
} // end namespace core\r
} // end namespace irr\r
\r
+namespace std\r
+{\r
+\r
+template<class T>\r
+struct hash<irr::core::vector3d<T> >\r
+{\r
+ size_t operator()(const irr::core::vector3d<T>& vec) const\r
+ {\r
+ size_t h1 = hash<T>()(vec.X);\r
+ size_t h2 = hash<T>()(vec.Y);\r
+ size_t h3 = hash<T>()(vec.Z);\r
+ return (h1 << (5 * sizeof(h1)) | h1 >> (3 * sizeof(h1))) ^ (h2 << (2 * sizeof(h2)) | h2 >> (6 * sizeof(h2))) ^ h3;\r
+ }\r
+};\r
+\r
+}\r
+\r
#endif\r
\r