Debian Codegraph @

code/qcommon/cm_local.h

raw symbols SCIP
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
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]; // negative numbers are leafs
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; // submodels don't reference the main tree
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; // the shader that determined the contents
61 int contents;
62 vec3_t bounds[2];
63 int numsides;
64 cbrushside_t *sides;
65 int checkcount; // to avoid repeated testings
66 } cbrush_t;
67
68
69 typedef struct {
70 int checkcount; // to avoid repeated testings
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; // if false, visibility is just a single cluster of ffs
116
117 int numEntityChars;
118 char *entityString;
119
120 int numAreas;
121 cArea_t *areas;
122 int *areaPortals; // [ numAreas*numAreas ] reference counts
123
124 int numSurfaces;
125 cPatch_t **surfaces; // non-patches will be NULL
126
127 int floodvalid;
128 int checkcount; // incremented on each trace
129 } clipMap_t;
130
131
132 // keep 1/8 unit away to keep the position valid before network snapping
133 // and to avoid various numeric issues
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 // cm_test.c
144
145 // Used for oriented capsule collision detection
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]; // size of the box being swept through the model
158 vec3_t offsets[8]; // [signbits][x] = either size[0][x] or size[1][x]
159 float maxOffset; // longest corner length from origin
160 vec3_t extents; // greatest of abs(size[0]) and abs(size[1])
161 vec3_t bounds[2]; // enclosing box of start and end surrounding by size
162 vec3_t modelOrigin;// origin of the model tracing through
163 int contents; // ored contents of the model tracing through
164 qboolean isPoint; // optimized case
165 trace_t trace; // returned from trace call
166 sphere_t sphere; // sphere for oriendted capsule collision
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; // for overflows where each leaf can't be stored individually
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 // cm_patch.c
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 );