| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
#include "q_shared.h" |
| 24 |
#include "qcommon.h" |
| 25 |
#include "cm_polylib.h" |
| 26 |
|
| 27 |
#define MAX_SUBMODELS 256 |
| 28 |
#define BOX_MODEL_HANDLE 255 |
| 29 |
#define CAPSULE_MODEL_HANDLE 254 |
| 30 |
|
| 31 |
|
| 32 |
typedef struct { |
| 33 |
cplane_t *plane; |
| 34 |
int children[2]; |
| 35 |
} cNode_t; |
| 36 |
|
| 37 |
typedef struct { |
| 38 |
int cluster; |
| 39 |
int area; |
| 40 |
|
| 41 |
int firstLeafBrush; |
| 42 |
int numLeafBrushes; |
| 43 |
|
| 44 |
int firstLeafSurface; |
| 45 |
int numLeafSurfaces; |
| 46 |
} cLeaf_t; |
| 47 |
|
| 48 |
typedef struct cmodel_s { |
| 49 |
vec3_t mins, maxs; |
| 50 |
cLeaf_t leaf; |
| 51 |
} cmodel_t; |
| 52 |
|
| 53 |
typedef struct { |
| 54 |
cplane_t *plane; |
| 55 |
int surfaceFlags; |
| 56 |
int shaderNum; |
| 57 |
} cbrushside_t; |
| 58 |
|
| 59 |
typedef struct { |
| 60 |
int shaderNum; |
| 61 |
int contents; |
| 62 |
vec3_t bounds[2]; |
| 63 |
int numsides; |
| 64 |
cbrushside_t *sides; |
| 65 |
int checkcount; |
| 66 |
} cbrush_t; |
| 67 |
|
| 68 |
|
| 69 |
typedef struct { |
| 70 |
int checkcount; |
| 71 |
int surfaceFlags; |
| 72 |
int contents; |
| 73 |
struct patchCollide_s *pc; |
| 74 |
} cPatch_t; |
| 75 |
|
| 76 |
|
| 77 |
typedef struct { |
| 78 |
int floodnum; |
| 79 |
int floodvalid; |
| 80 |
} cArea_t; |
| 81 |
|
| 82 |
typedef struct { |
| 83 |
char name[MAX_QPATH]; |
| 84 |
|
| 85 |
int numShaders; |
| 86 |
dshader_t *shaders; |
| 87 |
|
| 88 |
int numBrushSides; |
| 89 |
cbrushside_t *brushsides; |
| 90 |
|
| 91 |
int numPlanes; |
| 92 |
cplane_t *planes; |
| 93 |
|
| 94 |
int numNodes; |
| 95 |
cNode_t *nodes; |
| 96 |
|
| 97 |
int numLeafs; |
| 98 |
cLeaf_t *leafs; |
| 99 |
|
| 100 |
int numLeafBrushes; |
| 101 |
int *leafbrushes; |
| 102 |
|
| 103 |
int numLeafSurfaces; |
| 104 |
int *leafsurfaces; |
| 105 |
|
| 106 |
int numSubModels; |
| 107 |
cmodel_t *cmodels; |
| 108 |
|
| 109 |
int numBrushes; |
| 110 |
cbrush_t *brushes; |
| 111 |
|
| 112 |
int numClusters; |
| 113 |
int clusterBytes; |
| 114 |
byte *visibility; |
| 115 |
qboolean vised; |
| 116 |
|
| 117 |
int numEntityChars; |
| 118 |
char *entityString; |
| 119 |
|
| 120 |
int numAreas; |
| 121 |
cArea_t *areas; |
| 122 |
int *areaPortals; |
| 123 |
|
| 124 |
int numSurfaces; |
| 125 |
cPatch_t **surfaces; |
| 126 |
|
| 127 |
int floodvalid; |
| 128 |
int checkcount; |
| 129 |
} clipMap_t; |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
#define SURFACE_CLIP_EPSILON (0.125) |
| 135 |
|
| 136 |
extern clipMap_t cm; |
| 137 |
extern int c_pointcontents; |
| 138 |
extern int c_traces, c_brush_traces, c_patch_traces; |
| 139 |
extern cvar_t *cm_noAreas; |
| 140 |
extern cvar_t *cm_noCurves; |
| 141 |
extern cvar_t *cm_playerCurveClip; |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
typedef struct |
| 147 |
{ |
| 148 |
qboolean use; |
| 149 |
float radius; |
| 150 |
float halfheight; |
| 151 |
vec3_t offset; |
| 152 |
} sphere_t; |
| 153 |
|
| 154 |
typedef struct { |
| 155 |
vec3_t start; |
| 156 |
vec3_t end; |
| 157 |
vec3_t size[2]; |
| 158 |
vec3_t offsets[8]; |
| 159 |
float maxOffset; |
| 160 |
vec3_t extents; |
| 161 |
vec3_t bounds[2]; |
| 162 |
vec3_t modelOrigin; |
| 163 |
int contents; |
| 164 |
qboolean isPoint; |
| 165 |
trace_t trace; |
| 166 |
sphere_t sphere; |
| 167 |
} traceWork_t; |
| 168 |
|
| 169 |
typedef struct leafList_s { |
| 170 |
int count; |
| 171 |
int maxcount; |
| 172 |
qboolean overflowed; |
| 173 |
int *list; |
| 174 |
vec3_t bounds[2]; |
| 175 |
int lastLeaf; |
| 176 |
void (*storeLeafs)( struct leafList_s *ll, int nodenum ); |
| 177 |
} leafList_t; |
| 178 |
|
| 179 |
|
| 180 |
int CM_BoxBrushes( const vec3_t mins, const vec3_t maxs, cbrush_t **list, int listsize ); |
| 181 |
|
| 182 |
void CM_StoreLeafs( leafList_t *ll, int nodenum ); |
| 183 |
void CM_StoreBrushes( leafList_t *ll, int nodenum ); |
| 184 |
|
| 185 |
void CM_BoxLeafnums_r( leafList_t *ll, int nodenum ); |
| 186 |
|
| 187 |
cmodel_t *CM_ClipHandleToModel( clipHandle_t handle ); |
| 188 |
qboolean CM_BoundsIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 ); |
| 189 |
qboolean CM_BoundsIntersectPoint( const vec3_t mins, const vec3_t maxs, const vec3_t point ); |
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
struct patchCollide_s *CM_GeneratePatchCollide( int width, int height, vec3_t *points ); |
| 194 |
void CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc ); |
| 195 |
qboolean CM_PositionTestInPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc ); |
| 196 |
void CM_ClearLevelPatches( void ); |