TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Vector3int16.h
Go to the documentation of this file.
1 
13 #ifndef G3D_Vector3int16_h
14 #define G3D_Vector3int16_h
15 
16 #include "G3D/platform.h"
17 #include "G3D/g3dmath.h"
18 #include "G3D/HashTrait.h"
19 
20 #ifdef _MSC_VER
21 // Turn off "conditional expression is constant" warning; MSVC generates this
22 // for debug assertions in inlined methods.
23 #pragma warning (push)
24 #pragma warning (disable : 4127)
25 #endif
26 
27 
28 namespace G3D {
29 
36 private:
37  // Hidden operators
38  bool operator<(const Vector3int16&) const;
39  bool operator>(const Vector3int16&) const;
40  bool operator<=(const Vector3int16&) const;
41  bool operator>=(const Vector3int16&) const;
42 
43 public:
44  G3D::int16 x;
45  G3D::int16 y;
47 
48  Vector3int16() : x(0), y(0), z(0) {}
49  Vector3int16(G3D::int16 _x, G3D::int16 _y, G3D::int16 _z) : x(_x), y(_y), z(_z) {}
50  explicit Vector3int16(const class Vector3& v);
51  explicit Vector3int16(class BinaryInput& bi);
52 
53  void serialize(class BinaryOutput& bo) const;
54  void deserialize(class BinaryInput& bi);
55 
56  inline G3D::int16& operator[] (int i) {
57  debugAssert(i <= 2);
58  return ((G3D::int16*)this)[i];
59  }
60 
61  inline const G3D::int16& operator[] (int i) const {
62  debugAssert(i <= 2);
63  return ((G3D::int16*)this)[i];
64  }
65 
66  inline Vector3int16 operator+(const Vector3int16& other) const {
67  return Vector3int16(x + other.x, y + other.y, z + other.z);
68  }
69 
70  inline Vector3int16 operator-(const Vector3int16& other) const {
71  return Vector3int16(x - other.x, y - other.y, z - other.z);
72  }
73 
74  inline Vector3int16 operator*(const Vector3int16& other) const {
75  return Vector3int16(x * other.x, y * other.y, z * other.z);
76  }
77 
78  inline Vector3int16 operator*(const int s) const {
79  return Vector3int16(int16(x * s), int16(y * s), int16(z * s));
80  }
81 
82  inline Vector3int16& operator+=(const Vector3int16& other) {
83  x += other.x;
84  y += other.y;
85  z += other.z;
86  return *this;
87  }
88 
89  inline Vector3int16& operator-=(const Vector3int16& other) {
90  x -= other.x;
91  y -= other.y;
92  z -= other.z;
93  return *this;
94  }
95 
96  inline Vector3int16& operator*=(const Vector3int16& other) {
97  x *= other.x;
98  y *= other.y;
99  z *= other.z;
100  return *this;
101  }
102 
103  static Vector3int16 floor(const Vector3& v);
104  static Vector3int16 ceil(const Vector3& v);
105 
106  inline bool operator== (const Vector3int16& rkVector) const {
107  return ( x == rkVector.x && y == rkVector.y && z == rkVector.z );
108  }
109 
110  inline bool operator!= (const Vector3int16& rkVector) const {
111  return ( x != rkVector.x || y != rkVector.y || z != rkVector.z );
112  }
113 
114  int dot(const Vector3int16& v) const {
115  return x * v.x + y * v.y + z * v.z;
116  }
117 
118  Vector3int16 max(const Vector3int16& v) const {
119  return Vector3int16(std::max(x, v.x), std::max(y, v.y), std::max(z, v.z));
120  }
121 
122  Vector3int16 min(const Vector3int16& v) const {
123  return Vector3int16(std::min(x, v.x), std::min(y, v.y), std::min(z, v.z));
124  }
125 
126  std::string toString() const;
127 
128 
129  Vector3int16 operator-() const {
130  return Vector3int16(-x, -y, -z);
131  }
132 
133  Vector3int16 operator<<(int i) const {
134  return Vector3int16(x << i, y << i, z << i);
135  }
136 
137  Vector3int16 operator>>(int i) const {
138  return Vector3int16(x >> i, y >> i, z >> i);
139  }
140 
142  return Vector3int16(x >> v.x, y >> v.y, z >> v.z);
143  }
144 
146  return Vector3int16(x << v.x, y << v.y, z << v.z);
147  }
148 
150  return Vector3int16(x & i, y & i, z & i);
151  }
152 
154  return Vector3int16(x & v.x, y & v.y, z & v.z);
155  }
156 }
158 
160 
161 } // namespace G3D
162 
163 template <> struct HashTrait<G3D::Vector3int16> {
164  static size_t hashCode(const G3D::Vector3int16& key) { return static_cast<size_t>(key.x + ((int)key.y << 5) + ((int)key.z << 10)); }
165 };
166 
167 
168 #ifdef G3D_WINDOWS
169 #pragma warning( pop )
170 #endif
171 
172 #endif
unorm16 operator-(const unorm16 other) const
Definition: unorm16.h:131
int16_t int16
Definition: g3dmath.h:165
unorm16 & operator+=(const unorm16 other)
Definition: unorm16.h:126
static Vector3int16 floor(const Vector3 &v)
bool operator!=(const NetAddress &a, const NetAddress &b)
Definition: NetAddress.h:128
Vector3int16 min(const Vector3int16 &v) const
Definition: Vector3int16.h:122
bool operator<=(const unorm16 other) const
Definition: unorm16.h:110
Definition: HashTrait.h:105
Definition: AABox.h:25
unorm16 operator+(const unorm16 other) const
Definition: unorm16.h:122
bool operator<(const unorm16 other) const
Definition: unorm16.h:102
void deserialize(std::string &s, BinaryInput &b)
Definition: serialize.h:16
bool operator==(const NetAddress &a, const NetAddress &b)
Definition: NetAddress.h:123
T max(const T &x, const T &y)
Definition: g3dmath.h:320
T min(const T &x, const T &y)
Definition: g3dmath.h:305
unorm16 & operator-=(const unorm16 other)
Definition: unorm16.h:135
#define G3D_END_PACKED_CLASS(byteAlign)
Definition: platform.h:357
void serialize(const std::string &s, BinaryOutput &b)
Definition: serialize.h:12
Vector3int16
Definition: Vector3int16.h:35
#define debugAssert(exp)
Definition: debugAssert.h:160
G3D::int16 z
Definition: Vector3int16.h:46
std::string toString() const
Vector3int16 operator&(int16 i) const
Definition: Vector3int16.h:149
unorm16 & operator*=(const int i)
Definition: unorm16.h:144
G3D::int16 y
Definition: Vector2int16.h:38
Vector3int16 max(const Vector3int16 &v) const
Definition: Vector3int16.h:118
G3D::int16 & operator[](int i)
Definition: Vector2int16.h:51
static size_t hashCode(const G3D::Vector3int16 &key)
Definition: Vector3int16.h:164
bool operator>=(const unorm16 other) const
Definition: unorm16.h:106
bool operator>(const unorm16 other) const
Definition: unorm16.h:98
#define G3D_BEGIN_PACKED_CLASS(byteAlign)
Definition: platform.h:345
std::ostream & operator<<(std::ostream &os, const NetAddress &)
Definition: NetworkDevice.cpp:26
unorm16 operator>>(const int i) const
Definition: unorm16.h:167
float dot(float a, float b)
Definition: g3dmath.h:445
G3D::int16 x
Definition: Vector2int16.h:37
static Vector3int16 ceil(const Vector3 &v)
Definition: Vector3int16.cpp:55
G3D::Color3 operator*(float s, const G3D::Color3 &c)
Definition: Color3.h:275