TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Vector2int16.h
Go to the documentation of this file.
1 
13 #ifndef Vector2int16_h
14 #define Vector2int16_h
15 
16 #include "G3D/platform.h"
17 #include "G3D/g3dmath.h"
18 #include "G3D/HashTrait.h"
19 
20 namespace G3D {
21 
22 class Any;
29 private:
30  // Hidden operators
31  bool operator<(const Vector2int16&) const;
32  bool operator>(const Vector2int16&) const;
33  bool operator<=(const Vector2int16&) const;
34  bool operator>=(const Vector2int16&) const;
35 
36 public:
39 
40  Vector2int16() : x(0), y(0) {}
41  Vector2int16(G3D::int16 _x, G3D::int16 _y) : x(_x), y(_y){}
42  explicit Vector2int16(const class Vector2& v);
43  explicit Vector2int16(class BinaryInput& bi);
44  explicit Vector2int16(const class Any& a);
45  explicit Vector2int16(const class Vector2int32& v);
46 
47  Any toAny() const;
48 
49  Vector2int16& operator=(const Any& a);
50 
51  inline G3D::int16& operator[] (int i) {
52  debugAssert(((unsigned int)i) <= 1);
53  return ((G3D::int16*)this)[i];
54  }
55 
56  inline const G3D::int16& operator[] (int i) const {
57  debugAssert(((unsigned int)i) <= 1);
58  return ((G3D::int16*)this)[i];
59  }
60 
61  inline Vector2int16 operator+(const Vector2int16& other) const {
62  return Vector2int16(x + other.x, y + other.y);
63  }
64 
65  inline Vector2int16 operator-(const Vector2int16& other) const {
66  return Vector2int16(x - other.x, y - other.y);
67  }
68 
69  inline Vector2int16 operator*(const Vector2int16& other) const {
70  return Vector2int16(x * other.x, y * other.y);
71  }
72 
74  return Vector2int16(-x, -y);
75  }
76 
77  inline Vector2int16 operator*(const int s) const {
78  return Vector2int16(x * s, y * s);
79  }
80 
81  inline Vector2int16& operator+=(const Vector2int16& other) {
82  x += other.x;
83  y += other.y;
84  return *this;
85  }
86 
87  bool isZero() const {
88  return (x == 0) && (y == 0);
89  }
90 
92  inline Vector2int16 operator>>(const int s) const {
93  return Vector2int16(x >> s, y >> s);
94  }
95 
97  inline Vector2int16 operator<<(const int s) const {
98  return Vector2int16(x << s, y << s);
99  }
100 
101  inline Vector2int16& operator-=(const Vector2int16& other) {
102  x -= other.x;
103  y -= other.y;
104  return *this;
105  }
106 
107  inline Vector2int16& operator*=(const Vector2int16& other) {
108  x *= other.x;
109  y *= other.y;
110  return *this;
111  }
112 
113  Vector2int16 clamp(const Vector2int16& lo, const Vector2int16& hi);
114 
115  inline bool operator== (const Vector2int16& rkVector) const {
116  return ((int32*)this)[0] == ((int32*)&rkVector)[0];
117  }
118 
119  inline bool operator!= (const Vector2int16& rkVector) const {
120  return ((int32*)this)[0] != ((int32*)&rkVector)[0];
121  }
122 
123  Vector2int16 max(const Vector2int16& v) const {
124  return Vector2int16(iMax(x, v.x), iMax(y, v.y));
125  }
126 
127  Vector2int16 min(const Vector2int16& v) const {
128  return Vector2int16(iMin(x, v.x), iMin(y, v.y));
129  }
130 
131  void serialize(class BinaryOutput& bo) const;
132  void deserialize(class BinaryInput& bi);
133 }
135 
137 
138 }
139 
140 template<> struct HashTrait<G3D::Vector2int16> {
141  static size_t hashCode(const G3D::Vector2int16& key) { return static_cast<size_t>(key.x + ((int)key.y << 16)); }
142 };
143 
144 #endif
unorm16 operator-(const unorm16 other) const
Definition: unorm16.h:131
int16_t int16
Definition: g3dmath.h:165
class Any toAny() const
unorm16 & operator+=(const unorm16 other)
Definition: unorm16.h:126
Vector2int16
Definition: Vector2int16.h:28
bool isZero() const
Definition: Vector2int16.h:87
bool operator!=(const NetAddress &a, const NetAddress &b)
Definition: NetAddress.h:128
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
double clamp(double val, double low, double hi)
Definition: g3dmath.h:571
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
#define debugAssert(exp)
Definition: debugAssert.h:160
Vector2int16 & operator=(const Any &a)
unorm16 & operator*=(const int i)
Definition: unorm16.h:144
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 & operator[](int i)
Definition: Vector2int16.h:51
bool operator>=(const unorm16 other) const
Definition: unorm16.h:106
static size_t hashCode(const G3D::Vector2int16 &key)
Definition: Vector2int16.h:141
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
int32_t int32
Definition: g3dmath.h:167
G3D::int16 x
Definition: Vector2int16.h:37
int iMax(int x, int y)
Definition: g3dmath.h:759
Definition: Vector2int16.h:22
G3D::Color3 operator*(float s, const G3D::Color3 &c)
Definition: Color3.h:275
int iMin(int x, int y)
Definition: g3dmath.h:753