annotate VectorTypes.h @ 1504:ff1867836af5

Cleanup of VectorTypes.
author yoctozepto
date Mon, 02 Sep 2013 12:46:32 +0200
parents 0dbf6c4dd029
children af57b3b76fe4
rev   line source
0
Ritor1
parents:
diff changeset
1 #pragma once
1165
29a8defbad9e temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents: 1025
diff changeset
2
0
Ritor1
parents:
diff changeset
3 typedef unsigned __int32 uint;
Ritor1
parents:
diff changeset
4
Ritor1
parents:
diff changeset
5 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
6 struct Vec2_short_
Ritor1
parents:
diff changeset
7 {
Ritor1
parents:
diff changeset
8 __int16 x;
Ritor1
parents:
diff changeset
9 __int16 y;
Ritor1
parents:
diff changeset
10 };
Ritor1
parents:
diff changeset
11 #pragma pack(pop)
Ritor1
parents:
diff changeset
12
Ritor1
parents:
diff changeset
13 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
14 struct Vec3_float_
Ritor1
parents:
diff changeset
15 {
Ritor1
parents:
diff changeset
16 void Normalize();
Ritor1
parents:
diff changeset
17
Ritor1
parents:
diff changeset
18
1025
8b492d4722d4 Intersection
Ritor1
parents: 0
diff changeset
19 //----- (0049B32D) --------------------------------------------------------
8b492d4722d4 Intersection
Ritor1
parents: 0
diff changeset
20 static Vec3_float_ *Vec3_float_::Cross(Vec3_float_ *v1, Vec3_float_ *pOut, float x, float y, float z)
8b492d4722d4 Intersection
Ritor1
parents: 0
diff changeset
21 {
8b492d4722d4 Intersection
Ritor1
parents: 0
diff changeset
22 pOut->x = z * v1->y - y * v1->z;
8b492d4722d4 Intersection
Ritor1
parents: 0
diff changeset
23 pOut->y = x * v1->z - z * v1->x;
8b492d4722d4 Intersection
Ritor1
parents: 0
diff changeset
24 pOut->z = y * v1->x - x * v1->y;
8b492d4722d4 Intersection
Ritor1
parents: 0
diff changeset
25 return pOut;
8b492d4722d4 Intersection
Ritor1
parents: 0
diff changeset
26 }
0
Ritor1
parents:
diff changeset
27
Ritor1
parents:
diff changeset
28 //----- (0049B02E) --------------------------------------------------------
Ritor1
parents:
diff changeset
29 inline static float NegDot(Vec3_float_ *a1, Vec3_float_ *a2, float *a3)
Ritor1
parents:
diff changeset
30 {
Ritor1
parents:
diff changeset
31 return *a3 = -(a1->z * a2->z + a1->y * a2->y + a1->x * a2->x);
Ritor1
parents:
diff changeset
32 }
Ritor1
parents:
diff changeset
33
Ritor1
parents:
diff changeset
34 float x;
Ritor1
parents:
diff changeset
35 float y;
Ritor1
parents:
diff changeset
36 float z;
Ritor1
parents:
diff changeset
37 };
Ritor1
parents:
diff changeset
38 #pragma pack(pop)
Ritor1
parents:
diff changeset
39
Ritor1
parents:
diff changeset
40
Ritor1
parents:
diff changeset
41 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
42 struct Vec2_int_
Ritor1
parents:
diff changeset
43 {
Ritor1
parents:
diff changeset
44 int x;
Ritor1
parents:
diff changeset
45 int y;
Ritor1
parents:
diff changeset
46 };
Ritor1
parents:
diff changeset
47 #pragma pack(pop)
Ritor1
parents:
diff changeset
48
Ritor1
parents:
diff changeset
49 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
50 struct Vec2_float_
Ritor1
parents:
diff changeset
51 {
Ritor1
parents:
diff changeset
52 float x;
Ritor1
parents:
diff changeset
53 float y;
Ritor1
parents:
diff changeset
54 };
Ritor1
parents:
diff changeset
55 #pragma pack(pop)
Ritor1
parents:
diff changeset
56
Ritor1
parents:
diff changeset
57
Ritor1
parents:
diff changeset
58 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
59 struct Vec3_short_
Ritor1
parents:
diff changeset
60 {
Ritor1
parents:
diff changeset
61 __int16 x;
Ritor1
parents:
diff changeset
62 __int16 y;
Ritor1
parents:
diff changeset
63 __int16 z;
Ritor1
parents:
diff changeset
64 };
Ritor1
parents:
diff changeset
65 #pragma pack(pop)
Ritor1
parents:
diff changeset
66
Ritor1
parents:
diff changeset
67 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
68 struct Vec3_int_
Ritor1
parents:
diff changeset
69 {
Ritor1
parents:
diff changeset
70 inline Vec3_int_():
Ritor1
parents:
diff changeset
71 x(0), y(0), z(0)
Ritor1
parents:
diff changeset
72 {}
Ritor1
parents:
diff changeset
73 inline Vec3_int_(int a, int b = 0, int c = 0):
Ritor1
parents:
diff changeset
74 x(a), y(b), z(c)
Ritor1
parents:
diff changeset
75 {}
Ritor1
parents:
diff changeset
76
Ritor1
parents:
diff changeset
77 void Normalize_float();
Ritor1
parents:
diff changeset
78
Ritor1
parents:
diff changeset
79 static void __fastcall Rotate(int sDepth, int sRotY, int sRotX, Vec3_int_ v, int *outx, int *outy, int *outz);
Ritor1
parents:
diff changeset
80 static void Normalize(int *x, int *y, int *z);
Ritor1
parents:
diff changeset
81
Ritor1
parents:
diff changeset
82 int x;
Ritor1
parents:
diff changeset
83 int y;
Ritor1
parents:
diff changeset
84 int z;
Ritor1
parents:
diff changeset
85 };
Ritor1
parents:
diff changeset
86 #pragma pack(pop)
Ritor1
parents:
diff changeset
87
Ritor1
parents:
diff changeset
88 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
89 struct Vec4_int_
Ritor1
parents:
diff changeset
90 {
Ritor1
parents:
diff changeset
91 int x;
Ritor1
parents:
diff changeset
92 int y;
Ritor1
parents:
diff changeset
93 int z;
Ritor1
parents:
diff changeset
94 int w;
Ritor1
parents:
diff changeset
95 };
Ritor1
parents:
diff changeset
96 #pragma pack(pop)
Ritor1
parents:
diff changeset
97
Ritor1
parents:
diff changeset
98
Ritor1
parents:
diff changeset
99
Ritor1
parents:
diff changeset
100
Ritor1
parents:
diff changeset
101
Ritor1
parents:
diff changeset
102
Ritor1
parents:
diff changeset
103 /* 82 */
Ritor1
parents:
diff changeset
104 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
105 struct Plane_int_
Ritor1
parents:
diff changeset
106 {
Ritor1
parents:
diff changeset
107 Vec3_int_ vNormal;
Ritor1
parents:
diff changeset
108 int dist;
Ritor1
parents:
diff changeset
109 };
Ritor1
parents:
diff changeset
110 #pragma pack(pop)
Ritor1
parents:
diff changeset
111
Ritor1
parents:
diff changeset
112
Ritor1
parents:
diff changeset
113 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
114 struct BBox_short_
Ritor1
parents:
diff changeset
115 {
Ritor1
parents:
diff changeset
116 __int16 x1;
Ritor1
parents:
diff changeset
117 __int16 x2;
Ritor1
parents:
diff changeset
118 __int16 y1;
Ritor1
parents:
diff changeset
119 __int16 y2;
Ritor1
parents:
diff changeset
120 __int16 z1;
Ritor1
parents:
diff changeset
121 __int16 z2;
Ritor1
parents:
diff changeset
122 };
Ritor1
parents:
diff changeset
123 #pragma pack(pop)
Ritor1
parents:
diff changeset
124
Ritor1
parents:
diff changeset
125 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
126 struct BBox_int_
Ritor1
parents:
diff changeset
127 {
Ritor1
parents:
diff changeset
128 int x1;
Ritor1
parents:
diff changeset
129 int x2;
Ritor1
parents:
diff changeset
130 int y1;
Ritor1
parents:
diff changeset
131 int y2;
Ritor1
parents:
diff changeset
132 int z1;
Ritor1
parents:
diff changeset
133 int z2;
Ritor1
parents:
diff changeset
134 };
Ritor1
parents:
diff changeset
135 #pragma pack(pop)
Ritor1
parents:
diff changeset
136
Ritor1
parents:
diff changeset
137 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
138 struct Plane_float_
Ritor1
parents:
diff changeset
139 {
Ritor1
parents:
diff changeset
140 struct Vec3_float_ vNormal;
Ritor1
parents:
diff changeset
141 float dist;
Ritor1
parents:
diff changeset
142 };
Ritor1
parents:
diff changeset
143 #pragma pack(pop)
Ritor1
parents:
diff changeset
144
Ritor1
parents:
diff changeset
145
Ritor1
parents:
diff changeset
146
Ritor1
parents:
diff changeset
147
Ritor1
parents:
diff changeset
148 /* 196 */
Ritor1
parents:
diff changeset
149 #pragma pack(push, 1)
Ritor1
parents:
diff changeset
150 struct Matrix3x3_float_
Ritor1
parents:
diff changeset
151 {
Ritor1
parents:
diff changeset
152 union
Ritor1
parents:
diff changeset
153 {
Ritor1
parents:
diff changeset
154 struct
Ritor1
parents:
diff changeset
155 {
Ritor1
parents:
diff changeset
156 float _11; float _12; float _13;
Ritor1
parents:
diff changeset
157 float _21; float _22; float _23;
Ritor1
parents:
diff changeset
158 float _31; float _32; float _33;
Ritor1
parents:
diff changeset
159 };
Ritor1
parents:
diff changeset
160 float v[3][3];
Ritor1
parents:
diff changeset
161 };
Ritor1
parents:
diff changeset
162 };
Ritor1
parents:
diff changeset
163 #pragma pack(pop)
Ritor1
parents:
diff changeset
164