r_defs.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495
  1. /*
  2. ===========================================================================
  3. Doom 3 BFG Edition GPL Source Code
  4. Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
  5. This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
  6. Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
  16. In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
  17. If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
  18. ===========================================================================
  19. */
  20. #ifndef __R_DEFS__
  21. #define __R_DEFS__
  22. #include "Precompiled.h"
  23. // Screenwidth.
  24. #include "doomdef.h"
  25. // Some more or less basic data types
  26. // we depend on.
  27. #include "m_fixed.h"
  28. // We rely on the thinker data struct
  29. // to handle sound origins in sectors.
  30. #include "d_think.h"
  31. // SECTORS do store MObjs anyway.
  32. #include "p_mobj.h"
  33. // Silhouette, needed for clipping Segs (mainly)
  34. // and sprites representing things.
  35. #define SIL_NONE 0
  36. #define SIL_BOTTOM 1
  37. #define SIL_TOP 2
  38. #define SIL_BOTH 3
  39. #define MAXDRAWSEGS 1280
  40. //
  41. // INTERNAL MAP TYPES
  42. // used by play and refresh
  43. //
  44. //
  45. // Your plain vanilla vertex.
  46. // Note: transformed values not buffered locally,
  47. // like some DOOM-alikes ("wt", "WebView") did.
  48. //
  49. typedef struct
  50. {
  51. fixed_t x;
  52. fixed_t y;
  53. } vertex_t;
  54. // Forward of LineDefs, for Sectors.
  55. struct line_s;
  56. // Each sector has a degenmobj_t in its center
  57. // for sound origin purposes.
  58. // I suppose this does not handle sound from
  59. // moving objects (doppler), because
  60. // position is prolly just buffered, not
  61. // updated.
  62. typedef struct
  63. {
  64. thinker_t thinker; // not used for anything
  65. fixed_t x;
  66. fixed_t y;
  67. fixed_t z;
  68. } degenmobj_t;
  69. //
  70. // The SECTORS record, at runtime.
  71. // Stores things/mobjs.
  72. //
  73. typedef struct
  74. {
  75. fixed_t floorheight;
  76. fixed_t ceilingheight;
  77. short floorpic;
  78. short ceilingpic;
  79. short lightlevel;
  80. short special;
  81. short tag;
  82. // 0 = untraversed, 1,2 = sndlines -1
  83. int soundtraversed;
  84. // thing that made a sound (or null)
  85. mobj_t* soundtarget;
  86. // mapblock bounding box for height changes
  87. int blockbox[4];
  88. // origin for any sounds played by the sector
  89. degenmobj_t soundorg;
  90. // if == validcount, already checked
  91. int validcount;
  92. // list of mobjs in sector
  93. mobj_t* thinglist;
  94. // thinker_t for reversable actions
  95. void* specialdata;
  96. int linecount;
  97. struct line_s** lines; // [linecount] size
  98. } sector_t;
  99. //
  100. // The SideDef.
  101. //
  102. typedef struct
  103. {
  104. // add this to the calculated texture column
  105. fixed_t textureoffset;
  106. // add this to the calculated texture top
  107. fixed_t rowoffset;
  108. // Texture indices.
  109. // We do not maintain names here.
  110. short toptexture;
  111. short bottomtexture;
  112. short midtexture;
  113. // Sector the SideDef is facing.
  114. sector_t* sector;
  115. } side_t;
  116. //
  117. // Move clipping aid for LineDefs.
  118. //
  119. typedef enum
  120. {
  121. ST_HORIZONTAL,
  122. ST_VERTICAL,
  123. ST_POSITIVE,
  124. ST_NEGATIVE
  125. } slopetype_t;
  126. typedef struct line_s
  127. {
  128. // Vertices, from v1 to v2.
  129. vertex_t* v1;
  130. vertex_t* v2;
  131. // Precalculated v2 - v1 for side checking.
  132. fixed_t dx;
  133. fixed_t dy;
  134. // Animation related.
  135. short flags;
  136. short special;
  137. short tag;
  138. // Visual appearance: SideDefs.
  139. // sidenum[1] will be -1 if one sided
  140. short sidenum[2];
  141. // Neat. Another bounding box, for the extent
  142. // of the LineDef.
  143. fixed_t bbox[4];
  144. // To aid move clipping.
  145. slopetype_t slopetype;
  146. // Front and back sector.
  147. // Note: redundant? Can be retrieved from SideDefs.
  148. sector_t* frontsector;
  149. sector_t* backsector;
  150. // if == validcount, already checked
  151. int validcount;
  152. // thinker_t for reversable actions
  153. void* specialdata;
  154. } line_t;
  155. //
  156. // A SubSector.
  157. // References a Sector.
  158. // Basically, this is a list of LineSegs,
  159. // indicating the visible walls that define
  160. // (all or some) sides of a convex BSP leaf.
  161. //
  162. typedef struct subsector_s
  163. {
  164. sector_t* sector;
  165. short numlines;
  166. short firstline;
  167. } subsector_t;
  168. //
  169. // The LineSeg.
  170. //
  171. typedef struct
  172. {
  173. vertex_t* v1;
  174. vertex_t* v2;
  175. fixed_t offset;
  176. angle_t angle;
  177. side_t* sidedef;
  178. line_t* linedef;
  179. // Sector references.
  180. // Could be retrieved from linedef, too.
  181. // backsector is NULL for one sided lines
  182. sector_t* frontsector;
  183. sector_t* backsector;
  184. } seg_t;
  185. //
  186. // BSP node.
  187. //
  188. typedef struct
  189. {
  190. // Partition line.
  191. fixed_t x;
  192. fixed_t y;
  193. fixed_t dx;
  194. fixed_t dy;
  195. // Bounding box for each child.
  196. fixed_t bbox[2][4];
  197. // If NF_SUBSECTOR its a subsector.
  198. unsigned short children[2];
  199. } node_t;
  200. // posts are runs of non masked source pixels
  201. typedef struct
  202. {
  203. byte topdelta; // -1 is the last post in a column
  204. byte length; // length data bytes follows
  205. } post_t;
  206. // postColumn_t is a list of 0 or more post_t, (byte)-1 terminated
  207. typedef post_t postColumn_t;
  208. // PC direct to screen pointers
  209. //B UNUSED - keep till detailshift in r_draw.c resolved
  210. //extern byte* destview;
  211. //extern byte* destscreen;
  212. //
  213. // OTHER TYPES
  214. //
  215. // This could be wider for >8 bit display.
  216. // Indeed, true color support is posibble
  217. // precalculating 24bpp lightmap/colormap LUT.
  218. // from darkening PLAYPAL to all black.
  219. // Could even us emore than 32 levels.
  220. typedef byte lighttable_t;
  221. //
  222. // ?
  223. //
  224. typedef struct drawseg_s
  225. {
  226. seg_t* curline;
  227. int x1;
  228. int x2;
  229. fixed_t scale1;
  230. fixed_t scale2;
  231. fixed_t scalestep;
  232. // 0=none, 1=bottom, 2=top, 3=both
  233. int silhouette;
  234. // do not clip sprites above this
  235. fixed_t bsilheight;
  236. // do not clip sprites below this
  237. fixed_t tsilheight;
  238. // Pointers to lists for sprite clipping,
  239. // all three adjusted so [x1] is first value.
  240. short* sprtopclip;
  241. short* sprbottomclip;
  242. short* maskedtexturecol;
  243. } drawseg_t;
  244. // Patches.
  245. // A patch holds one or more columns.
  246. // Patches are used for sprites and all masked pictures,
  247. // and we compose textures from the TEXTURE1/2 lists
  248. // of patches.
  249. struct patch_t
  250. {
  251. short width; // bounding box size
  252. short height;
  253. short leftoffset; // pixels to the left of origin
  254. short topoffset; // pixels below the origin
  255. int columnofs[8]; // only [width] used
  256. // the [0] is &columnofs[width]
  257. };
  258. // A vissprite_t is a thing
  259. // that will be drawn during a refresh.
  260. // I.e. a sprite object that is partly visible.
  261. typedef struct vissprite_s
  262. {
  263. int suck; //Compiler opt fix...wtf
  264. // Doubly linked list.
  265. struct vissprite_s* prev;
  266. struct vissprite_s* next;
  267. int x1;
  268. int x2;
  269. // for line side calculation
  270. fixed_t gx;
  271. fixed_t gy;
  272. // global bottom / top for silhouette clipping
  273. fixed_t gz;
  274. fixed_t gzt;
  275. // horizontal position of x1
  276. fixed_t startfrac;
  277. fixed_t scale;
  278. // negative if flipped
  279. fixed_t xiscale;
  280. fixed_t texturemid;
  281. int patch;
  282. // for color translation and shadow draw,
  283. // maxbright frames as well
  284. lighttable_t* colormap;
  285. int mobjflags;
  286. } vissprite_t;
  287. //
  288. // Sprites are patches with a special naming convention
  289. // so they can be recognized by R_InitSprites.
  290. // The base name is NNNNFx or NNNNFxFx, with
  291. // x indicating the rotation, x = 0, 1-7.
  292. // The sprite and frame specified by a thing_t
  293. // is range checked at run time.
  294. // A sprite is a patch_t that is assumed to represent
  295. // a three dimensional object and may have multiple
  296. // rotations pre drawn.
  297. // Horizontal flipping is used to save space,
  298. // thus NNNNF2F5 defines a mirrored patch.
  299. // Some sprites will only have one picture used
  300. // for all views: NNNNF0
  301. //
  302. typedef struct
  303. {
  304. // If false use 0 for any position.
  305. // Note: as eight entries are available,
  306. // we might as well insert the same name eight times.
  307. qboolean rotate;
  308. // Lump to use for view angles 0-7.
  309. short lump[8];
  310. // Flip bit (1 = flip) to use for view angles 0-7.
  311. byte flip[8];
  312. } spriteframe_t;
  313. //
  314. // A sprite definition:
  315. // a number of animation frames.
  316. //
  317. typedef struct
  318. {
  319. int numframes;
  320. spriteframe_t* spriteframes;
  321. } spritedef_t;
  322. //
  323. // Now what is a visplane, anyway?
  324. //
  325. typedef struct
  326. {
  327. fixed_t height;
  328. int picnum;
  329. int lightlevel;
  330. int minx;
  331. int maxx;
  332. // leave pads for [minx-1]/[maxx+1]
  333. int nervePad1;
  334. int nervePad2;
  335. byte nervePad3;
  336. byte nervePad4;
  337. byte nervePad5;
  338. byte pad1;
  339. // Here lies the rub for all
  340. // dynamic resize/change of resolution.
  341. //unsigned short top[65535]; // [SCREENWIDTH];
  342. unsigned short top[SCREENWIDTH];
  343. byte pad2;
  344. byte pad3;
  345. // See above.
  346. //unsigned short bottom[65535]; // [SCREENWIDTH];
  347. unsigned short bottom[SCREENWIDTH];
  348. byte pad4;
  349. } visplane_t;
  350. #endif