UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tracing.h File Reference

Tracing functions. More...

Go to the source code of this file.

Data Structures

struct  trace_s
 
struct  mapTiles_s
 
struct  boxtrace_s
 

Macros

#define TRACE_VISIBLE_LEVELS   0x0FF
 
#define TRACE_CLIP_LEVELS   0x100
 
#define TRACE_ALL_LEVELS   0x1FF
 

Typedefs

typedef struct trace_s trace_t
 
typedef struct mapTiles_s mapTiles_t
 
typedef struct boxtrace_s boxtrace_t
 

Functions

int TR_BoxOnPlaneSide (const vec3_t mins, const vec3_t maxs, const TR_PLANE_TYPE *plane)
 Returns PSIDE_FRONT, PSIDE_BACK, or PSIDE_BOTH. More...
 
void TR_BuildTracingNode_r (TR_TILE_TYPE *tile, tnode_t **tnode, int32_t nodenum, int level)
 
int TR_TestLine_r (TR_TILE_TYPE *tile, int32_t nodenum, const vec3_t start, const vec3_t end)
 
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 line can be traveled from start to end before hitting a brush that meets the criteria in brushmask. The point that this line intersects that brush is also returned. There is a special case when start and end are the same vector. In this case, the bounding box formed by mins and maxs offset from start is examined for any brushes that meet the criteria. The first brush found inside the bounding box is returned. There is another special case when mins and maxs are both origin vectors (0, 0, 0). In this case, the. More...
 
bool TR_TestLine (mapTiles_t *mapTiles, const vec3_t start, const vec3_t end, const int levelmask)
 Checks traces against the world. More...
 
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. More...
 
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 past fraction to save time. More...
 

Detailed Description

Tracing functions.

Definition in file tracing.h.

Macro Definition Documentation

#define TRACE_ALL_LEVELS   0x1FF

Definition at line 52 of file tracing.h.

Referenced by G_TraceDraw(), R_Trace(), SV_PointContents(), and SV_Trace().

#define TRACE_CLIP_LEVELS   0x100

Definition at line 51 of file tracing.h.

#define TRACE_VISIBLE_LEVELS   0x0FF
Note
all the above types are declared in typedefs.h mask to trace against all the different visible levels (1-8) (resp. (1<<[0-7])

Definition at line 50 of file tracing.h.

Referenced by RT_GetMapSize().

Typedef Documentation

typedef struct boxtrace_s boxtrace_t
typedef struct mapTiles_s mapTiles_t
typedef struct trace_s trace_t

a trace is returned when a box is swept through the world

Function Documentation

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 at line 542 of file tracing.cpp.

References AXIAL, DotProduct, i, PLANESIDE_EPSILON, PSIDE_BACK, and PSIDE_FRONT.

Referenced by R_CullBox(), TestBrushToPlanenum(), and TR_BoxLeafnums_r().

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 line can be traveled from start to end before hitting a brush that meets the criteria in brushmask. The point that this line intersects that brush is also returned. There is a special case when start and end are the same vector. In this case, the bounding box formed by mins and maxs offset from start is examined for any brushes that meet the criteria. The first brush found inside the bounding box is returned. There is another special case when mins and maxs are both origin vectors (0, 0, 0). In this case, the.

Parameters
[in]traceDataAll parameters of the trace; also stores some intermediate results
[in]traceLineThe trace start and end vector
[in]traceBoxThe box we shove through the world
[in]headnodeif < 0 we are in a leaf node
[in]fractionThe furthest distance needed to trace before we stop.
Todo:
Would Interpolating traceData.end to traceData.fraction and passing traceData.fraction instead of 1.0 make this faster?

Definition at line 1003 of file tracing.cpp.

References boxtrace_s::absmaxs, boxtrace_s::absmins, trace_s::allsolid, checkcount, Com_Error(), boxtrace_s::end, trace_s::endpos, ERR_DROP, boxtrace_s::extents, f, trace_s::fraction, i, boxtrace_s::ispoint, MAX_LEAFS, boxtrace_s::maxs, boxtrace_s::mins, boxtrace_s::offset, Line::start, boxtrace_s::start, boxtrace_s::tile, TR_BoxLeafnums_headnode(), TR_RecursiveHullCheck(), TR_TestInLeaf(), boxtrace_s::trace, VectorAdd, VectorClear, VectorCopy, VectorEmpty, VectorEqual, VectorInterpolation, and VectorSubtract.

Referenced by CM_HintedTransformedBoxTrace(), and TR_TileBoxTrace().

void TR_BuildTracingNode_r ( TR_TILE_TYPE *  tile,
tnode_t **  tnode,
int32_t  nodenum,
int  level 
)
See also
CMod_LoadNodes
R_ModLoadNodes

We are checking for a leaf in the tracing node. For ufo2map, planenum == PLANENUMLEAF. For the game, plane will be nullptr.

Definition at line 122 of file tracing.cpp.

References tnode_s::children, Com_Error(), Com_Printf(), tnode_s::dist, ERR_DROP, i, level, MAX_MAP_NODES, tnode_s::normal, PLANE_NONE, PLANENUM_LEAF, Sys_Error(), TR_BuildTracingNode_r(), TR_MakeTracingNode(), tnode_s::type, VectorCopy, and VectorSet.

Referenced by CM_MakeTracingNodes(), MakeTracingNodes(), and TR_BuildTracingNode_r().

bool TR_TestLine ( mapTiles_t mapTiles,
const vec3_t  start,
const vec3_t  end,
const int  levelmask 
)

Checks traces against the world.

Parameters
[in]mapTilesList of tiles the current (RMA-)map is composed of
[in]startThe position to start the trace.
[in]endThe position where the trace ends.
[in]levelmaskIndicates which special levels, if any, to include in the trace.
Note
Special levels are LEVEL_ACTORCLIP and LEVEL_WEAPONCLIP.
See also
TR_TestLine_r
Returns
false if not blocked

Definition at line 310 of file tracing.cpp.

References mapTiles_s::mapTiles, mapTiles_s::numTiles, and TR_TileTestLine().

Referenced by CL_TestLine(), CM_EntTestLine(), and SV_TestLine().

int TR_TestLine_r ( TR_TILE_TYPE *  tile,
int32_t  nodenum,
const vec3_t  start,
const vec3_t  end 
)
Parameters
[in]tileThe map tile containing the structures to be traced.
[in]nodenumNode index
[in]startThe position to start the trace.
[in]endThe position where the trace ends.
Returns
zero if the line is not blocked, else a positive value
See also
TR_TestLineDist_r
CM_TestLine

Definition at line 209 of file tracing.cpp.

References tnode_s::children, tnode_s::dist, DotProduct, tnode_s::normal, ON_EPSILON, PLANE_NONE, PLANE_X, PLANE_Y, PLANE_Z, TR_TestLine_r(), tnode_s::type, and VectorInterpolation.

Referenced by TR_TestLine_r(), TR_TestLineSingleTile(), and TR_TileTestLine().

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.

Parameters
[in]mapTilesList of tiles the current (RMA-)map is composed of
[in]startThe position to start the trace.
[in]endThe position where the trace ends.
[out]hitThe position where the trace hits a object or the 'end' position if nothing is in the line.
[in]levelmaskIndicates which special levels, if any, to include in the trace.
See also
TR_TestLineDM
CL_ActorMouseTrace
Returns
false if no connection between start and end - 1 otherwise

Definition at line 458 of file tracing.cpp.

References EQUAL_EPSILON, mapTiles_s::mapTiles, mapTiles_s::numTiles, TR_TileTestLineDM(), VectorCompareEps(), VectorCopy, and VectorNearer().

Referenced by CM_EntTestLineDM().

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 past fraction to save time.

Parameters
[in]myTileThe tile being traced
[in]traceLineThe trace start and end vectors
[in]aabbThe box we are moving through the world
[in]levelmaskSelects which submodels get scanned.
[in]brushmaskbrushes the trace should stop at (see MASK_*)
[in]brushrejectbrushes the trace should ignore (see MASK_*)

Definition at line 1067 of file tracing.cpp.

References chead_s::cnode, trace_s::fraction, i, boxtrace_s::init(), chead_s::level, LEVEL_LASTVISIBLE, boxtrace_s::setLineAndBox(), tr, and TR_BoxTrace().

Referenced by CM_CompleteBoxTrace().