00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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];
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;
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;
00061 int contents;
00062 vec3_t bounds[2];
00063 int numsides;
00064 cbrushside_t *sides;
00065 int checkcount;
00066 } cbrush_t;
00067
00068
00069 typedef struct {
00070 int checkcount;
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;
00116
00117 int numEntityChars;
00118 char *entityString;
00119
00120 int numAreas;
00121 cArea_t *areas;
00122 int *areaPortals;
00123
00124 int numSurfaces;
00125 cPatch_t **surfaces;
00126
00127 int floodvalid;
00128 int checkcount;
00129 } clipMap_t;
00130
00131
00132
00133
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
00144
00145
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];
00158 vec3_t offsets[8];
00159 float maxOffset;
00160 vec3_t extents;
00161 vec3_t bounds[2];
00162 vec3_t modelOrigin;
00163 int contents;
00164 qboolean isPoint;
00165 trace_t trace;
00166 sphere_t sphere;
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;
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
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 );