Fix red, moved around a bit to much.
[kugel-rb.git] / apps / plugins / doom / r_defs.h
bloba70d8a306cd557dc84b9f30a5f297915dbc82192
1 /* Emacs style mode select -*- C++ -*-
2 *-----------------------------------------------------------------------------
5 * PrBoom a Doom port merged with LxDoom and LSDLDoom
6 * based on BOOM, a modified and improved DOOM engine
7 * Copyright (C) 1999 by
8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9 * Copyright (C) 1999-2000 by
10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-1307, USA.
27 * DESCRIPTION:
28 * Refresh/rendering module, shared data struct definitions.
30 *-----------------------------------------------------------------------------*/
32 #ifndef __R_DEFS__
33 #define __R_DEFS__
35 // Screenwidth.
36 #include "doomdef.h"
38 // Some more or less basic data types
39 // we depend on.
40 #include "m_fixed.h"
42 // We rely on the thinker data struct
43 // to handle sound origins in sectors.
44 #include "d_think.h"
45 // SECTORS do store MObjs anyway.
46 #include "p_mobj.h"
48 #ifdef __GNUG__
49 #pragma interface
50 #endif
52 // Silhouette, needed for clipping Segs (mainly)
53 // and sprites representing things.
54 #define SIL_NONE 0
55 #define SIL_BOTTOM 1
56 #define SIL_TOP 2
57 #define SIL_BOTH 3
59 #define MAXDRAWSEGS 256
62 // INTERNAL MAP TYPES
63 // used by play and refresh
67 // Your plain vanilla vertex.
68 // Note: transformed values not buffered locally,
69 // like some DOOM-alikes ("wt", "WebView") do.
71 typedef struct
73 fixed_t x, y;
75 vertex_t;
77 // Each sector has a degenmobj_t in its center for sound origin purposes.
78 typedef struct
80 thinker_t thinker; // not used for anything
81 fixed_t x, y, z;
83 degenmobj_t;
86 // The SECTORS record, at runtime.
87 // Stores things/mobjs.
90 typedef struct
92 fixed_t floorheight;
93 fixed_t ceilingheight;
94 int nexttag,firsttag; // killough 1/30/98: improves searches for tags.
95 int soundtraversed; // 0 = untraversed, 1,2 = sndlines-1
96 mobj_t *soundtarget; // thing that made a sound (or null)
97 int blockbox[4]; // mapblock bounding box for height changes
98 degenmobj_t soundorg; // origin for any sounds played by the sector
99 int validcount; // if == validcount, already checked
100 mobj_t *thinglist; // list of mobjs in sector
102 /* killough 8/28/98: friction is a sector property, not an mobj property.
103 * these fields used to be in mobj_t, but presented performance problems
104 * when processed as mobj properties. Fix is to make them sector properties.
106 int friction,movefactor;
108 // thinker_t for reversable actions
109 void *floordata; // jff 2/22/98 make thinkers on
110 void *ceilingdata; // floors, ceilings, lighting,
111 void *lightingdata; // independent of one another
113 // jff 2/26/98 lockout machinery for stairbuilding
114 int stairlock; // -2 on first locked -1 after thinker done 0 normally
115 int prevsec; // -1 or number of sector for previous step
116 int nextsec; // -1 or number of next step sector
118 // killough 3/7/98: support flat heights drawn at another sector's heights
119 int heightsec; // other sector, or -1 if no other sector
121 int bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps
123 // list of mobjs that are at least partially in the sector
124 // thinglist is a subset of touching_thinglist
125 struct msecnode_s *touching_thinglist; // phares 3/14/98
127 int linecount;
128 struct line_s **lines;
130 // killough 10/98: support skies coming from sidedefs. Allows scrolling
131 // skies and other effects. No "level info" kind of lump is needed,
132 // because you can use an arbitrary number of skies per level with this
133 // method. This field only applies when skyflatnum is used for floorpic
134 // or ceilingpic, because the rest of Doom needs to know which is sky
135 // and which isn't, etc.
137 int sky;
139 // killough 3/7/98: floor and ceiling texture offsets
140 fixed_t floor_xoffs, floor_yoffs;
141 fixed_t ceiling_xoffs, ceiling_yoffs;
143 // killough 4/11/98: support for lightlevels coming from another sector
144 int floorlightsec, ceilinglightsec;
146 short floorpic;
147 short ceilingpic;
148 short lightlevel;
149 short special;
150 short oldspecial; //jff 2/16/98 remembers if sector WAS secret (automap)
151 short tag;
153 sector_t;
156 // The SideDef.
159 typedef struct
161 fixed_t textureoffset; // add this to the calculated texture column
162 fixed_t rowoffset; // add this to the calculated texture top
163 short toptexture; // Texture indices. We do not maintain names here.
164 short bottomtexture;
165 short midtexture;
166 sector_t* sector; // Sector the SideDef is facing.
168 // killough 4/4/98, 4/11/98: highest referencing special linedef's type,
169 // or lump number of special effect. Allows texture names to be overloaded
170 // for other functions.
172 int special;
175 side_t;
178 // Move clipping aid for LineDefs.
180 typedef enum
182 ST_HORIZONTAL,
183 ST_VERTICAL,
184 ST_POSITIVE,
185 ST_NEGATIVE
186 } slopetype_t;
188 typedef struct line_s
190 vertex_t *v1, *v2; // Vertices, from v1 to v2.
191 fixed_t dx, dy; // Precalculated v2 - v1 for side checking.
192 short flags; // Animation related.
193 short special;
194 short tag;
195 short sidenum[2]; // Visual appearance: SideDefs.
196 fixed_t bbox[4]; // A bounding box, for the linedef's extent
197 slopetype_t slopetype; // To aid move clipping.
198 sector_t *frontsector; // Front and back sector.
199 sector_t *backsector;
200 int validcount; // if == validcount, already checked
201 void *specialdata; // thinker_t for reversable actions
202 int tranlump; // killough 4/11/98: translucency filter, -1 == none
203 int firsttag,nexttag; // killough 4/17/98: improves searches for tags.
204 int r_validcount; // cph: if == gametic, r_flags already done
205 enum { // cph:
206 RF_TOP_TILE = 1, // Upper texture needs tiling
207 RF_MID_TILE = 2, // Mid texture needs tiling
208 RF_BOT_TILE = 4, // Lower texture needs tiling
209 RF_IGNORE = 8, // Renderer can skip this line
210 RF_CLOSED =16, // Line blocks view
211 } r_flags;
213 line_t;
215 // phares 3/14/98
217 // Sector list node showing all sectors an object appears in.
219 // There are two threads that flow through these nodes. The first thread
220 // starts at touching_thinglist in a sector_t and flows through the m_snext
221 // links to find all mobjs that are entirely or partially in the sector.
222 // The second thread starts at touching_sectorlist in an mobj_t and flows
223 // through the m_tnext links to find all sectors a thing touches. This is
224 // useful when applying friction or push effects to sectors. These effects
225 // can be done as thinkers that act upon all objects touching their sectors.
226 // As an mobj moves through the world, these nodes are created and
227 // destroyed, with the links changed appropriately.
229 // For the links, NULL means top or end of list.
231 typedef struct msecnode_s
233 sector_t *m_sector; // a sector containing this object
234 struct mobj_s *m_thing; // this object
235 struct msecnode_s *m_tprev; // prev msecnode_t for this thing
236 struct msecnode_s *m_tnext; // next msecnode_t for this thing
237 struct msecnode_s *m_sprev; // prev msecnode_t for this sector
238 struct msecnode_s *m_snext; // next msecnode_t for this sector
239 boolean visited; // killough 4/4/98, 4/7/98: used in search algorithms
241 msecnode_t;
244 // The LineSeg.
246 typedef struct
248 vertex_t *v1, *v2;
249 fixed_t offset;
250 angle_t angle;
251 side_t* sidedef;
252 line_t* linedef;
254 boolean miniseg;
256 // Sector references.
257 // Could be retrieved from linedef, too
258 // (but that would be slower -- killough)
259 // backsector is NULL for one sided lines
261 sector_t *frontsector, *backsector;
263 seg_t;
266 // A SubSector.
267 // References a Sector.
268 // Basically, this is a list of LineSegs,
269 // indicating the visible walls that define
270 // (all or some) sides of a convex BSP leaf.
273 typedef struct subsector_s
275 sector_t *sector;
276 unsigned short numlines, firstline;
278 subsector_t;
281 // BSP node.
283 typedef struct
285 fixed_t x, y, dx, dy; // Partition line.
286 fixed_t bbox[2][4]; // Bounding box for each child.
287 unsigned short children[2]; // If NF_SUBSECTOR its a subsector.
289 node_t;
291 // posts are runs of non masked source pixels
292 typedef struct
294 byte topdelta; // -1 is the last post in a column
295 byte length; // length data bytes follows
297 post_t;
299 // column_t is a list of 0 or more post_t, (byte)-1 terminated
300 typedef post_t column_t;
303 // OTHER TYPES
306 // This could be wider for >8 bit display.
307 // Indeed, true color support is posibble
308 // precalculating 24bpp lightmap/colormap LUT.
309 // from darkening PLAYPAL to all black.
310 // Could use even more than 32 levels.
312 typedef byte lighttable_t;
315 // Masked 2s linedefs
317 typedef struct drawseg_s
319 seg_t *curline;
320 int x1, x2;
321 fixed_t scale1, scale2, scalestep;
322 int silhouette; // 0=none, 1=bottom, 2=top, 3=both
323 fixed_t bsilheight; // do not clip sprites above this
324 fixed_t tsilheight; // do not clip sprites below this
326 // Pointers to lists for sprite clipping,
327 // all three adjusted so [x1] is first value.
328 short *sprtopclip, *sprbottomclip, *maskedtexturecol;
331 drawseg_t;
334 // Patches.
335 // A patch holds one or more columns.
336 // Patches are used for sprites and all masked pictures,
337 // and we compose textures from the TEXTURE1/2 lists
338 // of patches.
341 typedef struct
343 short width, height; // bounding box size
344 short leftoffset; // pixels to the left of origin
345 short topoffset; // pixels below the origin
346 int columnofs[8]; // only [width] used
348 patch_t;
350 // proff: Added for OpenGL
351 typedef struct
353 int width,height;
354 int leftoffset,topoffset;
355 int lumpnum;
357 patchnum_t;
360 // A vissprite_t is a thing that will be drawn during a refresh.
361 // i.e. a sprite object that is partly visible.
364 typedef struct vissprite_s
366 int x1, x2;
367 fixed_t gx, gy; // for line side calculation
368 fixed_t gz, gzt; // global bottom / top for silhouette clipping
369 fixed_t startfrac; // horizontal position of x1
370 fixed_t scale;
371 fixed_t xiscale; // negative if flipped
372 fixed_t texturemid;
373 int patch;
374 uint_64_t mobjflags;
376 // for color translation and shadow draw, maxbright frames as well
377 lighttable_t *colormap;
379 // killough 3/27/98: height sector for underwater/fake ceiling support
380 int heightsec;
382 vissprite_t;
385 // Sprites are patches with a special naming convention
386 // so they can be recognized by R_InitSprites.
387 // The base name is NNNNFx or NNNNFxFx, with
388 // x indicating the rotation, x = 0, 1-7.
389 // The sprite and frame specified by a thing_t
390 // is range checked at run time.
391 // A sprite is a patch_t that is assumed to represent
392 // a three dimensional object and may have multiple
393 // rotations pre drawn.
394 // Horizontal flipping is used to save space,
395 // thus NNNNF2F5 defines a mirrored patch.
396 // Some sprites will only have one picture used
397 // for all views: NNNNF0
399 typedef struct
401 // If false use 0 for any position.
402 // Note: as eight entries are available,
403 // we might as well insert the same name eight times.
404 boolean rotate;
406 // Lump to use for view angles 0-7.
407 short lump[8];
409 // Flip bit (1 = flip) to use for view angles 0-7.
410 byte flip[8];
413 spriteframe_t;
416 // A sprite definition:
417 // a number of animation frames.
420 typedef struct
422 int numframes;
423 spriteframe_t *spriteframes;
425 spritedef_t;
428 // Now what is a visplane, anyway?
430 typedef struct visplane
432 struct visplane *next; // Next visplane in hash chain -- killough
433 int picnum, lightlevel, minx, maxx;
434 fixed_t height;
435 fixed_t xoffs, yoffs; // killough 2/28/98: Support scrolling flats
436 unsigned short pad1; // leave pads for [minx-1]/[maxx+1]
437 unsigned short top[MAX_SCREENWIDTH];
438 unsigned short pad2, pad3; // killough 2/8/98, 4/25/98
439 unsigned short bottom[MAX_SCREENWIDTH];
440 unsigned short pad4;
442 visplane_t;
444 #endif