UFO: Alien Invasion
typedefs.h
Go to the documentation of this file.
1#pragma once
2
3#include "defines.h"
4#include "mathlib.h"
5#include "shared.h"
6#include "../common/filesys.h"
7
20typedef struct cBspPlane_s {
22 float dist;
23 byte type;
25
26typedef struct cBspModel_s {
29 int32_t headnode;
31 int tile;
33 int firstface, numfaces;
35
37typedef struct cBspSurface_s {
39 uint32_t surfaceFlags;
41
42typedef struct cBspNode_s {
44 vec3_t mins, maxs;
45 int32_t children[2];
47
48typedef struct cBspBrushSide_s {
52
53typedef struct cBspLeaf_s {
54 uint32_t contentFlags;
55 unsigned short firstleafbrush;
56 unsigned short numleafbrushes;
58
59typedef struct cBspBrush_s {
65
69typedef struct tnode_s {
70 int type;
72 float dist;
73 int32_t children[2];
74 int pad;
75} tnode_t;
76
77typedef struct chead_s {
78 int cnode;
79 int level;
81
85class MapTile {
86public:
88 int idx;
89
92
95
97 cBspPlane_t* planes; /* numplanes + 12 for box hull */
98
100 cBspNode_t* nodes; /* numnodes + 6 for box hull */
101
105
107 unsigned short* leafbrushes;
108
111
114
115 /* tracing box */
120
121 /* line tracing */
124 intptr_t thead[LEVEL_MAX];
126
129
132
135
137 inline void getTileBox(AABB& box) {
138 const vec3_t halfBox = {UNIT_SIZE / 2, UNIT_SIZE / 2, UNIT_HEIGHT / 2};
139 PosToVec(wpMins, box.mins);
140 VectorSubtract(box.mins, halfBox, box.mins);
141 PosToVec(wpMaxs, box.maxs);
142 VectorAdd(box.maxs, halfBox, box.maxs);
143 }
144};
145
196typedef struct routing_s {
201
202 inline void setStepup (const int x, const int y, const int z, const int dir, const int val) {
203 _stepup[z][y][x][dir] = val;
204 }
205 inline byte getStepup (const int x, const int y, const int z, const int dir) const {
206 return _stepup[z][y][x][dir];
207 }
208
209 inline void setConn (const int x, const int y, const int z, const int dir, const int val) {
210 _route[z][y][x][dir] = val;
211 }
212 inline byte getConn (const int x, const int y, const int z, const int dir) const {
213 return _route[z][y][x][dir];
214 }
215
216 inline void setCeiling (const int x, const int y, const int z, const int val) {
217 _ceil[z][y][x] = val;
218 }
219 inline byte getCeiling (const int x, const int y, const int z) const {
220 return _ceil[z][y][x];
221 }
222 inline byte getCeiling (const pos3_t pos) const {
223 return getCeiling(pos[0], pos[1], pos[2]);
224 }
225
226 inline void setFloor (const int x, const int y, const int z, const int val) {
227 _floor[z][y][x] = val;
228 }
229 inline signed char getFloor (const int x, const int y, const int z) const {
230 return _floor[z][y][x];
231 }
232 inline signed char getFloor (const pos3_t pos) const {
233 return getFloor(pos[0], pos[1], pos[2]);
234 }
235} routing_t;
236
243/* A special bit mask indicating that the stepup causes the actor to rise a cell. */
244#define PATHFINDING_BIG_STEPUP 0x80
245/* A special bit mask indicating that the stepup causes the actor to walk down a cell. */
246#define PATHFINDING_BIG_STEPDOWN 0x40
247
249{
251public:
252
254 init();
255 }
256 inline void init () {
258 }
259 inline void setFloor (const int actorSize, const int x, const int y, const int z, const int val) {
260 routes[actorSize - 1].setFloor(x, y, z, val);
261 }
262 inline signed char getFloor (const actorSizeEnum_t actorSize, const pos3_t pos) const {
263 return routes[actorSize - 1].getFloor(pos);
264 }
265 inline signed char getFloor (const actorSizeEnum_t actorSize, const int x, const int y, const int z) const {
266 return routes[actorSize - 1].getFloor(x, y, z);
267 }
268
269 inline void setCeiling (const actorSizeEnum_t actorSize, const int x, const int y, const int z, const int val) {
270 routes[actorSize - 1].setCeiling(x, y, z, val);
271 }
272 inline byte getCeiling (const int actorSize, const pos3_t pos) const {
273 return routes[actorSize - 1].getCeiling(pos);
274 }
275 inline byte getCeiling (const int actorSize, const int x, const int y, const int z) const {
276 return routes[actorSize - 1].getCeiling(x, y, z);
277 }
278
279 inline void setFilled (const actorSizeEnum_t actorSize, const int x, const int y, const int lowZ, const int highZ)
280 {
281 int i;
282 for (i = lowZ; i <= highZ; i++) {
283 routes[actorSize - 1].setFloor(x, y, i, CELL_HEIGHT); /* There is no floor in this cell. */
284 routes[actorSize - 1].setCeiling(x, y, i, 0); /* There is no ceiling, the true indicator of a filled cell. */
285 }
286 }
287
288 inline void setConn (const int actorSize, const int x, const int y, const int z, const int dir, const int val) {
289 routes[actorSize - 1].setConn(x, y, z, dir, val);
290 }
291 inline byte getConn (const int actorSize, const int x, const int y, const int z, const int dir) const {
292 return routes[actorSize - 1].getConn(x, y, z, dir);
293 }
294 inline byte getConn (const actorSizeEnum_t actorSize, const pos3_t pos, const int dir) const {
295 return routes[actorSize - 1].getConn(pos[0], pos[1], pos[2], dir);
296 }
297
298 inline void setStepup (const int actorSize, const int x, const int y, const int z, const int dir, const int val) {
299 routes[actorSize - 1].setStepup(x, y, z, dir, val);
300 }
301 inline byte getStepup (const int actorSize, const int x, const int y, const int z, const int dir) const {
302 return routes[actorSize - 1].getStepup(x, y, z, dir);
303 }
305 inline byte getStepupHeight (const int actorSize, const int x, const int y, const int z, const int dir) const {
306 return routes[actorSize - 1].getStepup(x, y, z, dir) & ~(PATHFINDING_BIG_STEPDOWN | PATHFINDING_BIG_STEPUP);
307 }
308 inline byte isStepDownLevel (const actorSizeEnum_t actorSize, const pos3_t pos, const int dir) const {
309 return routes[actorSize - 1].getStepup(pos[0], pos[1], pos[2], dir) & PATHFINDING_BIG_STEPDOWN;
310 }
311 inline byte isStepUpLevel (const actorSizeEnum_t actorSize, const pos3_t pos, const int dir) const {
312 return routes[actorSize - 1].getStepup(pos[0], pos[1], pos[2], dir) & PATHFINDING_BIG_STEPUP;
313 }
314
317 inline void copyPosData (const Routing& other, actorSizeEnum_t actorSize, const int x, const int y, const int z, const int sX, const int sY, const int sZ)
318 {
319 setFloor(actorSize, x, y, z, other.getFloor(actorSize, x - sX, y - sY, z - sZ));
320 setCeiling(actorSize, x, y, z, other.getCeiling(actorSize, x - sX, y - sY, z - sZ));
321 int dir;
322 for (dir = 0; dir < CORE_DIRECTIONS; dir++) {
323 setConn(actorSize, x, y, z, dir, other.getConn(actorSize, x - sX, y - sY, z - sZ, dir));
324 setStepup(actorSize, x, y, z, dir, other.getStepup(actorSize, x - sX, y - sY, z - sZ, dir));
325 }
326 }
327};
328
329typedef struct mapData_s {
331 char mapEntityString[MAX_MAP_ENTSTRING];
332
335
336 unsigned mapChecksum;
337
342
352} mapData_t;
353
354typedef struct {
357 int32_t headnode;
358 int firstface, numfaces;
360
361typedef struct {
362 float point[3];
364
365typedef struct {
368
372typedef struct {
374 float dist;
375 int type;
377
378typedef struct {
379 int32_t planenum;
380 int32_t children[2];
381 short mins[3];
382 short maxs[3];
383 unsigned short firstface;
384 unsigned short numfaces;
385} dBspNode_t;
386
388typedef struct texinfo_s {
389 float vecs[2][4];
390 uint32_t surfaceFlags;
391 uint32_t value;
392 char texture[32];
394
399typedef struct {
400 unsigned short v[2];
401} dBspEdge_t;
402
403typedef struct {
404 uint16_t planenum;
405 short side;
406
408 short numedges;
409 short texinfo;
412 int lightofs[LIGHTMAP_MAX];
414
416typedef struct {
417 uint32_t contentFlags;
419 short area;
420
421 short mins[3];
422 short maxs[3];
426} dBspLeaf_t;
427
428typedef struct {
429 uint16_t planenum;
431 short texinfo;
433
434typedef struct {
439
440typedef struct {
441 /* tracing box */
446
447 /* line tracing */
450 int thead[LEVEL_MAX];
451 int theadlevel[LEVEL_MAX];
452
453 /* Used by TR_TileBoxTrace */
456
457 /* ---- */
459 char entdata[MAX_MAP_ENTSTRING];
460
462 byte routedata[MAX_MAP_ROUTING];
463
464 int lightdatasize[LIGHTMAP_MAX];
466
469
473
476
479
482
485
488
491
494
496 unsigned short leafbrushes[MAX_MAP_LEAFBRUSHES];
497
506 int surfedges[MAX_MAP_SURFEDGES];
507
511
514} dMapTile_t;
side_t brushsides[MAX_MAP_SIDES]
Definition: map.cpp:37
Definition: aabb.h:42
vec3_t maxs
Definition: aabb.h:258
vec3_t mins
Definition: aabb.h:257
Stores the data of a map tile, mostly the BSP stuff.
Definition: typedefs.h:85
int numbrushes
Definition: typedefs.h:112
cBspPlane_t * planes
Definition: typedefs.h:97
int numcheads
Definition: typedefs.h:127
int box_headnode
Definition: typedefs.h:117
cBspModel_t * models
Definition: typedefs.h:110
int numtexinfo
Definition: typedefs.h:93
int emptyleaf
Definition: typedefs.h:104
char name[MAX_QPATH]
Definition: typedefs.h:87
int numleafs
Definition: typedefs.h:102
int numtheads
Definition: typedefs.h:123
int idx
Definition: typedefs.h:88
int numbrushsides
Definition: typedefs.h:90
byte * lightdata
Definition: typedefs.h:134
int numleafbrushes
Definition: typedefs.h:106
cBspHead_t cheads[MAX_MAP_NODES]
Definition: typedefs.h:128
cBspBrush_t * box_brush
Definition: typedefs.h:118
cBspNode_t * nodes
Definition: typedefs.h:100
cBspLeaf_t * leafs
Definition: typedefs.h:103
byte lightquant
Definition: typedefs.h:133
int theadlevel[LEVEL_MAX]
Definition: typedefs.h:125
cBspPlane_t * box_planes
Definition: typedefs.h:116
void getTileBox(AABB &box)
Calculate the bounding box for the tile (in mapunits)
Definition: typedefs.h:137
ipos3_t wpMaxs
Definition: typedefs.h:131
cBspSurface_t * surfaces
Definition: typedefs.h:94
int nummodels
Definition: typedefs.h:109
intptr_t thead[LEVEL_MAX]
Definition: typedefs.h:124
tnode_t * tnodes
Definition: typedefs.h:122
cBspLeaf_t * box_leaf
Definition: typedefs.h:119
int numnodes
Definition: typedefs.h:99
int numplanes
Definition: typedefs.h:96
unsigned short * leafbrushes
Definition: typedefs.h:107
cBspBrushSide_t * brushsides
Definition: typedefs.h:91
cBspBrush_t * brushes
Definition: typedefs.h:113
ipos3_t wpMins
Definition: typedefs.h:130
void setStepup(const int actorSize, const int x, const int y, const int z, const int dir, const int val)
Definition: typedefs.h:298
void setFilled(const actorSizeEnum_t actorSize, const int x, const int y, const int lowZ, const int highZ)
Definition: typedefs.h:279
signed char getFloor(const actorSizeEnum_t actorSize, const int x, const int y, const int z) const
Definition: typedefs.h:265
byte isStepUpLevel(const actorSizeEnum_t actorSize, const pos3_t pos, const int dir) const
Definition: typedefs.h:311
Routing()
Definition: typedefs.h:253
void copyPosData(const Routing &other, actorSizeEnum_t actorSize, const int x, const int y, const int z, const int sX, const int sY, const int sZ)
Definition: typedefs.h:317
byte getStepup(const int actorSize, const int x, const int y, const int z, const int dir) const
Definition: typedefs.h:301
signed char getFloor(const actorSizeEnum_t actorSize, const pos3_t pos) const
Definition: typedefs.h:262
byte getConn(const int actorSize, const int x, const int y, const int z, const int dir) const
Definition: typedefs.h:291
byte isStepDownLevel(const actorSizeEnum_t actorSize, const pos3_t pos, const int dir) const
Definition: typedefs.h:308
void setCeiling(const actorSizeEnum_t actorSize, const int x, const int y, const int z, const int val)
Definition: typedefs.h:269
byte getCeiling(const int actorSize, const int x, const int y, const int z) const
Definition: typedefs.h:275
void init()
Definition: typedefs.h:256
byte getStepupHeight(const int actorSize, const int x, const int y, const int z, const int dir) const
return the value without the flags for z-level change
Definition: typedefs.h:305
byte getConn(const actorSizeEnum_t actorSize, const pos3_t pos, const int dir) const
Definition: typedefs.h:294
routing_t routes[ACTOR_MAX_SIZE]
Definition: typedefs.h:250
byte getCeiling(const int actorSize, const pos3_t pos) const
Definition: typedefs.h:272
void setConn(const int actorSize, const int x, const int y, const int z, const int dir, const int val)
Definition: typedefs.h:288
void setFloor(const int actorSize, const int x, const int y, const int z, const int val)
Definition: typedefs.h:259
Defined CONSTANTS (Macros are elsewhere)
#define MAX_MAP_EDGES
Definition: defines.h:146
#define LEVEL_MAX
Definition: defines.h:353
#define LIGHTMAP_MAX
Definition: defines.h:365
#define MAX_MAP_ROUTING
Definition: defines.h:150
#define MAX_MAP_SURFEDGES
Definition: defines.h:147
#define ACTOR_MAX_SIZE
Definition: defines.h:305
#define MAX_MAP_BRUSHSIDES
Definition: defines.h:141
#define MAX_MAP_LEAFS
Definition: defines.h:142
#define MAX_MAP_MODELS
Definition: defines.h:134
#define MAX_MAP_TEXINFO
Definition: defines.h:138
#define PATHFINDING_WIDTH
absolute max
Definition: defines.h:292
#define MAX_MAP_ENTSTRING
Definition: defines.h:137
#define UNIT_HEIGHT
Definition: defines.h:122
#define CELL_HEIGHT
A cell's height in QUANT sized units.
Definition: defines.h:296
#define MAX_MAP_FACES
Definition: defines.h:144
#define UNIT_SIZE
Definition: defines.h:121
#define MAX_MAP_VERTS
Definition: defines.h:143
#define MAX_MAP_NODES
Definition: defines.h:140
#define MAX_MAP_LIGHTING
Definition: defines.h:148
#define MAX_MAP_LEAFBRUSHES
Definition: defines.h:145
#define MAX_MAP_BRUSHES
Definition: defines.h:135
#define MAX_MAP_PLANES
Definition: defines.h:139
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
Definition: defines.h:294
#define MAX_QPATH
Definition: filesys.h:40
voidpf uLong int origin
Definition: ioapi.h:45
#define PosToVec(p, v)
Pos boundary size is +/- 128 - to get into the positive area we add the possible max negative value a...
Definition: mathlib.h:110
#define CORE_DIRECTIONS
Definition: mathlib.h:88
QGL_EXTERN int GLboolean GLfloat * v
Definition: r_gl.h:120
QGL_EXTERN GLint i
Definition: r_gl.h:113
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
static ipos3_t shift
The shift array is used for random map assemblies (RMA) to shift the mins/maxs and stuff like that.
#define OBJZERO(obj)
Definition: shared.h:178
int checkcount
Definition: typedefs.h:63
int firstbrushside
Definition: typedefs.h:62
uint32_t brushContentFlags
Definition: typedefs.h:60
int numsides
Definition: typedefs.h:61
cBspSurface_t * surface
Definition: typedefs.h:50
cBspPlane_t * plane
Definition: typedefs.h:49
int level
Definition: typedefs.h:79
int cnode
Definition: typedefs.h:78
unsigned short firstleafbrush
Definition: typedefs.h:55
uint32_t contentFlags
Definition: typedefs.h:54
unsigned short numleafbrushes
Definition: typedefs.h:56
int firstface
Definition: typedefs.h:33
int32_t headnode
Definition: typedefs.h:29
vec3_t angles
Definition: typedefs.h:28
AABB cbmBox
Definition: typedefs.h:27
int tile
Definition: typedefs.h:31
vec3_t maxs
Definition: typedefs.h:44
cBspPlane_t * plane
Definition: typedefs.h:43
plane_t structure
Definition: typedefs.h:20
byte type
Definition: typedefs.h:23
float dist
Definition: typedefs.h:22
vec3_t normal
Definition: typedefs.h:21
uint32_t surfaceFlags
Definition: typedefs.h:39
int numsides
Definition: typedefs.h:436
int firstbrushside
Definition: typedefs.h:435
uint32_t brushContentFlags
Definition: typedefs.h:437
uint16_t planenum
Definition: typedefs.h:429
convex region of space in the BSP tree
Definition: typedefs.h:416
short area
Definition: typedefs.h:419
uint16_t numleafbrushes
Definition: typedefs.h:425
uint32_t contentFlags
Definition: typedefs.h:417
uint16_t firstleafbrush
Definition: typedefs.h:424
int32_t headnode
Definition: typedefs.h:357
int firstface
Definition: typedefs.h:358
vec3_t origin
Definition: typedefs.h:356
AABB dbmBox
Definition: typedefs.h:355
int32_t planenum
Definition: typedefs.h:379
unsigned short numfaces
Definition: typedefs.h:384
unsigned short firstface
Definition: typedefs.h:383
vec3_t normal
Definition: typedefs.h:366
vec3_t normal
Definition: typedefs.h:373
float dist
Definition: typedefs.h:374
short texinfo
Definition: typedefs.h:409
short numedges
Definition: typedefs.h:408
short side
Definition: typedefs.h:405
uint16_t planenum
Definition: typedefs.h:404
uint32_t surfaceFlags
Definition: typedefs.h:390
uint32_t value
Definition: typedefs.h:391
int routedatasize
Definition: typedefs.h:461
int numbrushsides
Definition: typedefs.h:512
int entdatasize
Definition: typedefs.h:458
int numfaces
Definition: typedefs.h:489
int box_headnode
Definition: typedefs.h:443
int numtexinfo
Definition: typedefs.h:486
int numcheads
Definition: typedefs.h:454
int numedges
Definition: typedefs.h:492
tnode_t * tnodes
Definition: typedefs.h:448
int numsurfedges
Definition: typedefs.h:505
int numbrushes
Definition: typedefs.h:508
int nummodels
Definition: typedefs.h:467
int numtheads
Definition: typedefs.h:449
int emptyleaf
Definition: typedefs.h:472
dBspLeaf_t * box_leaf
Definition: typedefs.h:445
int numleafbrushes
Definition: typedefs.h:495
int numnormals
Definition: typedefs.h:477
int numvertexes
Definition: typedefs.h:480
int numplanes
Definition: typedefs.h:474
int numleafs
Definition: typedefs.h:470
int numnodes
Definition: typedefs.h:483
dBspPlane_t * box_planes
Definition: typedefs.h:442
dBspBrush_t * box_brush
Definition: typedefs.h:444
Routing routing
Definition: typedefs.h:341
int numInline
Definition: typedefs.h:334
unsigned mapChecksum
Definition: typedefs.h:336
AABB mapBox
Definition: typedefs.h:351
Pathfinding routing structure and tile layout.
Definition: typedefs.h:196
signed char getFloor(const pos3_t pos) const
Definition: typedefs.h:232
signed char getFloor(const int x, const int y, const int z) const
Definition: typedefs.h:229
void setCeiling(const int x, const int y, const int z, const int val)
Definition: typedefs.h:216
void setStepup(const int x, const int y, const int z, const int dir, const int val)
Definition: typedefs.h:202
void setFloor(const int x, const int y, const int z, const int val)
Definition: typedefs.h:226
void setConn(const int x, const int y, const int z, const int dir, const int val)
Definition: typedefs.h:209
byte getConn(const int x, const int y, const int z, const int dir) const
Definition: typedefs.h:212
byte getStepup(const int x, const int y, const int z, const int dir) const
Definition: typedefs.h:205
byte getCeiling(const pos3_t pos) const
Definition: typedefs.h:222
byte getCeiling(const int x, const int y, const int z) const
Definition: typedefs.h:219
Data for line tracing (?)
Definition: typedefs.h:69
int pad
Definition: typedefs.h:74
int type
Definition: typedefs.h:70
float dist
Definition: typedefs.h:72
vec3_t normal
Definition: typedefs.h:71
#define PATHFINDING_BIG_STEPUP
The home of the routing tables.
Definition: typedefs.h:244
#define PATHFINDING_BIG_STEPDOWN
Definition: typedefs.h:246
pos_t pos3_t[3]
Definition: ufotypes.h:58
vec_t vec3_t[3]
Definition: ufotypes.h:39
ipos_t ipos3_t[3]
Definition: ufotypes.h:70
int32_t actorSizeEnum_t
Definition: ufotypes.h:77
#define VectorSubtract(a, b, dest)
Definition: vector.h:45
#define VectorAdd(a, b, dest)
Definition: vector.h:47