1 | /** |
---|
2 | @file Vector2int16.h |
---|
3 | |
---|
4 | @maintainer Morgan McGuire, matrix@brown.edu |
---|
5 | |
---|
6 | @created 2003-08-09 |
---|
7 | @edited 2004-01-03 |
---|
8 | |
---|
9 | Copyright 2000-2006, Morgan McGuire. |
---|
10 | All rights reserved. |
---|
11 | */ |
---|
12 | |
---|
13 | #ifndef VECTOR2INT16_H |
---|
14 | #define VECTOR2INT16_H |
---|
15 | |
---|
16 | #include "G3D/platform.h" |
---|
17 | #include "G3D/g3dmath.h" |
---|
18 | |
---|
19 | namespace G3D { |
---|
20 | |
---|
21 | /** |
---|
22 | A Vector2 that packs its fields into uint16s. |
---|
23 | */ |
---|
24 | #ifdef G3D_WIN32 |
---|
25 | // Switch to tight alignment |
---|
26 | #pragma pack(push, 2) |
---|
27 | #endif |
---|
28 | |
---|
29 | class Vector2int16 { |
---|
30 | private: |
---|
31 | // Hidden operators |
---|
32 | bool operator<(const Vector2int16&) const; |
---|
33 | bool operator>(const Vector2int16&) const; |
---|
34 | bool operator<=(const Vector2int16&) const; |
---|
35 | bool operator>=(const Vector2int16&) const; |
---|
36 | |
---|
37 | public: |
---|
38 | G3D::int16 x; |
---|
39 | G3D::int16 y; |
---|
40 | |
---|
41 | Vector2int16() : x(0), y(0) {} |
---|
42 | Vector2int16(G3D::int16 _x, G3D::int16 _y) : x(_x), y(_y){} |
---|
43 | Vector2int16(const class Vector2& v); |
---|
44 | |
---|
45 | inline G3D::int16& operator[] (int i) { |
---|
46 | debugAssert(((unsigned int)i) <= 1); |
---|
47 | return ((G3D::int16*)this)[i]; |
---|
48 | } |
---|
49 | |
---|
50 | inline const G3D::int16& operator[] (int i) const { |
---|
51 | debugAssert(((unsigned int)i) <= 1); |
---|
52 | return ((G3D::int16*)this)[i]; |
---|
53 | } |
---|
54 | |
---|
55 | |
---|
56 | inline bool operator== (const Vector2int16& rkVector) const { |
---|
57 | return ((int32*)this)[0] == ((int32*)&rkVector)[0]; |
---|
58 | } |
---|
59 | |
---|
60 | inline bool operator!= (const Vector2int16& rkVector) const { |
---|
61 | return ((int32*)this)[0] != ((int32*)&rkVector)[0]; |
---|
62 | } |
---|
63 | |
---|
64 | } |
---|
65 | #if defined(G3D_LINUX) || defined(G3D_OSX) |
---|
66 | __attribute((aligned(1))) |
---|
67 | #endif |
---|
68 | ; |
---|
69 | |
---|
70 | #ifdef G3D_WIN32 |
---|
71 | #pragma pack(pop) |
---|
72 | #endif |
---|
73 | |
---|
74 | } |
---|
75 | #endif |
---|