UFO: Alien Invasion
Doxygen documentation generating
tracing.h
Go to the documentation of this file.
1 
6 /*
7 All original material Copyright (C) 2002-2023 UFO: Alien Invasion.
8 
9 Copyright (C) 1997-2001 Id Software, Inc.
10 
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License
13 as published by the Free Software Foundation; either version 2
14 of the License, or (at your option) any later version.
15 
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 
20 See the GNU General Public License for more details.
21 
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 
26 */
27 
28 #pragma once
29 
30 #include "../shared/typedefs.h"
31 
32 /*
33  * ufo2map and ufo have a different view on the data in the bsp tree,
34  * so they use different structs and classes.
35  */
36 #if defined(COMPILE_MAP)
37  #define TR_TILE_TYPE dMapTile_t
38  #define TR_PLANE_TYPE dBspPlane_t
39 #elif defined(COMPILE_UFO)
40  #define TR_TILE_TYPE MapTile
41  #define TR_PLANE_TYPE cBspPlane_t
42 #else
43  #error Either COMPILE_MAP or COMPILE_UFO must be defined in order for tracing.c to work.
44 #endif
45 
50 #define TRACE_VISIBLE_LEVELS 0x0FF
51 #define TRACE_CLIP_LEVELS 0x100
52 #define TRACE_ALL_LEVELS 0x1FF
53 
55 typedef struct trace_s {
56  bool allsolid;
57  bool startsolid;
58  float fraction;
60  TR_PLANE_TYPE plane;
62  int planenum;
63  uint32_t contentFlags;
64  int32_t leafnum;
65  int mapTile;
66  struct le_s* le;
67  int entNum;
69  inline trace_s () {
70  init();
71  }
72  inline void init() {
73  OBJZERO(*this);
74  }
75 } trace_t;
76 
77 typedef struct mapTiles_s {
79  TR_TILE_TYPE mapTiles[MAX_MAPTILES];
80 
82  int numTiles;
83 
84  void getTilesAt(int x ,int y, byte& fromTile1, byte& fromTile2, byte& fromTile3);
85  void getTileOverlap(const byte tile1, const byte tile2, int& minZ, int& maxZ);
86  void printTilesAt(int x ,int y);
87 } mapTiles_t;
88 
89 /*==============================================================
90 BOX AND LINE TRACING
91 ==============================================================*/
92 
93 /* This attempts to make the box tracing code thread safe. */
94 typedef struct boxtrace_s {
95  vec3_t start, end;
96  vec3_t mins, maxs;
97  vec3_t absmins, absmaxs;
100 
102  uint32_t contents;
103  uint32_t rejects;
104  bool ispoint; /* optimized case */
105 
106  TR_TILE_TYPE* tile;
108  void init (TR_TILE_TYPE* _tile, const int contentmask, const int brushreject, const float fraction);
109  void setLineAndBox(const Line& line, const AABB& box);
110 } boxtrace_t;
111 
112 int TR_BoxOnPlaneSide(const vec3_t mins, const vec3_t maxs, const TR_PLANE_TYPE* plane);
113 
114 void TR_BuildTracingNode_r(TR_TILE_TYPE* tile, tnode_t** tnode, int32_t nodenum, int level);
115 
116 #ifdef COMPILE_MAP
117 trace_t TR_SingleTileBoxTrace(mapTiles_t* mapTiles, const Line& traceLine, const AABB* traceBox, const int levelmask, const int brushmask, const int brushreject);
118 #endif
119 int TR_TestLine_r(TR_TILE_TYPE* tile, int32_t nodenum, const vec3_t start, const vec3_t end);
120 trace_t TR_BoxTrace(boxtrace_t& traceData, const Line& traceLine, const AABB& traceBox, const int headnode, const float fraction);
121 
122 bool TR_TestLine(mapTiles_t* mapTiles, const vec3_t start, const vec3_t end, const int levelmask);
123 bool TR_TestLineDM(mapTiles_t* mapTiles, const vec3_t start, const vec3_t end, vec3_t hit, const int levelmask);
124 trace_t TR_TileBoxTrace(TR_TILE_TYPE* myTile, const Line& traceLine, const AABB& aabb, const int levelmask, const int brushmask, const int brushreject);
trace_s()
Definition: tracing.h:69
Data for line tracing (?)
Definition: typedefs.h:69
vec3_t extents
Definition: tracing.h:98
bool TR_TestLineDM(mapTiles_t *mapTiles, const vec3_t start, const vec3_t end, vec3_t hit, const int levelmask)
Checks traces against the world, gives hit position back.
Definition: tracing.cpp:458
vec3_t offset
Definition: tracing.h:99
trace_t trace
Definition: tracing.h:101
uint32_t contentFlags
Definition: tracing.h:63
vec3_t endpos
Definition: tracing.h:59
void TR_BuildTracingNode_r(TR_TILE_TYPE *tile, tnode_t **tnode, int32_t nodenum, int level)
Definition: tracing.cpp:122
Definition: line.h:31
vec3_t start
Definition: tracing.h:95
TR_TILE_TYPE * tile
Definition: tracing.h:106
bool startsolid
Definition: tracing.h:57
bool allsolid
Definition: tracing.h:56
uint32_t rejects
Definition: tracing.h:103
uint32_t contents
Definition: tracing.h:102
int entNum
Definition: tracing.h:67
struct le_s * le
Definition: tracing.h:66
#define OBJZERO(obj)
Definition: shared.h:178
int TR_TestLine_r(TR_TILE_TYPE *tile, int32_t nodenum, const vec3_t start, const vec3_t end)
Definition: tracing.cpp:209
vec3_t absmins
Definition: tracing.h:97
int mapTile
Definition: tracing.h:65
Definition: aabb.h:42
void init()
Definition: tracing.h:72
trace_t TR_BoxTrace(boxtrace_t &traceData, const Line &traceLine, const AABB &traceBox, const int headnode, const float fraction)
This function traces a line from start to end. It returns a trace_t indicating what portion of the li...
Definition: tracing.cpp:1003
float fraction
Definition: tracing.h:58
bool TR_TestLine(mapTiles_t *mapTiles, const vec3_t start, const vec3_t end, const int levelmask)
Checks traces against the world.
Definition: tracing.cpp:310
vec3_t mins
Definition: tracing.h:96
int TR_BoxOnPlaneSide(const vec3_t mins, const vec3_t maxs, const TR_PLANE_TYPE *plane)
Returns PSIDE_FRONT, PSIDE_BACK, or PSIDE_BOTH.
Definition: tracing.cpp:542
trace_t TR_TileBoxTrace(TR_TILE_TYPE *myTile, const Line &traceLine, const AABB &aabb, const int levelmask, const int brushmask, const int brushreject)
Traces all submodels in the specified tile. Provides for a short circuit if the trace tries to move p...
Definition: tracing.cpp:1067
bool ispoint
Definition: tracing.h:104
vec_t vec3_t[3]
Definition: ufotypes.h:39
int planenum
Definition: tracing.h:62
cBspSurface_t * surface
Definition: tracing.h:61
int numTiles
Definition: tracing.h:82
uint8_t byte
Definition: ufotypes.h:34
static mapTiles_t mapTiles
level_locals_t level
Definition: g_main.cpp:38
int32_t leafnum
Definition: tracing.h:64
TR_PLANE_TYPE plane
Definition: tracing.h:60