Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

cm_local.h

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 
00023 #include "../game/q_shared.h"
00024 #include "qcommon.h"
00025 #include "cm_polylib.h"
00026 
00027 #define MAX_SUBMODELS           256
00028 #define BOX_MODEL_HANDLE        255
00029 #define CAPSULE_MODEL_HANDLE    254
00030 
00031 
00032 typedef struct {
00033     cplane_t    *plane;
00034     int         children[2];        // negative numbers are leafs
00035 } cNode_t;
00036 
00037 typedef struct {
00038     int         cluster;
00039     int         area;
00040 
00041     int         firstLeafBrush;
00042     int         numLeafBrushes;
00043 
00044     int         firstLeafSurface;
00045     int         numLeafSurfaces;
00046 } cLeaf_t;
00047 
00048 typedef struct cmodel_s {
00049     vec3_t      mins, maxs;
00050     cLeaf_t     leaf;           // submodels don't reference the main tree
00051 } cmodel_t;
00052 
00053 typedef struct {
00054     cplane_t    *plane;
00055     int         surfaceFlags;
00056     int         shaderNum;
00057 } cbrushside_t;
00058 
00059 typedef struct {
00060     int         shaderNum;      // the shader that determined the contents
00061     int         contents;
00062     vec3_t      bounds[2];
00063     int         numsides;
00064     cbrushside_t    *sides;
00065     int         checkcount;     // to avoid repeated testings
00066 } cbrush_t;
00067 
00068 
00069 typedef struct {
00070     int         checkcount;             // to avoid repeated testings
00071     int         surfaceFlags;
00072     int         contents;
00073     struct patchCollide_s   *pc;
00074 } cPatch_t;
00075 
00076 
00077 typedef struct {
00078     int         floodnum;
00079     int         floodvalid;
00080 } cArea_t;
00081 
00082 typedef struct {
00083     char        name[MAX_QPATH];
00084 
00085     int         numShaders;
00086     dshader_t   *shaders;
00087 
00088     int         numBrushSides;
00089     cbrushside_t *brushsides;
00090 
00091     int         numPlanes;
00092     cplane_t    *planes;
00093 
00094     int         numNodes;
00095     cNode_t     *nodes;
00096 
00097     int         numLeafs;
00098     cLeaf_t     *leafs;
00099 
00100     int         numLeafBrushes;
00101     int         *leafbrushes;
00102 
00103     int         numLeafSurfaces;
00104     int         *leafsurfaces;
00105 
00106     int         numSubModels;
00107     cmodel_t    *cmodels;
00108 
00109     int         numBrushes;
00110     cbrush_t    *brushes;
00111 
00112     int         numClusters;
00113     int         clusterBytes;
00114     byte        *visibility;
00115     qboolean    vised;          // if false, visibility is just a single cluster of ffs
00116 
00117     int         numEntityChars;
00118     char        *entityString;
00119 
00120     int         numAreas;
00121     cArea_t     *areas;
00122     int         *areaPortals;   // [ numAreas*numAreas ] reference counts
00123 
00124     int         numSurfaces;
00125     cPatch_t    **surfaces;         // non-patches will be NULL
00126 
00127     int         floodvalid;
00128     int         checkcount;                 // incremented on each trace
00129 } clipMap_t;
00130 
00131 
00132 // keep 1/8 unit away to keep the position valid before network snapping
00133 // and to avoid various numeric issues
00134 #define SURFACE_CLIP_EPSILON    (0.125)
00135 
00136 extern  clipMap_t   cm;
00137 extern  int         c_pointcontents;
00138 extern  int         c_traces, c_brush_traces, c_patch_traces;
00139 extern  cvar_t      *cm_noAreas;
00140 extern  cvar_t      *cm_noCurves;
00141 extern  cvar_t      *cm_playerCurveClip;
00142 
00143 // cm_test.c
00144 
00145 // Used for oriented capsule collision detection
00146 typedef struct
00147 {
00148     qboolean    use;
00149     float       radius;
00150     float       halfheight;
00151     vec3_t      offset;
00152 } sphere_t;
00153 
00154 typedef struct {
00155     vec3_t      start;
00156     vec3_t      end;
00157     vec3_t      size[2];    // size of the box being swept through the model
00158     vec3_t      offsets[8]; // [signbits][x] = either size[0][x] or size[1][x]
00159     float       maxOffset;  // longest corner length from origin
00160     vec3_t      extents;    // greatest of abs(size[0]) and abs(size[1])
00161     vec3_t      bounds[2];  // enclosing box of start and end surrounding by size
00162     vec3_t      modelOrigin;// origin of the model tracing through
00163     int         contents;   // ored contents of the model tracing through
00164     qboolean    isPoint;    // optimized case
00165     trace_t     trace;      // returned from trace call
00166     sphere_t    sphere;     // sphere for oriendted capsule collision
00167 } traceWork_t;
00168 
00169 typedef struct leafList_s {
00170     int     count;
00171     int     maxcount;
00172     qboolean    overflowed;
00173     int     *list;
00174     vec3_t  bounds[2];
00175     int     lastLeaf;       // for overflows where each leaf can't be stored individually
00176     void    (*storeLeafs)( struct leafList_s *ll, int nodenum );
00177 } leafList_t;
00178 
00179 
00180 int CM_BoxBrushes( const vec3_t mins, const vec3_t maxs, cbrush_t **list, int listsize );
00181 
00182 void CM_StoreLeafs( leafList_t *ll, int nodenum );
00183 void CM_StoreBrushes( leafList_t *ll, int nodenum );
00184 
00185 void CM_BoxLeafnums_r( leafList_t *ll, int nodenum );
00186 
00187 cmodel_t    *CM_ClipHandleToModel( clipHandle_t handle );
00188 
00189 // cm_patch.c
00190 
00191 struct patchCollide_s   *CM_GeneratePatchCollide( int width, int height, vec3_t *points );
00192 void CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );
00193 qboolean CM_PositionTestInPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );
00194 void CM_ClearLevelPatches( void );

Generated on Thu Aug 25 12:37:45 2005 for Quake III Arena by  doxygen 1.3.9.1