/
r_data.h
289 lines (252 loc) · 8.42 KB
/
r_data.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
//===========================================================================
// R_DATA.H
// Data structures for refresh.
//===========================================================================
#ifndef __DOOMSDAY_REFRESH_DATA_H__
#define __DOOMSDAY_REFRESH_DATA_H__
#include "p_data.h"
#include "p_think.h"
#include "m_nodepile.h"
#include "dedfile.h"
#define SIF_VISIBLE 0x1 // Sector is visible on this frame.
#define SIF_FRAME_CLEAR 0x1 // Flags to clear before each frame.
// Sector flags.
#define SECF_INVIS_FLOOR 0x1
#define SECF_INVIS_CEILING 0x2
#define LINE_INFO(x) (lineinfo + GET_LINE_IDX(x))
#define SUBSECT_INFO(x) (subsecinfo + GET_SUBSECTOR_IDX(x))
#define SECT_INFO(x) (secinfo + GET_SECTOR_IDX(x))
#define SECT_FLOOR(x) (secinfo[GET_SECTOR_IDX(x)].visfloor)
#define SECT_CEIL(x) (secinfo[GET_SECTOR_IDX(x)].visceil)
// Flags for decorations.
#define DCRF_NO_IWAD 0x1 // Don't use if from IWAD.
#define DCRF_PWAD 0x2 // Can use if from PWAD.
#define DCRF_EXTERNAL 0x4 // Can use if from external resource.
// Texture flags.
#define TXF_MASKED 0x1
#define TXF_GLOW 0x2 // For lava etc, textures that glow.
// Animation group flags.
#define AGF_SMOOTH 0x1
#define AGF_FIRST_ONLY 0x2
#define AGF_TEXTURE 0x1000
#define AGF_FLAT 0x2000
#define AGF_PRECACHE 0x4000 // Group is just for precaching.
enum
{ // bbox coordinates
BOXTOP,
BOXBOTTOM,
BOXLEFT,
BOXRIGHT
};
// Detail texture information.
typedef struct detailinfo_s {
DGLuint tex;
int width, height;
float strength;
float scale;
float maxdist;
} detailinfo_t;
typedef struct gltexture_s {
DGLuint id;
ushort width, height;
detailinfo_t *detail;
} gltexture_t;
typedef struct glcommand_vertex_s {
float s, t;
int index;
} glcommand_vertex_t;
#define RL_MAX_POLY_SIDES 64
#define RL_MAX_DIVS 64
// Rendpoly flags.
#define RPF_MASKED 0x0001 // Use the special list for masked textures.
#define RPF_SKY_MASK 0x0004 // A sky mask polygon.
#define RPF_LIGHT 0x0008 // A dynamic light.
#define RPF_DYNLIT 0x0010 // Normal list: poly is dynamically lit.
#define RPF_GLOW 0x0020 // Multiply original vtx colors.
#define RPF_DETAIL 0x0040 // Render with detail (incl. vtx distances)
#define RPF_SHADOW 0x0100
#define RPF_DONE 0x8000 // This poly has already been drawn.
typedef enum {
RP_NONE,
RP_QUAD, // Wall segment.
RP_DIVQUAD, // Divided wall segment.
RP_FLAT // Floor or ceiling.
} rendpolytype_t;
typedef struct {
float pos[2]; // X and Y coordinates.
gl_rgba_t color; // Color of the vertex.
float dist; // Distance to the vertex.
} rendpoly_vertex_t;
// rendpoly_t is only for convenience; the data written in the rendering
// list data buffer is taken from this struct.
typedef struct {
rendpolytype_t type;
short flags; // RPF_*.
float texoffx, texoffy; // Texture coordinates for left/top (in real texcoords).
gltexture_t tex;
gltexture_t intertex;
float interpos; // Blending strength (0..1).
struct dynlight_s *lights; // List of lights that affect this poly.
uint numlights;
DGLuint decorlightmap; // Pregen RGB lightmap for decor lights.
sector_t *sector; // The sector this poly belongs to (if any).
// The geometry:
float top, bottom;
float length;
byte numvertices; // Number of vertices for the poly.
rendpoly_vertex_t vertices[RL_MAX_POLY_SIDES];
struct div_t {
byte num;
float pos[RL_MAX_DIVS];
} divs[2]; // For wall segments (two vertices).
} rendpoly_t;
// This is the dummy mobj_t used for blockring roots.
// It has some excess information since it has to be compatible with
// regular mobjs (otherwise the rings don't really work).
// Note: the thinker and x,y,z data could be used for something else...
typedef struct linkmobj_s {
thinker_t thinker;
fixed_t x,y,z;
struct mobj_s *next, *prev;
} linkmobj_t;
typedef struct {
float visfloor, visceil; // Visible floor and ceiling, floats.
sector_t *linkedfloor; // Floor attached to another sector.
sector_t *linkedceil; // Ceiling attached to another sector.
boolean permanentlink;
float bounds[4]; // Bounding box for the sector.
int flags;
fixed_t oldfloor[2], oldceil[2];
float visflooroffset, visceiloffset;
int addspritecount; // frame number of last R_AddSprites
} sectorinfo_t;
typedef struct planeinfo_s {
short flags;
ushort numvertices;
fvertex_t *vertices;
int pic;
boolean isfloor;
} planeinfo_t;
typedef struct subsectorinfo_s {
planeinfo_t floor, ceil;
int validcount;
} subsectorinfo_t;
typedef struct {
float length; // Accurate length.
} lineinfo_t;
typedef struct polyblock_s {
polyobj_t *polyobj;
struct polyblock_s *prev;
struct polyblock_s *next;
} polyblock_t;
typedef struct vertexowner_s {
unsigned short num; // Number of owners.
unsigned short *list; // Sector indices.
} vertexowner_t;
// The sector divisions list is similar to vertexowners.
typedef struct vertexowner_s sector_divisions_t;
typedef struct {
int originx; // block origin (allways UL), which has allready
int originy; // accounted for the patch's internal origin
int patch;
} texpatch_t;
// a maptexturedef_t describes a rectangular texture, which is composed of one
// or more mappatch_t structures that arrange graphic patches
typedef struct {
char name[9]; // for switch changing, etc; ends in \0
short width;
short height;
int flags; // TXF_* flags.
short patchcount;
DGLuint tex; // Name of the associated DGL texture.
byte masked; // Is the (DGL) texture masked?
detailinfo_t detail; // Detail texture information.
byte ingroup; // True if texture belongs to some animgroup.
struct ded_decor_s *decoration; // Pointer to the surface decoration, if any.
texpatch_t patches[1]; // [patchcount] drawn back to front
} texture_t; // into the cached texture
typedef struct {
byte rgb[3];
} rgbcol_t;
typedef struct translation_s {
int current;
int next;
float inter;
} translation_t;
typedef struct flat_s {
struct flat_s *next;
int lump;
translation_t translation;
short flags;
rgbcol_t color;
detailinfo_t detail; // Detail texture information.
byte ingroup; // True if belongs to some animgroup.
struct ded_decor_s *decoration; // Pointer to the surface decoration, if any.
} flat_t;
typedef struct lumptexinfo_s {
DGLuint tex[2]; // Names of the textures (two parts for big ones)
unsigned short width[2], height;
short offx, offy;
} lumptexinfo_t;
typedef struct animframe_s {
int number;
ushort tics;
ushort random;
} animframe_t;
typedef struct animgroup_s {
int id;
int flags;
int index;
int maxtimer;
int timer;
int count;
animframe_t *frames;
} animgroup_t;
extern vertexowner_t *vertexowners;
extern sectorinfo_t *secinfo;
extern subsectorinfo_t *subsecinfo;
extern lineinfo_t *lineinfo;
extern nodeindex_t *linelinks;
extern short *blockmaplump; // offsets in blockmap are from here
extern short *blockmap;
extern int bmapwidth, bmapheight; // in mapblocks
extern fixed_t bmaporgx, bmaporgy; // origin of block map
extern linkmobj_t *blockrings;
extern polyblock_t **polyblockmap;
extern byte *rejectmatrix; // for fast sight rejection
extern nodepile_t thingnodes, linenodes;
extern lumptexinfo_t *lumptexinfo;
extern int numlumptexinfo;
extern int viewwidth, viewheight;
extern int numtextures;
extern texture_t **textures;
extern translation_t *texturetranslation; // for global animation
extern int numgroups;
extern animgroup_t *groups;
extern int LevelFullBright;
extern int r_texglow;
extern int r_precache_sprites, r_precache_skins;
void R_InitData(void);
void R_UpdateData(void);
void R_ShutdownData(void);
void R_PrecacheLevel(void);
void R_InitAnimGroup(ded_group_t *def);
boolean R_IsInAnimGroup(int groupNum, int type, int number);
void R_AnimateAnimGroups(void);
int R_TextureFlags(int texture);
int R_FlatFlags(int flat);
flat_t* R_FindFlat(int lumpnum); // May return NULL.
flat_t* R_GetFlat(int lumpnum); // Creates new entries.
flat_t** R_CollectFlats(int *count);
int R_FlatNumForName (char *name);
int R_CheckTextureNumForName (char *name);
int R_TextureNumForName (char *name);
char* R_TextureNameForNum(int num);
int R_SetFlatTranslation(int flat, int translateTo);
int R_SetTextureTranslation(int tex, int translateTo);
void R_SetAnimGroup(int type, int number, int group);
boolean R_IsCustomTexture(int texture);
boolean R_IsAllowedDecoration(ded_decor_t *def, int index, boolean hasExternal);
boolean R_IsValidLightDecoration(ded_decorlight_t *lightDef);
void R_GenerateDecorMap(ded_decor_t *def);
#endif