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