TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Vector4int8.h
Go to the documentation of this file.
1 
15 #ifndef G3D_VECTOR4INT8_H
16 #define G3D_VECTOR4INT8_H
17 
18 #include "G3D/platform.h"
19 #include "G3D/g3dmath.h"
20 
21 namespace G3D {
22 
23 class Vector3;
24 class Vector4;
25 
30 class Vector4int8 {
31 private:
32  // Hidden operators
33  bool operator<(const Vector4int8&) const;
34  bool operator>(const Vector4int8&) const;
35  bool operator<=(const Vector4int8&) const;
36  bool operator>=(const Vector4int8&) const;
37 
38 
41  inline uint32& asInt32() {
42  return *reinterpret_cast<uint32*>(this);
43  }
44 
45  inline const uint32& asInt32() const {
46  return *reinterpret_cast<const uint32*>(this);
47  }
48 
49 public:
50  // construction
51  inline Vector4int8() : x(0), y(0), z(0), w(0) {}
52 
54  explicit Vector4int8(const Vector4& source);
55 
57  explicit Vector4int8(const Vector3& source, int8 w);
58 
59  inline Vector4int8(int8 x, int8 y, int8 z, int8 w) : x(x), y(y), z(z), w(w) {}
60 
61  explicit Vector4int8(class BinaryInput& b);
62  void serialize(class BinaryOutput& b) const;
63  void deserialize(class BinaryInput& b);
64 
65  // coordinates
66  int8 x, y, z, w;
67 
68  inline operator int8* () {
69  return reinterpret_cast<int8*>(this);
70  }
71 
72  inline operator const int8* () const {
73  return reinterpret_cast<const int8*>(this);
74  }
75 
76  // access vector V as V[0] = V.x, V[1] = V.y, V[2] = V.z, etc.
77  //
78  // WARNING. These member functions rely on
79  // (1) Vector4int8 not having virtual functions
80  // (2) the data packed in a 4*sizeof(int8) memory block
81  inline int8& operator[] (int i) {
82  debugAssert(i >= 0 && i <= 4);
83  return ((int8*)this)[i];
84  }
85 
86  const int8& operator[] (int i) const {
87  debugAssert(i >= 0 && i <= 4);
88  return ((const int8*)this)[i];
89  }
90 
91  // assignment and comparison
93  asInt32() = other.asInt32();
94  return *this;
95  }
96 
97  inline bool operator== (const Vector4int8& other) const {
98  return asInt32() == other.asInt32();
99  }
100 
101  inline bool operator!= (const Vector4int8& other) const {
102  return ! (*this == other);
103  }
104 
105  inline unsigned int hashCode() const {
106  return asInt32();
107  }
108 };
109 
110 } // namespace G3D
111 
112 
113 #endif
int8 x
Definition: Vector4int8.h:66
Definition: BinaryInput.h:69
uint32 & asInt32()
Definition: Vector4int8.h:41
int8_t int8
Definition: g3dmath.h:163
Definition: Vector4int8.h:30
Definition: AABox.h:25
Vector4int8()
Definition: Vector4int8.h:51
Definition: Vector3.h:58
unsigned int hashCode() const
Definition: Vector4int8.h:105
bool operator>=(const Vector4int8 &) const
bool operator==(const Vector4int8 &other) const
Definition: Vector4int8.h:97
int8 & operator[](int i)
Definition: Vector4int8.h:81
#define debugAssert(exp)
Definition: debugAssert.h:160
void deserialize(class BinaryInput &b)
Definition: Vector4int8.cpp:50
bool operator<=(const Vector4int8 &) const
void serialize(class BinaryOutput &b) const
Definition: Vector4int8.cpp:42
Vector4int8 & operator=(const Vector4int8 &other)
Definition: Vector4int8.h:92
Definition: Vector4.h:39
int8 y
Definition: Vector4int8.h:66
bool operator!=(const Vector4int8 &other) const
Definition: Vector4int8.h:101
Definition: BinaryOutput.h:52
bool operator>(const Vector4int8 &) const
uint32_t uint32
Definition: g3dmath.h:168
Vector4int8(int8 x, int8 y, int8 z, int8 w)
Definition: Vector4int8.h:59
int8 w
Definition: Vector4int8.h:66
bool operator<(const Vector4int8 &) const
const uint32 & asInt32() const
Definition: Vector4int8.h:45
int8 z
Definition: Vector4int8.h:66