]> de.git.xonotic.org Git - xonotic/darkplaces.git/blob - bspfile.h
Changed the collision code used by sv_gameplayfix_nudgeoutofsolid to not consider...
[xonotic/darkplaces.git] / bspfile.h
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21
22 #define MAX_MAP_HULLS 16 // Q1BSP has 4, Hexen2 Q1BSP has 8, MCBSP has 16
23
24 //=============================================================================
25
26
27 #define BSPVERSION      29
28
29 typedef struct lump_s
30 {
31         int             fileofs, filelen;
32 } lump_t;
33
34 #define LUMP_ENTITIES   0
35 #define LUMP_PLANES             1
36 #define LUMP_TEXTURES   2
37 #define LUMP_VERTEXES   3
38 #define LUMP_VISIBILITY 4
39 #define LUMP_NODES              5
40 #define LUMP_TEXINFO    6
41 #define LUMP_FACES              7
42 #define LUMP_LIGHTING   8
43 #define LUMP_CLIPNODES  9
44 #define LUMP_LEAFS              10
45 #define LUMP_MARKSURFACES 11
46 #define LUMP_EDGES              12
47 #define LUMP_SURFEDGES  13
48 #define LUMP_MODELS             14
49 #define HEADER_LUMPS    15
50
51 typedef struct hullinfo_s
52 {
53         int                     filehulls;
54         float           hullsizes[MAX_MAP_HULLS][2][3];
55 } hullinfo_t;
56
57 typedef struct mmodel_s
58 {
59         float           mins[3], maxs[3];
60         float           origin[3];
61         int                     headnode[MAX_MAP_HULLS];
62         int                     visleafs;               // not including the solid leaf 0
63         int                     firstface, numfaces;
64 } mmodel_t;
65
66 /*
67 // WARNING: this struct does NOT match q1bsp's disk format because MAX_MAP_HULLS has been changed by Sajt's MCBSP code, this struct is only being used in memory as a result
68 typedef struct dmodel_s
69 {
70         float           mins[3], maxs[3];
71         float           origin[3];
72         int                     headnode[MAX_MAP_HULLS];
73         int                     visleafs;               // not including the solid leaf 0
74         int                     firstface, numfaces;
75 } dmodel_t;
76
77 typedef struct dheader_s
78 {
79         int                     version;
80         lump_t          lumps[HEADER_LUMPS];
81 } dheader_t;
82
83 typedef struct dmiptexlump_s
84 {
85         int                     nummiptex;
86         int                     dataofs[4];             // [nummiptex]
87 } dmiptexlump_t;
88 */
89
90 #define MIPLEVELS       4
91 /*
92 typedef struct miptex_s
93 {
94         char            name[16];
95         unsigned        width, height;
96         unsigned        offsets[MIPLEVELS];             // four mip maps stored
97 } miptex_t;
98
99
100 typedef struct dvertex_s
101 {
102         float   point[3];
103 } dvertex_t;
104 */
105
106
107 // 0-2 are axial planes
108 #define PLANE_X                 0
109 #define PLANE_Y                 1
110 #define PLANE_Z                 2
111
112 // 3-5 are non-axial planes snapped to the nearest
113 #define PLANE_ANYX              3
114 #define PLANE_ANYY              4
115 #define PLANE_ANYZ              5
116
117 /*
118 typedef struct dplane_s
119 {
120         float   normal[3];
121         float   dist;
122         int             type;           // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
123 } dplane_t;
124 */
125
126
127 // contents values in Q1 maps
128 #define CONTENTS_EMPTY                  -1
129 #define CONTENTS_SOLID                  -2
130 #define CONTENTS_WATER                  -3
131 #define CONTENTS_SLIME                  -4
132 #define CONTENTS_LAVA                           -5
133 #define CONTENTS_SKY                            -6
134 // these were #ifdef QUAKE2 in the quake source
135 #define CONTENTS_ORIGIN                 -7 // removed at csg time
136 #define CONTENTS_CLIP                           -8 // changed to contents_solid
137 #define CONTENTS_CURRENT_0              -9
138 #define CONTENTS_CURRENT_90             -10
139 #define CONTENTS_CURRENT_180            -11
140 #define CONTENTS_CURRENT_270            -12
141 #define CONTENTS_CURRENT_UP             -13
142 #define CONTENTS_CURRENT_DOWN           -14
143
144 //contents flags in Q2 maps
145 #define CONTENTSQ2_SOLID                        0x00000001 // an eye is never valid in a solid
146 #define CONTENTSQ2_WINDOW                       0x00000002 // translucent, but not watery
147 #define CONTENTSQ2_AUX                          0x00000004
148 #define CONTENTSQ2_LAVA                         0x00000008
149 #define CONTENTSQ2_SLIME                        0x00000010
150 #define CONTENTSQ2_WATER                        0x00000020
151 #define CONTENTSQ2_MIST                         0x00000040
152 #define CONTENTSQ2_AREAPORTAL           0x00008000
153 #define CONTENTSQ2_PLAYERCLIP           0x00010000
154 #define CONTENTSQ2_MONSTERCLIP          0x00020000
155 #define CONTENTSQ2_CURRENT_0            0x00040000
156 #define CONTENTSQ2_CURRENT_90           0x00080000
157 #define CONTENTSQ2_CURRENT_180          0x00100000
158 #define CONTENTSQ2_CURRENT_270          0x00200000
159 #define CONTENTSQ2_CURRENT_UP           0x00400000
160 #define CONTENTSQ2_CURRENT_DOWN         0x00800000
161 #define CONTENTSQ2_ORIGIN                       0x01000000 // removed before bsping an entity
162 #define CONTENTSQ2_MONSTER                      0x02000000 // should never be on a brush, only in game
163 #define CONTENTSQ2_DEADMONSTER          0x04000000
164 #define CONTENTSQ2_DETAIL                       0x08000000 // brushes to be added after vis leafs
165 #define CONTENTSQ2_TRANSLUCENT          0x10000000 // auto set if any surface has trans
166 #define CONTENTSQ2_LADDER                       0x20000000
167
168 //contents flags in Q3 maps
169 #define CONTENTSQ3_SOLID                        0x00000001 // solid (opaque and transparent)
170 #define CONTENTSQ3_LAVA                         0x00000008 // lava
171 #define CONTENTSQ3_SLIME                        0x00000010 // slime
172 #define CONTENTSQ3_WATER                        0x00000020 // water
173 #define CONTENTSQ3_FOG                          0x00000040 // unused?
174 #define CONTENTSQ3_AREAPORTAL           0x00008000 // areaportal (separates areas)
175 #define CONTENTSQ3_PLAYERCLIP           0x00010000 // block players
176 #define CONTENTSQ3_MONSTERCLIP          0x00020000 // block monsters
177 #define CONTENTSQ3_TELEPORTER           0x00040000 // hint for Q3's bots
178 #define CONTENTSQ3_JUMPPAD                      0x00080000 // hint for Q3's bots
179 #define CONTENTSQ3_CLUSTERPORTAL        0x00100000 // hint for Q3's bots
180 #define CONTENTSQ3_DONOTENTER           0x00200000 // hint for Q3's bots
181 #define CONTENTSQ3_BOTCLIP                      0x00400000 // hint for Q3's bots
182 #define CONTENTSQ3_ORIGIN                       0x01000000 // used by origin brushes to indicate origin of bmodel (removed by map compiler)
183 #define CONTENTSQ3_BODY                         0x02000000 // used by bbox entities (should never be on a brush)
184 #define CONTENTSQ3_CORPSE                       0x04000000 // used by dead bodies (SOLID_CORPSE in darkplaces)
185 #define CONTENTSQ3_DETAIL                       0x08000000 // brushes that do not split the bsp tree (decorations)
186 #define CONTENTSQ3_STRUCTURAL           0x10000000 // brushes that split the bsp tree
187 #define CONTENTSQ3_TRANSLUCENT          0x20000000 // leaves surfaces that are inside for rendering
188 #define CONTENTSQ3_TRIGGER                      0x40000000 // used by trigger entities
189 #define CONTENTSQ3_NODROP                       0x80000000 // remove items that fall into this brush
190
191 #define SUPERCONTENTS_SOLID                     0x00000001
192 #define SUPERCONTENTS_WATER                     0x00000002
193 #define SUPERCONTENTS_SLIME                     0x00000004
194 #define SUPERCONTENTS_LAVA                      0x00000008
195 #define SUPERCONTENTS_SKY                       0x00000010
196 #define SUPERCONTENTS_BODY                      0x00000020
197 #define SUPERCONTENTS_CORPSE            0x00000040
198 #define SUPERCONTENTS_NODROP            0x00000080
199 #define SUPERCONTENTS_PLAYERCLIP        0x00000100
200 #define SUPERCONTENTS_MONSTERCLIP       0x00000200
201 #define SUPERCONTENTS_DONOTENTER        0x00000400
202 #define SUPERCONTENTS_BOTCLIP           0x00000800
203 #define SUPERCONTENTS_OPAQUE            0x00001000
204 // TODO: is there any reason to define:
205 //   fog?
206 //   areaportal?
207 //   teleporter?
208 //   jumppad?
209 //   clusterportal?
210 //   detail?         (div0) no, game code should not be allowed to differentiate between structural and detail
211 //   structural?     (div0) no, game code should not be allowed to differentiate between structural and detail
212 //   trigger?        (div0) no, as these are always solid anyway, and that's all that matters for trigger brushes
213 #define SUPERCONTENTS_LIQUIDSMASK       (SUPERCONTENTS_LAVA | SUPERCONTENTS_SLIME | SUPERCONTENTS_WATER)
214 #define SUPERCONTENTS_VISBLOCKERMASK    SUPERCONTENTS_OPAQUE
215
216 /*
217 #define SUPERCONTENTS_DEADMONSTER       0x00000000
218 #define SUPERCONTENTS_CURRENT_0         0x00000000
219 #define SUPERCONTENTS_CURRENT_90        0x00000000
220 #define SUPERCONTENTS_CURRENT_180       0x00000000
221 #define SUPERCONTENTS_CURRENT_270       0x00000000
222 #define SUPERCONTENTS_CURRENT_DOWN      0x00000000
223 #define SUPERCONTENTS_CURRENT_UP        0x00000000
224 #define SUPERCONTENTS_AREAPORTAL        0x00000000
225 #define SUPERCONTENTS_AUX                       0x00000000
226 #define SUPERCONTENTS_CLUSTERPORTAL     0x00000000
227 #define SUPERCONTENTS_DETAIL            0x00000000
228 #define SUPERCONTENTS_STRUCTURAL        0x00000000
229 #define SUPERCONTENTS_DONOTENTER        0x00000000
230 #define SUPERCONTENTS_JUMPPAD           0x00000000
231 #define SUPERCONTENTS_LADDER            0x00000000
232 #define SUPERCONTENTS_MONSTER           0x00000000
233 #define SUPERCONTENTS_MONSTERCLIP       0x00000000
234 #define SUPERCONTENTS_PLAYERCLIP        0x00000000
235 #define SUPERCONTENTS_TELEPORTER        0x00000000
236 #define SUPERCONTENTS_TRANSLUCENT       0x00000000
237 #define SUPERCONTENTS_TRIGGER           0x00000000
238 #define SUPERCONTENTS_WINDOW            0x00000000
239 */
240
241 /*
242 typedef struct dnode_s
243 {
244         int                     planenum;
245         short           children[2];    // negative numbers are -(leafs+1), not nodes
246         short           mins[3];                // for sphere culling
247         short           maxs[3];
248         unsigned short  firstface;
249         unsigned short  numfaces;       // counting both sides
250 } dnode_t;
251
252 typedef struct dclipnode_s
253 {
254         int                     planenum;
255         short           children[2];    // negative numbers are contents
256 } dclipnode_t;
257
258
259 typedef struct texinfo_s
260 {
261         float           vecs[2][4];             // [s/t][xyz offset]
262         int                     miptex;
263         int                     flags;
264 } texinfo_t;
265 */
266 #define TEX_SPECIAL             1               // sky or slime, no lightmap or 256 subdivision
267
268 // note that edge 0 is never used, because negative edge nums are used for
269 // counterclockwise use of the edge in a face
270 /*
271 typedef struct dedge_s
272 {
273         unsigned short  v[2];           // vertex numbers
274 } dedge_t;
275 */
276
277 #define MAXLIGHTMAPS    4
278 /*
279 typedef struct dface_s
280 {
281         // LordHavoc: changed from short to unsigned short for q2 support
282         unsigned short  planenum;
283         short           side;
284
285         int                     firstedge;              // we must support > 64k edges
286         short           numedges;
287         short           texinfo;
288
289 // lighting info
290         unsigned char           styles[MAXLIGHTMAPS];
291         int                     lightofs;               // start of [numstyles*surfsize] samples
292 } dface_t;
293 */
294
295
296
297 #define AMBIENT_WATER   0
298 #define AMBIENT_SKY             1
299 #define AMBIENT_SLIME   2
300 #define AMBIENT_LAVA    3
301
302 #define NUM_AMBIENTS                    4               // automatic ambient sounds
303
304 // leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
305 // all other leafs need visibility info
306 /*
307 typedef struct dleaf_s
308 {
309         int                     contents;
310         int                     visofs;                         // -1 = no visibility info
311
312         short           mins[3];                        // for frustum culling
313         short           maxs[3];
314
315         unsigned short          firstmarksurface;
316         unsigned short          nummarksurfaces;
317
318         unsigned char           ambient_level[NUM_AMBIENTS];
319 } dleaf_t;
320 */
321