tracing.h

Go to the documentation of this file.
00001 
00006 /*
00007 All original material Copyright (C) 2002-2010 UFO: Alien Invasion.
00008 
00009 Copyright (C) 1997-2001 Id Software, Inc.
00010 
00011 This program is free software; you can redistribute it and/or
00012 modify it under the terms of the GNU General Public License
00013 as published by the Free Software Foundation; either version 2
00014 of the License, or (at your option) any later version.
00015 
00016 This program is distributed in the hope that it will be useful,
00017 but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00019 
00020 See the GNU General Public License for more details.
00021 
00022 You should have received a copy of the GNU General Public License
00023 along with this program; if not, write to the Free Software
00024 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00025 
00026 */
00027 
00028 #ifndef COMMON_TRACING_H
00029 #define COMMON_TRACING_H
00030 
00031 
00032 #include "../shared/typedefs.h"
00033 
00034 /*==============================================================
00035 GLOBAL TYPES
00036 ==============================================================*/
00037 #if defined(COMPILE_MAP)
00038   #define TR_TILE_TYPE          dMapTile_t
00039   #define TR_PLANE_TYPE         dBspPlane_t
00040   #define TR_PLANE2_TYPE        plane_t
00041   #define TR_NODE_TYPE          dBspNode_t
00042   #define TR_LEAF_TYPE          dBspLeaf_t
00043   #define TR_BRUSH_TYPE         dBspBrush_t
00044   #define TR_BRUSHSIDE_TYPE     dBspBrushSide_t
00045 #elif defined(COMPILE_UFO)
00046   #define TR_TILE_TYPE          mapTile_t
00047   #define TR_PLANE_TYPE         cBspPlane_t
00048   #define TR_PLANE2_TYPE        cBspPlane_t
00049   #define TR_NODE_TYPE          cBspNode_t
00050   #define TR_LEAF_TYPE          cBspLeaf_t
00051   #define TR_BRUSH_TYPE         cBspBrush_t
00052   #define TR_BRUSHSIDE_TYPE     cBspBrushSide_t
00053 #else
00054   #error Either COMPILE_MAP or COMPILE_UFO must be defined in order for tracing.c to work.
00055 #endif
00056 
00060 #define TRACING_ALL_VISIBLE_LEVELS 0x1FF
00061 
00063 typedef struct trace_s {
00064     qboolean allsolid;          
00065     qboolean startsolid;        
00066     float fraction;             
00067     vec3_t endpos;              
00068     TR_PLANE_TYPE plane;        
00069     cBspSurface_t *surface;     
00070     int planenum;               
00071     int contentFlags;           
00072     int32_t leafnum;
00073     int mapTile;                
00074     struct le_s *le;            
00075     struct edict_s *ent;        
00076 } trace_t;
00077 
00078 /* This attempts to make the box tracing code thread safe. */
00079 typedef struct boxtrace_s {
00080     vec3_t start, end;
00081     vec3_t mins, maxs;
00082     vec3_t absmins, absmaxs;
00083     vec3_t extents;
00084 
00085     trace_t trace;
00086     int contents;
00087     int rejects;
00088     qboolean ispoint;           /* optimized case */
00089 
00090     TR_TILE_TYPE *tile;
00091 } boxtrace_t;
00092 
00093 typedef struct box_s {
00094     vec3_t mins, maxs;
00095 } box_t;
00096 
00097 typedef struct {
00099     TR_TILE_TYPE mapTiles[MAX_MAPTILES];
00100 
00102     int numTiles;
00103 } mapTiles_t;
00104 
00105 /*==============================================================
00106 BOX AND LINE TRACING
00107 ==============================================================*/
00108 
00109 int TR_BoxOnPlaneSide(const vec3_t mins, const vec3_t maxs, const TR_PLANE_TYPE *plane);
00110 
00111 void TR_BuildTracingNode_r(TR_TILE_TYPE *tile, tnode_t **tnode, int32_t nodenum, int level);
00112 
00113 #ifdef COMPILE_MAP
00114 trace_t TR_SingleTileBoxTrace(mapTiles_t *mapTiles, const vec3_t start, const vec3_t end, const box_t* traceBox, const int levelmask, const int brushmask, const int brushreject);
00115 #endif
00116 int TR_TestLine_r(TR_TILE_TYPE *tile, int32_t nodenum, const vec3_t start, const vec3_t stop);
00117 trace_t TR_BoxTrace(TR_TILE_TYPE *tile, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, const int headnode, const int brushmask, const int brushreject, const float fraction);
00118 
00119 qboolean TR_TestLine(mapTiles_t *mapTiles, const vec3_t start, const vec3_t stop, const int levelmask);
00120 qboolean TR_TestLineDM(mapTiles_t* mapTiles, const vec3_t start, const vec3_t stop, vec3_t end, const int levelmask);
00121 trace_t TR_TileBoxTrace(TR_TILE_TYPE *myTile, const vec3_t start, const vec3_t end, const vec3_t mins, const vec3_t maxs, const int levelmask, const int brushmask, const int brushreject);
00122 
00123 #endif /* COMMON_TRACING_H */

Generated by  doxygen 1.6.2