1 //---------------------------------------------------------------------------- 2 // EDGE Rendering Definitions Header 3 //---------------------------------------------------------------------------- 4 // 5 // Copyright (c) 1999-2009 The EDGE Team. 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License 9 // as published by the Free Software Foundation; either version 2 10 // of the License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 //---------------------------------------------------------------------------- 18 // 19 // Based on the DOOM source code, released by Id Software under the 20 // following copyright: 21 // 22 // Copyright (C) 1993-1996 by id Software, Inc. 23 // 24 //---------------------------------------------------------------------------- 25 26 #ifndef __R_DEFS_H__ 27 #define __R_DEFS_H__ 28 29 // Screenwidth. 30 #include "dm_defs.h" 31 32 // Some more or less basic data types 33 // we depend on. 34 #include "m_math.h" 35 36 // SECTORS do store MObjs anyway. 37 #include "p_mobj.h" 38 39 // -AJA- 1999/07/10: Need this for colourmap_c. 40 #include "ddf/main.h" 41 42 class image_c; 43 44 45 // 46 // INTERNAL MAP TYPES 47 // used by play and refresh 48 // 49 50 // 51 // Your plain vanilla vertex. 52 // Note: transformed values not buffered locally, like some 53 // DOOM-alikes ("wt", "WebView") did. 54 // 55 typedef vec2_t vertex_t; 56 57 // Forward of LineDefs, for Sectors. 58 struct line_s; 59 struct side_s; 60 struct region_properties_s; 61 62 63 // 64 // Touch Node 65 // 66 // -AJA- Used for remembering things that are inside or touching 67 // sectors. The idea is blatantly copied from BOOM: there are two 68 // lists running through each node, (a) list for things, to remember 69 // what sectors they are in/touch, (b) list for sectors, holding what 70 // things are in or touch them. 71 // 72 // NOTE: we use the same optimisation: in P_UnsetThingPos we just 73 // clear all the `mo' fields to NULL. During P_SetThingPos we find 74 // the first NULL `mo' field (i.e. as an allocation). The interesting 75 // part is that we only need to unlink the node from the sector list 76 // (and relink) if the sector in that node is different. Thus saving 77 // work for the common case where the sector(s) don't change. 78 // 79 // CAVEAT: this means that very little should be done in between 80 // P_UnsetThingPos and P_SetThingPos calls, ideally just load some new 81 // x/y position. Avoid especially anything that scans the sector 82 // touch lists. 83 // 84 typedef struct touch_node_s 85 { 86 struct mobj_s *mo; 87 struct touch_node_s *mo_next; 88 struct touch_node_s *mo_prev; 89 90 struct sector_s *sec; 91 struct touch_node_s *sec_next; 92 struct touch_node_s *sec_prev; 93 } 94 touch_node_t; 95 96 97 // 98 // Region Properties 99 // 100 // Stores the properties that affect each vertical region. 101 // 102 typedef struct region_properties_s 103 { 104 // rendering related 105 int lightlevel; 106 107 const colourmap_c *colourmap; // can be NULL 108 109 // special type (e.g. damaging) 110 int type; 111 const sectortype_c *special; 112 113 // -KM- 1998/10/29 Added gravity + friction 114 float gravity; 115 float friction; 116 float viscosity; 117 float drag; 118 119 // pushing sector information (normally all zero) 120 vec3_t push; 121 } 122 region_properties_t; 123 124 // 125 // Surface 126 // 127 // Stores the texturing information about a single "surface", which is 128 // either a wall part or a ceiling/floor. Doesn't include position 129 // info -- that is elsewhere. 130 // 131 // Texture coordinates are computed from World coordinates via: 132 // wx += offset.x 133 // wy += offset.y 134 // 135 // tx = wx * x_mat.x + wy * x_mat.y 136 // ty = wx * y_mat.x + wy * y_mat.y 137 // 138 typedef struct surface_s 139 { 140 const image_c *image; 141 142 float translucency; 143 144 // texturing matrix (usually identity) 145 vec2_t x_mat; 146 vec2_t y_mat; 147 148 // current offset and scrolling deltas (world coords) 149 vec2_t offset; 150 vec2_t scroll; 151 152 // lighting override (as in BOOM). Usually NULL. 153 struct region_properties_s *override_p; 154 } 155 surface_t; 156 157 // 158 // ExtraFloor 159 // 160 // Stores information about a single extrafloor within a sector. 161 // 162 // -AJA- 2001/07/11: added this, replaces vert_region. 163 // 164 typedef struct extrafloor_s 165 { 166 // links in chain. These are sorted by increasing heights, using 167 // bottom_h as the reference. This is important, especially when a 168 // liquid extrafloor overlaps a solid one: using this rule, the 169 // liquid region will be higher than the solid one. 170 // 171 struct extrafloor_s *higher; 172 struct extrafloor_s *lower; 173 174 struct sector_s *sector; 175 176 // top and bottom heights of the extrafloor. For non-THICK 177 // extrafloors, these are the same. These are generally the same as 178 // in the dummy sector, EXCEPT during the process of moving the 179 // extrafloor. 180 // 181 float top_h, bottom_h; 182 183 // top/bottom surfaces of the extrafloor 184 surface_t *top; 185 surface_t *bottom; 186 187 // properties used for stuff below us 188 region_properties_t *p; 189 190 // type of extrafloor this is. Only NULL for unused extrafloors. 191 // This value is cached pointer to ef_line->special->ef. 192 // 193 const extrafloordef_c *ef_info; 194 195 // extrafloor linedef (frontsector == control sector). Only NULL 196 // for unused extrafloors. 197 // 198 struct line_s *ef_line; 199 200 // link in dummy sector's controlling list 201 struct extrafloor_s *ctrl_next; 202 } 203 extrafloor_t; 204 205 // Vertical gap between a floor & a ceiling. 206 // -AJA- 1999/07/19. 207 // 208 typedef struct 209 { 210 float f; // floor 211 float c; // ceiling 212 } 213 vgap_t; 214 215 typedef struct slope_plane_s 216 { 217 // Note: z coords are relative to the floor/ceiling height 218 float x1, y1, dz1; 219 float x2, y2, dz2; 220 } 221 slope_plane_t; 222 223 224 // 225 // The SECTORS record, at runtime. 226 // 227 struct subsector_s; 228 229 typedef struct sector_s 230 { 231 // floor and ceiling heights 232 float f_h, c_h; 233 234 surface_t floor, ceil; 235 236 region_properties_t props; 237 238 int tag; 239 240 // set of extrafloors (in the global `extrafloors' array) that this 241 // sector can use. At load time we can deduce the maximum number 242 // needed for extrafloors, even if they dynamically come and go. 243 // 244 short exfloor_max; 245 short exfloor_used; 246 extrafloor_t *exfloor_first; 247 248 // -AJA- 2001/07/11: New multiple extrafloor code. 249 // 250 // Now the FLOORS ARE IMPLIED. Unlike before, the floor below an 251 // extrafloor is NOT stored in each extrafloor_t -- you must scan 252 // down to find them, and use the sector's floor if you hit NULL. 253 // 254 extrafloor_t *bottom_ef; 255 extrafloor_t *top_ef; 256 257 // Liquid extrafloors are now kept in a separate list. For many 258 // purposes (especially moving sectors) they otherwise just get in 259 // the way. 260 // 261 extrafloor_t *bottom_liq; 262 extrafloor_t *top_liq; 263 264 // properties that are active for this sector (top-most extrafloor). 265 // This may be different than the sector's actual properties (the 266 // "props" field) due to flooders. 267 // 268 region_properties_t *p; 269 270 // slope information, normally NULL 271 slope_plane_t *f_slope; 272 slope_plane_t *c_slope; 273 274 // linked list of extrafloors that this sector controls. NULL means 275 // that this sector is not a controller. 276 // 277 extrafloor_t *control_floors; 278 279 // movement thinkers, for quick look-up 280 struct plane_move_s *floor_move; 281 struct plane_move_s *ceil_move; 282 283 // 0 = untraversed, 1,2 = sndlines-1 284 int soundtraversed; 285 286 // player# that made a sound (starting at 0), or -1 287 int sound_player; 288 289 // origin for any sounds played by the sector 290 position_c sfx_origin; 291 292 int linecount; 293 struct line_s **lines; // [linecount] size 294 295 // touch list: objects in or touching this sector 296 touch_node_t *touch_things; 297 298 // list of sector glow things (linked via dlnext/dlprev) 299 mobj_t *glow_things; 300 301 // sky height for GL renderer 302 float sky_h; 303 304 // keep track of vertical sight gaps within the sector. This is 305 // just a much more convenient form of the info in the extrafloor 306 // list. 307 // 308 short max_gaps; 309 short sight_gap_num; 310 311 vgap_t *sight_gaps; 312 313 // if == validcount, already checked 314 int validcount; 315 316 // -AJA- 1999/07/29: Keep sectors with same tag in a list. 317 struct sector_s *tag_next; 318 struct sector_s *tag_prev; 319 320 // -AJA- 2000/03/30: Keep a list of child subsectors. 321 struct subsector_s *subsectors; 322 } 323 sector_t; 324 325 326 // 327 // The SideDef. 328 // 329 typedef struct side_s 330 { 331 surface_t top; 332 surface_t middle; 333 surface_t bottom; 334 335 // Sector the SideDef is facing. 336 sector_t *sector; 337 338 // midmasker Y offset 339 float midmask_offset; 340 } 341 side_t; 342 343 // 344 // Move clipping aid for LineDefs. 345 // 346 typedef enum 347 { 348 ST_HORIZONTAL, 349 ST_VERTICAL, 350 ST_POSITIVE, 351 ST_NEGATIVE 352 } 353 slopetype_t; 354 355 #define SECLIST_MAX 11 356 357 typedef struct 358 { 359 unsigned short num; 360 unsigned short sec[SECLIST_MAX]; 361 } 362 vertex_seclist_t; 363 364 // 365 // LINEDEF 366 // 367 368 typedef struct line_s 369 { 370 // Vertices, from v1 to v2. 371 vec2_t *v1; 372 vec2_t *v2; 373 374 // Precalculated v2 - v1 for side checking. 375 float dx; 376 float dy; 377 float length; 378 379 // Animation related. 380 int flags; 381 int tag; 382 int count; 383 384 const linetype_c *special; 385 386 // Visual appearance: SideDefs. 387 // side[1] will be NULL if one sided. 388 side_t *side[2]; 389 390 // Front and back sector. 391 // Note: kinda redundant (could be retrieved from sidedefs), but it 392 // simplifies the code. 393 sector_t *frontsector; 394 sector_t *backsector; 395 396 // Neat. Another bounding box, for the extent of the LineDef. 397 float bbox[4]; 398 399 // To aid move clipping. 400 slopetype_t slopetype; 401 402 // if == validcount, already checked 403 int validcount; 404 405 // whether this linedef is "blocking" for rendering purposes. 406 // Always true for 1s lines. Always false when both sides of the 407 // line reference the same sector. 408 // 409 bool blocked; 410 411 // -AJA- 1999/07/19: Extra floor support. We now keep track of the 412 // gaps between the front & back sectors here, instead of computing 413 // them each time in P_LineOpening() -- which got a lot more complex 414 // due to extra floors. Now they only need to be recomputed when 415 // one of the sectors changes height. The pointer here points into 416 // the single global array `vertgaps'. 417 // 418 short max_gaps; 419 short gap_num; 420 421 vgap_t *gaps; 422 423 const linetype_c *slide_door; 424 425 // slider thinker, normally NULL 426 struct slider_move_s *slider_move; 427 428 struct line_s *portal_pair; 429 } 430 line_t; 431 432 // 433 // SubSector. 434 // 435 // References a Sector. 436 // Basically, this is a list of LineSegs, indicating the visible walls 437 // that define all sides of a convex BSP leaf. 438 // 439 typedef struct subsector_s 440 { 441 // link in sector list 442 struct subsector_s *sec_next; 443 444 sector_t *sector; 445 struct seg_s *segs; 446 447 // list of mobjs in subsector 448 mobj_t *thinglist; 449 450 // pointer to bounding box (usually in parent node) 451 float *bbox; 452 453 // -AJA- 2004/04/20: used when emulating deep-water TRICK 454 struct sector_s *deep_ref; 455 } 456 subsector_t; 457 458 // 459 // The LineSeg 460 // 461 // Defines part of a wall that faces inwards on a convex BSP leaf. 462 // 463 typedef struct seg_s 464 { 465 vec2_t *v1; 466 vec2_t *v2; 467 468 angle_t angle; 469 470 float length; 471 472 // link in subsector list. 473 // (NOTE: sorted in clockwise order) 474 struct seg_s *sub_next; 475 476 // -AJA- 1999/12/20: Reference to partner seg, or NULL if the seg 477 // lies along a one-sided line. 478 struct seg_s *partner; 479 480 // -AJA- 1999/09/23: Reference to subsector on each side of seg, 481 // back_sub is NULL for one-sided segs. 482 // (Addendum: back_sub is obsolete with new `partner' field) 483 subsector_t *front_sub; 484 subsector_t *back_sub; 485 486 // -AJA- 1999/09/23: For "True BSP rendering", we keep track of the 487 // `minisegs' which define all the non-wall borders of the 488 // subsector. Thus all the segs (normal + mini) define a 489 // closed convex polygon. When the `miniseg' field is true, 490 // all the fields below it are unused. 491 // 492 bool miniseg; 493 494 float offset; 495 496 side_t *sidedef; 497 line_t *linedef; 498 499 int side; // 0 for front, 1 for back 500 501 // Sector references. 502 // backsector is NULL for one sided lines 503 504 sector_t *frontsector; 505 sector_t *backsector; 506 507 // compact list of sectors touching each vertex (can be NULL) 508 vertex_seclist_t *nb_sec[2]; 509 } 510 seg_t; 511 512 // Partition line. 513 typedef struct divline_s 514 { 515 float x; 516 float y; 517 float dx; 518 float dy; 519 } 520 divline_t; 521 522 // 523 // BSP node. 524 // 525 typedef struct node_s 526 { 527 divline_t div; 528 float div_len; 529 530 // bit NF_V5_SUBSECTOR set for a subsector. 531 unsigned int children[2]; 532 533 // Bounding boxes for this node. 534 float bbox[2][4]; 535 } 536 node_t; 537 538 539 #endif /*__R_DEFS__*/ 540 541 //--- editor settings --- 542 // vi:ts=4:sw=4:noexpandtab 543