r_defs.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  1. /* Emacs style mode select -*- C++ -*-
  2. *-----------------------------------------------------------------------------
  3. *
  4. *
  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
  11. * Copyright 2005, 2006 by
  12. * Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License
  16. * as published by the Free Software Foundation; either version 2
  17. * of the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  27. * 02111-1307, USA.
  28. *
  29. * DESCRIPTION:
  30. * Refresh/rendering module, shared data struct definitions.
  31. *
  32. *-----------------------------------------------------------------------------*/
  33. #ifndef __R_DEFS__
  34. #define __R_DEFS__
  35. // Screenwidth.
  36. #include "doomdef.h"
  37. // Some more or less basic data types
  38. // we depend on.
  39. #include "m_fixed.h"
  40. // We rely on the thinker data struct
  41. // to handle sound origins in sectors.
  42. #include "d_think.h"
  43. // SECTORS do store MObjs anyway.
  44. #include "p_mobj.h"
  45. // Silhouette, needed for clipping Segs (mainly)
  46. // and sprites representing things.
  47. #define SIL_NONE 0
  48. #define SIL_BOTTOM 1
  49. #define SIL_TOP 2
  50. #define SIL_BOTH 3
  51. #define MAXDRAWSEGS 256
  52. //
  53. // INTERNAL MAP TYPES
  54. // used by play and refresh
  55. //
  56. //
  57. // Your plain vanilla vertex.
  58. // Note: transformed values not buffered locally,
  59. // like some DOOM-alikes ("wt", "WebView") do.
  60. //
  61. typedef struct
  62. {
  63. fixed_t x, y;
  64. } vertex_t;
  65. // Each sector has a degenmobj_t in its center for sound origin purposes.
  66. typedef struct
  67. {
  68. thinker_t thinker; // not used for anything
  69. fixed_t x, y, z;
  70. } degenmobj_t;
  71. //
  72. // The SECTORS record, at runtime.
  73. // Stores things/mobjs.
  74. //
  75. typedef struct
  76. {
  77. int iSectorID; // proff 04/05/2000: needed for OpenGL and used in debugmode by the HUD to draw sectornum
  78. boolean no_toptextures;
  79. boolean no_bottomtextures;
  80. fixed_t floorheight;
  81. fixed_t ceilingheight;
  82. int nexttag,firsttag; // killough 1/30/98: improves searches for tags.
  83. int soundtraversed; // 0 = untraversed, 1,2 = sndlines-1
  84. mobj_t *soundtarget; // thing that made a sound (or null)
  85. int blockbox[4]; // mapblock bounding box for height changes
  86. degenmobj_t soundorg; // origin for any sounds played by the sector
  87. int validcount; // if == validcount, already checked
  88. mobj_t *thinglist; // list of mobjs in sector
  89. /* killough 8/28/98: friction is a sector property, not an mobj property.
  90. * these fields used to be in mobj_t, but presented performance problems
  91. * when processed as mobj properties. Fix is to make them sector properties.
  92. */
  93. int friction,movefactor;
  94. // thinker_t for reversable actions
  95. void *floordata; // jff 2/22/98 make thinkers on
  96. void *ceilingdata; // floors, ceilings, lighting,
  97. void *lightingdata; // independent of one another
  98. // jff 2/26/98 lockout machinery for stairbuilding
  99. int stairlock; // -2 on first locked -1 after thinker done 0 normally
  100. int prevsec; // -1 or number of sector for previous step
  101. int nextsec; // -1 or number of next step sector
  102. // killough 3/7/98: support flat heights drawn at another sector's heights
  103. int heightsec; // other sector, or -1 if no other sector
  104. int bottommap, midmap, topmap; // killough 4/4/98: dynamic colormaps
  105. // list of mobjs that are at least partially in the sector
  106. // thinglist is a subset of touching_thinglist
  107. struct msecnode_s *touching_thinglist; // phares 3/14/98
  108. int linecount;
  109. struct line_s **lines;
  110. // killough 10/98: support skies coming from sidedefs. Allows scrolling
  111. // skies and other effects. No "level info" kind of lump is needed,
  112. // because you can use an arbitrary number of skies per level with this
  113. // method. This field only applies when skyflatnum is used for floorpic
  114. // or ceilingpic, because the rest of Doom needs to know which is sky
  115. // and which isn't, etc.
  116. int sky;
  117. // killough 3/7/98: floor and ceiling texture offsets
  118. fixed_t floor_xoffs, floor_yoffs;
  119. fixed_t ceiling_xoffs, ceiling_yoffs;
  120. // killough 4/11/98: support for lightlevels coming from another sector
  121. int floorlightsec, ceilinglightsec;
  122. short floorpic;
  123. short ceilingpic;
  124. short lightlevel;
  125. short special;
  126. short oldspecial; //jff 2/16/98 remembers if sector WAS secret (automap)
  127. short tag;
  128. #ifdef IPHONE // JDC: high performance renderer
  129. // floors and ceiling have identical index count, but reference different verts
  130. int numIndexes;
  131. int numVerts;
  132. unsigned short *indexes[2]; // floor = 0, ceiling = 1
  133. struct drawVert_s *verts[2];
  134. #endif
  135. } sector_t;
  136. //
  137. // The LineSeg. (JDC: moved above sidedef_t)
  138. //
  139. typedef struct side_s side_t; // JDC: forward definiteion
  140. typedef struct line_s line_t; // JDC: forward definiteion
  141. typedef struct
  142. {
  143. vertex_t *v1, *v2;
  144. fixed_t offset;
  145. angle_t angle;
  146. side_t* sidedef;
  147. line_t* linedef;
  148. int iSegID; // proff 11/05/2000: needed for OpenGL
  149. // figgi -- needed for glnodes
  150. float length;
  151. boolean miniseg;
  152. // Sector references.
  153. // Could be retrieved from linedef, too
  154. // (but that would be slower -- killough)
  155. // backsector is NULL for one sided lines
  156. sector_t *frontsector, *backsector;
  157. } seg_t;
  158. //
  159. // The SideDef.
  160. //
  161. struct side_s // JDC: moved typedef for forward reference
  162. {
  163. fixed_t textureoffset; // add this to the calculated texture column
  164. fixed_t rowoffset; // add this to the calculated texture top
  165. short toptexture; // Texture indices. We do not maintain names here.
  166. short bottomtexture;
  167. short midtexture;
  168. sector_t* sector; // Sector the SideDef is facing.
  169. // killough 4/4/98, 4/11/98: highest referencing special linedef's type,
  170. // or lump number of special effect. Allows texture names to be overloaded
  171. // for other functions.
  172. int special;
  173. #ifdef IPHONE
  174. seg_t sideSeg; // This segment stretches the entire length of the line,
  175. // even if the line was broken into multiple seg_t by
  176. // the bsp.
  177. #endif
  178. };
  179. //
  180. // Move clipping aid for LineDefs.
  181. //
  182. typedef enum
  183. {
  184. ST_HORIZONTAL,
  185. ST_VERTICAL,
  186. ST_POSITIVE,
  187. ST_NEGATIVE
  188. } slopetype_t;
  189. struct line_s // JDC: moved typedef for forward reference
  190. {
  191. int iLineID; // proff 04/05/2000: needed for OpenGL
  192. vertex_t *v1, *v2; // Vertices, from v1 to v2.
  193. fixed_t dx, dy; // Precalculated v2 - v1 for side checking.
  194. unsigned short flags; // Animation related.
  195. short special;
  196. short tag;
  197. unsigned short sidenum[2]; // Visual appearance: SideDefs.
  198. fixed_t bbox[4]; // A bounding box, for the linedef's extent
  199. slopetype_t slopetype; // To aid move clipping.
  200. sector_t *frontsector; // Front and back sector.
  201. sector_t *backsector;
  202. int validcount; // if == validcount, already checked
  203. void *specialdata; // thinker_t for reversable actions
  204. int tranlump; // killough 4/11/98: translucency filter, -1 == none
  205. int firsttag,nexttag; // killough 4/17/98: improves searches for tags.
  206. int r_validcount; // cph: if == gametic, r_flags already done
  207. enum { // cph:
  208. RF_TOP_TILE = 1, // Upper texture needs tiling
  209. RF_MID_TILE = 2, // Mid texture needs tiling
  210. RF_BOT_TILE = 4, // Lower texture needs tiling
  211. RF_IGNORE = 8, // Renderer can skip this line
  212. RF_CLOSED =16, // Line blocks view
  213. } r_flags;
  214. degenmobj_t soundorg; // sound origin for switches/buttons
  215. };
  216. // phares 3/14/98
  217. //
  218. // Sector list node showing all sectors an object appears in.
  219. //
  220. // There are two threads that flow through these nodes. The first thread
  221. // starts at touching_thinglist in a sector_t and flows through the m_snext
  222. // links to find all mobjs that are entirely or partially in the sector.
  223. // The second thread starts at touching_sectorlist in an mobj_t and flows
  224. // through the m_tnext links to find all sectors a thing touches. This is
  225. // useful when applying friction or push effects to sectors. These effects
  226. // can be done as thinkers that act upon all objects touching their sectors.
  227. // As an mobj moves through the world, these nodes are created and
  228. // destroyed, with the links changed appropriately.
  229. //
  230. // For the links, NULL means top or end of list.
  231. typedef struct msecnode_s
  232. {
  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
  240. } msecnode_t;
  241. //
  242. // A SubSector.
  243. // References a Sector.
  244. // Basically, this is a list of LineSegs,
  245. // indicating the visible walls that define
  246. // (all or some) sides of a convex BSP leaf.
  247. //
  248. typedef struct subsector_s
  249. {
  250. sector_t *sector;
  251. unsigned short numlines, firstline;
  252. } subsector_t;
  253. //
  254. // BSP node.
  255. //
  256. typedef struct
  257. {
  258. fixed_t x, y, dx, dy; // Partition line.
  259. fixed_t bbox[2][4]; // Bounding box for each child.
  260. unsigned short children[2]; // If NF_SUBSECTOR its a subsector.
  261. } node_t;
  262. //
  263. // OTHER TYPES
  264. //
  265. // This could be wider for >8 bit display.
  266. // Indeed, true color support is posibble
  267. // precalculating 24bpp lightmap/colormap LUT.
  268. // from darkening PLAYPAL to all black.
  269. // Could use even more than 32 levels.
  270. typedef byte lighttable_t;
  271. //
  272. // Masked 2s linedefs
  273. //
  274. typedef struct drawseg_s
  275. {
  276. seg_t *curline;
  277. int x1, x2;
  278. fixed_t scale1, scale2, scalestep;
  279. int silhouette; // 0=none, 1=bottom, 2=top, 3=both
  280. fixed_t bsilheight; // do not clip sprites above this
  281. fixed_t tsilheight; // do not clip sprites below this
  282. // Added for filtering (fractional texture u coord) support - POPE
  283. fixed_t rw_offset, rw_distance, rw_centerangle;
  284. // Pointers to lists for sprite clipping,
  285. // all three adjusted so [x1] is first value.
  286. int *sprtopclip, *sprbottomclip, *maskedtexturecol; // dropoff overflow
  287. } drawseg_t;
  288. // proff: Added for OpenGL
  289. typedef struct
  290. {
  291. int width,height;
  292. int leftoffset,topoffset;
  293. int lumpnum;
  294. } patchnum_t;
  295. //
  296. // A vissprite_t is a thing that will be drawn during a refresh.
  297. // i.e. a sprite object that is partly visible.
  298. //
  299. typedef struct vissprite_s
  300. {
  301. mobj_t *thing;
  302. boolean flip;
  303. int x1, x2;
  304. fixed_t gx, gy; // for line side calculation
  305. fixed_t gz, gzt; // global bottom / top for silhouette clipping
  306. fixed_t startfrac; // horizontal position of x1
  307. fixed_t scale;
  308. fixed_t xiscale; // negative if flipped
  309. fixed_t texturemid;
  310. int patch;
  311. uint_64_t mobjflags;
  312. // for color translation and shadow draw, maxbright frames as well
  313. const lighttable_t *colormap;
  314. // killough 3/27/98: height sector for underwater/fake ceiling support
  315. int heightsec;
  316. boolean isplayersprite;
  317. } vissprite_t;
  318. //
  319. // Sprites are patches with a special naming convention
  320. // so they can be recognized by R_InitSprites.
  321. // The base name is NNNNFx or NNNNFxFx, with
  322. // x indicating the rotation, x = 0, 1-7.
  323. // The sprite and frame specified by a thing_t
  324. // is range checked at run time.
  325. // A sprite is a patch_t that is assumed to represent
  326. // a three dimensional object and may have multiple
  327. // rotations pre drawn.
  328. // Horizontal flipping is used to save space,
  329. // thus NNNNF2F5 defines a mirrored patch.
  330. // Some sprites will only have one picture used
  331. // for all views: NNNNF0
  332. //
  333. typedef struct
  334. {
  335. // If false use 0 for any position.
  336. // Note: as eight entries are available,
  337. // we might as well insert the same name eight times.
  338. boolean rotate;
  339. // Lump to use for view angles 0-7.
  340. short lump[8];
  341. // Flip bit (1 = flip) to use for view angles 0-7.
  342. byte flip[8];
  343. } spriteframe_t;
  344. //
  345. // A sprite definition:
  346. // a number of animation frames.
  347. //
  348. typedef struct
  349. {
  350. int numframes;
  351. spriteframe_t *spriteframes;
  352. } spritedef_t;
  353. //
  354. // Now what is a visplane, anyway?
  355. //
  356. // Go to http://classicgaming.com/doom/editing/ to find out -- killough
  357. //
  358. typedef struct visplane
  359. {
  360. struct visplane *next; // Next visplane in hash chain -- killough
  361. int picnum, lightlevel, minx, maxx;
  362. fixed_t height;
  363. fixed_t xoffs, yoffs; // killough 2/28/98: Support scrolling flats
  364. unsigned int pad1; // leave pads for [minx-1]/[maxx+1]
  365. unsigned int top[MAX_SCREENWIDTH];
  366. unsigned int pad2, pad3; // killough 2/8/98, 4/25/98
  367. unsigned int bottom[MAX_SCREENWIDTH];
  368. unsigned int pad4; // dropoff overflow
  369. } visplane_t;
  370. #endif