OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
cm_local.h
1/*
2===========================================================================
3Copyright (C) 1999-2005 Id Software, Inc.
4
5This file is part of Quake III Arena source code.
6
7Quake III Arena source code is free software; you can redistribute it
8and/or modify it under the terms of the GNU General Public License as
9published by the Free Software Foundation; either version 2 of the License,
10or (at your option) any later version.
11
12Quake III Arena source code is distributed in the hope that it will be
13useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with Quake III Arena source code; if not, write to the Free Software
19Foundation, 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#include "cm_terrain.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#define MAX_SUBMODELS 1024
33#define BOX_MODEL_HANDLE (MAX_SUBMODELS-1)
34#define CAPSULE_MODEL_HANDLE 510
35#define MAX_OBFUSCATIONS 1024
36
37typedef struct {
38 cplane_t *plane;
39 int children[2]; // negative numbers are leafs
40} cNode_t;
41
42typedef struct {
43 int cluster;
44 int area;
45
46 intptr_t firstLeafBrush;
47 int numLeafBrushes;
48
49 intptr_t firstLeafSurface;
50 int numLeafSurfaces;
51
52 //added for mohaa
53 int firstLeafTerrain;
54 int numLeafTerrains;
55} cLeaf_t;
56
57typedef struct cfencemask_s {
58 char name[ 64 ];
59 int iWidth;
60 int iHeight;
61 byte *pData;
62 struct cfencemask_s *pNext;
63} cfencemask_t;
64
65typedef struct {
66 char shader[ 64 ];
67 int surfaceFlags;
68 int contentFlags;
69 cfencemask_t *mask;
70 float obfuscationWidthDensity;
71 float obfuscationHeightDensity;
72} cshader_t;
73
74typedef struct cmodel_s {
75 vec3_t mins, maxs;
76 cLeaf_t leaf; // submodels don't reference the main tree
77} cmodel_t;
78
79typedef struct {
80 cplane_t *plane;
81 int surfaceFlags;
82 int shaderNum;
83
84 dsideequation_t *pEq;
86
87typedef struct {
88 int shaderNum; // the shader that determined the contents
89 int contents;
90 vec3_t bounds[2];
91 int numsides;
92 cbrushside_t *sides;
93 int checkcount; // to avoid repeated testings
94} cbrush_t;
95
96
97typedef struct {
98 int checkcount; // to avoid repeated testings
99 int surfaceFlags;
100 int contents;
101
102 int shaderNum;
103 int subdivisions;
104
105 struct patchCollide_s *pc;
106} cPatch_t;
107
108typedef struct {
109 int checkcount;
110 int surfaceFlags;
111 int contents;
112 int shaderNum;
114} cTerrain_t;
115
116typedef struct {
117 int floodnum;
118 int floodvalid;
119} cArea_t;
120
121// IneQuation
122typedef struct {
123 int checkcount; // to avoid repeated testings
124
125 struct terPatchCollide_s *tc;
127
128typedef struct {
129 char name[ MAX_QPATH ];
130
131 int numShaders;
132 cfencemask_t *fencemasks;
133 cshader_t *shaders;
134
135 int numSideEquations;
136 dsideequation_t *sideequations;
137
138 int numBrushSides;
139 cbrushside_t *brushsides;
140
141 int numPlanes;
142 cplane_t *planes;
143
144 int numNodes;
145 cNode_t *nodes;
146
147 int numLeafs;
148 cLeaf_t *leafs;
149
150 int numLeafBrushes;
151 int *leafbrushes;
152
153 int numLeafSurfaces;
154 int *leafsurfaces;
155
156 int numLeafTerrains;
157 cTerrain_t **leafterrains;
158
159 int numSubModels;
160 cmodel_t *cmodels;
161
162 int numBrushes;
163 cbrush_t *brushes;
164
165 int numClusters;
166 int clusterBytes;
167 byte *visibility;
168 qboolean vised; // if false, visibility is just a single cluster of ffs
169
170 int numEntityChars;
171 char *entityString;
172
173 int numAreas;
174 cArea_t *areas;
175 int *areaPortals; // [ numAreas*numAreas ] reference counts
176
177 int numSurfaces;
178 cPatch_t **surfaces; // non-patches will be NULL
179
180 // IneQuation
181 int numTerrain;
182 cTerrain_t *terrain;
183
184 int floodvalid;
185 int checkcount; // incremented on each trace
186} clipMap_t;
187
188
189// keep 1/8 unit away to keep the position valid before network snapping
190// and to avoid various numeric issues
191#define SURFACE_CLIP_EPSILON (0.125)
192
193// cm_test.c
194
195// Used for oriented capsule collision detection
196typedef struct
197{
198 qboolean use;
199 float radius;
200 vec3_t offset;
201} sphere_t;
202
203typedef struct {
204 vec3_t start;
205 vec3_t end;
206 vec3_t size[2]; // size of the box being swept through the model
207 vec3_t offsets[8]; // [signbits][x] = either size[0][x] or size[1][x]
208 float maxOffset; // longest corner length from origin
209 vec3_t extents; // greatest of abs(size[0]) and abs(size[1])
210 vec3_t bounds[2]; // enclosing box of start and end surrounding by size
211 float height;
212 float radius;
213 int contents; // ored contents of the model tracing through
214 qboolean isPoint; // optimized case
215 trace_t trace; // returned from trace call
217
218typedef struct leafList_s {
219 int count;
220 int maxcount;
221 qboolean overflowed;
222 int *list;
223 vec3_t bounds[2];
224 int lastLeaf; // for overflows where each leaf can't be stored individually
225 void (*storeLeafs)( struct leafList_s *ll, int nodenum );
226} leafList_t;
227
228typedef struct {
229 char name[MAX_QPATH];
230 float widthDensity;
231 float heightDensity;
233
234extern clipMap_t cm;
235extern int c_pointcontents;
236extern int c_traces, c_brush_traces, c_patch_traces, c_terrain_patch_traces;
237extern cvar_t *cm_noAreas;
238extern cvar_t *cm_noCurves;
239extern cvar_t *cm_playerCurveClip;
240extern cvar_t *cm_FCMcacheall;
241extern cvar_t *cm_FCMdebug;
242extern cvar_t *cm_ter_usesphere;
243extern sphere_t sphere;
244
245
246int CM_BoxBrushes( const vec3_t mins, const vec3_t maxs, cbrush_t **list, int listsize );
247
248void CM_StoreLeafs( leafList_t *ll, int nodenum );
249void CM_StoreBrushes( leafList_t *ll, int nodenum );
250
251void CM_BoxLeafnums_r( leafList_t *ll, int nodenum );
252
253cmodel_t *CM_ClipHandleToModel( clipHandle_t handle );
254qboolean CM_BoundsIntersect( const vec3_t mins, const vec3_t maxs, const vec3_t mins2, const vec3_t maxs2 );
255qboolean CM_BoundsIntersectPoint( const vec3_t mins, const vec3_t maxs, const vec3_t point );
256
257// cm_patch.c
258
259qboolean CM_PlaneFromPoints( vec4_t plane, vec3_t a, vec3_t b, vec3_t c );
260struct patchCollide_s *CM_GeneratePatchCollide( int width, int height, vec3_t *points, float subdivisions );
261void CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );
262qboolean CM_PositionTestInPatchCollide( traceWork_t *tw, const struct patchCollide_s *pc );
263void CM_ClearLevelPatches( void );
264
265// cm_terrain.c
266struct terPatchCollide_s *CM_GenerateTerPatchCollide(vec3_t origin, byte heightmap[9][9], baseshader_t *shader);
267void CM_TraceThroughTerrainCollide(traceWork_t *tw, terrainCollide_t *tc);
268qboolean CM_PositionTestInTerrainCollide( traceWork_t *tw, terrainCollide_t *tc );
269qboolean CM_SightTracePointThroughTerrainCollide( void );
270qboolean CM_SightTraceThroughTerrainCollide( traceWork_t *tw, terrainCollide_t *tc );
271
272// cm_fencemask.c
273cfencemask_t *CM_GetFenceMask( const char *szMaskName );
274qboolean CM_TraceThroughFence( traceWork_t *tw, cbrush_t *brush, cbrushside_t *side, float fTraceFraction );
275
276// cm_trace_obfuscation.cpp
277obfuscation_t* CM_SetupObfuscationMapping();
278void CM_ReleaseObfuscationMapping(obfuscation_t* obfuscation);
279void CM_ObfuscationForShader(obfuscation_t* list, const char* shaderName, float* widthDensity, float* heightDensity);
280
281#ifdef __cplusplus
282}
283#endif
Definition cm_local.h:116
Definition cm_local.h:42
Definition cm_local.h:37
Definition cm_local.h:97
Definition cm_local.h:108
Definition navigation_bsp.h:131
Definition navigation_bsp.h:117
Definition cm_local.h:57
Definition cm_local.h:128
Definition cm_local.h:74
Definition navigation_bsp.h:139
Definition navigation_bsp.h:111
Definition cm_local.h:122
Definition qfiles.h:612
Definition cm_local.h:218
Definition cm_local.h:228
Definition cm_patch.h:82
Definition cm_local.h:197
Definition cm_terrain.h:46
Definition navigation_bsp.h:256
Definition cm_local.h:203
Definition q_shared.h:1452