r_defs.h 13 KB

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