]> git.lizzy.rs Git - irrlicht.git/blobdiff - include/vector3d.h
Add setRelativeMode for SDL driver (#123)
[irrlicht.git] / include / vector3d.h
index 5f4f6133bd8d3cb9be00b511ca349b6e09bd430d..ed910e9f29bea6fe777e807a62a2f84eb8310faf 100644 (file)
@@ -7,6 +7,8 @@
 \r
 #include "irrMath.h"\r
 \r
+#include <functional>\r
+\r
 namespace irr\r
 {\r
 namespace core\r
@@ -28,15 +30,11 @@ namespace core
                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
@@ -54,8 +52,8 @@ namespace core
 \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
@@ -470,5 +468,22 @@ namespace core
 } // 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