Mercurial > mm7
annotate VectorTypes.h @ 1622:01c04ff9b7a5
m
author | Ritor1 |
---|---|
date | Sun, 15 Sep 2013 19:12:34 +0600 |
parents | 4055b09160ae |
children |
rev | line source |
---|---|
0 | 1 #pragma once |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1025
diff
changeset
|
2 |
1513 | 3 #include <cstdint> |
4 | |
5 uint32_t int_get_vector_length(int32_t x, int32_t y, int32_t z); | |
0 | 6 |
7 #pragma pack(push, 1) | |
1513 | 8 template <class T> |
9 struct Vec2 | |
0 | 10 { |
1513 | 11 T x; |
12 T y; | |
0 | 13 |
1513 | 14 inline Vec2(T a = 0, T b = 0): |
15 x(a), y(b) | |
16 {} | |
0 | 17 }; |
18 #pragma pack(pop) | |
19 | |
1513 | 20 #define Vec2_int_ Vec2<int32_t> |
21 #define Vec2_float_ Vec2<float> | |
22 | |
0 | 23 #pragma pack(push, 1) |
1513 | 24 template <class T> |
25 struct Vec3: public Vec2<T> | |
0 | 26 { |
1513 | 27 T z; |
28 | |
29 inline Vec3(T a = 0, T b = 0, T c = 0): | |
30 Vec2(a, b), z(c) | |
31 {} | |
32 | |
33 void Normalize_float(); | |
34 template <class U> | |
35 inline uint32_t GetDistanceTo(Vec3<U> &o) | |
36 { | |
37 return int_get_vector_length( | |
38 abs(this->x - o.x), | |
39 abs(this->y - o.y), | |
40 abs(this->z - o.z) | |
41 ); | |
42 } | |
43 | |
44 static void __fastcall Rotate(T sDepth, T sRotY, T sRotX, Vec3<T> v, T *outx, T *outy, T *outz); | |
45 static void Normalize(T *x, T *y, T *z); | |
0 | 46 }; |
47 #pragma pack(pop) | |
48 | |
1513 | 49 #define Vec3_short_ Vec3<int16_t> |
50 #define Vec3_int_ Vec3<int32_t> | |
0 | 51 |
52 #pragma pack(push, 1) | |
1512 | 53 struct Vec3_float_ |
54 { | |
55 void Normalize(); | |
56 | |
57 //----- (0049B32D) -------------------------------------------------------- | |
58 static Vec3_float_ *Vec3_float_::Cross(Vec3_float_ *v1, Vec3_float_ *pOut, float x, float y, float z) | |
59 { | |
60 pOut->x = z * v1->y - y * v1->z; | |
61 pOut->y = x * v1->z - z * v1->x; | |
62 pOut->z = y * v1->x - x * v1->y; | |
63 return pOut; | |
64 } | |
65 | |
66 //----- (0049B02E) -------------------------------------------------------- | |
67 inline static float NegDot(Vec3_float_ *a1, Vec3_float_ *a2, float *a3) | |
68 { | |
69 return *a3 = -(a1->z * a2->z + a1->y * a2->y + a1->x * a2->x); | |
70 } | |
71 | |
72 float x; | |
73 float y; | |
74 float z; | |
75 }; | |
76 #pragma pack(pop) | |
77 | |
78 #pragma pack(push, 1) | |
0 | 79 struct Vec4_int_ |
80 { | |
81 int x; | |
82 int y; | |
83 int z; | |
84 int w; | |
85 }; | |
86 #pragma pack(pop) | |
87 | |
88 /* 82 */ | |
89 #pragma pack(push, 1) | |
90 struct Plane_int_ | |
91 { | |
92 Vec3_int_ vNormal; | |
93 int dist; | |
94 }; | |
95 #pragma pack(pop) | |
96 | |
97 #pragma pack(push, 1) | |
98 struct BBox_short_ | |
99 { | |
100 __int16 x1; | |
101 __int16 x2; | |
102 __int16 y1; | |
103 __int16 y2; | |
104 __int16 z1; | |
105 __int16 z2; | |
106 }; | |
107 #pragma pack(pop) | |
108 | |
109 #pragma pack(push, 1) | |
110 struct BBox_int_ | |
111 { | |
112 int x1; | |
113 int x2; | |
114 int y1; | |
115 int y2; | |
116 int z1; | |
117 int z2; | |
118 }; | |
119 #pragma pack(pop) | |
120 | |
121 #pragma pack(push, 1) | |
122 struct Plane_float_ | |
123 { | |
124 struct Vec3_float_ vNormal; | |
125 float dist; | |
126 }; | |
127 #pragma pack(pop) | |
128 | |
129 /* 196 */ | |
130 #pragma pack(push, 1) | |
131 struct Matrix3x3_float_ | |
132 { | |
133 union | |
134 { | |
135 struct | |
136 { | |
137 float _11; float _12; float _13; | |
138 float _21; float _22; float _23; | |
139 float _31; float _32; float _33; | |
140 }; | |
141 float v[3][3]; | |
142 }; | |
143 }; | |
144 #pragma pack(pop) |