/
p_maptypes.h
477 lines (409 loc) · 18.6 KB
/
p_maptypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
/* Generated by .\..\..\engine\scripts\makedmt.py */
#ifndef __DOOMSDAY_PLAY_MAP_DATA_TYPES_H__
#define __DOOMSDAY_PLAY_MAP_DATA_TYPES_H__
#include "p_mapdata.h"
#define LO_prev link[0]
#define LO_next link[1]
typedef struct shadowvert_s {
float inner[2];
float extended[2];
} shadowvert_t;
typedef struct lineowner_s {
struct linedef_s *lineDef;
struct lineowner_s *link[2]; // {prev, next} (i.e. {anticlk, clk}).
binangle_t angle; // between this and next clockwise.
shadowvert_t shadowOffsets;
} lineowner_t;
#define V_pos v.pos
typedef struct mvertex_s {
// Vertex index. Always valid after loading and pruning of unused
// vertices has occurred.
int index;
// Reference count. When building normal node info, unused vertices
// will be pruned.
int refCount;
// Usually NULL, unless this vertex occupies the same location as a
// previous vertex. Only used during the pruning phase.
struct vertex_s *equiv;
struct edgetip_s *tipSet; // Set of wall_tips.
// Final data.
double pos[2];
} mvertex_t;
typedef struct vertex_s {
runtime_mapdata_header_t header;
unsigned int numLineOwners; // Number of line owners.
lineowner_t* lineOwners; // Lineowner base ptr [numlineowners] size. A doubly, circularly linked list. The base is the line with the lowest angle and the next-most with the largest angle.
fvertex_t v;
mvertex_t buildData;
} vertex_t;
// Helper macros for accessing hedge data elements.
#define FRONT 0
#define BACK 1
#define HE_v(n) v[(n)? 1:0]
#define HE_vpos(n) HE_v(n)->V_pos
#define HE_v1 HE_v(0)
#define HE_v1pos HE_v(0)->V_pos
#define HE_v2 HE_v(1)
#define HE_v2pos HE_v(1)->V_pos
#define HE_sector(n) sec[(n)? 1:0]
#define HE_frontsector HE_sector(FRONT)
#define HE_backsector HE_sector(BACK)
#define HEDGE_SIDEDEF(s) ((s)->lineDef->sideDefs[(s)->side])
// HEdge flags
#define HEDGEF_POLYOBJ 0x1 // HEdge is part of a poly object.
// HEdge frame flags
#define HEDGEINF_FACINGFRONT 0x0001
typedef struct hedge_s {
runtime_mapdata_header_t header;
struct vertex_s* v[2]; // [Start, End] of the segment.
struct linedef_s* lineDef;
struct sector_s* sec[2];
struct subsector_s* subsector;
struct hedge_s* twin;
angle_t angle;
byte side; // 0=front, 1=back
byte flags;
float length; // Accurate length of the segment (v1 -> v2).
float offset;
biassurface_t* bsuf[3]; // 0=middle, 1=top, 2=bottom
short frameFlags;
} HEdge;
#define SUBF_MIDPOINT 0x80 // Midpoint is tri-fan centre.
typedef struct subsector_s {
runtime_mapdata_header_t header;
unsigned int hedgeCount;
struct hedge_s** hedges; // [hedgeCount] size.
struct polyobj_s* polyObj; // NULL, if there is no polyobj.
struct sector_s* sector;
int addSpriteCount; // frame number of last R_AddSprites
unsigned int inSectorID;
int flags;
int validCount;
unsigned int reverb[NUM_REVERB_DATA];
AABoxf aaBox; // Min and max points.
float worldGridOffset[2]; // Offset to align the top left of the bBox to the world grid.
fvertex_t midPoint; // Center of vertices.
unsigned short numVertices;
struct fvertex_s** vertices; // [numvertices] size
struct shadowlink_s* shadows;
struct biassurface_s** bsuf; // [sector->planeCount] size.
} subsector_t;
typedef enum {
MEC_UNKNOWN = -1,
MEC_FIRST = 0,
MEC_METAL = MEC_FIRST,
MEC_ROCK,
MEC_WOOD,
MEC_CLOTH,
NUM_MATERIAL_ENV_CLASSES
} material_env_class_t;
#define VALID_MATERIAL_ENV_CLASS(v) ((v) >= MEC_FIRST && (v) < NUM_MATERIAL_ENV_CLASSES)
struct material_variantlist_node_s;
typedef struct material_s {
runtime_mapdata_header_t header;
struct ded_material_s* _def;
struct material_variantlist_node_s* _variants;
material_env_class_t _envClass; // Environmental sound class.
materialid_t _primaryBind; // Unique identifier of the MaterialBind associated with this Material or @c NULL if not bound.
Size2* _size; // Logical dimensions in world-space units.
short _flags; // @see materialFlags
boolean _inAnimGroup; // @c true if belongs to some animgroup.
boolean _isCustom;
struct texture_s* _detailTex;
float _detailScale;
float _detailStrength;
struct texture_s* _shinyTex;
blendmode_t _shinyBlendmode;
float _shinyMinColor[3];
float _shinyStrength;
struct texture_s* _shinyMaskTex;
byte _prepared;
} material_t;
// Internal surface flags:
#define SUIF_PVIS 0x0001
#define SUIF_FIX_MISSING_MATERIAL 0x0002 // Current texture is a fix replacement
// (not sent to clients, returned via DMU etc).
#define SUIF_BLEND 0x0004 // Surface possibly has a blended texture.
#define SUIF_NO_RADIO 0x0008 // No fakeradio for this surface.
#define SUIF_UPDATE_FLAG_MASK 0xff00
#define SUIF_UPDATE_DECORATIONS 0x8000
typedef struct surfacedecor_s {
float pos[3]; // World coordinates of the decoration.
subsector_t* subsector;
const struct ded_decorlight_s* def;
} surfacedecor_t;
typedef struct surface_s {
runtime_mapdata_header_t header;
void* owner; // Either @c DMU_SIDEDEF, or @c DMU_PLANE
int flags; // SUF_ flags
int oldFlags;
material_t* material;
blendmode_t blendMode;
float tangent[3];
float bitangent[3];
float normal[3];
float offset[2]; // [X, Y] Planar offset to surface material origin.
float oldOffset[2][2];
float visOffset[2];
float visOffsetDelta[2];
float rgba[4]; // Surface color tint
short inFlags; // SUIF_* flags
unsigned int numDecorations;
surfacedecor_t *decorations;
} surface_t;
typedef enum {
PLN_FLOOR,
PLN_CEILING,
PLN_MID,
NUM_PLANE_TYPES
} planetype_t;
#define PS_tangent surface.tangent
#define PS_bitangent surface.bitangent
#define PS_normal surface.normal
#define PS_material surface.material
#define PS_offset surface.offset
#define PS_visoffset surface.visOffset
#define PS_rgba surface.rgba
#define PS_flags surface.flags
#define PS_inflags surface.inFlags
typedef struct plane_s {
runtime_mapdata_header_t header;
ddmobj_base_t soundOrg; // Sound origin for plane
struct sector_s* sector; // Owner of the plane (temp)
surface_t surface;
float height; // Current height
float oldHeight[2];
float target; // Target height
float speed; // Move speed
float visHeight; // Visible plane height (smoothed)
float visHeightDelta;
planetype_t type; // PLN_* type.
int planeID;
} plane_t;
// Helper macros for accessing sector floor/ceiling plane data elements.
#define SP_plane(n) planes[(n)]
#define SP_planesurface(n) SP_plane(n)->surface
#define SP_planeheight(n) SP_plane(n)->height
#define SP_planetangent(n) SP_plane(n)->surface.tangent
#define SP_planebitangent(n) SP_plane(n)->surface.bitangent
#define SP_planenormal(n) SP_plane(n)->surface.normal
#define SP_planematerial(n) SP_plane(n)->surface.material
#define SP_planeoffset(n) SP_plane(n)->surface.offset
#define SP_planergb(n) SP_plane(n)->surface.rgba
#define SP_planetarget(n) SP_plane(n)->target
#define SP_planespeed(n) SP_plane(n)->speed
#define SP_planesoundorg(n) SP_plane(n)->soundOrg
#define SP_planevisheight(n) SP_plane(n)->visHeight
#define SP_ceilsurface SP_planesurface(PLN_CEILING)
#define SP_ceilheight SP_planeheight(PLN_CEILING)
#define SP_ceiltangent SP_planetangent(PLN_CEILING)
#define SP_ceilbitangent SP_planebitangent(PLN_CEILING)
#define SP_ceilnormal SP_planenormal(PLN_CEILING)
#define SP_ceilmaterial SP_planematerial(PLN_CEILING)
#define SP_ceiloffset SP_planeoffset(PLN_CEILING)
#define SP_ceilrgb SP_planergb(PLN_CEILING)
#define SP_ceiltarget SP_planetarget(PLN_CEILING)
#define SP_ceilspeed SP_planespeed(PLN_CEILING)
#define SP_ceilsoundorg SP_planesoundorg(PLN_CEILING)
#define SP_ceilvisheight SP_planevisheight(PLN_CEILING)
#define SP_floorsurface SP_planesurface(PLN_FLOOR)
#define SP_floorheight SP_planeheight(PLN_FLOOR)
#define SP_floortangent SP_planetangent(PLN_FLOOR)
#define SP_floorbitangent SP_planebitangent(PLN_FLOOR)
#define SP_floornormal SP_planenormal(PLN_FLOOR)
#define SP_floormaterial SP_planematerial(PLN_FLOOR)
#define SP_flooroffset SP_planeoffset(PLN_FLOOR)
#define SP_floorrgb SP_planergb(PLN_FLOOR)
#define SP_floortarget SP_planetarget(PLN_FLOOR)
#define SP_floorspeed SP_planespeed(PLN_FLOOR)
#define SP_floorsoundorg SP_planesoundorg(PLN_FLOOR)
#define SP_floorvisheight SP_planevisheight(PLN_FLOOR)
#define S_skyfix(n) skyFix[(n)]
#define S_floorskyfix S_skyfix(PLN_FLOOR)
#define S_ceilskyfix S_skyfix(PLN_CEILING)
// Sector frame flags
#define SIF_VISIBLE 0x1 // Sector is visible on this frame.
#define SIF_FRAME_CLEAR 0x1 // Flags to clear before each frame.
#define SIF_LIGHT_CHANGED 0x2
// Sector flags.
#define SECF_UNCLOSED 0x1 // An unclosed sector (some sort of fancy hack).
typedef struct msector_s {
// Sector index. Always valid after loading & pruning.
int index;
// Suppress superfluous mini warnings.
int warnedFacing;
int refCount;
} msector_t;
typedef struct sector_s {
runtime_mapdata_header_t header;
int frameFlags;
int validCount; // if == validCount, already checked.
int flags;
float bBox[4]; // Bounding box for the sector.
float approxArea; // Rough approximation of sector area.
float lightLevel;
float oldLightLevel;
float rgb[3];
float oldRGB[3];
struct mobj_s* mobjList; // List of mobjs in the sector.
unsigned int lineDefCount;
struct linedef_s** lineDefs; // [lineDefCount+1] size.
unsigned int ssectorCount;
struct subsector_s** ssectors; // [ssectorCount+1] size.
unsigned int numReverbSSecAttributors;
struct subsector_s** reverbSSecs; // [numReverbSSecAttributors] size.
ddmobj_base_t soundOrg;
unsigned int planeCount;
struct plane_s** planes; // [planeCount+1] size.
unsigned int blockCount; // Number of gridblocks in the sector.
unsigned int changedBlockCount; // Number of blocks to mark changed.
unsigned short* blocks; // Light grid block indices.
float reverb[NUM_REVERB_DATA];
msector_t buildData;
} sector_t;
// Sidedef sections.
typedef enum sidedefsection_e {
SS_MIDDLE,
SS_TOP,
SS_BOTTOM
} sidedefsection_t;
// Helper macros for accessing sidedef top/middle/bottom section data elements.
#define SW_surface(n) sections[(n)]
#define SW_surfaceflags(n) SW_surface(n).flags
#define SW_surfaceinflags(n) SW_surface(n).inFlags
#define SW_surfacematerial(n) SW_surface(n).material
#define SW_surfacetangent(n) SW_surface(n).tangent
#define SW_surfacebitangent(n) SW_surface(n).bitangent
#define SW_surfacenormal(n) SW_surface(n).normal
#define SW_surfaceoffset(n) SW_surface(n).offset
#define SW_surfacevisoffset(n) SW_surface(n).visOffset
#define SW_surfacergba(n) SW_surface(n).rgba
#define SW_surfaceblendmode(n) SW_surface(n).blendMode
#define SW_middlesurface SW_surface(SS_MIDDLE)
#define SW_middleflags SW_surfaceflags(SS_MIDDLE)
#define SW_middleinflags SW_surfaceinflags(SS_MIDDLE)
#define SW_middlematerial SW_surfacematerial(SS_MIDDLE)
#define SW_middletangent SW_surfacetangent(SS_MIDDLE)
#define SW_middlebitangent SW_surfacebitangent(SS_MIDDLE)
#define SW_middlenormal SW_surfacenormal(SS_MIDDLE)
#define SW_middletexmove SW_surfacetexmove(SS_MIDDLE)
#define SW_middleoffset SW_surfaceoffset(SS_MIDDLE)
#define SW_middlevisoffset SW_surfacevisoffset(SS_MIDDLE)
#define SW_middlergba SW_surfacergba(SS_MIDDLE)
#define SW_middleblendmode SW_surfaceblendmode(SS_MIDDLE)
#define SW_topsurface SW_surface(SS_TOP)
#define SW_topflags SW_surfaceflags(SS_TOP)
#define SW_topinflags SW_surfaceinflags(SS_TOP)
#define SW_topmaterial SW_surfacematerial(SS_TOP)
#define SW_toptangent SW_surfacetangent(SS_TOP)
#define SW_topbitangent SW_surfacebitangent(SS_TOP)
#define SW_topnormal SW_surfacenormal(SS_TOP)
#define SW_toptexmove SW_surfacetexmove(SS_TOP)
#define SW_topoffset SW_surfaceoffset(SS_TOP)
#define SW_topvisoffset SW_surfacevisoffset(SS_TOP)
#define SW_toprgba SW_surfacergba(SS_TOP)
#define SW_bottomsurface SW_surface(SS_BOTTOM)
#define SW_bottomflags SW_surfaceflags(SS_BOTTOM)
#define SW_bottominflags SW_surfaceinflags(SS_BOTTOM)
#define SW_bottommaterial SW_surfacematerial(SS_BOTTOM)
#define SW_bottomtangent SW_surfacetangent(SS_BOTTOM)
#define SW_bottombitangent SW_surfacebitangent(SS_BOTTOM)
#define SW_bottomnormal SW_surfacenormal(SS_BOTTOM)
#define SW_bottomtexmove SW_surfacetexmove(SS_BOTTOM)
#define SW_bottomoffset SW_surfaceoffset(SS_BOTTOM)
#define SW_bottomvisoffset SW_surfacevisoffset(SS_BOTTOM)
#define SW_bottomrgba SW_surfacergba(SS_BOTTOM)
#define FRONT 0
#define BACK 1
typedef struct msidedef_s {
// Sidedef index. Always valid after loading & pruning.
int index;
int refCount;
} msidedef_t;
typedef struct sidedef_s {
runtime_mapdata_header_t header;
surface_t sections[3];
unsigned int hedgeCount;
struct hedge_s** hedges; // [hedgeCount] size, hedges arranged left>right
struct linedef_s* line;
struct sector_s* sector;
short flags;
msidedef_t buildData;
int fakeRadioUpdateCount; // frame number of last update
shadowcorner_t topCorners[2];
shadowcorner_t bottomCorners[2];
shadowcorner_t sideCorners[2];
edgespan_t spans[2]; // [left, right]
} sidedef_t;
// Helper macros for accessing linedef data elements.
#define L_v(n) v[(n)? 1:0]
#define L_vpos(n) v[(n)? 1:0]->V_pos
#define L_v1 L_v(0)
#define L_v1pos L_v(0)->V_pos
#define L_v2 L_v(1)
#define L_v2pos L_v(1)->V_pos
#define L_vo(n) vo[(n)? 1:0]
#define L_vo1 L_vo(0)
#define L_vo2 L_vo(1)
#define L_side(n) sideDefs[(n)? 1:0]
#define L_frontside L_side(FRONT)
#define L_backside L_side(BACK)
#define L_sector(n) sideDefs[(n)? 1:0]->sector
#define L_frontsector L_sector(FRONT)
#define L_backsector L_sector(BACK)
// Is this line self-referencing (front sec == back sec)?
#define LINE_SELFREF(l) ((l)->L_frontside && (l)->L_backside && \
(l)->L_frontsector == (l)->L_backsector)
// Internal flags:
#define LF_POLYOBJ 0x1 // Line is part of a polyobject.
#define MLF_TWOSIDED 0x1 // Line is marked two-sided.
#define MLF_ZEROLENGTH 0x2 // Zero length (line should be totally ignored).
#define MLF_SELFREF 0x4 // Sector is the same on both sides.
#define MLF_POLYOBJ 0x8 // Line is part of a polyobj.
typedef struct mlinedef_s {
// Linedef index. Always valid after loading & pruning of zero
// length lines has occurred.
int index;
int mlFlags; // MLF_* flags.
// One-sided linedef used for a special effect (windows).
// The value refers to the opposite sector on the back side.
struct sector_s *windowEffect;
// Normally NULL, except when this linedef directly overlaps an earlier
// one (a rarely-used trick to create higher mid-masked textures).
// No hedges should be created for these overlapping linedefs.
struct linedef_s *overlap;
} mlinedef_t;
typedef struct linedef_s {
runtime_mapdata_header_t header;
struct vertex_s* v[2];
struct lineowner_s* vo[2]; // Links to vertex line owner nodes [left, right]
struct sidedef_s* sideDefs[2];
int flags; // Public DDLF_* flags.
byte inFlags; // Internal LF_* flags
slopetype_t slopeType;
int validCount;
binangle_t angle; // Calculated from front side's normal
float dX;
float dY;
float length; // Accurate length
AABoxf aaBox;
boolean mapped[DDMAXPLAYERS]; // Whether the line has been mapped by each player yet.
mlinedef_t buildData;
unsigned short shadowVisFrame[2]; // Framecount of last time shadows were drawn for this line, for each side [right, left].
} linedef_t;
#define RIGHT 0
#define LEFT 1
/**
* An infinite line of the form point + direction vectors.
*/
typedef struct partition_s {
float x, y;
float dX, dY;
} partition_t;
typedef struct node_s {
runtime_mapdata_header_t header;
partition_t partition;
float bBox[2][4]; // Bounding box for each child.
unsigned int children[2]; // If NF_SUBSECTOR it's a subsector.
} node_t;
#endif