| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 4 | * |
| 5 | * This program is free software: you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation, either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program 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 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/terrainrender.cpp $ |
| 21 | * $Revision: 242 $ |
| 22 | * $Date: 9/06/01 12:15p $ |
| 23 | * $Author: Matt $ |
| 24 | * |
| 25 | * Terrain rendering code |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/terrainrender.cpp $ |
| 28 | * |
| 29 | * 242 9/06/01 12:15p Matt |
| 30 | * Added bounds checking for postrender list. |
| 31 | * |
| 32 | * 241 4/19/00 5:30p Matt |
| 33 | * From Duane for 1.4 |
| 34 | * Mac sky changes |
| 35 | * |
| 36 | * 240 3/20/00 12:21p Matt |
| 37 | * Merge of Duane's post-1.3 changes. |
| 38 | * Caching optimization. |
| 39 | * |
| 40 | * 239 10/21/99 9:29p Jeff |
| 41 | * B.A. Macintosh code merge |
| 42 | * |
| 43 | * 238 10/21/99 5:27p Gwar |
| 44 | * fixed a pesky crash |
| 45 | * |
| 46 | * 237 10/21/99 4:33p Gwar |
| 47 | * objects weren't displaying in NEWEDITOR release build |
| 48 | * |
| 49 | * 236 10/12/99 10:55a Gwar |
| 50 | * added DrawTerrainOutline for NEWEDITOR |
| 51 | * |
| 52 | * 235 10/12/99 10:19a Gwar |
| 53 | * adding terrain support to NEWEDITOR |
| 54 | * |
| 55 | * 234 7/28/99 3:40p Kevin |
| 56 | * Macintosh! |
| 57 | * |
| 58 | * 233 5/13/99 3:42p Ardussi |
| 59 | * changes for compiling on the Mac |
| 60 | * |
| 61 | * 232 5/07/99 7:22p Jason |
| 62 | * changes for cards with low videomemory |
| 63 | * |
| 64 | * 230 5/05/99 6:09p 3dsmax |
| 65 | * checked in dumb hack for now |
| 66 | * |
| 67 | * 229 4/27/99 3:36p Jason |
| 68 | * fixed terrain occlusion bug |
| 69 | * |
| 70 | * 228 4/23/99 7:18p Jason |
| 71 | * fixed some multiplayer issues with observer mode |
| 72 | * |
| 73 | * 227 4/22/99 12:05p Jason |
| 74 | * fixed some more direct3d issues |
| 75 | * |
| 76 | * 226 4/21/99 11:05a Kevin |
| 77 | * new ps_rand and ps_srand to replace rand & srand |
| 78 | * |
| 79 | * 225 4/17/99 6:15p Samir |
| 80 | * replaced gr.h with grdefs.h and fixed resulting compile bugs. |
| 81 | * |
| 82 | * 224 4/16/99 11:33p Jeff |
| 83 | * ifdef out some terrain triangle draw code, needs software renderer (for |
| 84 | * linux) |
| 85 | * |
| 86 | * 223 4/16/99 12:37a Matt |
| 87 | * Made Windows & Linux versions use the same qsort calls. |
| 88 | * |
| 89 | * 222 4/15/99 1:43a Jeff |
| 90 | * changes for linux compile |
| 91 | * |
| 92 | * 221 4/14/99 3:57a Jeff |
| 93 | * fixed case mismatch in #includes |
| 94 | * |
| 95 | * 220 4/03/99 2:20p Jason |
| 96 | * added better heat damage effect |
| 97 | * |
| 98 | * 219 4/01/99 1:19p Jason |
| 99 | * draw band even with textured sky |
| 100 | * |
| 101 | * 218 3/31/99 11:41a Jason |
| 102 | * added support for attached thick lightning |
| 103 | * |
| 104 | * 217 3/01/99 2:39p Jason |
| 105 | * fixed star and halo rendering |
| 106 | * |
| 107 | * 216 2/26/99 3:26p Jason |
| 108 | * made satellites clip properly |
| 109 | * |
| 110 | * 215 2/19/99 4:26p Jason |
| 111 | * more work on Katmai support |
| 112 | * |
| 113 | * 214 2/19/99 12:04p Jason |
| 114 | * took out sky band |
| 115 | * |
| 116 | * 213 2/17/99 1:59p Jason |
| 117 | * fixed some postrender issues |
| 118 | * |
| 119 | * 212 2/17/99 1:05p Jason |
| 120 | * revamped object/face/terrain selection code |
| 121 | * |
| 122 | * 211 2/16/99 12:39a Matt |
| 123 | * Removed render_objs from terrain_segment and created parallel array |
| 124 | * |
| 125 | * 210 2/09/99 12:10p Jason |
| 126 | * rewriting indoor engine |
| 127 | * |
| 128 | * 209 2/08/99 5:07p Jason |
| 129 | * orthogonalize sky rotation matrix |
| 130 | * |
| 131 | * 208 2/05/99 3:37p Jason |
| 132 | * added/fixed features for the designers |
| 133 | * |
| 134 | * 207 2/04/99 12:17p Kevin |
| 135 | * Small fix for release builds |
| 136 | * |
| 137 | * 206 2/04/99 12:13p Jason |
| 138 | * fixed release array |
| 139 | * |
| 140 | * 205 2/01/99 10:51a Jason |
| 141 | * fixed outlines on terrain |
| 142 | * |
| 143 | * 204 1/29/99 11:29a Jason |
| 144 | * added misc bug fixes/features |
| 145 | * |
| 146 | * 203 1/24/99 5:43p Jason |
| 147 | * changes for terrain tiling |
| 148 | * |
| 149 | * 202 1/24/99 2:11a Jason |
| 150 | * fixed dumb texture UV problem |
| 151 | * |
| 152 | * 201 1/22/99 3:59p Jason |
| 153 | * added 256x256 textures to help with terrain skies |
| 154 | * |
| 155 | * 200 1/21/99 11:17a Jason |
| 156 | * fixed terrain rendering problem at the edges of the map |
| 157 | * |
| 158 | * 199 1/20/99 3:50p Jason |
| 159 | * fixed automap problem |
| 160 | * |
| 161 | * 197 1/20/99 2:48p Jason |
| 162 | * more terrain speedups |
| 163 | * |
| 164 | * 196 1/20/99 1:40p Jason |
| 165 | * terrain speedups |
| 166 | * |
| 167 | * 195 1/20/99 10:50a Jason |
| 168 | * added new terrain |
| 169 | * |
| 170 | * 194 12/29/98 6:12p Jason |
| 171 | * stupid fix for level designers |
| 172 | * |
| 173 | * 193 12/17/98 2:18p Jason |
| 174 | * fixed mip mapping problem |
| 175 | * |
| 176 | * 192 12/11/98 2:43p Jason |
| 177 | * tweaked snow |
| 178 | * |
| 179 | * 191 12/09/98 1:09p Jason |
| 180 | * second draft of automap |
| 181 | * |
| 182 | * 190 11/18/98 5:10p Jason |
| 183 | * fixed z buffer snow |
| 184 | * |
| 185 | * 189 11/18/98 4:30p Jason |
| 186 | * added some functionality to terrain fog |
| 187 | * |
| 188 | * 188 11/18/98 2:54p Jason |
| 189 | * added snow effect |
| 190 | * |
| 191 | * 187 11/06/98 5:42p Jason |
| 192 | * took out terrain casting |
| 193 | * |
| 194 | * 186 10/22/98 4:02p Jason |
| 195 | * made lightmaps draw even in nolightmap mode |
| 196 | * |
| 197 | * 185 10/22/98 10:21a Jason |
| 198 | * fixed wrap/clamp problem |
| 199 | * |
| 200 | * 184 10/21/98 9:28p Jason |
| 201 | * Made no lightmaps work globally |
| 202 | * |
| 203 | * 183 10/21/98 8:40p Jason |
| 204 | * testing for Mark |
| 205 | * |
| 206 | * 182 10/21/98 6:54p Jason |
| 207 | * changes for shitty direct3d cards |
| 208 | * |
| 209 | * 181 10/19/98 6:30p Jeff |
| 210 | * changes made for detail variables. Put in preset values. Preset |
| 211 | * options. Removed terrain_cast from detail. Put new callbacks in |
| 212 | * UIListBox and UISlider |
| 213 | * |
| 214 | * 180 10/16/98 1:54p Kevin |
| 215 | * Changes for Demo Beta 4 |
| 216 | * |
| 217 | * 179 10/07/98 5:17p Jason |
| 218 | * fixed lighting on the terrain |
| 219 | * |
| 220 | * 178 10/03/98 11:21p Matt |
| 221 | * Added system to seperately control outline mode for mine, terrain, sky, |
| 222 | * & objects |
| 223 | * |
| 224 | * 177 10/02/98 5:31p Jason |
| 225 | * tweaks for statelimited stuff |
| 226 | * |
| 227 | * 176 10/02/98 12:26p Jason |
| 228 | * fixed fogging of indoor rooms |
| 229 | * |
| 230 | * 175 9/29/98 3:00p Jason |
| 231 | * fixed state limited bug with lightmaps |
| 232 | * |
| 233 | * 174 9/29/98 2:02p Jason |
| 234 | * fixed external rooms rendering even when they shouldn't |
| 235 | * |
| 236 | * 173 9/25/98 9:25p Jason |
| 237 | * did some graphics optimizations |
| 238 | * |
| 239 | * 172 9/25/98 11:58a Jason |
| 240 | * various rendering optimizations |
| 241 | * |
| 242 | * 171 9/24/98 12:57p Jason |
| 243 | * more state limited optimizations |
| 244 | * |
| 245 | * 170 9/23/98 11:16a Jason |
| 246 | * fixed some lightmap problems |
| 247 | * |
| 248 | * 169 9/22/98 11:46a Jason |
| 249 | * made terrain lightmap rendering more state friendly |
| 250 | * |
| 251 | * 168 9/17/98 6:51p Jason |
| 252 | * fixed streaking vectors |
| 253 | * |
| 254 | * 167 9/17/98 3:03p Jason |
| 255 | * added lightning and invul hit effects |
| 256 | * |
| 257 | * 166 9/11/98 5:09p Jason |
| 258 | * made terrain state-change friendly |
| 259 | * |
| 260 | * 165 8/25/98 6:34p Craig |
| 261 | * Include terrain outline func in non-editor debug versions. |
| 262 | * |
| 263 | * 164 8/25/98 1:50p Jason |
| 264 | * made outlines draw in ndebug mode, instead of editor mode |
| 265 | * |
| 266 | * 163 8/19/98 5:48p Jason |
| 267 | * made robots have at least a mininum amount of lighting |
| 268 | * |
| 269 | * 162 8/19/98 2:19p Jeff |
| 270 | * moved detail globals to a struct |
| 271 | * |
| 272 | * 161 8/17/98 5:27p Jason |
| 273 | * fixed dynamic lighting for objects above the terrain ceiling |
| 274 | * |
| 275 | * 160 8/14/98 4:00p Jason |
| 276 | * added specular objects outside |
| 277 | * |
| 278 | * 159 8/06/98 11:00a Jason |
| 279 | * added blurred stars |
| 280 | * |
| 281 | * 158 8/04/98 2:55p Jason |
| 282 | * added motion blurred stars |
| 283 | * |
| 284 | * 157 7/24/98 4:49p Jason |
| 285 | * made terrain casting work again |
| 286 | * |
| 287 | * 156 7/20/98 12:04p Jason |
| 288 | * added per level satellite lighting |
| 289 | * |
| 290 | * 155 6/24/98 7:03p Jason |
| 291 | * fixed omega and external room sorting problem |
| 292 | * |
| 293 | * 154 6/24/98 3:56p Jason |
| 294 | * added code for new omega cannon |
| 295 | * |
| 296 | * 153 6/16/98 2:56p Jason |
| 297 | * fixed terrain occlusion bug with objects |
| 298 | * |
| 299 | * 152 6/15/98 4:00p Jason |
| 300 | * replaced monochromatic polymodel lighting with rgb lighting |
| 301 | * |
| 302 | * 151 6/12/98 5:15p Jason |
| 303 | * added dynamic volume light system |
| 304 | * |
| 305 | * 150 6/10/98 12:23p Jason |
| 306 | * added new skies |
| 307 | * |
| 308 | * 149 6/04/98 6:45p Jason |
| 309 | * made objects use the terrain occlusion system |
| 310 | * |
| 311 | * 148 5/26/98 6:54p Jason |
| 312 | * viseffect optimizations |
| 313 | * |
| 314 | * 147 5/25/98 3:46p Jason |
| 315 | * added better light glows |
| 316 | * |
| 317 | * 146 5/14/98 2:17p Jason |
| 318 | * more changes to be memory friendly |
| 319 | * |
| 320 | * 145 5/14/98 12:56p Jason |
| 321 | * changes to help lower memory usage |
| 322 | * |
| 323 | * 144 5/11/98 7:03p Jason |
| 324 | * fixed terrain bug with microwave effect |
| 325 | * |
| 326 | * 143 5/06/98 6:18p Jason |
| 327 | * improved terrain raycasting |
| 328 | * |
| 329 | * 142 5/05/98 6:27p Chris |
| 330 | * Added BBoxs and spheres to external rooms (in mode 2) |
| 331 | * |
| 332 | * 141 5/05/98 5:28p Jason |
| 333 | * more terrain speedups |
| 334 | * |
| 335 | * 140 5/05/98 4:38p Jason |
| 336 | * added raycasting test stuff |
| 337 | * |
| 338 | * 139 5/04/98 8:04p Jason |
| 339 | * made wireframe sky view |
| 340 | * |
| 341 | * 138 5/01/98 5:46p Jason |
| 342 | * fixed external room popping bug |
| 343 | * |
| 344 | * 137 5/01/98 3:51p Jason |
| 345 | * sped up terrain rendering by precaching all megacell lod bitmaps |
| 346 | * |
| 347 | * 136 5/01/98 12:42p Jason |
| 348 | * slight framerate enhancement |
| 349 | * |
| 350 | * 135 4/30/98 6:45p Jason |
| 351 | * more changes for weather |
| 352 | * |
| 353 | * 134 4/30/98 12:22p Jason |
| 354 | * did some lo-res model optimizations |
| 355 | * |
| 356 | * 133 4/29/98 3:27p Jason |
| 357 | * added weather engine |
| 358 | * |
| 359 | * 132 4/29/98 11:38a Jason |
| 360 | * added some weather effects (first pass) |
| 361 | * |
| 362 | * 131 4/23/98 12:21p Jason |
| 363 | * fixed rendering bug if satellite values were out of range |
| 364 | * |
| 365 | * 130 4/19/98 5:00p Jason |
| 366 | * added cool napalm effect, plus made object effects dynamically |
| 367 | * allocated |
| 368 | * |
| 369 | * 129 4/17/98 3:57p Jason |
| 370 | * added microwave effect |
| 371 | * |
| 372 | * 128 4/10/98 6:04p Jason |
| 373 | * fixed some lighting issues |
| 374 | * |
| 375 | * 127 4/03/98 1:36p Jason |
| 376 | * saved some memory |
| 377 | * |
| 378 | * 126 4/01/98 11:26a Jeff |
| 379 | * Added an editor bool to skip Terrain object rendering |
| 380 | * |
| 381 | * 125 3/26/98 10:54a Jason |
| 382 | * tweaked some stuff for size independant terrain |
| 383 | * |
| 384 | * 124 3/17/98 5:02p Jason |
| 385 | * sped up rendering the terrain from the mine by a large amount |
| 386 | * |
| 387 | * 123 3/09/98 4:54p Jason |
| 388 | * don't render objects that can't been seen through a portal |
| 389 | * |
| 390 | * 122 3/06/98 2:33p Jason |
| 391 | * fixed potential memory overwrite bug |
| 392 | * |
| 393 | * 121 3/06/98 2:17p Jason |
| 394 | * sped up terrain by making lod'd triangles quads |
| 395 | * |
| 396 | * 120 2/25/98 2:05p Jason |
| 397 | * did FOV and object visibility changes |
| 398 | * |
| 399 | * 119 2/17/98 2:22p Jason |
| 400 | * fixed some potential z sorting problems |
| 401 | * |
| 402 | * 118 2/12/98 1:32p Jason |
| 403 | * got mipmapping working |
| 404 | * |
| 405 | * 117 2/10/98 5:42p Jason |
| 406 | * fixed object rendering with RT_ROOM type |
| 407 | * |
| 408 | * 116 2/10/98 10:28a Matt |
| 409 | * Got rid of compile warning |
| 410 | * |
| 411 | * 115 2/09/98 7:31p Matt |
| 412 | * Changed object rendering code to not look at Viewer_object to determine |
| 413 | * whether to render the object |
| 414 | * |
| 415 | * 114 2/05/98 6:02p Jason |
| 416 | * fixed bug my previous rev introduced |
| 417 | * |
| 418 | * 113 2/05/98 4:41p Jason |
| 419 | * fixed off by one bug |
| 420 | * |
| 421 | * 112 2/05/98 12:35p Jason |
| 422 | * fixed screen clearing problem with gouraud sky |
| 423 | * |
| 424 | * 111 2/04/98 6:58p Matt |
| 425 | * Fixed viseffect rendering on terrain. |
| 426 | * |
| 427 | * 110 2/04/98 6:09p Matt |
| 428 | * Changed object room number to indicate a terrain cell via a flag. Got |
| 429 | * rid of the object flag which used to indicate terrain. |
| 430 | * |
| 431 | * 109 2/02/98 3:19p Jason |
| 432 | * made stars draw with different colors |
| 433 | * |
| 434 | * 108 1/30/98 12:12p Jason |
| 435 | * fixed LOD bug. This gives us twice the framerate in hilly areas!!! |
| 436 | * |
| 437 | * 107 1/29/98 5:50p Matt |
| 438 | * Changed old camera object type to be viewer object (for editor), and |
| 439 | * now camera objects will just be for game cameras. |
| 440 | * |
| 441 | * 106 1/28/98 4:06p Jason |
| 442 | * made stars not darken so much on blur |
| 443 | * |
| 444 | * 105 1/28/98 3:55p Jason |
| 445 | * added stars after the textured sky |
| 446 | * |
| 447 | * 104 1/23/98 6:25p Jason |
| 448 | * Got spray weapons working |
| 449 | * |
| 450 | * 103 1/20/98 2:17p Jason |
| 451 | * fixed weird sorting problem with objects and viseffects |
| 452 | * |
| 453 | * 102 1/20/98 12:10p Jason |
| 454 | * implemented vis effect system |
| 455 | * |
| 456 | * 101 1/16/98 8:06p Jason |
| 457 | * added selectable halos and atmosphere blends to satellites |
| 458 | * |
| 459 | * 100 1/16/98 3:05p Jason |
| 460 | * fixed LOD cracking at terrain edges |
| 461 | * |
| 462 | * 99 1/16/98 2:47p Jason |
| 463 | * tweaked some things for speed reasons |
| 464 | * |
| 465 | * 98 1/16/98 1:04p Jason |
| 466 | * don't do update environment |
| 467 | * |
| 468 | * 97 1/15/98 6:32p Jason |
| 469 | * added v wrapping for sky textures |
| 470 | * |
| 471 | * 96 1/15/98 12:42p Jason |
| 472 | * big fix for terrain sky rendering |
| 473 | * |
| 474 | * 95 1/12/98 3:34p Jason |
| 475 | * sped up indoor rendering by clipping faces against portals |
| 476 | * |
| 477 | * 94 1/07/98 4:19p Jason |
| 478 | * added dome to terrain sky |
| 479 | * |
| 480 | * 93 1/06/98 1:29p Matt |
| 481 | * Cleaned up interfaces to rendering routines, deleted unused code, etc. |
| 482 | * |
| 483 | * 92 1/02/98 6:08p Jason |
| 484 | * fixed bug with alphaed moons and halos |
| 485 | * |
| 486 | * 90 12/30/97 5:45p Jason |
| 487 | * added toggleable fog |
| 488 | * |
| 489 | * 89 12/29/97 5:44p Samir |
| 490 | * Took out references to grViewport and old 2d library. |
| 491 | * |
| 492 | * 88 12/19/97 5:58p Jason |
| 493 | * fixed out-of-bounds bug |
| 494 | * |
| 495 | * 87 12/19/97 5:38p Jason |
| 496 | * fixed errors with 2d/3d integration |
| 497 | * |
| 498 | * 86 12/19/97 12:20p Jason |
| 499 | * changes for better 2d/3d system integration |
| 500 | * |
| 501 | * 85 12/18/97 3:29p Jason |
| 502 | * fixed some lightmap wrapping issues |
| 503 | * |
| 504 | * 84 12/17/97 5:26p Jason |
| 505 | * added support for selectable wraparound sky |
| 506 | * |
| 507 | * 83 12/17/97 4:08p Jason |
| 508 | * took out fog (again) |
| 509 | * |
| 510 | * 82 12/10/97 6:54p Jason |
| 511 | * toned down star blur effect |
| 512 | * |
| 513 | * 81 12/09/97 7:13p Jason |
| 514 | * added support for blurred lines in hardware |
| 515 | * |
| 516 | * 80 12/01/97 10:52a Jason |
| 517 | * separated satellite and star rendering flags |
| 518 | * |
| 519 | * 79 11/21/97 5:33p Jason |
| 520 | * fixed far clip bug |
| 521 | * |
| 522 | * 78 11/19/97 5:23p Jason |
| 523 | * added terrain dynamic lighting |
| 524 | * |
| 525 | * 77 11/17/97 8:33p Jason |
| 526 | * fixed bug with object selection introduced by last rev |
| 527 | * |
| 528 | * 76 11/17/97 6:13p Mark |
| 529 | * allowed object 0 to be selected |
| 530 | * |
| 531 | * 75 11/10/97 12:21p Jason |
| 532 | * implemented different object visibility |
| 533 | * |
| 534 | * 74 11/10/97 12:00p Jason |
| 535 | * fixed view scaling bug in g3_DrawRotatedBitmap |
| 536 | * |
| 537 | * 73 10/30/97 4:38p Jason |
| 538 | * special cased highest-lod in DrawTerrainTrianglesHardware |
| 539 | * |
| 540 | * 72 10/29/97 12:37p Jason |
| 541 | * fixed tjoint problems |
| 542 | * |
| 543 | * 71 10/28/97 2:06p Jason |
| 544 | * check for backfaces early |
| 545 | * |
| 546 | * 70 10/17/97 1:23p Jason |
| 547 | * took out references to bitmap8bit.h |
| 548 | * |
| 549 | * 69 10/13/97 5:06p Chris |
| 550 | * Made it compile in the main project (outline mode only in editor) |
| 551 | * |
| 552 | * 68 10/10/97 6:31p Jason |
| 553 | * added extra level of detail level |
| 554 | * |
| 555 | * 67 10/09/97 11:11a Jason |
| 556 | * turned fog back on for now |
| 557 | * |
| 558 | * 66 10/08/97 4:34p Jason |
| 559 | * fixed line drawing problems |
| 560 | * |
| 561 | * 65 10/06/97 6:39p Jason |
| 562 | * got terrain objects working with lightmaps/radiosity |
| 563 | * |
| 564 | * 64 10/02/97 6:45p Jason |
| 565 | * optimized terrain rotation |
| 566 | * |
| 567 | * 63 10/02/97 6:21p Jason |
| 568 | * checked in for matt |
| 569 | * |
| 570 | * |
| 571 | * 62 10/02/97 3:48p Matt |
| 572 | * Don't render room (via room object) if terrain renderer was called from |
| 573 | * room renderer |
| 574 | * |
| 575 | * 61 10/02/97 2:45p Jason |
| 576 | * got invisible terrain cells working |
| 577 | * |
| 578 | * 60 10/01/97 7:51p Matt |
| 579 | * Added code for external rooms |
| 580 | * |
| 581 | * 59 9/30/97 4:20p Jason |
| 582 | * took out terrain object light |
| 583 | * |
| 584 | * 58 9/29/97 5:40p Jason |
| 585 | * patched circular linked list bug |
| 586 | * |
| 587 | * 57 9/21/97 7:57p Jason |
| 588 | * separated hardware/software rendering pipes, plus got lightmaps working |
| 589 | * with tmap2's |
| 590 | * |
| 591 | * 56 9/21/97 7:17p Jason |
| 592 | * Made terrain lightmaps work again |
| 593 | * |
| 594 | * 55 9/18/97 1:24p Matt |
| 595 | * Changed terrain object rendering to keep its data locally, instead of |
| 596 | * in the object struct |
| 597 | * |
| 598 | * 54 9/17/97 5:08p Jason |
| 599 | * took out fog (maybe just temporary) |
| 600 | * |
| 601 | * |
| 602 | * 53 9/17/97 12:02p Jason |
| 603 | * ripped out segment engine |
| 604 | * |
| 605 | * 52 9/12/97 7:06p Jason |
| 606 | * fixed bug with MAX_RENDER_ROOMS being too low |
| 607 | * |
| 608 | * 51 9/12/97 5:17p Jason |
| 609 | * fixed problem where buildings could be lower than terrain, thus |
| 610 | * generating error |
| 611 | * |
| 612 | * 50 9/10/97 5:17p Jason |
| 613 | * more lighting improvements |
| 614 | * |
| 615 | * 49 9/09/97 6:17p Jason |
| 616 | * fixed bug with color model and dynamic objects |
| 617 | * |
| 618 | * 48 9/09/97 6:15p Jason |
| 619 | * Added groovy dynamic terrain lighting system |
| 620 | * |
| 621 | * 47 9/09/97 1:12p Jason |
| 622 | * fixed color model bug |
| 623 | * |
| 624 | * 46 9/09/97 11:44a Jason |
| 625 | * changed the way alpha works with the renderer |
| 626 | * |
| 627 | * 45 9/08/97 4:13p Jason |
| 628 | * added colored lighting for the terrain |
| 629 | * |
| 630 | * 44 9/05/97 4:38p Jason |
| 631 | * incremental updates |
| 632 | * |
| 633 | * 43 9/02/97 11:07a Jason |
| 634 | * added alpha component to uvl struct |
| 635 | * |
| 636 | * 42 8/29/97 11:41a Jason |
| 637 | * made textures not clamp if renderering the mine view |
| 638 | * |
| 639 | * 41 8/26/97 10:23a Jason |
| 640 | * added some asserts, plus clamping for terrain textures |
| 641 | * |
| 642 | * 40 8/20/97 6:18p Jason |
| 643 | * fixed memory corruption bug |
| 644 | * |
| 645 | * 39 8/20/97 4:22p Matt |
| 646 | * Took out unneeded extern |
| 647 | * |
| 648 | * 38 8/19/97 5:12p Jason |
| 649 | * (hopefully) fixed the polygon object popping problem |
| 650 | * |
| 651 | * 37 8/07/97 5:06p Jason |
| 652 | * added new tiling system for terrain |
| 653 | * |
| 654 | * 36 8/07/97 3:19p Jason |
| 655 | * replaced old terrain tmap system with new one |
| 656 | * |
| 657 | * 35 8/07/97 11:47a Jason |
| 658 | * got tmap2s rotatable by themselves |
| 659 | * |
| 660 | * 34 8/06/97 5:00p Jason |
| 661 | * ripped out lightmaps pending a better lighting system for terrain |
| 662 | * |
| 663 | * 33 8/06/97 11:43a Jason |
| 664 | * made lightmaps work correctly in the terrain |
| 665 | * |
| 666 | * 32 8/01/97 5:46p Jason |
| 667 | * did some housekeeping |
| 668 | * |
| 669 | * 31 7/31/97 3:28p Jason |
| 670 | * fixed bug where memory would get corrupted when drawing newstyle |
| 671 | * gouraud objects |
| 672 | * |
| 673 | * 30 7/29/97 5:33p Jason |
| 674 | * precompute the edge rotation list |
| 675 | * |
| 676 | * 29 7/29/97 10:28a Jason |
| 677 | * added RenderOBject abstraction layer |
| 678 | * |
| 679 | * 28 7/28/97 5:23p Jason |
| 680 | * added features to lod engine - namely dynamic texture generation |
| 681 | * |
| 682 | * 27 7/28/97 1:14p Chris |
| 683 | * Added support for sub-object visability. Plus, debris. |
| 684 | * |
| 685 | * 26 7/25/97 5:25p Jason |
| 686 | * fixed multiple bugs in terrain LOD engine |
| 687 | * |
| 688 | * 25 7/23/97 6:27p Jason |
| 689 | * added code to support terrain simplification |
| 690 | * |
| 691 | * 24 7/21/97 1:59p Jason |
| 692 | * added user adjustable fog parameters |
| 693 | * |
| 694 | * 23 7/20/97 8:37p Jason |
| 695 | * fixed some fog problems |
| 696 | * |
| 697 | * 22 7/20/97 7:37p Jason |
| 698 | * added new sky |
| 699 | * |
| 700 | * 21 7/20/97 3:40p Jason |
| 701 | * got room/terrain links working (at least in the terrain) |
| 702 | * |
| 703 | * 20 7/18/97 7:25p Jason |
| 704 | * do object drawing rather better |
| 705 | * |
| 706 | * 19 7/17/97 3:00p Jason |
| 707 | * changed "moons" to be called satellites since we're going to have suns |
| 708 | * and other things in orbit |
| 709 | * |
| 710 | * |
| 711 | * 18 7/16/97 5:20p Jason |
| 712 | * implemented selection of moons with mouse click |
| 713 | * |
| 714 | * 17 7/16/97 4:18p Matt |
| 715 | * Changes to work with changed 3d draw functions |
| 716 | * |
| 717 | * 16 7/15/97 7:40p Jason |
| 718 | * made fogplane obscenely close |
| 719 | * |
| 720 | * 15 7/15/97 6:44p Mark |
| 721 | * |
| 722 | * 14 7/15/97 5:32p Jason |
| 723 | * got simple static lighting working with objects |
| 724 | * |
| 725 | * 13 7/15/97 4:57p Mark |
| 726 | * Corrected usage of UseHardware flag |
| 727 | * |
| 728 | * 12 7/15/97 4:54p Jason |
| 729 | * made water not move its friends |
| 730 | * |
| 731 | * 11 7/15/97 4:18p Matt |
| 732 | * Don't do water undulation on tiles that have tmap2's on them |
| 733 | * |
| 734 | * 10 7/15/97 4:11p Jason |
| 735 | * added focus selection to terrain objects |
| 736 | * |
| 737 | * 9 7/15/97 3:33p Jason |
| 738 | * fixed some object sorting problems |
| 739 | * |
| 740 | * 8 7/15/97 3:09p Jason |
| 741 | * fixed dumb bug that I introduced in my last rev |
| 742 | * |
| 743 | * 7 7/15/97 2:59p Matt |
| 744 | * Added assert |
| 745 | * |
| 746 | * 39 6/24/97 4:24p Jason |
| 747 | * changes for y only terrain |
| 748 | * |
| 749 | * 38 6/24/97 12:45p Jason |
| 750 | * checked in for safety |
| 751 | * |
| 752 | * 37 6/17/97 11:35a Jason |
| 753 | * checked in for safety |
| 754 | * |
| 755 | * 36 6/16/97 2:34p Jason |
| 756 | * added 3dfx support |
| 757 | * |
| 758 | * 35 6/12/97 12:26p Jason |
| 759 | * fixed dumb rotational bug |
| 760 | * |
| 761 | * 34 5/22/97 5:16p Jason |
| 762 | * added tmap2 capability to the terrain |
| 763 | * |
| 764 | * 33 5/21/97 3:40p Jason |
| 765 | * added terrain editing stuff |
| 766 | * |
| 767 | * 32 5/19/97 5:10p Jason |
| 768 | * changes for our new abstracted renderer code |
| 769 | * |
| 770 | * 31 5/16/97 4:53p Jason |
| 771 | * made terrain clear the screen only when called from inside a mine |
| 772 | * |
| 773 | * 30 5/15/97 4:37p Jason |
| 774 | * fixed some terrain bugs |
| 775 | * |
| 776 | * 29 5/15/97 3:28a Jason |
| 777 | * tried to get subwindow clearing to work with terrain - but it won't |
| 778 | * until samir fixes lock_clear |
| 779 | * |
| 780 | * 28 5/13/97 11:34a Samir |
| 781 | * Changed some NDEBUGs to ifdef EDITORs |
| 782 | * |
| 783 | * 27 5/11/97 1:31p Matt |
| 784 | * Added code to only render terrain that might be visible when terrain |
| 785 | * called from the mine renderer. |
| 786 | * |
| 787 | * $NoKeywords: $ |
| 788 | */ |
| 789 | #ifdef NEWEDITOR |
| 790 | #include "neweditor\globals.h" |
| 791 | void RenderMine(int viewer_roomnum, int flag_automap, int called_from_terrain, bool render_all, bool outline, bool flat, |
| 792 | prim *prim); |
| 793 | #endif |
| 794 | #include "terrain.h"cxx . . $ `<file>/Descent3/terrain.h`/ |
| 795 | #include "grdefs.h"cxx . . $ `<file>/lib/grdefs.h`/ |
| 796 | #include "3d.h"cxx . . $ `<file>/lib/3d.h`/ |
| 797 | #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/ |
| 798 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 799 | #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/ |
| 800 | #include "gametexture.h"cxx . . $ `<file>/Descent3/gametexture.h`/ |
| 801 | #include "descent.h"cxx . . $ `<file>/Descent3/descent.h`/ |
| 802 | #include "render.h"cxx . . $ `<file>/Descent3/render.h`/ |
| 803 | #include "game.h"cxx . . $ `<file>/Descent3/game.h`/ |
| 804 | #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/ |
| 805 | #include "polymodel.h"cxx . . $ `<file>/model/polymodel.h`/ |
| 806 | #include "lighting.h"cxx . . $ `<file>/Descent3/lighting.h`/ |
| 807 | #include "vecmat.h"cxx . . $ `<file>/lib/vecmat.h`/ |
| 808 | #include "renderobject.h"cxx . . $ `<file>/Descent3/renderobject.h`/ |
| 809 | #include "findintersection.h"cxx . . $ `<file>/physics/findintersection.h`/ |
| 810 | #include "weapon.h"cxx . . $ `<file>/Descent3/weapon.h`/ |
| 811 | #include "weather.h"cxx . . $ `<file>/Descent3/weather.h`/ |
| 812 | #include "viseffect.h"cxx . . $ `<file>/Descent3/viseffect.h`/ |
| 813 | #ifdef EDITOR |
| 814 | #include "editor\d3edit.h" |
| 815 | #endif |
| 816 | #include "fireball.h"cxx . . $ `<file>/Descent3/fireball.h`/ |
| 817 | #include <stdlib.h> |
| 818 | #include "config.h"cxx . . $ `<file>/Descent3/config.h`/ |
| 819 | #include "gameloop.h"cxx . . $ `<file>/Descent3/gameloop.h`/ |
| 820 | #include "postrender.h"cxx . . $ `<file>/Descent3/postrender.h`/ |
| 821 | #include "psrand.h"cxx . . $ `<file>/misc/psrand.h`/ |
| 822 | #include "player.h"cxx . . $ `<file>/Descent3/player.h`/ |
| 823 | |
| 824 | #include <algorithm> |
| 825 | |
| 826 | #define TERRAIN_PERSPECTIVE_TEXTURE_DEPTHcxx . . $ `Descent3/terrainrender.cpp:826:9`! 1 * TERRAIN_SIZE |
| 827 | #define LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! (MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`! + 1) |
| 828 | int DrawTerrainTrianglesSoftwarecxx . . $ DrawTerrainTrianglesSoftware(d4c1ccc1fe1a56c0).(int index, int bm_handle, int upper_left, int lower_right); |
| 829 | int DrawTerrainTrianglesHardwarecxx . . $ DrawTerrainTrianglesHardware(d4c1ccc1fe1a56c0).(int index, int bm_handle, int upper_left, int lower_right); |
| 830 | int DrawTerrainTrianglesHardwareNoLightcxx . . $ DrawTerrainTrianglesHardwareNoLight(d4c1ccc1fe1a56c0).(int index, int bm_handle, int upper_left, int lower_right); |
| 831 | void DrawTerrainLightmapsHardwarecxx . . $ DrawTerrainLightmapsHardware(b1146eedae1e1d0b).(int index, int upper_left, int lower_right); |
| 832 | void DrawSkycxx . . $ DrawSky(bc315f98e1febb02).(vectorcxx . . $ vector# *veye, matrixcxx . . $ matrix# *vorient); |
| 833 | function_modecxx . . $ function_mode# View_modecxx . . $ View_mode.; |
| 834 | int ManageFrameratecxx . . $ ManageFramerate. = 0; |
| 835 | int MinAllowableFrameratecxx . . $ MinAllowableFramerate. = 15; |
| 836 | uint8_tcxx . . $ uint8_t# Fast_terraincxx . . $ Fast_terrain. = 1; |
| 837 | float Far_fog_bordercxx . . $ Far_fog_border.; |
| 838 | vectorcxx . . $ vector# Terrain_viewer_eyecxx . . $ Terrain_viewer_eye.; |
| 839 | uint8_tcxx . . $ uint8_t# Terrain_from_minecxx . . $ Terrain_from_mine. = 0; |
| 840 | uint8_tcxx . . $ uint8_t# Show_invisible_terraincxx . . $ Show_invisible_terrain. = 0; |
| 841 | int Terrain_objects_drawncxx . . $ Terrain_objects_drawn. = 0; |
| 842 | vectorcxx . . $ vector# Last_frame_starscxx . . $ Last_frame_stars.[MAX_STARScxx . . $ `Descent3/terrain.h:51:9`!]; |
| 843 | float Terrain_texture_distancecxx . . $ Terrain_texture_distance. = DEFAULT_TEXTURE_DISTANCEcxx . . $ `Descent3/terrain.h:29:9`!; |
| 844 | int Check_terrain_portalcxx . . $ Check_terrain_portal. = 0; |
| 845 | static vectorcxx . . $ vector# Temp_sky_vectorscxx . . $ Temp_sky_vectors.[MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!][6]; |
| 846 | static vectorcxx . . $ vector# Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!][6]; |
| 847 | // Last time terrain was rendered |
| 848 | float Last_terrain_render_timecxx . . $ Last_terrain_render_time. = -1; |
| 849 | // Sets UV's based on 90 degree rotations |
| 850 | float TerrainUSpeedupcxx . . $ TerrainUSpeedup.[4][LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!]; |
| 851 | float TerrainVSpeedupcxx . . $ TerrainVSpeedup.[4][LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!]; |
| 852 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 853 | // for building a render list for each terrain cell |
| 854 | int render_nextcxx . . $ render_next.[MAX_OBJECTScxx . . $ `lib/object_external_struct.h:107:9`!]; |
| 855 | #endif |
| 856 | void DrawPlayerOnWireframecxx . . $ DrawPlayerOnWireframe(49f6e7a06ebc5aa8).(); |
| 857 | float Clip_scale_leftcxx . . $ Clip_scale_left., Clip_scale_topcxx . . $ Clip_scale_top., Clip_scale_rightcxx . . $ Clip_scale_right., Clip_scale_botcxx . . $ Clip_scale_bot.; |
| 858 | #ifdef NEWEDITOR |
| 859 | bool Rendering_main_view = true; |
| 860 | #endif |
| 861 | void InitTerrainRenderSpeedupscxx . . $ InitTerrainRenderSpeedups(49f6e7a06ebc5aa8).() { |
| 862 | // Figure out a table of values for rotated uv points |
| 863 | for (int y = 0; y <= MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!; y++) { |
| 864 | for (int x = 0; x <= MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!; x++) { |
| 865 | TerrainUSpeedupcxx . . $ TerrainUSpeedup.[0][(y * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + x] = (float)x / (float)MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!; |
| 866 | TerrainVSpeedupcxx . . $ TerrainVSpeedup.[0][(y * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + x] = (float)y / (float)MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!; |
| 867 | TerrainUSpeedupcxx . . $ TerrainUSpeedup.[1][(y * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + x] = 1.0 - ((float)y / (float)MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!); |
| 868 | TerrainVSpeedupcxx . . $ TerrainVSpeedup.[1][(y * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + x] = (float)x / (float)MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!; |
| 869 | TerrainUSpeedupcxx . . $ TerrainUSpeedup.[2][(y * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + x] = 1.0 - ((float)x / (float)MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!); |
| 870 | TerrainVSpeedupcxx . . $ TerrainVSpeedup.[2][(y * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + x] = 1.0 - ((float)y / (float)MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!); |
| 871 | TerrainUSpeedupcxx . . $ TerrainUSpeedup.[3][(y * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + x] = ((float)y / (float)MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!); |
| 872 | TerrainVSpeedupcxx . . $ TerrainVSpeedup.[3][(y * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + x] = 1.0 - ((float)x / (float)MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!); |
| 873 | } |
| 874 | } |
| 875 | } |
| 876 | // codes a point for visibility in the window passed to RenderTerrain() |
| 877 | uint8_tcxx . . $ uint8_t# CodeTerrainPointcxx . . $ CodeTerrainPoint(1c2cda054d3314c5).(g3Pointcxx . . $ g3Point# *p) { |
| 878 | uint8_tcxx . . $ uint8_t# cc = 0; |
| 879 | if (p->p3_sxcxx . . $ g3Point#p3_sx. > Clip_scale_rightcxx . . $ Clip_scale_right.) |
| 880 | cc |= CC_OFF_RIGHTcxx . . $ `lib/3d.h:225:9`!; |
| 881 | if (p->p3_sxcxx . . $ g3Point#p3_sx. < Clip_scale_leftcxx . . $ Clip_scale_left.) |
| 882 | cc |= CC_OFF_LEFTcxx . . $ `lib/3d.h:224:9`!; |
| 883 | if (p->p3_sycxx . . $ g3Point#p3_sy. > Clip_scale_botcxx . . $ Clip_scale_bot.) |
| 884 | cc |= CC_OFF_BOTcxx . . $ `lib/3d.h:226:9`!; |
| 885 | if (p->p3_sycxx . . $ g3Point#p3_sy. < Clip_scale_topcxx . . $ Clip_scale_top.) |
| 886 | cc |= CC_OFF_TOPcxx . . $ `lib/3d.h:227:9`!; |
| 887 | return cc; |
| 888 | } |
| 889 | // Returns true if light can hit this segment/heighth bit |
| 890 | int IsTerrainDynamicCheckedcxx . . $ IsTerrainDynamicChecked(9b79fb6aee4c0440).(int seg, int bit) { |
| 891 | if (seg < 0 || seg >= (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!)) |
| 892 | return 1; |
| 893 | if (bit >= 8) |
| 894 | return 1; |
| 895 | uint8_tcxx . . $ uint8_t# val = Terrain_dynamic_tablecxx . . $ Terrain_dynamic_table.[seg] & (1 << bit); |
| 896 | if (val) |
| 897 | return 1; |
| 898 | return 0; |
| 899 | } |
| 900 | // Gets the dynamic light value for this position |
| 901 | float GetTerrainDynamicScalarcxx . . $ GetTerrainDynamicScalar(bdb4036c8ebf1af).(vectorcxx . . $ vector# *pos, int seg) { |
| 902 | float cube_values[10]; |
| 903 | int y_increment = MAX_TERRAIN_HEIGHTcxx . . $ `Descent3/terrain.h:46:9`! / 8; |
| 904 | int y_int = pos->ycxx . . $ vector#y. / y_increment; |
| 905 | int x_int = pos->xcxx . . $ vector#x. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!; |
| 906 | int z_int = pos->zcxx . . $ vector#z. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!; |
| 907 | |
| 908 | float x_norm = (pos->xcxx . . $ vector#x. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) - x_int; |
| 909 | float z_norm = (pos->zcxx . . $ vector#z. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) - z_int; |
| 910 | float y_norm = (pos->ycxx . . $ vector#y. / y_increment) - y_int; |
| 911 | if (y_norm < 0) { |
| 912 | y_norm = 0; |
| 913 | y_int = 0; |
| 914 | } |
| 915 | if (y_norm > 1) { |
| 916 | y_norm = 1.0; |
| 917 | y_int = 7; |
| 918 | } |
| 919 | if (x_norm < 0 || x_norm > 1 || z_norm < 0 || z_norm > 1) |
| 920 | return .5; |
| 921 | float left_norm, right_norm, top_norm, bottom_norm, scalar; |
| 922 | |
| 923 | cube_values[0] = IsTerrainDynamicCheckedcxx . . $ IsTerrainDynamicChecked(9b79fb6aee4c0440).(seg, y_int); |
| 924 | cube_values[1] = IsTerrainDynamicCheckedcxx . . $ IsTerrainDynamicChecked(9b79fb6aee4c0440).(seg + TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!, y_int); |
| 925 | cube_values[2] = IsTerrainDynamicCheckedcxx . . $ IsTerrainDynamicChecked(9b79fb6aee4c0440).(seg + TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! + 1, y_int); |
| 926 | cube_values[3] = IsTerrainDynamicCheckedcxx . . $ IsTerrainDynamicChecked(9b79fb6aee4c0440).(seg + 1, y_int); |
| 927 | cube_values[4] = IsTerrainDynamicCheckedcxx . . $ IsTerrainDynamicChecked(9b79fb6aee4c0440).(seg, y_int + 1); |
| 928 | cube_values[5] = IsTerrainDynamicCheckedcxx . . $ IsTerrainDynamicChecked(9b79fb6aee4c0440).(seg + TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!, y_int + 1); |
| 929 | cube_values[6] = IsTerrainDynamicCheckedcxx . . $ IsTerrainDynamicChecked(9b79fb6aee4c0440).(seg + TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! + 1, y_int + 1); |
| 930 | cube_values[7] = IsTerrainDynamicCheckedcxx . . $ IsTerrainDynamicChecked(9b79fb6aee4c0440).(seg + 1, y_int + 1); |
| 931 | left_norm = ((1 - z_norm) * cube_values[0]) + (z_norm * cube_values[1]); |
| 932 | right_norm = ((1 - z_norm) * cube_values[3]) + (z_norm * cube_values[2]); |
| 933 | bottom_norm = ((1 - x_norm) * left_norm) + (x_norm * right_norm); |
| 934 | left_norm = ((1 - z_norm) * cube_values[4]) + (z_norm * cube_values[5]); |
| 935 | right_norm = ((1 - z_norm) * cube_values[7]) + (z_norm * cube_values[6]); |
| 936 | top_norm = ((1 - x_norm) * left_norm) + (x_norm * right_norm); |
| 937 | scalar = ((1 - y_norm) * bottom_norm) + (y_norm * top_norm); |
| 938 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(scalar >= 0 && scalar <= 1); |
| 939 | return scalar; |
| 940 | } |
| 941 | // Takes a min,max vector and makes a surrounding cube from it |
| 942 | void MakePointsFromMinMaxcxx . . $ MakePointsFromMinMax(af83aca25ba5b41c).(vectorcxx . . $ vector# *corners, vectorcxx . . $ vector# *minp, vectorcxx . . $ vector# *maxp); |
| 943 | struct obj_sort_itemcxx . . $ obj_sort_item# { |
| 944 | int objnumcxx . . $ obj_sort_item#objnum.; |
| 945 | float distcxx . . $ obj_sort_item#dist.; |
| 946 | int vis_effectcxx . . $ obj_sort_item#vis_effect.; |
| 947 | }; |
| 948 | // Compare function for room face sort |
| 949 | static int obj_sort_funccxx . . $ obj_sort_func(20b978cffff2d3d3).(const obj_sort_itemcxx . . $ obj_sort_item# *a, const obj_sort_itemcxx . . $ obj_sort_item# *b) { |
| 950 | if (a->distcxx . . $ obj_sort_item#dist. < b->distcxx . . $ obj_sort_item#dist.) |
| 951 | return -1; |
| 952 | else if (a->distcxx . . $ obj_sort_item#dist. > b->distcxx . . $ obj_sort_item#dist.) |
| 953 | return 1; |
| 954 | else |
| 955 | return 0; |
| 956 | } |
| 957 | // Returns true if the object is outside of our terrain portal |
| 958 | int ObjectOutOfPortalcxx . . $ ObjectOutOfPortal(2da2a862cad4c994).(objectcxx . . $ object# *obj) { |
| 959 | g3Pointcxx . . $ g3Point# pnt1, pnt2; |
| 960 | uint8_tcxx . . $ uint8_t# anded = 0xff; |
| 961 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnt1, &obj->min_xyzcxx . . $ object#min_xyz.); |
| 962 | if (pnt1.p3_codescxx . . $ g3Point#p3_codes. & CC_BEHINDcxx . . $ `lib/3d.h:230:9`!) |
| 963 | return 0; |
| 964 | g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&pnt1); |
| 965 | anded &= CodeTerrainPointcxx . . $ CodeTerrainPoint(1c2cda054d3314c5).(&pnt1); |
| 966 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnt2, &obj->max_xyzcxx . . $ object#max_xyz.); |
| 967 | if (pnt2.p3_codescxx . . $ g3Point#p3_codes. & CC_BEHINDcxx . . $ `lib/3d.h:230:9`!) |
| 968 | return 0; |
| 969 | g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&pnt2); |
| 970 | anded &= CodeTerrainPointcxx . . $ CodeTerrainPoint(1c2cda054d3314c5).(&pnt2); |
| 971 | if (anded) |
| 972 | return 1; |
| 973 | return 0; |
| 974 | } |
| 975 | obj_sort_itemcxx . . $ obj_sort_item# objs_to_rendercxx . . $ objs_to_render.[MAX_OBJECTScxx . . $ `lib/object_external_struct.h:107:9`! + MAX_VIS_EFFECTScxx . . $ `Descent3/viseffect_external.h:57:9`!]; |
| 976 | obj_sort_itemcxx . . $ obj_sort_item# rooms_to_rendercxx . . $ rooms_to_render.[MAX_ROOMScxx . . $ `Descent3/room.h:377:9`!]; |
| 977 | // Checks to see if this object can even be seen from our current viewpoint |
| 978 | // By shooting rays to it |
| 979 | // Returns true if any of the rays hit |
| 980 | int ShootRaysToObjectcxx . . $ ShootRaysToObject(2da2a862cad4c994).(objectcxx . . $ object# *obj) { |
| 981 | vectorcxx . . $ vector# corners[8]; |
| 982 | if (obj->typecxx . . $ object#type. == OBJ_ROOMcxx . . $ `Descent3/object_external.h:178:9`!) { |
| 983 | roomcxx . . $ room# *rp = &Roomscxx . . $ Rooms.[obj->idcxx . . $ object#id.]; |
| 984 | MakePointsFromMinMaxcxx . . $ MakePointsFromMinMax(af83aca25ba5b41c).(corners, &rp->min_xyzcxx . . $ room#min_xyz., &rp->max_xyzcxx . . $ room#max_xyz.); |
| 985 | } else { |
| 986 | MakePointsFromMinMaxcxx . . $ MakePointsFromMinMax(af83aca25ba5b41c).(corners, &obj->min_xyzcxx . . $ object#min_xyz., &obj->max_xyzcxx . . $ object#max_xyz.); |
| 987 | } |
| 988 | fvi_infocxx . . $ fvi_info# hit_info; |
| 989 | fvi_querycxx . . $ fvi_query# fq; |
| 990 | fq.p0cxx . . $ fvi_query#p0. = &Viewer_objectcxx . . $ Viewer_object.->poscxx . . $ object#pos.; |
| 991 | fq.startroomcxx . . $ fvi_query#startroom. = Viewer_objectcxx . . $ Viewer_object.->roomnumcxx . . $ object#roomnum.; |
| 992 | fq.radcxx . . $ fvi_query#rad. = 0.0f; |
| 993 | fq.flagscxx . . $ fvi_query#flags. = FQ_NO_RELINKcxx . . $ `lib/findintersection_external.h:73:9`! | FQ_EXTERNAL_ROOMS_AS_SPHEREcxx . . $ `lib/findintersection_external.h:74:9`! | FQ_IGNORE_EXTERNAL_ROOMScxx . . $ `lib/findintersection_external.h:78:9`!; |
| 994 | fq.thisobjnumcxx . . $ fvi_query#thisobjnum. = Viewer_objectcxx . . $ Viewer_object. - Objectscxx . . $ Objects.; |
| 995 | fq.ignore_obj_listcxx . . $ fvi_query#ignore_obj_list. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 996 | |
| 997 | for (int i = 0; i < 8; i++) { |
| 998 | fq.p1cxx . . $ fvi_query#p1. = &corners[i]; |
| 999 | int fate = fvi_FindIntersectioncxx . . $ fvi_FindIntersection(e1c4d7bd350effc8).(&fq, &hit_info); |
| 1000 | /*g3Point pnt1,pnt2; |
| 1001 | vector fpnt = *fq.p0 + 3.0 * Viewer_object->orient.fvec; |
| 1002 | g3_RotatePoint (&pnt1,&fpnt); |
| 1003 | g3_RotatePoint (&pnt2,&hit_info.hit_pnt); |
| 1004 | g3_DrawLine ((GR_RGB(255,255,255)),&pnt1,&pnt2);*/ |
| 1005 | if (fate == HIT_NONEcxx . . $ `lib/findintersection_external.h:45:9`!) |
| 1006 | return 1; |
| 1007 | } |
| 1008 | return 0; |
| 1009 | } |
| 1010 | // Returns true if the external room is in the view cone |
| 1011 | // Else returns false |
| 1012 | bool ExternalRoomVisiblecxx . . $ ExternalRoomVisible(a31e7f4015760bb).(roomcxx . . $ room# *rp, vectorcxx . . $ vector# *center, float *zdist) { |
| 1013 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(rp->flags & RF_EXTERNALcxx . . $ `Descent3/room_external.h:177:9`!); |
| 1014 | g3Pointcxx . . $ g3Point# pnt; |
| 1015 | uint8_tcxx . . $ uint8_t# ccode; |
| 1016 | |
| 1017 | vectorcxx . . $ vector# corners[8]; |
| 1018 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnt, center); |
| 1019 | *zdist = pnt.p3_zcxx . . $ `lib/3d.h:247:9`!; |
| 1020 | MakePointsFromMinMaxcxx . . $ MakePointsFromMinMax(af83aca25ba5b41c).(corners, &rp->min_xyzcxx . . $ room#min_xyz., &rp->max_xyzcxx . . $ room#max_xyz.); |
| 1021 | uint8_tcxx . . $ uint8_t# andbyte = 0xff; |
| 1022 | for (int t = 0; t < 8; t++) { |
| 1023 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnt, &corners[t]); |
| 1024 | ccode = g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(&pnt); |
| 1025 | if (!ccode) |
| 1026 | return true; |
| 1027 | andbyte &= ccode; |
| 1028 | } |
| 1029 | if (andbyte) |
| 1030 | return false; |
| 1031 | return true; |
| 1032 | } |
| 1033 | // Render all the rooms out on the terrain for this frame |
| 1034 | void RenderTerrainRoomscxx . . $ RenderTerrainRooms(49f6e7a06ebc5aa8).() { |
| 1035 | objectcxx . . $ object# *obj; |
| 1036 | #ifdef EDITOR |
| 1037 | if (!Terrain_render_ext_room_objs) |
| 1038 | return; |
| 1039 | #endif |
| 1040 | |
| 1041 | int room_count = 0; |
| 1042 | float zdist; |
| 1043 | int use_occlusion = 0; |
| 1044 | int src_occlusion_index; |
| 1045 | int i; |
| 1046 | if (Terrain_from_minecxx . . $ Terrain_from_mine.) |
| 1047 | return; |
| 1048 | if ((Terrain_checksumcxx . . $ Terrain_checksum. + 1) == Terrain_occlusion_checksumcxx . . $ Terrain_occlusion_checksum.) { |
| 1049 | use_occlusion = 1; |
| 1050 | int oz = (Viewer_objectcxx . . $ Viewer_object.->poscxx . . $ object#pos..zcxx . . $ vector#z. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) / OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!; |
| 1051 | int ox = (Viewer_objectcxx . . $ Viewer_object.->poscxx . . $ object#pos..xcxx . . $ vector#x. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) / OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!; |
| 1052 | if (oz < 0 || oz >= OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`! || ox < 0 || ox >= OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!) |
| 1053 | use_occlusion = 0; |
| 1054 | src_occlusion_index = oz * OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`! + ox; |
| 1055 | } |
| 1056 | for (i = 0; i <= Highest_object_indexcxx . . $ Highest_object_index.; i++) { |
| 1057 | obj = &Objectscxx . . $ Objects.[i]; |
| 1058 | if (obj->typecxx . . $ object#type. != OBJ_ROOMcxx . . $ `Descent3/object_external.h:178:9`!) |
| 1059 | continue; |
| 1060 | |
| 1061 | if (obj->flagscxx . . $ object#flags. & OF_DEADcxx . . $ `Descent3/object_external.h:270:9`!) |
| 1062 | continue; |
| 1063 | if (obj->render_typecxx . . $ object#render_type. == RT_NONEcxx . . $ `Descent3/object_external.h:257:9`!) |
| 1064 | continue; |
| 1065 | if (!OBJECT_OUTSIDEcxx . . $ `lib/object_external_struct.h:130:9`!(obj)) |
| 1066 | continue; |
| 1067 | float size = obj->sizecxx . . $ object#size.; |
| 1068 | |
| 1069 | if (use_occlusion) { |
| 1070 | int y1 = (obj->poscxx . . $ object#pos..zcxx . . $ vector#z. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) / OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!; |
| 1071 | int x1 = (obj->poscxx . . $ object#pos..xcxx . . $ vector#x. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) / OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!; |
| 1072 | int dest_occlusion_index = (y1 * OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!); |
| 1073 | dest_occlusion_index += x1; |
| 1074 | int occ_byte = dest_occlusion_index / 8; |
| 1075 | int occ_bit = dest_occlusion_index % 8; |
| 1076 | if (obj->poscxx . . $ object#pos..ycxx . . $ vector#y. < MAX_TERRAIN_HEIGHTcxx . . $ `Descent3/terrain.h:46:9`!) { |
| 1077 | if (!(Terrain_occlusion_mapcxx . . $ Terrain_occlusion_map.[src_occlusion_index][occ_byte] & (1 << occ_bit))) |
| 1078 | continue; |
| 1079 | } |
| 1080 | } |
| 1081 | if (!ExternalRoomVisiblecxx . . $ ExternalRoomVisible(a31e7f4015760bb).(&Roomscxx . . $ Rooms.[obj->idcxx . . $ object#id.], &obj->poscxx . . $ object#pos., &zdist)) |
| 1082 | continue; |
| 1083 | if (!IsPointVisiblecxx . . $ IsPointVisible(a3c3a6b9788a7132).(&obj->poscxx . . $ object#pos., size, &zdist)) |
| 1084 | continue; |
| 1085 | |
| 1086 | if (Check_terrain_portalcxx . . $ Check_terrain_portal. && ObjectOutOfPortalcxx . . $ ObjectOutOfPortal(2da2a862cad4c994).(obj)) |
| 1087 | continue; |
| 1088 | /*if (!Terrain_from_mine) |
| 1089 | { |
| 1090 | if (!ShootRaysToObject (obj)) |
| 1091 | continue; |
| 1092 | }*/ |
| 1093 | rooms_to_rendercxx . . $ rooms_to_render.[room_count].vis_effectcxx . . $ obj_sort_item#vis_effect. = 0; |
| 1094 | rooms_to_rendercxx . . $ rooms_to_render.[room_count].objnumcxx . . $ obj_sort_item#objnum. = obj - Objectscxx . . $ Objects.; |
| 1095 | rooms_to_rendercxx . . $ rooms_to_render.[room_count].distcxx . . $ obj_sort_item#dist. = zdist; |
| 1096 | room_count++; |
| 1097 | } |
| 1098 | // Sort and draw rooms |
| 1099 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(rooms_to_rendercxx . . $ rooms_to_render., room_count, sizeof(*rooms_to_rendercxx . . $ rooms_to_render.), (int (*)(const void *, const void *))obj_sort_funccxx . . $ obj_sort_func(20b978cffff2d3d3).); |
| 1100 | for (i = room_count - 1; i >= 0; i--) { |
| 1101 | int objnum = rooms_to_rendercxx . . $ rooms_to_render.[i].objnumcxx . . $ obj_sort_item#objnum.; |
| 1102 | objectcxx . . $ object# *obj = &Objectscxx . . $ Objects.[objnum]; |
| 1103 | #ifndef NEWEDITOR |
| 1104 | RenderMinecxx . . $ RenderMine(b1146eedae1e1d0b).(obj->idcxx . . $ object#id., 0, 1); |
| 1105 | #else |
| 1106 | RenderMine(obj->id, 0, 1, 1, 0, 0, NULL); |
| 1107 | #endif |
| 1108 | // Draw a surrounding sphere |
| 1109 | #if (defined(_DEBUGcxx . . $ `<built-in>:482:9`!) && !defined(NEWEDITOR)) |
| 1110 | if (Game_show_spherecxx . . $ Game_show_sphere. == 2) |
| 1111 | DrawDebugInfocxx . . $ DrawDebugInfo(419c470199a90a97).(obj); |
| 1112 | #endif |
| 1113 | } |
| 1114 | } |
| 1115 | // Renders every visible terrain object |
| 1116 | void RenderAllTerrainObjectscxx . . $ RenderAllTerrainObjects(49f6e7a06ebc5aa8).() { |
| 1117 | objectcxx . . $ object# *obj; |
| 1118 | int snows[500]; |
| 1119 | int num_snows = 0; |
| 1120 | int obj_count = 0; |
| 1121 | float zdist; |
| 1122 | int use_occlusion = 0; |
| 1123 | int src_occlusion_index; |
| 1124 | int i; |
| 1125 | if ((Terrain_checksumcxx . . $ Terrain_checksum. + 1) == Terrain_occlusion_checksumcxx . . $ Terrain_occlusion_checksum.) { |
| 1126 | use_occlusion = 1; |
| 1127 | int oz = (Viewer_objectcxx . . $ Viewer_object.->poscxx . . $ object#pos..zcxx . . $ vector#z. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) / OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!; |
| 1128 | int ox = (Viewer_objectcxx . . $ Viewer_object.->poscxx . . $ object#pos..xcxx . . $ vector#x. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) / OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!; |
| 1129 | if (oz < 0 || oz >= OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`! || ox < 0 || ox >= OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!) |
| 1130 | use_occlusion = 0; |
| 1131 | src_occlusion_index = oz * OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`! + ox; |
| 1132 | } |
| 1133 | for (i = 0; i <= Highest_object_indexcxx . . $ Highest_object_index.; i++) { |
| 1134 | obj = &Objectscxx . . $ Objects.[i]; |
| 1135 | if (obj == Viewer_objectcxx . . $ Viewer_object.) |
| 1136 | continue; |
| 1137 | // Don't draw piggybacked objects |
| 1138 | if (Viewer_objectcxx . . $ Viewer_object.->typecxx . . $ object#type. == OBJ_OBSERVERcxx . . $ `Descent3/object_external.h:182:9`! && i == Playerscxx . . $ Players.[Viewer_objectcxx . . $ Viewer_object.->idcxx . . $ object#id.].piggy_objnumcxx . . $ player#piggy_objnum.) |
| 1139 | continue; |
| 1140 | if (obj->typecxx . . $ object#type. == OBJ_ROOMcxx . . $ `Descent3/object_external.h:178:9`!) |
| 1141 | continue; |
| 1142 | |
| 1143 | if (obj->typecxx . . $ object#type. == OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!) |
| 1144 | continue; |
| 1145 | if (obj->flagscxx . . $ object#flags. & OF_DEADcxx . . $ `Descent3/object_external.h:270:9`!) |
| 1146 | continue; |
| 1147 | if (obj->render_typecxx . . $ object#render_type. == RT_NONEcxx . . $ `Descent3/object_external.h:257:9`!) |
| 1148 | continue; |
| 1149 | if (!OBJECT_OUTSIDEcxx . . $ `lib/object_external_struct.h:130:9`!(obj)) |
| 1150 | continue; |
| 1151 | float size = obj->sizecxx . . $ object#size.; |
| 1152 | |
| 1153 | // Special case weapons with streamers |
| 1154 | if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && (Weaponscxx . . $ Weapons.[obj->idcxx . . $ object#id.].flagscxx . . $ weapon#flags. & WF_STREAMERcxx . . $ `Descent3/weapon.h:225:9`!)) |
| 1155 | size = Weaponscxx . . $ Weapons.[obj->idcxx . . $ object#id.].phys_infocxx . . $ weapon#phys_info..velocitycxx . . $ physics_info#velocity..zcxx . . $ vector#z.; |
| 1156 | if (use_occlusion) { |
| 1157 | int y1 = (obj->poscxx . . $ object#pos..zcxx . . $ vector#z. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) / OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!; |
| 1158 | int x1 = (obj->poscxx . . $ object#pos..xcxx . . $ vector#x. / TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) / OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!; |
| 1159 | int dest_occlusion_index = (y1 * OCCLUSION_SIZEcxx . . $ `Descent3/terrain.h:67:9`!); |
| 1160 | dest_occlusion_index += x1; |
| 1161 | int occ_byte = dest_occlusion_index / 8; |
| 1162 | int occ_bit = dest_occlusion_index % 8; |
| 1163 | if (obj->poscxx . . $ object#pos..ycxx . . $ vector#y. + obj->sizecxx . . $ object#size. < MAX_TERRAIN_HEIGHTcxx . . $ `Descent3/terrain.h:46:9`!) { |
| 1164 | if (!(Terrain_occlusion_mapcxx . . $ Terrain_occlusion_map.[src_occlusion_index][occ_byte] & (1 << occ_bit))) |
| 1165 | continue; |
| 1166 | } |
| 1167 | } |
| 1168 | if (obj->typecxx . . $ object#type. == OBJ_WEAPONcxx . . $ `Descent3/object_external.h:165:9`! && Weaponscxx . . $ Weapons.[obj->idcxx . . $ object#id.].flagscxx . . $ weapon#flags. & WF_ELECTRICALcxx . . $ `Descent3/weapon.h:222:9`!) { |
| 1169 | // Automatically render all electrical objects |
| 1170 | zdist = 0; |
| 1171 | } else { |
| 1172 | if (!IsPointVisiblecxx . . $ IsPointVisible(a3c3a6b9788a7132).(&obj->poscxx . . $ object#pos., size, &zdist)) |
| 1173 | continue; |
| 1174 | |
| 1175 | if (Check_terrain_portalcxx . . $ Check_terrain_portal. && ObjectOutOfPortalcxx . . $ ObjectOutOfPortal(2da2a862cad4c994).(obj)) |
| 1176 | continue; |
| 1177 | } |
| 1178 | |
| 1179 | if (UseHardwarecxx . . $ UseHardware.) { |
| 1180 | if (Num_postrenderscxx . . $ Num_postrenders. < MAX_POSTRENDERScxx . . $ `Descent3/postrender.h:22:9`!) { |
| 1181 | Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].typecxx . . $ postrender_struct#type. = PRT_OBJECTcxx . . $ `Descent3/postrender.h:24:9`!; |
| 1182 | Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].zcxx . . $ postrender_struct#z. = zdist; |
| 1183 | Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.++].objnumcxx . . $ postrender_struct#$anonymous_type_0#objnum. = obj - Objectscxx . . $ Objects.; |
| 1184 | } |
| 1185 | } else { |
| 1186 | objs_to_rendercxx . . $ objs_to_render.[obj_count].vis_effectcxx . . $ obj_sort_item#vis_effect. = 0; |
| 1187 | objs_to_rendercxx . . $ objs_to_render.[obj_count].objnumcxx . . $ obj_sort_item#objnum. = obj - Objectscxx . . $ Objects.; |
| 1188 | objs_to_rendercxx . . $ objs_to_render.[obj_count].distcxx . . $ obj_sort_item#dist. = zdist; |
| 1189 | obj_count++; |
| 1190 | } |
| 1191 | } |
| 1192 | #ifndef NEWEDITOR |
| 1193 | for (i = 0; i <= Highest_vis_effect_indexcxx . . $ Highest_vis_effect_index.; i++) { |
| 1194 | vis_effectcxx . . $ vis_effect# *vis = &VisEffectscxx . . $ VisEffects.[i]; |
| 1195 | |
| 1196 | if (vis->typecxx . . $ vis_effect#type. == VIS_NONEcxx . . $ `Descent3/viseffect_external.h:60:9`!) |
| 1197 | continue; |
| 1198 | if (vis->flagscxx . . $ vis_effect#flags. & VF_DEADcxx . . $ `Descent3/viseffect_external.h:66:9`!) |
| 1199 | continue; |
| 1200 | if (!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(vis->roomnum)) |
| 1201 | continue; |
| 1202 | // Special case snow |
| 1203 | if (vis->idcxx . . $ vis_effect#id. == SNOWFLAKE_INDEXcxx . . $ `Descent3/fireball_external.h:61:9`!) { |
| 1204 | snows[num_snows] = vis - VisEffectscxx . . $ VisEffects.; |
| 1205 | num_snows++; |
| 1206 | } else { |
| 1207 | if ((vis->flagscxx . . $ vis_effect#flags. & VF_WINDSHIELD_EFFECTcxx . . $ `Descent3/viseffect_external.h:65:9`!) || IsPointVisiblecxx . . $ IsPointVisible(a3c3a6b9788a7132).(&vis->poscxx . . $ vis_effect#pos., vis->sizecxx . . $ vis_effect#size., &zdist)) { |
| 1208 | if (vis->flagscxx . . $ vis_effect#flags. & VF_WINDSHIELD_EFFECTcxx . . $ `Descent3/viseffect_external.h:65:9`!) |
| 1209 | zdist = 0; |
| 1210 | if (UseHardwarecxx . . $ UseHardware.) { |
| 1211 | if (Num_postrenderscxx . . $ Num_postrenders. < MAX_POSTRENDERScxx . . $ `Descent3/postrender.h:22:9`!) { |
| 1212 | Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].typecxx . . $ postrender_struct#type. = PRT_VISEFFECTcxx . . $ `Descent3/postrender.h:25:9`!; |
| 1213 | Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.].zcxx . . $ postrender_struct#z. = zdist; |
| 1214 | Postrender_listcxx . . $ Postrender_list.[Num_postrenderscxx . . $ Num_postrenders.++].objnumcxx . . $ postrender_struct#$anonymous_type_0#objnum. = vis - VisEffectscxx . . $ VisEffects.; |
| 1215 | } |
| 1216 | } else { |
| 1217 | objs_to_rendercxx . . $ objs_to_render.[obj_count].vis_effectcxx . . $ obj_sort_item#vis_effect. = 1; |
| 1218 | objs_to_rendercxx . . $ objs_to_render.[obj_count].objnumcxx . . $ obj_sort_item#objnum. = vis - VisEffectscxx . . $ VisEffects.; |
| 1219 | objs_to_rendercxx . . $ objs_to_render.[obj_count].distcxx . . $ obj_sort_item#dist. = zdist; |
| 1220 | obj_count++; |
| 1221 | } |
| 1222 | } |
| 1223 | } |
| 1224 | } |
| 1225 | #endif |
| 1226 | |
| 1227 | // Sort objects |
| 1228 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(objs_to_rendercxx . . $ objs_to_render., obj_count, sizeof(*objs_to_rendercxx . . $ objs_to_render.), (int (*)(const void *, const void *))obj_sort_funccxx . . $ obj_sort_func(20b978cffff2d3d3).); |
| 1229 | // Render the objects |
| 1230 | for (i = obj_count - 1; i >= 0; i--) { |
| 1231 | int vis_effect = objs_to_rendercxx . . $ objs_to_render.[i].vis_effectcxx . . $ obj_sort_item#vis_effect.; |
| 1232 | int objnum = objs_to_rendercxx . . $ objs_to_render.[i].objnumcxx . . $ obj_sort_item#objnum.; |
| 1233 | if (vis_effect) |
| 1234 | DrawVisEffectcxx . . $ DrawVisEffect(6089e83781d51a35).(&VisEffectscxx . . $ VisEffects.[objnum]); |
| 1235 | else |
| 1236 | RenderObjectcxx . . $ RenderObject(419c470199a90a97).(&Objectscxx . . $ Objects.[objnum]); |
| 1237 | } |
| 1238 | // Render snows |
| 1239 | rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(0); |
| 1240 | for (i = 0; i < num_snows; i++) |
| 1241 | DrawVisEffectcxx . . $ DrawVisEffect(6089e83781d51a35).(&VisEffectscxx . . $ VisEffects.[snows[i]]); |
| 1242 | rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1); |
| 1243 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1); |
| 1244 | rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.); |
| 1245 | } |
| 1246 | #define FOG_LAYER_HEIGHTcxx . . $ `Descent3/terrainrender.cpp:1246:9`! (TERRAIN_HEIGHT_INCREMENTcxx . . $ `Descent3/terrain.h:47:9`! * 30.5f) |
| 1247 | // Draws a flat fog layer |
| 1248 | void DrawFogLayercxx . . $ DrawFogLayer(49f6e7a06ebc5aa8).() { |
| 1249 | vectorcxx . . $ vector# worldvec[4]; |
| 1250 | g3Pointcxx . . $ g3Point# pnt[4], *pntlist[6]; |
| 1251 | rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(132, 132, 255)); |
| 1252 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(64); |
| 1253 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`!); |
| 1254 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.); |
| 1255 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 1256 | worldvec[0].xcxx . . $ vector#x. = 0; |
| 1257 | worldvec[0].ycxx . . $ vector#y. = FOG_LAYER_HEIGHTcxx . . $ `Descent3/terrainrender.cpp:1246:9`!; |
| 1258 | worldvec[0].zcxx . . $ vector#z. = 0; |
| 1259 | worldvec[1].xcxx . . $ vector#x. = 0; |
| 1260 | worldvec[1].ycxx . . $ vector#y. = FOG_LAYER_HEIGHTcxx . . $ `Descent3/terrainrender.cpp:1246:9`!; |
| 1261 | worldvec[1].zcxx . . $ vector#z. = TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`! * TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!; |
| 1262 | worldvec[2].xcxx . . $ vector#x. = TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!; |
| 1263 | worldvec[2].ycxx . . $ vector#y. = FOG_LAYER_HEIGHTcxx . . $ `Descent3/terrainrender.cpp:1246:9`!; |
| 1264 | worldvec[2].zcxx . . $ vector#z. = TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`! * TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!; |
| 1265 | worldvec[3].xcxx . . $ vector#x. = TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!; |
| 1266 | worldvec[3].ycxx . . $ vector#y. = FOG_LAYER_HEIGHTcxx . . $ `Descent3/terrainrender.cpp:1246:9`!; |
| 1267 | worldvec[3].zcxx . . $ vector#z. = 0; |
| 1268 | for (int i = 0; i < 4; i++) { |
| 1269 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnt[i], &worldvec[i]); |
| 1270 | pntlist[i] = &pnt[i]; |
| 1271 | } |
| 1272 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(4, pntlist, 0); |
| 1273 | } |
| 1274 | #define CLOUD_LAYER_HEIGHTcxx . . $ `Descent3/terrainrender.cpp:1274:9`! (TERRAIN_HEIGHT_INCREMENTcxx . . $ `Descent3/terrain.h:47:9`! * 320.0f) |
| 1275 | // Draws a flat fog layer |
| 1276 | void DrawCloudLayercxx . . $ DrawCloudLayer(49f6e7a06ebc5aa8).() { |
| 1277 | vectorcxx . . $ vector# worldvec[4]; |
| 1278 | g3Pointcxx . . $ g3Point# pnt[4], *pntlist[6]; |
| 1279 | rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(192, 192, 255)); |
| 1280 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(32); |
| 1281 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`!); |
| 1282 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.); |
| 1283 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 1284 | worldvec[0].xcxx . . $ vector#x. = -(TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! * 100); |
| 1285 | worldvec[0].ycxx . . $ vector#y. = CLOUD_LAYER_HEIGHTcxx . . $ `Descent3/terrainrender.cpp:1274:9`!; |
| 1286 | worldvec[0].zcxx . . $ vector#z. = (TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! * (100 + TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!)); |
| 1287 | |
| 1288 | worldvec[1].xcxx . . $ vector#x. = -(TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! * 100); |
| 1289 | worldvec[1].ycxx . . $ vector#y. = CLOUD_LAYER_HEIGHTcxx . . $ `Descent3/terrainrender.cpp:1274:9`!; |
| 1290 | worldvec[1].zcxx . . $ vector#z. = -(TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! * (100)); |
| 1291 | |
| 1292 | worldvec[2].xcxx . . $ vector#x. = (TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! * (100 + TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!)); |
| 1293 | worldvec[2].ycxx . . $ vector#y. = CLOUD_LAYER_HEIGHTcxx . . $ `Descent3/terrainrender.cpp:1274:9`!; |
| 1294 | worldvec[2].zcxx . . $ vector#z. = -(TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! * (100)); |
| 1295 | |
| 1296 | worldvec[3].xcxx . . $ vector#x. = (TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! * (100 + TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!)); |
| 1297 | worldvec[3].ycxx . . $ vector#y. = CLOUD_LAYER_HEIGHTcxx . . $ `Descent3/terrainrender.cpp:1274:9`!; |
| 1298 | worldvec[3].zcxx . . $ vector#z. = (TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! * (100 + TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!)); |
| 1299 | for (int i = 0; i < 4; i++) { |
| 1300 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnt[i], &worldvec[i]); |
| 1301 | pntlist[i] = &pnt[i]; |
| 1302 | } |
| 1303 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(4, pntlist, 0); |
| 1304 | } |
| 1305 | // left,top,right,bot are optional parameters. Omiting them (or setting them to -1) will |
| 1306 | // render to the whole screen. Passing valid values will only render tiles visible in the |
| 1307 | // specified window (though it won't clip those tiles to the window) |
| 1308 | void RenderTerraincxx . . $ RenderTerrain(29744a30b22ab106).(uint8_tcxx . . $ uint8_t# from_mine, int left, int top, int right, int bot) { |
| 1309 | static int first = 1; |
| 1310 | if (first) { |
| 1311 | InitTerrainRenderSpeedupscxx . . $ InitTerrainRenderSpeedups(49f6e7a06ebc5aa8).(); |
| 1312 | first = 0; |
| 1313 | } |
| 1314 | |
| 1315 | // Get the size of the current render window |
| 1316 | int render_width, render_height; |
| 1317 | rend_GetProjectionParameterscxx . . $ rend_GetProjectionParameters(ce8f7825f8908cfa).(&render_width, &render_height); |
| 1318 | float w2 = ((float)render_width - 1) / 2.0f; |
| 1319 | float h2 = ((float)render_height - 1) / 2.0f; |
| 1320 | |
| 1321 | // Set up vars for (psuedo-)clipping window |
| 1322 | if (left < 0) { |
| 1323 | Check_terrain_portalcxx . . $ Check_terrain_portal. = 0; |
| 1324 | left = 0; |
| 1325 | } else { |
| 1326 | int w = right - left; |
| 1327 | int h = bot - top; |
| 1328 | |
| 1329 | // If the portal takes up more than 50% the screen space then we don't check against it |
| 1330 | float threshold = (render_width * render_height) * 0.5f; |
| 1331 | if (w * h > threshold) { |
| 1332 | Check_terrain_portalcxx . . $ Check_terrain_portal. = 0; |
| 1333 | } else { |
| 1334 | Check_terrain_portalcxx . . $ Check_terrain_portal. = 1; |
| 1335 | } |
| 1336 | } |
| 1337 | |
| 1338 | if (top < 0) { |
| 1339 | top = 0; |
| 1340 | } |
| 1341 | if ((right == -1) || right > render_width) |
| 1342 | right = render_width - 1; |
| 1343 | if ((bot == -1) || bot > render_height) |
| 1344 | bot = render_height - 1; |
| 1345 | Clip_scale_leftcxx . . $ Clip_scale_left. = left; |
| 1346 | Clip_scale_rightcxx . . $ Clip_scale_right. = right; |
| 1347 | Clip_scale_topcxx . . $ Clip_scale_top. = top; |
| 1348 | Clip_scale_botcxx . . $ Clip_scale_bot. = bot; |
| 1349 | if (!Terrain_skycxx . . $ Terrain_sky..texturedcxx . . $ terrain_sky#textured.) { |
| 1350 | rend_FillRectcxx . . $ rend_FillRect(fe09a4b73d8d396f).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color., left, top, right + 1, bot + 1); |
| 1351 | } |
| 1352 | |
| 1353 | rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.); |
| 1354 | View_modecxx . . $ View_mode. = GetFunctionModecxx . . $ GetFunctionMode(4270339a2fa9f0f5).(); |
| 1355 | |
| 1356 | // Set this so we don't do reentrant rendering between terrain/mine |
| 1357 | Terrain_from_minecxx . . $ Terrain_from_mine. = from_mine; |
| 1358 | |
| 1359 | #ifndef NEWEDITOR |
| 1360 | // See if we're supposed change the fog plane distance based on our framerate |
| 1361 | if (View_modecxx . . $ View_mode. != EDITOR_MODEcxx . . $ EDITOR_MODE. && ManageFrameratecxx . . $ ManageFramerate.) { |
| 1362 | float fps = GetFPScxx . . $ GetFPS(9b8c9e39889c762c).(); |
| 1363 | if (fps < MinAllowableFrameratecxx . . $ MinAllowableFramerate.) { |
| 1364 | if (Detail_settingscxx . . $ Detail_settings..Terrain_render_distancecxx . . $ tDetailSettings#Terrain_render_distance. > TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) { |
| 1365 | Detail_settingscxx . . $ Detail_settings..Terrain_render_distancecxx . . $ tDetailSettings#Terrain_render_distance. -= (float)(TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! / 4); |
| 1366 | } |
| 1367 | } else if (fps > MinAllowableFrameratecxx . . $ MinAllowableFramerate. + 1) { |
| 1368 | if (Detail_settingscxx . . $ Detail_settings..Terrain_render_distancecxx . . $ tDetailSettings#Terrain_render_distance. < 60 * TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`!) { |
| 1369 | Detail_settingscxx . . $ Detail_settings..Terrain_render_distancecxx . . $ tDetailSettings#Terrain_render_distance. += (float)(TERRAIN_SIZEcxx . . $ `Descent3/terrain.h:33:9`! / 4); |
| 1370 | } |
| 1371 | } |
| 1372 | } |
| 1373 | #endif |
| 1374 | |
| 1375 | #ifndef NEWEDITOR |
| 1376 | const float kTerrainRenderDistance = Detail_settingscxx . . $ Detail_settings..Terrain_render_distancecxx . . $ tDetailSettings#Terrain_render_distance.; |
| 1377 | #else |
| 1378 | const float kTerrainRenderDistance = 1200.0f; |
| 1379 | #endif |
| 1380 | VisibleTerrainZcxx . . $ VisibleTerrainZ. = kTerrainRenderDistance * Matrix_scalecxx . . $ Matrix_scale..zcxx . . $ vector#z.; |
| 1381 | Far_fog_bordercxx . . $ Far_fog_border. = VisibleTerrainZcxx . . $ VisibleTerrainZ.; |
| 1382 | |
| 1383 | // Set up our z wall |
| 1384 | g3_SetFarClipZcxx . . $ g3_SetFarClipZ(9364e6e7bff7660).(VisibleTerrainZcxx . . $ VisibleTerrainZ.); |
| 1385 | |
| 1386 | // Get the viewer position & orientation |
| 1387 | vectorcxx . . $ vector# viewer_eye; |
| 1388 | matrixcxx . . $ matrix# viewer_orient; |
| 1389 | g3_GetViewPositioncxx . . $ g3_GetViewPosition(ec8cf6451c36d470).(&viewer_eye); |
| 1390 | g3_GetViewMatrixcxx . . $ g3_GetViewMatrix(dca75c48c9ab5b54).(&viewer_orient); |
| 1391 | |
| 1392 | // Get all of the cells visible to us |
| 1393 | int nt = GetVisibleTerraincxx . . $ GetVisibleTerrain(ffb987d81e13bf99).(&viewer_eye, &viewer_orient); |
| 1394 | |
| 1395 | // Set this to really far away so our sky can render |
| 1396 | g3_SetFarClipZcxx . . $ g3_SetFarClipZ(9364e6e7bff7660).(60000); |
| 1397 | rend_SetFogStatecxx . . $ rend_SetFogState(4af4fd0e2b26c4ac).(0); |
| 1398 | |
| 1399 | // Draw the sky |
| 1400 | DrawSkycxx . . $ DrawSky(bc315f98e1febb02).(&viewer_eye, &viewer_orient); |
| 1401 | |
| 1402 | //// Set up our z wall |
| 1403 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1); |
| 1404 | rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1); |
| 1405 | g3_SetFarClipZcxx . . $ g3_SetFarClipZ(9364e6e7bff7660).(VisibleTerrainZcxx . . $ VisibleTerrainZ.); |
| 1406 | |
| 1407 | #ifndef NEWEDITOR |
| 1408 | if ((Terrain_skycxx . . $ Terrain_sky..flagscxx . . $ terrain_sky#flags. & TF_FOGcxx . . $ `Descent3/terrain.h:58:9`!) && (UseHardwarecxx . . $ UseHardware. || (!UseHardwarecxx . . $ UseHardware. && Lighting_oncxx . . $ Lighting_on.))) { |
| 1409 | rend_SetZValuescxx . . $ rend_SetZValues(5102ef758adc0ae7).(0, VisibleTerrainZcxx . . $ VisibleTerrainZ.); |
| 1410 | rend_SetFogStatecxx . . $ rend_SetFogState(4af4fd0e2b26c4ac).(1); |
| 1411 | rend_SetFogBorderscxx . . $ rend_SetFogBorders(5102ef758adc0ae7).(VisibleTerrainZcxx . . $ VisibleTerrainZ. * Terrain_skycxx . . $ Terrain_sky..fog_scalarcxx . . $ terrain_sky#fog_scalar., Far_fog_bordercxx . . $ Far_fog_border.); |
| 1412 | rend_SetFogColorcxx . . $ rend_SetFogColor(cb2f890c2fdad230).(Terrain_skycxx . . $ Terrain_sky..fog_colorcxx . . $ terrain_sky#fog_color.); |
| 1413 | } else |
| 1414 | #endif |
| 1415 | { |
| 1416 | rend_SetZValuescxx . . $ rend_SetZValues(5102ef758adc0ae7).(0, 5000); |
| 1417 | } |
| 1418 | |
| 1419 | // And display! |
| 1420 | if (nt > 0) { |
| 1421 | DisplayTerrainListcxx . . $ DisplayTerrainList(918ebd27a9ddbad3).(nt); |
| 1422 | } |
| 1423 | |
| 1424 | // Draw rooms |
| 1425 | RenderTerrainRoomscxx . . $ RenderTerrainRooms(49f6e7a06ebc5aa8).(); |
| 1426 | |
| 1427 | // Show objects |
| 1428 | if (nt < 1 || UseHardwarecxx . . $ UseHardware.) { |
| 1429 | RenderAllTerrainObjectscxx . . $ RenderAllTerrainObjects(49f6e7a06ebc5aa8).(); |
| 1430 | } |
| 1431 | |
| 1432 | mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(2, 5, 0, "Objs Drawn=%5d", Terrain_objects_drawn); |
| 1433 | Last_terrain_render_timecxx . . $ Last_terrain_render_time. = Gametimecxx . . $ Gametime.; |
| 1434 | } |
| 1435 | |
| 1436 | // Draws a segment of lightning that is always facing you |
| 1437 | // Vectors are in world coords |
| 1438 | void DrawLightningSegmentcxx . . $ DrawLightningSegment(b5a398a01f383273).(vectorcxx . . $ vector# *from, vectorcxx . . $ vector# *to) { |
| 1439 | vectorcxx . . $ vector# src_vecs[2], world_vecs[6]; |
| 1440 | g3Pointcxx . . $ g3Point# rot_src_pnts[2], world_points[6], *pntlist[6]; |
| 1441 | static float alphas[] = {0.3f, 1.0f, 0.3f, 0.3f, 1.0f, 0.3f}; |
| 1442 | src_vecs[0] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *from; |
| 1443 | src_vecs[1] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). *to; |
| 1444 | |
| 1445 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&rot_src_pnts[0], &src_vecs[0]); |
| 1446 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&rot_src_pnts[1], &src_vecs[1]); |
| 1447 | if (rot_src_pnts[0].p3_codescxx . . $ g3Point#p3_codes. & rot_src_pnts[1].p3_codescxx . . $ g3Point#p3_codes.) |
| 1448 | return; // Don't draw because both points are off screen |
| 1449 | vectorcxx . . $ vector# rvec = Viewer_objectcxx . . $ Viewer_object.->orientcxx . . $ object#orient..rveccxx . . $ matrix#rvec. *cxx . . $ `operator*`(252247219a31502c). 10; |
| 1450 | |
| 1451 | // Put all points so that they face the viewer |
| 1452 | world_vecs[0] =cxx . . $ vector#`operator=`(c0842353a20857d). src_vecs[0] -cxx . . $ operator-(b77b703cd1e43e33). rvec; |
| 1453 | world_vecs[1] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). src_vecs[0]; |
| 1454 | world_vecs[2] =cxx . . $ vector#`operator=`(c0842353a20857d). src_vecs[0] +cxx . . $ operator+(b77b703cd1e43e33). rvec; |
| 1455 | world_vecs[3] =cxx . . $ vector#`operator=`(c0842353a20857d). src_vecs[1] +cxx . . $ operator+(b77b703cd1e43e33). rvec; |
| 1456 | world_vecs[4] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). src_vecs[1]; |
| 1457 | world_vecs[5] =cxx . . $ vector#`operator=`(c0842353a20857d). src_vecs[1] -cxx . . $ operator-(b77b703cd1e43e33). rvec; |
| 1458 | for (int i = 0; i < 6; i++) { |
| 1459 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&world_points[i], &world_vecs[i]); |
| 1460 | world_points[i].p3_flagscxx . . $ g3Point#p3_flags. |= PF_RGBAcxx . . $ `lib/3d.h:219:9`!; |
| 1461 | world_points[i].p3_rcxx . . $ `lib/3d.h:253:9`! = .2f; |
| 1462 | world_points[i].p3_gcxx . . $ `lib/3d.h:254:9`! = .4f; |
| 1463 | world_points[i].p3_bcxx . . $ `lib/3d.h:255:9`! = 1.0f; |
| 1464 | world_points[i].p3_acxx . . $ `lib/3d.h:256:9`! = alphas[i]; |
| 1465 | pntlist[i] = &world_points[i]; |
| 1466 | } |
| 1467 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.); |
| 1468 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.); |
| 1469 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_SATURATE_VERTEXcxx . . $ `lib/renderer.h:411:9`!); |
| 1470 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_RGBcxx . . $ CM_RGB.); |
| 1471 | g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&world_points[1]); |
| 1472 | g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&world_points[4]); |
| 1473 | rend_DrawSpecialLinecxx . . $ rend_DrawSpecialLine(1b637e6b3e24914d).(&world_points[1], &world_points[4]); |
| 1474 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(6, pntlist, 0); |
| 1475 | } |
| 1476 | #define PUSH_LIGHTNING_TREEcxx . . $ `Descent3/terrainrender.cpp:1476:9`!(f, l, sp) \ |
| 1477 | { \ |
| 1478 | froms[si] = f; \ |
| 1479 | stack_level[si] = l; \ |
| 1480 | splits[si] = sp; \ |
| 1481 | si++; \ |
| 1482 | } |
| 1483 | #define POP_LIGHTNING_TREEcxx . . $ `Descent3/terrainrender.cpp:1483:9`!() \ |
| 1484 | { \ |
| 1485 | si--; \ |
| 1486 | cur_from = froms[si]; \ |
| 1487 | level = stack_level[si]; \ |
| 1488 | cur_splits = splits[si]; \ |
| 1489 | } |
| 1490 | // Draws an entire strip of lightning |
| 1491 | void DrawLightningcxx . . $ DrawLightning(49f6e7a06ebc5aa8).(void) { |
| 1492 | angveccxx . . $ angvec# player_angs; |
| 1493 | matrixcxx . . $ matrix# mat; |
| 1494 | vectorcxx . . $ vector# froms[50]; |
| 1495 | int si = 0, level; |
| 1496 | int stack_level[50]; |
| 1497 | int splits[50]; |
| 1498 | int cur_splits = 0; |
| 1499 | int new_heading; |
| 1500 | float scalar; |
| 1501 | scalar = ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 1000) - 500) / 500.0; |
| 1502 | scalar *= 15000; |
| 1503 | vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&player_angs, &Viewer_objectcxx . . $ Viewer_object.->orientcxx . . $ object#orient.); |
| 1504 | new_heading = (player_angs.hcxx . . $ angvec#h. + (int)scalar) % 65536; |
| 1505 | vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&mat, 0, new_heading, 0); |
| 1506 | // Put the starting point way up in the air |
| 1507 | float ylimit = (-(Viewer_objectcxx . . $ Viewer_object.->poscxx . . $ object#pos..ycxx . . $ vector#y. * 2)) + (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 400); |
| 1508 | vectorcxx . . $ vector# cur_from = Viewer_objectcxx . . $ Viewer_object.->poscxx . . $ object#pos. +cxx . . $ operator+(b77b703cd1e43e33). (mat.fveccxx . . $ matrix#fvec. *cxx . . $ `operator*`(252247219a31502c). 4000); |
| 1509 | vectorcxx . . $ vector# new_vec; |
| 1510 | cur_from.ycxx . . $ vector#y. += 800.0f; |
| 1511 | cur_from.ycxx . . $ vector#y. += (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 100); |
| 1512 | // Set some states |
| 1513 | |
| 1514 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_SATURATE_TEXTUREcxx . . $ `lib/renderer.h:408:9`!); |
| 1515 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(.5 * 255); |
| 1516 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 1517 | int bm_handle; |
| 1518 | |
| 1519 | // See if we should drawn an origin bitmap |
| 1520 | if (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 3) { |
| 1521 | // Pick an origin bitmap |
| 1522 | if (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 2) |
| 1523 | bm_handle = Fireballscxx . . $ Fireballs.[LIGHTNING_ORIGIN_INDEXAcxx . . $ `Descent3/fireball_external.h:48:9`!].bm_handlecxx . . $ fireball#bm_handle.; |
| 1524 | else |
| 1525 | bm_handle = Fireballscxx . . $ Fireballs.[LIGHTNING_ORIGIN_INDEXBcxx . . $ `Descent3/fireball_external.h:49:9`!].bm_handlecxx . . $ fireball#bm_handle.; |
| 1526 | // Draw the origin bitmap |
| 1527 | int size = 300 + (ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 200); |
| 1528 | g3_DrawRotatedBitmapcxx . . $ g3_DrawRotatedBitmap(b3c51db2a67f6227).(&cur_from, 0, size, (size * bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, 0)) / bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, 0), bm_handle); |
| 1529 | } |
| 1530 | PUSH_LIGHTNING_TREEcxx . . $ `Descent3/terrainrender.cpp:1476:9`!(cur_from, 0, 0) |
| 1531 | while (si > 0) { |
| 1532 | POP_LIGHTNING_TREEcxx . . $ `Descent3/terrainrender.cpp:1483:9`!() |
| 1533 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(level < 50); |
| 1534 | float x_adjust = ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 200) - 100) / 100.0; |
| 1535 | float y_adjust = .3 + ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 100) / 100.0); |
| 1536 | |
| 1537 | new_vec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). cur_from; |
| 1538 | new_vec +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). x_adjust *cxx . . $ `operator*`(9d6577ff3e9faa29). (mat.rveccxx . . $ matrix#rvec. *cxx . . $ `operator*`(252247219a31502c). 70); |
| 1539 | new_vec -=cxx . . $ `operator-=`(801a8d6f7ab7bef9). y_adjust *cxx . . $ `operator*`(9d6577ff3e9faa29). (mat.uveccxx . . $ matrix#uvec. *cxx . . $ `operator*`(252247219a31502c). 100); |
| 1540 | DrawLightningSegmentcxx . . $ DrawLightningSegment(b5a398a01f383273).(&cur_from, &new_vec); |
| 1541 | if (cur_from.ycxx . . $ vector#y. < ylimit) // We're close to the ground, so just bail! |
| 1542 | continue; |
| 1543 | |
| 1544 | if ((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % ((level * level * 20) + 8)) == 0 && cur_splits < 2) { |
| 1545 | // Make this branch split |
| 1546 | PUSH_LIGHTNING_TREEcxx . . $ `Descent3/terrainrender.cpp:1476:9`!(new_vec, level, cur_splits + 1) |
| 1547 | PUSH_LIGHTNING_TREEcxx . . $ `Descent3/terrainrender.cpp:1476:9`!(new_vec, level, cur_splits + 1) |
| 1548 | } else { |
| 1549 | PUSH_LIGHTNING_TREEcxx . . $ `Descent3/terrainrender.cpp:1476:9`!(new_vec, level, cur_splits) |
| 1550 | } |
| 1551 | } |
| 1552 | } |
| 1553 | // Draws a lightning sky |
| 1554 | void DrawLightningSkycxx . . $ DrawLightningSky(49f6e7a06ebc5aa8).(void) { |
| 1555 | int t, k, tw; |
| 1556 | float r, g, b; |
| 1557 | |
| 1558 | g3Pointcxx . . $ g3Point# pnt[4], *pntlist[6]; |
| 1559 | |
| 1560 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.); |
| 1561 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_RGBcxx . . $ CM_RGB.); |
| 1562 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.); |
| 1563 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_SATURATE_VERTEXcxx . . $ `lib/renderer.h:411:9`!); |
| 1564 | |
| 1565 | // figure out colors for sky |
| 1566 | r = .8f; |
| 1567 | g = .8f; |
| 1568 | b = 1.0; |
| 1569 | // Draw top part |
| 1570 | for (t = 0; t < MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; t++) { |
| 1571 | tw = (t + 1) % MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; |
| 1572 | pnt[0].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][0]; |
| 1573 | pnt[0].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][0]; |
| 1574 | pnt[1].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][1]; |
| 1575 | pnt[1].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[tw][1]; |
| 1576 | pnt[2].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][1]; |
| 1577 | pnt[2].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][1]; |
| 1578 | |
| 1579 | for (k = 0; k < 3; k++) { |
| 1580 | g3Pointcxx . . $ g3Point# *p = &pnt[k]; |
| 1581 | p->p3_flagscxx . . $ g3Point#p3_flags. = PF_RGBAcxx . . $ `lib/3d.h:219:9`! | PF_ORIGPOINTcxx . . $ `lib/3d.h:221:9`!; |
| 1582 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(p); |
| 1583 | p->p3_acxx . . $ `lib/3d.h:256:9`! = .3f; |
| 1584 | p->p3_rcxx . . $ `lib/3d.h:253:9`! = r; |
| 1585 | p->p3_gcxx . . $ `lib/3d.h:254:9`! = g; |
| 1586 | p->p3_bcxx . . $ `lib/3d.h:255:9`! = b; |
| 1587 | } |
| 1588 | pntlist[0] = &pnt[0]; |
| 1589 | pntlist[1] = &pnt[1]; |
| 1590 | pntlist[2] = &pnt[2]; |
| 1591 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(3, pntlist, 0); |
| 1592 | } |
| 1593 | // Draw bottom part |
| 1594 | for (int i = 1; i < 5; i++) { |
| 1595 | for (t = 0; t < MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; t++) { |
| 1596 | tw = (t + 1) % MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; |
| 1597 | pnt[0].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][i]; |
| 1598 | pnt[0].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][i]; |
| 1599 | pnt[1].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][i]; |
| 1600 | pnt[1].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[tw][i]; |
| 1601 | pnt[2].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][i + 1]; |
| 1602 | pnt[2].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[tw][i + 1]; |
| 1603 | pnt[3].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][i + 1]; |
| 1604 | pnt[3].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][i + 1]; |
| 1605 | |
| 1606 | for (k = 0; k < 4; k++) { |
| 1607 | g3Pointcxx . . $ g3Point# *p = &pnt[k]; |
| 1608 | p->p3_flagscxx . . $ g3Point#p3_flags. = PF_RGBAcxx . . $ `lib/3d.h:219:9`! | PF_ORIGPOINTcxx . . $ `lib/3d.h:221:9`!; |
| 1609 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(p); |
| 1610 | p->p3_acxx . . $ `lib/3d.h:256:9`! = .3f; |
| 1611 | p->p3_rcxx . . $ `lib/3d.h:253:9`! = r; |
| 1612 | p->p3_gcxx . . $ `lib/3d.h:254:9`! = g; |
| 1613 | p->p3_bcxx . . $ `lib/3d.h:255:9`! = b; |
| 1614 | pntlist[k] = p; |
| 1615 | } |
| 1616 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(4, pntlist, 0); |
| 1617 | } |
| 1618 | } |
| 1619 | } |
| 1620 | // Draws the gouraud sky |
| 1621 | void DrawGouraudSkycxx . . $ DrawGouraudSky(49f6e7a06ebc5aa8).(void) { |
| 1622 | int t, k, tw; |
| 1623 | float sr, sg, sb, hr, hg, hb; |
| 1624 | |
| 1625 | g3Pointcxx . . $ g3Point# pnt[4], *pntlist[6]; |
| 1626 | g3UVLcxx . . $ g3UVL# uvls[10]; |
| 1627 | if (Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color. == Terrain_skycxx . . $ Terrain_sky..horizon_colorcxx . . $ terrain_sky#horizon_color.) |
| 1628 | return; // No sense in drawing anything |
| 1629 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.); |
| 1630 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_RGBcxx . . $ CM_RGB.); |
| 1631 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_ALWAYScxx . . $ `lib/renderer.h:399:9`!); |
| 1632 | // figure out colors for sky |
| 1633 | { |
| 1634 | sr = (float)GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.) / 255.0; |
| 1635 | sg = (float)GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.) / 255.0; |
| 1636 | sb = (float)GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.) / 255.0; |
| 1637 | hr = (float)GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..horizon_colorcxx . . $ terrain_sky#horizon_color.) / 255.0; |
| 1638 | hg = (float)GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..horizon_colorcxx . . $ terrain_sky#horizon_color.) / 255.0; |
| 1639 | hb = (float)GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..horizon_colorcxx . . $ terrain_sky#horizon_color.) / 255.0; |
| 1640 | } |
| 1641 | for (t = 0; t < MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; t++) { |
| 1642 | tw = (t + 1) % MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; |
| 1643 | pnt[0].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][4]; |
| 1644 | pnt[0].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][4]; |
| 1645 | uvls[0].rcxx . . $ g3UVL#$anonymous_type_0#r. = sr; |
| 1646 | uvls[0].gcxx . . $ g3UVL#g. = sg; |
| 1647 | uvls[0].bcxx . . $ g3UVL#b. = sb; |
| 1648 | |
| 1649 | pnt[1].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][4]; |
| 1650 | pnt[1].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[tw][4]; |
| 1651 | uvls[1].rcxx . . $ g3UVL#$anonymous_type_0#r. = sr; |
| 1652 | uvls[1].gcxx . . $ g3UVL#g. = sg; |
| 1653 | uvls[1].bcxx . . $ g3UVL#b. = sb; |
| 1654 | |
| 1655 | pnt[2].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][5]; |
| 1656 | pnt[2].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[tw][5]; |
| 1657 | uvls[2].rcxx . . $ g3UVL#$anonymous_type_0#r. = hr; |
| 1658 | uvls[2].gcxx . . $ g3UVL#g. = hg; |
| 1659 | uvls[2].bcxx . . $ g3UVL#b. = hb; |
| 1660 | |
| 1661 | pnt[3].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][5]; |
| 1662 | pnt[3].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][5]; |
| 1663 | uvls[3].rcxx . . $ g3UVL#$anonymous_type_0#r. = hr; |
| 1664 | uvls[3].gcxx . . $ g3UVL#g. = hg; |
| 1665 | uvls[3].bcxx . . $ g3UVL#b. = hb; |
| 1666 | |
| 1667 | for (k = 0; k < 4; k++) { |
| 1668 | g3Pointcxx . . $ g3Point# *p = &pnt[k]; |
| 1669 | p->p3_flagscxx . . $ g3Point#p3_flags. = PF_RGBAcxx . . $ `lib/3d.h:219:9`! | PF_ORIGPOINTcxx . . $ `lib/3d.h:221:9`!; |
| 1670 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(p); |
| 1671 | pntlist[k] = p; |
| 1672 | p->p3_uvlcxx . . $ g3Point#p3_uvl. =cxx . . $ g3UVL#`operator=`(e9042e12405fa663). uvls[k]; |
| 1673 | } |
| 1674 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(4, pntlist, 0); |
| 1675 | } |
| 1676 | } |
| 1677 | // Draws the sky textures |
| 1678 | void DrawTexturedSkycxx . . $ DrawTexturedSky(49f6e7a06ebc5aa8).(void) { |
| 1679 | int t, k, tw; |
| 1680 | float sr, sg, sb, hr, hg, hb; |
| 1681 | |
| 1682 | // Change terrain sky if needed |
| 1683 | int dome_bm = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(Terrain_skycxx . . $ Terrain_sky..dome_texturecxx . . $ terrain_sky#dome_texture., 0); |
| 1684 | |
| 1685 | g3Pointcxx . . $ g3Point# pnt[6], *pntlist[6]; |
| 1686 | g3UVLcxx . . $ g3UVL# uvls[10]; |
| 1687 | |
| 1688 | rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.); |
| 1689 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_PERSPECTIVEcxx . . $ TT_PERSPECTIVE.); |
| 1690 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.); |
| 1691 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(ATF_TEXTUREcxx . . $ `lib/renderer.h:395:9`!); |
| 1692 | g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(1); |
| 1693 | |
| 1694 | // Draw top part |
| 1695 | for (t = 0; t < MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; t++) { |
| 1696 | tw = (t + 1) % MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; |
| 1697 | pnt[0].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][0]; |
| 1698 | pnt[0].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][0]; |
| 1699 | uvls[0].ucxx . . $ g3UVL#u. = Terrain_skycxx . . $ Terrain_sky..horizon_ucxx . . $ terrain_sky#horizon_u.[t][0]; |
| 1700 | uvls[0].vcxx . . $ g3UVL#v. = Terrain_skycxx . . $ Terrain_sky..horizon_vcxx . . $ terrain_sky#horizon_v.[t][0]; |
| 1701 | |
| 1702 | pnt[1].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][1]; |
| 1703 | pnt[1].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[tw][1]; |
| 1704 | uvls[1].ucxx . . $ g3UVL#u. = Terrain_skycxx . . $ Terrain_sky..horizon_ucxx . . $ terrain_sky#horizon_u.[tw][1]; |
| 1705 | uvls[1].vcxx . . $ g3UVL#v. = Terrain_skycxx . . $ Terrain_sky..horizon_vcxx . . $ terrain_sky#horizon_v.[tw][1]; |
| 1706 | |
| 1707 | pnt[2].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][1]; |
| 1708 | pnt[2].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][1]; |
| 1709 | uvls[2].ucxx . . $ g3UVL#u. = Terrain_skycxx . . $ Terrain_sky..horizon_ucxx . . $ terrain_sky#horizon_u.[t][1]; |
| 1710 | uvls[2].vcxx . . $ g3UVL#v. = Terrain_skycxx . . $ Terrain_sky..horizon_vcxx . . $ terrain_sky#horizon_v.[t][1]; |
| 1711 | |
| 1712 | for (k = 0; k < 3; k++) { |
| 1713 | g3Pointcxx . . $ g3Point# *p = &pnt[k]; |
| 1714 | p->p3_flagscxx . . $ g3Point#p3_flags. = PF_UVcxx . . $ `lib/3d.h:217:9`! | PF_Lcxx . . $ `lib/3d.h:218:9`! | PF_ORIGPOINTcxx . . $ `lib/3d.h:221:9`!; |
| 1715 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(p); |
| 1716 | p->p3_uvlcxx . . $ g3Point#p3_uvl. =cxx . . $ g3UVL#`operator=`(e9042e12405fa663). uvls[k]; |
| 1717 | p->p3_lcxx . . $ `lib/3d.h:252:9`! = 1; |
| 1718 | } |
| 1719 | |
| 1720 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 1721 | ddgr_color oldcolor; |
| 1722 | if (TSearch_on) { |
| 1723 | rend_SetPixel(GR_RGB(0, 255, 0), TSearch_x, TSearch_y); |
| 1724 | oldcolor = rend_GetPixel(TSearch_x, TSearch_y); // will be different in 15/16-bit color |
| 1725 | } |
| 1726 | #endif |
| 1727 | |
| 1728 | pntlist[0] = &pnt[0]; |
| 1729 | pntlist[1] = &pnt[1]; |
| 1730 | pntlist[2] = &pnt[2]; |
| 1731 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(3, pntlist, dome_bm); |
| 1732 | |
| 1733 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 1734 | if (TSearch_on) { |
| 1735 | ddgr_color newcolor = rend_GetPixel(TSearch_x, TSearch_y); |
| 1736 | if (newcolor != oldcolor) { |
| 1737 | TSearch_seg = t; |
| 1738 | TSearch_found_type = TSEARCH_FOUND_SKY_DOME; |
| 1739 | } |
| 1740 | } |
| 1741 | #endif |
| 1742 | } |
| 1743 | |
| 1744 | // Draw bottom part |
| 1745 | for (int i = 1; i < 4; i++) { |
| 1746 | for (t = 0; t < MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; t++) { |
| 1747 | tw = (t + 1) % MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; |
| 1748 | pnt[0].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][i]; |
| 1749 | pnt[0].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][i]; |
| 1750 | uvls[0].ucxx . . $ g3UVL#u. = Terrain_skycxx . . $ Terrain_sky..horizon_ucxx . . $ terrain_sky#horizon_u.[t][i]; |
| 1751 | uvls[0].vcxx . . $ g3UVL#v. = Terrain_skycxx . . $ Terrain_sky..horizon_vcxx . . $ terrain_sky#horizon_v.[t][i]; |
| 1752 | |
| 1753 | pnt[1].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][i]; |
| 1754 | pnt[1].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[tw][i]; |
| 1755 | uvls[1].ucxx . . $ g3UVL#u. = Terrain_skycxx . . $ Terrain_sky..horizon_ucxx . . $ terrain_sky#horizon_u.[tw][i]; |
| 1756 | uvls[1].vcxx . . $ g3UVL#v. = Terrain_skycxx . . $ Terrain_sky..horizon_vcxx . . $ terrain_sky#horizon_v.[tw][i]; |
| 1757 | |
| 1758 | pnt[2].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][i + 1]; |
| 1759 | pnt[2].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[tw][i + 1]; |
| 1760 | uvls[2].ucxx . . $ g3UVL#u. = Terrain_skycxx . . $ Terrain_sky..horizon_ucxx . . $ terrain_sky#horizon_u.[tw][i + 1]; |
| 1761 | uvls[2].vcxx . . $ g3UVL#v. = Terrain_skycxx . . $ Terrain_sky..horizon_vcxx . . $ terrain_sky#horizon_v.[tw][i + 1]; |
| 1762 | |
| 1763 | pnt[3].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][i + 1]; |
| 1764 | pnt[3].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][i + 1]; |
| 1765 | uvls[3].ucxx . . $ g3UVL#u. = Terrain_skycxx . . $ Terrain_sky..horizon_ucxx . . $ terrain_sky#horizon_u.[t][i + 1]; |
| 1766 | uvls[3].vcxx . . $ g3UVL#v. = Terrain_skycxx . . $ Terrain_sky..horizon_vcxx . . $ terrain_sky#horizon_v.[t][i + 1]; |
| 1767 | |
| 1768 | for (k = 0; k < 4; k++) { |
| 1769 | g3Pointcxx . . $ g3Point# *p = &pnt[k]; |
| 1770 | p->p3_flagscxx . . $ g3Point#p3_flags. = PF_UVcxx . . $ `lib/3d.h:217:9`! | PF_Lcxx . . $ `lib/3d.h:218:9`! | PF_ORIGPOINTcxx . . $ `lib/3d.h:221:9`!; |
| 1771 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(p); |
| 1772 | pntlist[k] = p; |
| 1773 | p->p3_uvlcxx . . $ g3Point#p3_uvl. =cxx . . $ g3UVL#`operator=`(e9042e12405fa663). uvls[k]; |
| 1774 | p->p3_lcxx . . $ `lib/3d.h:252:9`! = 1; |
| 1775 | } |
| 1776 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 1777 | ddgr_color oldcolor; |
| 1778 | if (TSearch_on) { |
| 1779 | rend_SetPixel(GR_RGB(0, 255, 0), TSearch_x, TSearch_y); |
| 1780 | oldcolor = rend_GetPixel(TSearch_x, TSearch_y); // will be different in 15/16-bit color |
| 1781 | } |
| 1782 | #endif |
| 1783 | |
| 1784 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(4, pntlist, dome_bm); |
| 1785 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 1786 | if (TSearch_on) { |
| 1787 | ddgr_color newcolor = rend_GetPixel(TSearch_x, TSearch_y); |
| 1788 | if (newcolor != oldcolor) { |
| 1789 | TSearch_seg = t; |
| 1790 | TSearch_found_type = TSEARCH_FOUND_SKY_DOME; |
| 1791 | } |
| 1792 | } |
| 1793 | #endif |
| 1794 | } |
| 1795 | } |
| 1796 | // Now draw band |
| 1797 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.); |
| 1798 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_RGBcxx . . $ CM_RGB.); |
| 1799 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_ALWAYScxx . . $ `lib/renderer.h:399:9`!); |
| 1800 | |
| 1801 | // figure out colors for sky |
| 1802 | { |
| 1803 | sr = (float)GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.) / 255.0; |
| 1804 | sg = (float)GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.) / 255.0; |
| 1805 | sb = (float)GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.) / 255.0; |
| 1806 | hr = (float)GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..horizon_colorcxx . . $ terrain_sky#horizon_color.) / 255.0; |
| 1807 | hg = (float)GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..horizon_colorcxx . . $ terrain_sky#horizon_color.) / 255.0; |
| 1808 | hb = (float)GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..horizon_colorcxx . . $ terrain_sky#horizon_color.) / 255.0; |
| 1809 | } |
| 1810 | |
| 1811 | for (t = 0; t < MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; t++) { |
| 1812 | tw = (t + 1) % MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; |
| 1813 | pnt[0].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][4]; |
| 1814 | pnt[0].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][4]; |
| 1815 | uvls[0].rcxx . . $ g3UVL#$anonymous_type_0#r. = sr; |
| 1816 | uvls[0].gcxx . . $ g3UVL#g. = sg; |
| 1817 | uvls[0].bcxx . . $ g3UVL#b. = sb; |
| 1818 | |
| 1819 | pnt[1].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][4]; |
| 1820 | pnt[1].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[tw][4]; |
| 1821 | uvls[1].rcxx . . $ g3UVL#$anonymous_type_0#r. = sr; |
| 1822 | uvls[1].gcxx . . $ g3UVL#g. = sg; |
| 1823 | uvls[1].bcxx . . $ g3UVL#b. = sb; |
| 1824 | |
| 1825 | pnt[2].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][5]; |
| 1826 | pnt[2].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[tw][5]; |
| 1827 | uvls[2].rcxx . . $ g3UVL#$anonymous_type_0#r. = hr; |
| 1828 | uvls[2].gcxx . . $ g3UVL#g. = hg; |
| 1829 | uvls[2].bcxx . . $ g3UVL#b. = hb; |
| 1830 | |
| 1831 | pnt[3].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][5]; |
| 1832 | pnt[3].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][5]; |
| 1833 | uvls[3].rcxx . . $ g3UVL#$anonymous_type_0#r. = hr; |
| 1834 | uvls[3].gcxx . . $ g3UVL#g. = hg; |
| 1835 | uvls[3].bcxx . . $ g3UVL#b. = hb; |
| 1836 | |
| 1837 | for (k = 0; k < 4; k++) { |
| 1838 | g3Pointcxx . . $ g3Point# *p = &pnt[k]; |
| 1839 | p->p3_flagscxx . . $ g3Point#p3_flags. = PF_RGBAcxx . . $ `lib/3d.h:219:9`! | PF_ORIGPOINTcxx . . $ `lib/3d.h:221:9`!; |
| 1840 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(p); |
| 1841 | pntlist[k] = p; |
| 1842 | p->p3_uvlcxx . . $ g3Point#p3_uvl. =cxx . . $ g3UVL#`operator=`(e9042e12405fa663). uvls[k]; |
| 1843 | } |
| 1844 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(4, pntlist, 0); |
| 1845 | } |
| 1846 | g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(0); |
| 1847 | rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.); |
| 1848 | } |
| 1849 | |
| 1850 | // Draws the sky textures |
| 1851 | void DrawWireframeSkycxx . . $ DrawWireframeSky(49f6e7a06ebc5aa8).(void) { |
| 1852 | int t, k, tw, i; |
| 1853 | g3Pointcxx . . $ g3Point# pnt[6]; |
| 1854 | |
| 1855 | // Draw top part |
| 1856 | for (t = 0; t < MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; t++) { |
| 1857 | tw = (t + 1) % MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; |
| 1858 | pnt[0].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][0]; |
| 1859 | pnt[1].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][1]; |
| 1860 | pnt[2].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][1]; |
| 1861 | |
| 1862 | for (k = 0; k < 3; k++) { |
| 1863 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(&pnt[k]); |
| 1864 | pnt[k].p3_flagscxx . . $ g3Point#p3_flags. = 0; |
| 1865 | } |
| 1866 | |
| 1867 | for (k = 0; k < 3; k++) |
| 1868 | g3_DrawLinecxx . . $ g3_DrawLine(79482445f52a1992).(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 255, 255), &pnt[k], &pnt[(k + 1) % 3]); |
| 1869 | } |
| 1870 | // Draw bottom parts |
| 1871 | for (i = 1; i < 5; i++) { |
| 1872 | for (t = 0; t < MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; t++) { |
| 1873 | tw = (t + 1) % MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; |
| 1874 | pnt[0].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][i]; |
| 1875 | pnt[1].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][i]; |
| 1876 | pnt[2].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[tw][i + 1]; |
| 1877 | pnt[3].p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][i + 1]; |
| 1878 | for (k = 0; k < 4; k++) { |
| 1879 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(&pnt[k]); |
| 1880 | pnt[k].p3_flagscxx . . $ g3Point#p3_flags. = 0; |
| 1881 | } |
| 1882 | |
| 1883 | for (k = 0; k < 4; k++) |
| 1884 | g3_DrawLinecxx . . $ g3_DrawLine(79482445f52a1992).(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(255, 255, 255), &pnt[k], &pnt[(k + 1) % 4]); |
| 1885 | } |
| 1886 | } |
| 1887 | } |
| 1888 | // Draws the atmosphere over a satellite |
| 1889 | void DrawAtmosphereBlendcxx . . $ DrawAtmosphereBlend(bac30d42f00edb2).(vectorcxx . . $ vector# *pos, anglecxx . . $ angle# rotAngle, float w, float h, int bm, float r, float g, float b) { |
| 1890 | g3Pointcxx . . $ g3Point# pnt; |
| 1891 | if (g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&pnt, pos) & CC_BEHINDcxx . . $ `lib/3d.h:230:9`!) |
| 1892 | return; |
| 1893 | |
| 1894 | // create the rotation matrix |
| 1895 | matrixcxx . . $ matrix# rotMatrix; |
| 1896 | vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&rotMatrix, 0, 0, rotAngle); |
| 1897 | |
| 1898 | // get the view matrix |
| 1899 | matrixcxx . . $ matrix# viewToWorld; |
| 1900 | g3_GetUnscaledMatrixcxx . . $ g3_GetUnscaledMatrix(dca75c48c9ab5b54).(&viewToWorld); |
| 1901 | viewToWorld =cxx . . $ matrix#`operator=`(e859ffc26b91394f). ~cxx . . $ `operator~`(1e820934589b6814).viewToWorld; |
| 1902 | |
| 1903 | // combine the matrices into one |
| 1904 | matrixcxx . . $ matrix# rotationToWorld = rotMatrix *cxx . . $ `operator*`(683f8e040c904cb). viewToWorld; |
| 1905 | |
| 1906 | // setup the rotation vectors |
| 1907 | vectorcxx . . $ vector# rotVectors[4]; |
| 1908 | rotVectors[0].xcxx . . $ vector#x. = -w; |
| 1909 | rotVectors[0].ycxx . . $ vector#y. = h; |
| 1910 | rotVectors[1].xcxx . . $ vector#x. = w; |
| 1911 | rotVectors[1].ycxx . . $ vector#y. = h; |
| 1912 | rotVectors[2].xcxx . . $ vector#x. = w; |
| 1913 | rotVectors[2].ycxx . . $ vector#y. = -h; |
| 1914 | rotVectors[3].xcxx . . $ vector#x. = -w; |
| 1915 | rotVectors[3].ycxx . . $ vector#y. = -h; |
| 1916 | |
| 1917 | // rotate the points |
| 1918 | g3Pointcxx . . $ g3Point# rotPoints[8], *pntList[8]; |
| 1919 | int i; |
| 1920 | for (i = 0; i < 4; ++i) { |
| 1921 | rotVectors[i].zcxx . . $ vector#z. = 0.0f; |
| 1922 | rotVectors[i] =cxx . . $ vector#`operator=`(c0842353a20857d). (rotVectors[i] *cxx . . $ `operator*`(14b8f9ac5c1e7b85). rotationToWorld) +cxx . . $ operator+(b77b703cd1e43e33). (*pos); |
| 1923 | |
| 1924 | // setup the point |
| 1925 | g3_RotatePointcxx . . $ g3_RotatePoint(fd2e8930c920e2b9).(&rotPoints[i], &rotVectors[i]); |
| 1926 | rotPoints[i].p3_flagscxx . . $ g3Point#p3_flags. |= PF_UVcxx . . $ `lib/3d.h:217:9`! | PF_RGBAcxx . . $ `lib/3d.h:219:9`!; |
| 1927 | rotPoints[i].p3_rcxx . . $ `lib/3d.h:253:9`! = r; |
| 1928 | rotPoints[i].p3_gcxx . . $ `lib/3d.h:254:9`! = g; |
| 1929 | rotPoints[i].p3_bcxx . . $ `lib/3d.h:255:9`! = b; |
| 1930 | rotPoints[i].p3_acxx . . $ `lib/3d.h:256:9`! = 0.4f; |
| 1931 | |
| 1932 | pntList[i] = &rotPoints[i]; |
| 1933 | } |
| 1934 | |
| 1935 | rotPoints[0].p3_ucxx . . $ `lib/3d.h:250:9`! = 0.0f; |
| 1936 | rotPoints[0].p3_vcxx . . $ `lib/3d.h:251:9`! = 0.0f; |
| 1937 | rotPoints[1].p3_ucxx . . $ `lib/3d.h:250:9`! = 1.0f; |
| 1938 | rotPoints[1].p3_vcxx . . $ `lib/3d.h:251:9`! = 0.0f; |
| 1939 | rotPoints[2].p3_ucxx . . $ `lib/3d.h:250:9`! = 1.0f; |
| 1940 | rotPoints[2].p3_vcxx . . $ `lib/3d.h:251:9`! = 1.0f; |
| 1941 | rotPoints[3].p3_ucxx . . $ `lib/3d.h:250:9`! = 0.0f; |
| 1942 | rotPoints[3].p3_vcxx . . $ `lib/3d.h:251:9`! = 1.0f; |
| 1943 | |
| 1944 | // and draw!! |
| 1945 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 1946 | rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.); |
| 1947 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_TEXTURE_VERTEXcxx . . $ `lib/renderer.h:405:9`!); |
| 1948 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.); |
| 1949 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(4, pntList, bm); |
| 1950 | } |
| 1951 | |
| 1952 | // Draws our pretty stars |
| 1953 | void DrawStarscxx . . $ DrawStars(dca75c48c9ab5b54).(matrixcxx . . $ matrix# *vorient) { |
| 1954 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 1955 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_FLATcxx . . $ TT_FLAT.); |
| 1956 | rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!); |
| 1957 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.); |
| 1958 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_VERTEXcxx . . $ `lib/renderer.h:403:9`!); |
| 1959 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(0); |
| 1960 | g3_SetFarClipZcxx . . $ g3_SetFarClipZ(9364e6e7bff7660).(6000000); |
| 1961 | vectorcxx . . $ vector# tempvec; |
| 1962 | if (Rendering_main_viewcxx . . $ Rendering_main_view. && Terrain_skycxx . . $ Terrain_sky..flagscxx . . $ terrain_sky#flags. & TF_ROTATE_STARScxx . . $ `Descent3/terrain.h:59:9`! && Terrain_skycxx . . $ Terrain_sky..rotate_ratecxx . . $ terrain_sky#rotate_rate. > 0) { |
| 1963 | matrixcxx . . $ matrix# mat; |
| 1964 | vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&mat, 0, Terrain_skycxx . . $ Terrain_sky..rotate_ratecxx . . $ terrain_sky#rotate_rate. * Frametimecxx . . $ Frametime. * (65536.0 / 360.0), 0); |
| 1965 | vm_Orthogonalizecxx . . $ vm_Orthogonalize(dca75c48c9ab5b54).(&mat); |
| 1966 | for (int i = 0; i < MAX_STARScxx . . $ `Descent3/terrain.h:51:9`!; i++) { |
| 1967 | vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&tempvec, &Terrain_skycxx . . $ Terrain_sky..star_vectorscxx . . $ terrain_sky#star_vectors.[i], &mat); |
| 1968 | Terrain_skycxx . . $ Terrain_sky..star_vectorscxx . . $ terrain_sky#star_vectors.[i] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). tempvec; |
| 1969 | } |
| 1970 | } |
| 1971 | for (int i = 0; i < MAX_STARScxx . . $ `Descent3/terrain.h:51:9`!; i++) { |
| 1972 | g3Pointcxx . . $ g3Point# starpnt, lastpnt; |
| 1973 | vectorcxx . . $ vector# streak_vec; |
| 1974 | float mag; |
| 1975 | // Rotate star |
| 1976 | tempvec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Terrain_skycxx . . $ Terrain_sky..star_vectorscxx . . $ terrain_sky#star_vectors.[i]; |
| 1977 | vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&starpnt.p3_veccxx . . $ g3Point#p3_vec., &tempvec, vorient); |
| 1978 | starpnt.p3_flagscxx . . $ g3Point#p3_flags. = PF_RGBAcxx . . $ `lib/3d.h:219:9`!; |
| 1979 | // Get streaking line from last frame |
| 1980 | if (Rendering_main_viewcxx . . $ Rendering_main_view.) { |
| 1981 | streak_vec =cxx . . $ vector#`operator=`(c0842353a20857d). Last_frame_starscxx . . $ Last_frame_stars.[i] -cxx . . $ operator-(b77b703cd1e43e33). starpnt.p3_veccxx . . $ g3Point#p3_vec.; |
| 1982 | mag = vm_GetMagnitudeFastcxx . . $ vm_GetMagnitudeFast(4939a7e530383cd4).(&streak_vec); |
| 1983 | } else { |
| 1984 | mag = 0.0f; |
| 1985 | } |
| 1986 | |
| 1987 | if (Rendering_main_viewcxx . . $ Rendering_main_view. && mag > 9000.0) { |
| 1988 | streak_vec /=cxx . . $ `operator/=`(f132838b2cd11d6). mag; |
| 1989 | float norm = (mag / 90000); |
| 1990 | if (norm > 1) |
| 1991 | norm = 1.0; |
| 1992 | float revnorm = 1.0 - (norm * 4); |
| 1993 | if (revnorm < 0) |
| 1994 | revnorm = 0; |
| 1995 | float color_norm = (.6 + (revnorm * .4)); |
| 1996 | |
| 1997 | lastpnt.p3_veccxx . . $ g3Point#p3_vec. =cxx . . $ vector#`operator=`(c0842353a20857d). starpnt.p3_veccxx . . $ g3Point#p3_vec. +cxx . . $ operator+(b77b703cd1e43e33). ((norm * .75 * 90000) *cxx . . $ `operator*`(9d6577ff3e9faa29). streak_vec); |
| 1998 | lastpnt.p3_flagscxx . . $ g3Point#p3_flags. = PF_RGBAcxx . . $ `lib/3d.h:219:9`!; |
| 1999 | lastpnt.p3_acxx . . $ `lib/3d.h:256:9`! = 0; |
| 2000 | starpnt.p3_acxx . . $ `lib/3d.h:256:9`! = color_norm; |
| 2001 | |
| 2002 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(&starpnt); |
| 2003 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(&lastpnt); |
| 2004 | rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(Terrain_skycxx . . $ Terrain_sky..star_colorcxx . . $ terrain_sky#star_color.[i]); |
| 2005 | g3_DrawSpecialLinecxx . . $ g3_DrawSpecialLine(1b637e6b3e24914d).(&starpnt, &lastpnt); |
| 2006 | } else { |
| 2007 | starpnt.p3_flagscxx . . $ g3Point#p3_flags. = PF_RGBAcxx . . $ `lib/3d.h:219:9`!; |
| 2008 | if (!g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(&starpnt)) // only draw if this point is on screen |
| 2009 | { |
| 2010 | starpnt.p3_acxx . . $ `lib/3d.h:256:9`! = 1.0; |
| 2011 | |
| 2012 | g3_ProjectPointcxx . . $ g3_ProjectPoint(4c7ad40c64d4fb9c).(&starpnt); |
| 2013 | lastpnt =cxx . . $ g3Point#`operator=`(c45224b80d125eec). starpnt; |
| 2014 | lastpnt.p3_sxcxx . . $ g3Point#p3_sx.++; |
| 2015 | rend_SetFlatColorcxx . . $ rend_SetFlatColor(cb2f890c2fdad230).(Terrain_skycxx . . $ Terrain_sky..star_colorcxx . . $ terrain_sky#star_color.[i]); |
| 2016 | rend_DrawSpecialLinecxx . . $ rend_DrawSpecialLine(1b637e6b3e24914d).(&starpnt, &lastpnt); |
| 2017 | // rend_SetPixel (Terrain_sky.star_color[i],starpnt.p3_sx,starpnt.p3_sy); |
| 2018 | } |
| 2019 | } |
| 2020 | if (Rendering_main_viewcxx . . $ Rendering_main_view.) |
| 2021 | Last_frame_starscxx . . $ Last_frame_stars.[i] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). starpnt.p3_veccxx . . $ g3Point#p3_vec.; |
| 2022 | } |
| 2023 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1); |
| 2024 | g3_SetFarClipZcxx . . $ g3_SetFarClipZ(9364e6e7bff7660).(60000); |
| 2025 | } |
| 2026 | // Draw the suns,moons,stars, horizon, etc |
| 2027 | void DrawSkycxx . . $ DrawSky(bc315f98e1febb02).(vectorcxx . . $ vector# *veye, matrixcxx . . $ matrix# *vorient) { |
| 2028 | int i, t; |
| 2029 | |
| 2030 | vectorcxx . . $ vector# tempvec; |
| 2031 | |
| 2032 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_GOURAUDcxx . . $ LS_GOURAUD.); |
| 2033 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(0); |
| 2034 | rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(0); |
| 2035 | |
| 2036 | // If the sky is rotating, update the horizon vectors accordingly |
| 2037 | if (Rendering_main_viewcxx . . $ Rendering_main_view. && Terrain_skycxx . . $ Terrain_sky..flagscxx . . $ terrain_sky#flags. & TF_ROTATE_SKYcxx . . $ `Descent3/terrain.h:60:9`! && Terrain_skycxx . . $ Terrain_sky..rotate_ratecxx . . $ terrain_sky#rotate_rate. > 0) { |
| 2038 | matrixcxx . . $ matrix# mat; |
| 2039 | vm_AnglesToMatrixcxx . . $ vm_AnglesToMatrix(654fa9e3c9c3be99).(&mat, 0, Terrain_skycxx . . $ Terrain_sky..rotate_ratecxx . . $ terrain_sky#rotate_rate. * Frametimecxx . . $ Frametime. * (65536.0 / 360.0), 0); |
| 2040 | vm_Orthogonalizecxx . . $ vm_Orthogonalize(dca75c48c9ab5b54).(&mat); |
| 2041 | for (i = 0; i < 6; i++) { |
| 2042 | for (t = 0; t < MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; t++) { |
| 2043 | vectorcxx . . $ vector# rot_vec; |
| 2044 | tempvec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Terrain_skycxx . . $ Terrain_sky..horizon_vectorscxx . . $ terrain_sky#horizon_vectors.[t][i]; |
| 2045 | vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&rot_vec, &tempvec, &mat); |
| 2046 | Terrain_skycxx . . $ Terrain_sky..horizon_vectorscxx . . $ terrain_sky#horizon_vectors.[t][i] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). rot_vec; |
| 2047 | } |
| 2048 | } |
| 2049 | } |
| 2050 | |
| 2051 | for (i = 0; i < 6; i++) { |
| 2052 | for (t = 0; t < MAX_HORIZON_PIECEScxx . . $ `Descent3/terrain.h:53:9`!; t++) { |
| 2053 | tempvec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Terrain_skycxx . . $ Terrain_sky..horizon_vectorscxx . . $ terrain_sky#horizon_vectors.[t][i]; |
| 2054 | tempvec.ycxx . . $ vector#y. -= veye->ycxx . . $ vector#y. * 0.5f; |
| 2055 | vm_MatrixMulVectorcxx . . $ vm_MatrixMulVector(76352432a16beb64).(&Temp_sky_vectorscxx . . $ Temp_sky_vectors.[t][i], &tempvec, vorient); |
| 2056 | |
| 2057 | tempvec =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). Terrain_skycxx . . $ Terrain_sky..horizon_vectorscxx . . $ terrain_sky#horizon_vectors.[t][i]; |
| 2058 | tempvec.xcxx . . $ vector#x. += veye->xcxx . . $ vector#x.; |
| 2059 | tempvec.zcxx . . $ vector#z. += veye->zcxx . . $ vector#z.; |
| 2060 | tempvec.ycxx . . $ vector#y. += veye->ycxx . . $ vector#y. * 0.5f; |
| 2061 | Temp_sky_vectors_unrotatedcxx . . $ Temp_sky_vectors_unrotated.[t][i] =cxx . . $ vector#`operator=`(a48bc7e93a8dae5e). tempvec; |
| 2062 | } |
| 2063 | } |
| 2064 | float sr = (float)GR_COLOR_REDcxx . . $ GR_COLOR_RED(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.) / 255.0; |
| 2065 | float sg = (float)GR_COLOR_GREENcxx . . $ GR_COLOR_GREEN(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.) / 255.0; |
| 2066 | float sb = (float)GR_COLOR_BLUEcxx . . $ GR_COLOR_BLUE(4c679297bf94b9eb).(Terrain_skycxx . . $ Terrain_sky..sky_colorcxx . . $ terrain_sky#sky_color.) / 255.0; |
| 2067 | if (!Terrain_skycxx . . $ Terrain_sky..texturedcxx . . $ terrain_sky#textured.) { |
| 2068 | DrawGouraudSkycxx . . $ DrawGouraudSky(49f6e7a06ebc5aa8).(); |
| 2069 | } else { |
| 2070 | DrawTexturedSkycxx . . $ DrawTexturedSky(49f6e7a06ebc5aa8).(); |
| 2071 | } |
| 2072 | |
| 2073 | if (Terrain_skycxx . . $ Terrain_sky..flagscxx . . $ terrain_sky#flags. & TF_STARScxx . . $ `Descent3/terrain.h:56:9`!) { |
| 2074 | DrawStarscxx . . $ DrawStars(dca75c48c9ab5b54).(vorient); |
| 2075 | } |
| 2076 | |
| 2077 | if (Terrain_skycxx . . $ Terrain_sky..flagscxx . . $ terrain_sky#flags. & TF_SATELLITEScxx . . $ `Descent3/terrain.h:57:9`!) { |
| 2078 | rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_CLAMPcxx . . $ WT_CLAMP.); |
| 2079 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.); |
| 2080 | |
| 2081 | // do satellites |
| 2082 | for (i = 0; i < Terrain_skycxx . . $ Terrain_sky..num_satellitescxx . . $ terrain_sky#num_satellites.; i++) { |
| 2083 | int bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(Terrain_skycxx . . $ Terrain_sky..satellite_texturecxx . . $ terrain_sky#satellite_texture.[i], 0); |
| 2084 | vectorcxx . . $ vector# subvec = Terrain_skycxx . . $ Terrain_sky..satellite_vectorscxx . . $ terrain_sky#satellite_vectors.[i] -cxx . . $ operator-(b77b703cd1e43e33). *veye; |
| 2085 | float size = Terrain_skycxx . . $ Terrain_sky..satellite_sizecxx . . $ terrain_sky#satellite_size.[i]; |
| 2086 | |
| 2087 | // Get position, angle of satellite |
| 2088 | vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&subvec); |
| 2089 | tempvec =cxx . . $ vector#`operator=`(c0842353a20857d). *veye +cxx . . $ operator+(b77b703cd1e43e33). (subvec *cxx . . $ `operator*`(252247219a31502c). (Terrain_skycxx . . $ Terrain_sky..radiuscxx . . $ terrain_sky#radius. * 3)); |
| 2090 | |
| 2091 | #ifndef NEWEDITOR |
| 2092 | texturecxx . . $ texture# *tex = &GameTexturescxx . . $ GameTextures.[Terrain_skycxx . . $ Terrain_sky..satellite_texturecxx . . $ terrain_sky#satellite_texture.[i]]; |
| 2093 | #else |
| 2094 | ned_texture_info *tex = &GameTextures[Terrain_sky.satellite_texture[i]]; |
| 2095 | #endif |
| 2096 | float str = Terrain_skycxx . . $ Terrain_sky..satellite_rcxx . . $ terrain_sky#satellite_r.[i]; |
| 2097 | float stg = Terrain_skycxx . . $ Terrain_sky..satellite_gcxx . . $ terrain_sky#satellite_g.[i]; |
| 2098 | float stb = Terrain_skycxx . . $ Terrain_sky..satellite_bcxx . . $ terrain_sky#satellite_b.[i]; |
| 2099 | float maxc = stdcxx . . $ std/::maxcxx . . $ std/max(7d979dd22a97e265).({str, stg, stb}); |
| 2100 | float r, g, b; |
| 2101 | if (maxc > 1.0) { |
| 2102 | r = str / maxc; |
| 2103 | g = stg / maxc; |
| 2104 | b = stb / maxc; |
| 2105 | } else { |
| 2106 | r = str; |
| 2107 | g = stg; |
| 2108 | b = stb; |
| 2109 | } |
| 2110 | #ifndef NEWEDITOR |
| 2111 | // Draw halo |
| 2112 | if (Terrain_skycxx . . $ Terrain_sky..satellite_flagscxx . . $ terrain_sky#satellite_flags.[i] & TSF_HALOcxx . . $ `Descent3/terrain.h:63:9`!) { |
| 2113 | rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(0); |
| 2114 | DrawColoredRingcxx . . $ DrawColoredRing(142fcd92eb1a0c9f).(&tempvec, r, g, b, .4f, 0, size * 1.2, .3f, 0, 0); |
| 2115 | rend_SetZBufferWriteMaskcxx . . $ rend_SetZBufferWriteMask(d4f767463ce0a6b3).(1); |
| 2116 | } |
| 2117 | #endif |
| 2118 | // Draw satellite |
| 2119 | if (tex->flagscxx . . $ texture#flags. & TF_SATURATEcxx . . $ `Descent3/gametexture.h:222:9`!) |
| 2120 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_SATURATE_TEXTUREcxx . . $ `lib/renderer.h:408:9`!); |
| 2121 | else |
| 2122 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`! + AT_TEXTUREcxx . . $ `lib/renderer.h:401:9`!); |
| 2123 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 2124 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(tex->alphacxx . . $ texture#alpha. * 255); |
| 2125 | // Check to see if the user clicked on a satellite |
| 2126 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 2127 | ddgr_color oldcolor; |
| 2128 | if (TSearch_on) { |
| 2129 | rend_SetPixel(GR_RGB(0, 255, 0), TSearch_x, TSearch_y); |
| 2130 | oldcolor = rend_GetPixel(TSearch_x, TSearch_y); // will be different in 15/16-bit color |
| 2131 | } |
| 2132 | #endif |
| 2133 | |
| 2134 | g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(1); |
| 2135 | g3_DrawPlanarRotatedBitmapcxx . . $ g3_DrawPlanarRotatedBitmap(71c6e0d12bc5318b).(&tempvec, &subvec, 0, size, (size * bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, 0)) / bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, 0), |
| 2136 | bm_handle); |
| 2137 | g3_SetTriangulationTestcxx . . $ g3_SetTriangulationTest(d4f767463ce0a6b3).(0); |
| 2138 | |
| 2139 | // Draw atmosphere blend |
| 2140 | if (UseHardwarecxx . . $ UseHardware.) { |
| 2141 | if (Terrain_skycxx . . $ Terrain_sky..satellite_flagscxx . . $ terrain_sky#satellite_flags.[i] & TSF_ATMOSPHEREcxx . . $ `Descent3/terrain.h:64:9`!) { |
| 2142 | angveccxx . . $ angvec# angs; |
| 2143 | vm_ExtractAnglesFromMatrixcxx . . $ vm_ExtractAnglesFromMatrix(5f9a6d6f613ae256).(&angs, vorient); |
| 2144 | DrawAtmosphereBlendcxx . . $ DrawAtmosphereBlend(bac30d42f00edb2).(&tempvec, angs.bcxx . . $ angvec#b., size, (size * bm_hcxx . . $ bm_h(9b79fb6aee4c0440).(bm_handle, 0)) / bm_wcxx . . $ bm_w(9b79fb6aee4c0440).(bm_handle, 0), bm_handle, sr, |
| 2145 | sg, sb); |
| 2146 | } |
| 2147 | } |
| 2148 | |
| 2149 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 2150 | if (TSearch_on) { |
| 2151 | if (rend_GetPixel(TSearch_x, TSearch_y) != oldcolor) { |
| 2152 | TSearch_seg = i; |
| 2153 | TSearch_found_type = TSEARCH_FOUND_SATELLITE; |
| 2154 | } |
| 2155 | } |
| 2156 | #endif |
| 2157 | } |
| 2158 | } |
| 2159 | #ifndef NEWEDITOR |
| 2160 | if ((Weathercxx . . $ Weather..flagscxx . . $ weather#flags. & WEATHER_FLAGS_LIGHTNINGcxx . . $ `Descent3/weather.h:23:9`!) && Weathercxx . . $ Weather..lightning_sequencecxx . . $ weather#lightning_sequence. == 2) { |
| 2161 | DrawLightningcxx . . $ DrawLightning(49f6e7a06ebc5aa8).(); |
| 2162 | Weathercxx . . $ Weather..lightning_sequencecxx . . $ weather#lightning_sequence. = 0; |
| 2163 | } |
| 2164 | |
| 2165 | if ((Weathercxx . . $ Weather..flagscxx . . $ weather#flags. & WEATHER_FLAGS_LIGHTNINGcxx . . $ `Descent3/weather.h:23:9`!) && Weathercxx . . $ Weather..lightning_sequencecxx . . $ weather#lightning_sequence. == 1) { |
| 2166 | DrawLightningSkycxx . . $ DrawLightningSky(49f6e7a06ebc5aa8).(); |
| 2167 | Weathercxx . . $ Weather..lightning_sequencecxx . . $ weather#lightning_sequence. = 2; |
| 2168 | } |
| 2169 | #endif |
| 2170 | // DrawCloudLayer(); |
| 2171 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 2172 | if (OUTLINE_ONcxx . . $ `Descent3/render.h:197:9`!(OM_SKYcxx . . $ `Descent3/render.h:204:9`!)) |
| 2173 | DrawWireframeSkycxx . . $ DrawWireframeSky(49f6e7a06ebc5aa8).(); |
| 2174 | #endif |
| 2175 | |
| 2176 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255); |
| 2177 | rend_SetZBufferStatecxx . . $ rend_SetZBufferState(4af4fd0e2b26c4ac).(1); |
| 2178 | } |
| 2179 | |
| 2180 | int AddRenderObjectToTerrainSegcxx . . $ AddRenderObjectToTerrainSeg(9b79fb6aee4c0440).(int n, int objnum); |
| 2181 | // Checks to see if we should render objects and also sets which order the objects |
| 2182 | // should be rendered in |
| 2183 | void SortTerrainObjectsForRenderingcxx . . $ SortTerrainObjectsForRendering(d4f767463ce0a6b3).(int cellcount) { |
| 2184 | int i, segnum; |
| 2185 | objectcxx . . $ object# *obj; |
| 2186 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 2187 | for (i = 0; i < cellcount; i++) |
| 2188 | Terrain_seg_render_objscxx . . $ Terrain_seg_render_objs.[Terrain_listcxx . . $ Terrain_list.[i].segmentcxx . . $ terrain_render_info#segment.] = -1; |
| 2189 | #endif |
| 2190 | |
| 2191 | // Go through each object and do trivial rejection |
| 2192 | for (i = 0; i <= Highest_object_indexcxx . . $ Highest_object_index.; i++) { |
| 2193 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 2194 | render_nextcxx . . $ render_next.[i] = -1; |
| 2195 | #endif |
| 2196 | obj = &Objectscxx . . $ Objects.[i]; |
| 2197 | if (obj->typecxx . . $ object#type. == OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!) |
| 2198 | continue; |
| 2199 | if (obj->render_typecxx . . $ object#render_type. == RT_NONEcxx . . $ `Descent3/object_external.h:257:9`!) |
| 2200 | continue; |
| 2201 | if (!OBJECT_OUTSIDEcxx . . $ `lib/object_external_struct.h:130:9`!(obj)) |
| 2202 | continue; |
| 2203 | // Ok, we know that we can see this point. If its segment is in our list |
| 2204 | // then make this object draw right after this segment is drawn. Otherwise |
| 2205 | // just draw it |
| 2206 | segnum = CELLNUMcxx . . $ `lib/object_external_struct.h:121:9`!(obj->roomnum); |
| 2207 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(segnum >= 0 && segnum <= (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!)); |
| 2208 | if (Terrain_rotate_listcxx . . $ Terrain_rotate_list.[segnum] == TS_FrameCountcxx . . $ TS_FrameCount.) { |
| 2209 | AddRenderObjectToTerrainSegcxx . . $ AddRenderObjectToTerrainSeg(9b79fb6aee4c0440).(segnum, i); |
| 2210 | } else |
| 2211 | AddRenderObjectToTerrainSegcxx . . $ AddRenderObjectToTerrainSeg(9b79fb6aee4c0440).(Terrain_listcxx . . $ Terrain_list.[cellcount - 1].segmentcxx . . $ terrain_render_info#segment., i); |
| 2212 | } |
| 2213 | } |
| 2214 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 2215 | #define CROSS_WIDTH 8.0 |
| 2216 | #define CROSS_HEIGHT 8.0 |
| 2217 | void TerrainDrawCurrentVert(int tcell) { |
| 2218 | if (TerrainSelected[tcell]) { |
| 2219 | g3Point pnt; |
| 2220 | pnt.p3_flags = 0; |
| 2221 | pnt.p3_vec = World_point_buffer[tcell].p3_vec; |
| 2222 | g3_ProjectPoint(&pnt); // make sure projected |
| 2223 | |
| 2224 | rend_SetFlatColor(GR_RGB(0, 250, 0)); |
| 2225 | rend_DrawLine(pnt.p3_sx - CROSS_WIDTH, pnt.p3_sy, pnt.p3_sx, pnt.p3_sy - CROSS_HEIGHT); |
| 2226 | rend_DrawLine(pnt.p3_sx, pnt.p3_sy - CROSS_HEIGHT, pnt.p3_sx + CROSS_WIDTH, pnt.p3_sy); |
| 2227 | rend_DrawLine(pnt.p3_sx + CROSS_WIDTH, pnt.p3_sy, pnt.p3_sx, pnt.p3_sy + CROSS_HEIGHT); |
| 2228 | rend_DrawLine(pnt.p3_sx, pnt.p3_sy + CROSS_HEIGHT, pnt.p3_sx - CROSS_WIDTH, pnt.p3_sy); |
| 2229 | } |
| 2230 | } |
| 2231 | #endif |
| 2232 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 2233 | __inline void DrawTerrainOutlinecxx . . $ DrawTerrainOutline(aafc6ca7b5565e1b).(int tcell, int nverts, g3Pointcxx . . $ g3Point# **pointlist) |
| 2234 | { |
| 2235 | int i; |
| 2236 | g3Pointcxx . . $ g3Point# tpnt[256]; |
| 2237 | g3Pointcxx . . $ g3Point# *tpnt_list[256]; |
| 2238 | for (i = 0; i < nverts; i++) { |
| 2239 | tpnt[i] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). *pointlist[i]; |
| 2240 | tpnt_list[i] = &tpnt[i]; |
| 2241 | } |
| 2242 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 2243 | if (TerrainSelected[tcell]) { |
| 2244 | for (i = 0; i < nverts - 1; i++) |
| 2245 | g3_DrawLine(GR_RGB(255, 255, 255), tpnt_list[i], tpnt_list[i + 1]); |
| 2246 | g3_DrawLine(GR_RGB(255, 255, 255), tpnt_list[i], tpnt_list[0]); |
| 2247 | } else |
| 2248 | #endif |
| 2249 | { |
| 2250 | for (i = 0; i < nverts - 1; i++) |
| 2251 | g3_DrawLinecxx . . $ g3_DrawLine(79482445f52a1992).(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(128, 128, 128), tpnt_list[i], tpnt_list[i + 1]); |
| 2252 | g3_DrawLinecxx . . $ g3_DrawLine(79482445f52a1992).(GR_RGBcxx . . $ GR_RGB(530956271a9518a5).(128, 128, 128), tpnt_list[i], tpnt_list[0]); |
| 2253 | } |
| 2254 | } |
| 2255 | #endif |
| 2256 | int TerrainSortingFunctioncxx . . $ TerrainSortingFunction(d140d406bafa7f55).(const terrain_render_infocxx . . $ terrain_render_info# *a, terrain_render_infocxx . . $ terrain_render_info# *b) { return b->zcxx . . $ terrain_render_info#z. - a->zcxx . . $ terrain_render_info#z.; } |
| 2257 | void SortTerrainListcxx . . $ SortTerrainList(d4f767463ce0a6b3).(int cellcount) { |
| 2258 | int i, t, k; |
| 2259 | int lod, simplemul; |
| 2260 | int n[4]; |
| 2261 | |
| 2262 | for (i = 0; i < cellcount; i++) { |
| 2263 | t = Terrain_listcxx . . $ Terrain_list.[i].segmentcxx . . $ terrain_render_info#segment.; |
| 2264 | lod = Terrain_listcxx . . $ Terrain_list.[i].lodcxx . . $ terrain_render_info#lod.; |
| 2265 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 2266 | Terrain_seg_render_objscxx . . $ Terrain_seg_render_objs.[t] = -1; |
| 2267 | #endif |
| 2268 | |
| 2269 | simplemul = 1 << ((MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) - lod); |
| 2270 | Terrain_listcxx . . $ Terrain_list.[i].zcxx . . $ terrain_render_info#z. = 0.0f; |
| 2271 | n[0] = t; |
| 2272 | n[1] = t + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * simplemul); |
| 2273 | n[2] = t + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * simplemul) + simplemul; |
| 2274 | n[3] = t + simplemul; |
| 2275 | for (k = 0; k < 4; k++) |
| 2276 | if (n[k] <= 65535) |
| 2277 | Terrain_listcxx . . $ Terrain_list.[i].zcxx . . $ terrain_render_info#z. += World_point_buffercxx . . $ World_point_buffer.[n[k]].p3_veccxx . . $ g3Point#p3_vec..zcxx . . $ vector#z.; |
| 2278 | Terrain_listcxx . . $ Terrain_list.[i].zcxx . . $ terrain_render_info#z. /= 4; |
| 2279 | } |
| 2280 | // Sort the faces |
| 2281 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(Terrain_listcxx . . $ Terrain_list., cellcount, sizeof(*Terrain_listcxx . . $ Terrain_list.), (int (*)(const void *, const void *))TerrainSortingFunctioncxx . . $ TerrainSortingFunction(d140d406bafa7f55).); |
| 2282 | } |
| 2283 | // Returns the number of points to rotate, plus the actual numbers of the points |
| 2284 | // are returned in the "n" array |
| 2285 | int BuildEdgeListscxx . . $ BuildEdgeLists(23ae8a29b180954c).(int *n, int tlist_index) { |
| 2286 | int lod, simplemul; |
| 2287 | int t, k; |
| 2288 | int smul_x, smul_z; // for tracing the very edge of the terrain |
| 2289 | |
| 2290 | // Now match up all edges of the differing levels of detail |
| 2291 | int cx, cz; |
| 2292 | int transcount; |
| 2293 | int offset; |
| 2294 | int maplod; |
| 2295 | int start = 0; |
| 2296 | int seg; |
| 2297 | int answer; |
| 2298 | int edgecount = 0; |
| 2299 | int edge1, edge2; |
| 2300 | float delta, cury; |
| 2301 | int max_edge_size = 1 << (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1); |
| 2302 | |
| 2303 | t = Terrain_listcxx . . $ Terrain_list.[tlist_index].segmentcxx . . $ terrain_render_info#segment.; |
| 2304 | lod = Terrain_listcxx . . $ Terrain_list.[tlist_index].lodcxx . . $ terrain_render_info#lod.; |
| 2305 | simplemul = 1 << ((MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) - lod); |
| 2306 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(simplemul <= max_edge_size); |
| 2307 | cx = t % TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2308 | cz = t / TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2309 | if (cx == TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! - simplemul) { |
| 2310 | if (lod == MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) |
| 2311 | return 0; |
| 2312 | |
| 2313 | smul_x = simplemul - 1; |
| 2314 | } else |
| 2315 | smul_x = simplemul; |
| 2316 | if (cz == TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`! - simplemul) { |
| 2317 | if (lod == MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) |
| 2318 | return 0; |
| 2319 | |
| 2320 | smul_z = simplemul - 1; |
| 2321 | } else |
| 2322 | smul_z = simplemul; |
| 2323 | if (lod != MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) { |
| 2324 | // Bottom edge |
| 2325 | // | | |
| 2326 | // 2-------1 |
| 2327 | |
| 2328 | Terrain_listcxx . . $ Terrain_list.[tlist_index].bottom_edgecxx . . $ terrain_render_info#bottom_edge. = 0; |
| 2329 | Terrain_listcxx . . $ Terrain_list.[tlist_index].bottom_countcxx . . $ terrain_render_info#bottom_count. = 0; |
| 2330 | transcount = 0; |
| 2331 | if (cz != 0) { |
| 2332 | edge1 = t + smul_x; |
| 2333 | edge2 = t; |
| 2334 | delta = (Terrain_segcxx . . $ Terrain_seg.[edge2].modycxx . . $ terrain_segment#mody. - Terrain_segcxx . . $ Terrain_seg.[edge1].modycxx . . $ terrain_segment#mody.) / smul_x; |
| 2335 | cury = Terrain_segcxx . . $ Terrain_seg.[edge1].modycxx . . $ terrain_segment#mody.; |
| 2336 | |
| 2337 | offset = ((cz - 1) * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) + cx + smul_x; |
| 2338 | for (k = 0; k < smul_x; k++, cury += delta) { |
| 2339 | maplod = TerrainJoinMapcxx . . $ TerrainJoinMap.[offset - k]; |
| 2340 | answer = TerrainEdgeTestcxx . . $ TerrainEdgeTest.[maplod][k + simplemul - smul_x]; |
| 2341 | if (answer || k == 0) { |
| 2342 | seg = t + smul_x - k; |
| 2343 | n[transcount + start] = seg; |
| 2344 | Terrain_segcxx . . $ Terrain_seg.[seg].modycxx . . $ terrain_segment#mody. = cury; |
| 2345 | |
| 2346 | Terrain_listcxx . . $ Terrain_list.[tlist_index].bottom_edgecxx . . $ terrain_render_info#bottom_edge. |= (1 << k); |
| 2347 | Terrain_listcxx . . $ Terrain_list.[tlist_index].bottom_countcxx . . $ terrain_render_info#bottom_count.++; |
| 2348 | |
| 2349 | transcount++; |
| 2350 | } |
| 2351 | } |
| 2352 | } else { |
| 2353 | Terrain_listcxx . . $ Terrain_list.[tlist_index].bottom_edgecxx . . $ terrain_render_info#bottom_edge. |= 1; |
| 2354 | Terrain_listcxx . . $ Terrain_list.[tlist_index].bottom_countcxx . . $ terrain_render_info#bottom_count.++; |
| 2355 | seg = t + smul_x; |
| 2356 | n[transcount + start] = seg; |
| 2357 | transcount++; |
| 2358 | } |
| 2359 | |
| 2360 | start += transcount; |
| 2361 | // Right edge |
| 2362 | //---1 |
| 2363 | // | |
| 2364 | // | |
| 2365 | //-- 2 |
| 2366 | |
| 2367 | Terrain_listcxx . . $ Terrain_list.[tlist_index].right_edgecxx . . $ terrain_render_info#right_edge. = 0; |
| 2368 | Terrain_listcxx . . $ Terrain_list.[tlist_index].right_countcxx . . $ terrain_render_info#right_count. = 0; |
| 2369 | transcount = 0; |
| 2370 | offset = ((cz + smul_z) * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) + cx + smul_x; |
| 2371 | edge1 = t + smul_x + (smul_z * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!); |
| 2372 | edge2 = t + smul_x; |
| 2373 | delta = (Terrain_segcxx . . $ Terrain_seg.[edge2].modycxx . . $ terrain_segment#mody. - Terrain_segcxx . . $ Terrain_seg.[edge1].modycxx . . $ terrain_segment#mody.) / smul_z; |
| 2374 | cury = Terrain_segcxx . . $ Terrain_seg.[edge1].modycxx . . $ terrain_segment#mody.; |
| 2375 | for (k = 0; k < smul_z; k++, cury += delta) { |
| 2376 | maplod = TerrainJoinMapcxx . . $ TerrainJoinMap.[offset - (k * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!)]; |
| 2377 | answer = TerrainEdgeTestcxx . . $ TerrainEdgeTest.[maplod][k + simplemul - smul_z]; |
| 2378 | if (answer || k == 0) { |
| 2379 | seg = t + smul_x + ((smul_z - k) * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!); |
| 2380 | n[transcount + start] = seg; |
| 2381 | Terrain_segcxx . . $ Terrain_seg.[seg].modycxx . . $ terrain_segment#mody. = cury; |
| 2382 | Terrain_listcxx . . $ Terrain_list.[tlist_index].right_edgecxx . . $ terrain_render_info#right_edge. |= (1 << k); |
| 2383 | Terrain_listcxx . . $ Terrain_list.[tlist_index].right_countcxx . . $ terrain_render_info#right_count.++; |
| 2384 | transcount++; |
| 2385 | } |
| 2386 | } |
| 2387 | start += transcount; |
| 2388 | // Top edge |
| 2389 | // 1--------2 |
| 2390 | // | | |
| 2391 | |
| 2392 | Terrain_listcxx . . $ Terrain_list.[tlist_index].top_edgecxx . . $ terrain_render_info#top_edge. = 0; |
| 2393 | Terrain_listcxx . . $ Terrain_list.[tlist_index].top_countcxx . . $ terrain_render_info#top_count. = 0; |
| 2394 | transcount = 0; |
| 2395 | offset = cx + ((cz + smul_z) * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!); |
| 2396 | edge1 = t + (smul_z * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!); |
| 2397 | edge2 = t + smul_x + (smul_z * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!); |
| 2398 | delta = (Terrain_segcxx . . $ Terrain_seg.[edge2].modycxx . . $ terrain_segment#mody. - Terrain_segcxx . . $ Terrain_seg.[edge1].modycxx . . $ terrain_segment#mody.) / smul_x; |
| 2399 | cury = Terrain_segcxx . . $ Terrain_seg.[edge1].modycxx . . $ terrain_segment#mody.; |
| 2400 | for (k = 0; k < smul_x; k++, cury += delta) { |
| 2401 | maplod = TerrainJoinMapcxx . . $ TerrainJoinMap.[offset + k]; |
| 2402 | answer = TerrainEdgeTestcxx . . $ TerrainEdgeTest.[maplod][k]; |
| 2403 | if (answer || k == 0) { |
| 2404 | seg = (t + k) + (smul_z * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!); |
| 2405 | n[transcount + start] = seg; |
| 2406 | Terrain_segcxx . . $ Terrain_seg.[seg].modycxx . . $ terrain_segment#mody. = cury; |
| 2407 | Terrain_listcxx . . $ Terrain_list.[tlist_index].top_edgecxx . . $ terrain_render_info#top_edge. |= (1 << k); |
| 2408 | Terrain_listcxx . . $ Terrain_list.[tlist_index].top_countcxx . . $ terrain_render_info#top_count.++; |
| 2409 | transcount++; |
| 2410 | } |
| 2411 | } |
| 2412 | start += transcount; |
| 2413 | // left edge |
| 2414 | // 2---- |
| 2415 | // | |
| 2416 | // | |
| 2417 | // 1---- |
| 2418 | Terrain_listcxx . . $ Terrain_list.[tlist_index].left_edgecxx . . $ terrain_render_info#left_edge. = 0; |
| 2419 | Terrain_listcxx . . $ Terrain_list.[tlist_index].left_countcxx . . $ terrain_render_info#left_count. = 0; |
| 2420 | transcount = 0; |
| 2421 | if (cx != 0) { |
| 2422 | offset = (cz * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) + cx - 1; |
| 2423 | edge1 = t; |
| 2424 | edge2 = t + (smul_z * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!); |
| 2425 | delta = (Terrain_segcxx . . $ Terrain_seg.[edge2].modycxx . . $ terrain_segment#mody. - Terrain_segcxx . . $ Terrain_seg.[edge1].modycxx . . $ terrain_segment#mody.) / smul_z; |
| 2426 | cury = Terrain_segcxx . . $ Terrain_seg.[edge1].modycxx . . $ terrain_segment#mody.; |
| 2427 | for (k = 0; k < smul_z; k++, cury += delta) { |
| 2428 | maplod = TerrainJoinMapcxx . . $ TerrainJoinMap.[offset + (k * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!)]; |
| 2429 | answer = TerrainEdgeTestcxx . . $ TerrainEdgeTest.[maplod][k]; |
| 2430 | if (answer || k == 0) { |
| 2431 | seg = t + (k * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!); |
| 2432 | n[transcount + start] = seg; |
| 2433 | Terrain_segcxx . . $ Terrain_seg.[seg].modycxx . . $ terrain_segment#mody. = cury; |
| 2434 | Terrain_listcxx . . $ Terrain_list.[tlist_index].left_edgecxx . . $ terrain_render_info#left_edge. |= (1 << k); |
| 2435 | Terrain_listcxx . . $ Terrain_list.[tlist_index].left_countcxx . . $ terrain_render_info#left_count.++; |
| 2436 | transcount++; |
| 2437 | } |
| 2438 | } |
| 2439 | } else { |
| 2440 | seg = t; |
| 2441 | n[transcount + start] = seg; |
| 2442 | Terrain_listcxx . . $ Terrain_list.[tlist_index].left_edgecxx . . $ terrain_render_info#left_edge. |= 1; |
| 2443 | Terrain_listcxx . . $ Terrain_list.[tlist_index].left_countcxx . . $ terrain_render_info#left_count.++; |
| 2444 | transcount++; |
| 2445 | } |
| 2446 | |
| 2447 | edgecount = start + transcount; |
| 2448 | } else { |
| 2449 | n[0] = t; |
| 2450 | n[1] = t + TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2451 | n[2] = t + TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! + 1; |
| 2452 | n[3] = t + 1; |
| 2453 | Terrain_listcxx . . $ Terrain_list.[tlist_index].left_edgecxx . . $ terrain_render_info#left_edge. = 1; |
| 2454 | Terrain_listcxx . . $ Terrain_list.[tlist_index].bottom_edgecxx . . $ terrain_render_info#bottom_edge. = 1; |
| 2455 | Terrain_listcxx . . $ Terrain_list.[tlist_index].right_edgecxx . . $ terrain_render_info#right_edge. = 1; |
| 2456 | Terrain_listcxx . . $ Terrain_list.[tlist_index].top_edgecxx . . $ terrain_render_info#top_edge. = 1; |
| 2457 | edgecount = 4; |
| 2458 | } |
| 2459 | return edgecount; |
| 2460 | } |
| 2461 | // This function rotates all the points that we can see. |
| 2462 | // If a cell is a low-res cell, then we rotate all the points down each edge |
| 2463 | // of the cell to make sure any higher res blocks that touch the cell don't |
| 2464 | // appear with cracks |
| 2465 | vectorcxx . . $ vector# Terrain_alter_veccxx . . $ Terrain_alter_vec. = {19, -19, 19}; |
| 2466 | void RotateTerrainListcxx . . $ RotateTerrainList(918ebd27a9ddbad3).(int cellcount, bool from_automap) { |
| 2467 | int lod, simplemul, edgecount; |
| 2468 | int i, n[200], t, k, cx, cz; |
| 2469 | vectorcxx . . $ vector# camlight = Terrain_skycxx . . $ Terrain_sky..lightsourcecxx . . $ terrain_sky#lightsource.; |
| 2470 | vm_NormalizeVectorcxx . . $ vm_NormalizeVector(4939a7e530383cd4).(&camlight); |
| 2471 | // Reset all modified y values for the corners of each cell |
| 2472 | for (i = 0; i < cellcount; i++) { |
| 2473 | int ax, az; |
| 2474 | t = Terrain_listcxx . . $ Terrain_list.[i].segmentcxx . . $ terrain_render_info#segment.; |
| 2475 | lod = Terrain_listcxx . . $ Terrain_list.[i].lodcxx . . $ terrain_render_info#lod.; |
| 2476 | simplemul = 1 << ((MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) - lod); |
| 2477 | cx = t & (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! - 1); |
| 2478 | cz = t >> 8; |
| 2479 | |
| 2480 | ax = az = simplemul; |
| 2481 | |
| 2482 | if (cx + ax >= TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) |
| 2483 | ax = (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! - 1) - cx; |
| 2484 | if (cz + az >= TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!) |
| 2485 | az = (TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`! - 1) - cz; |
| 2486 | |
| 2487 | n[0] = t; |
| 2488 | n[1] = t + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * az); |
| 2489 | n[2] = t + (az * TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) + ax; |
| 2490 | n[3] = t + ax; |
| 2491 | // This could be in a loop, but I unrolled it for speed |
| 2492 | Terrain_segcxx . . $ Terrain_seg.[n[0]].modycxx . . $ terrain_segment#mody. = Terrain_segcxx . . $ Terrain_seg.[n[0]].ycxx . . $ terrain_segment#y.; |
| 2493 | Terrain_segcxx . . $ Terrain_seg.[n[1]].modycxx . . $ terrain_segment#mody. = Terrain_segcxx . . $ Terrain_seg.[n[1]].ycxx . . $ terrain_segment#y.; |
| 2494 | Terrain_segcxx . . $ Terrain_seg.[n[2]].modycxx . . $ terrain_segment#mody. = Terrain_segcxx . . $ Terrain_seg.[n[2]].ycxx . . $ terrain_segment#y.; |
| 2495 | Terrain_segcxx . . $ Terrain_seg.[n[3]].modycxx . . $ terrain_segment#mody. = Terrain_segcxx . . $ Terrain_seg.[n[3]].ycxx . . $ terrain_segment#y.; |
| 2496 | if (StateLimitedcxx . . $ StateLimited. || from_automap) // Setup for sorting later |
| 2497 | { |
| 2498 | int unique_id; |
| 2499 | unique_id = Terrain_tex_segcxx . . $ Terrain_tex_seg.[Terrain_segcxx . . $ Terrain_seg.[t].texseg_indexcxx . . $ terrain_segment#texseg_index.].tex_indexcxx . . $ terrain_tex_segment#tex_index.; |
| 2500 | State_elementscxx . . $ State_elements.[i].facenumcxx . . $ state_limited_element#facenum. = i; |
| 2501 | State_elementscxx . . $ State_elements.[i].sort_keycxx . . $ state_limited_element#sort_key. = unique_id + (Terrain_segcxx . . $ Terrain_seg.[t].lm_quadcxx . . $ terrain_segment#lm_quad. << 24); |
| 2502 | } |
| 2503 | } |
| 2504 | for (i = 0; i < cellcount; i++) { |
| 2505 | edgecount = BuildEdgeListscxx . . $ BuildEdgeLists(23ae8a29b180954c).(n, i); |
| 2506 | for (k = 0; k < edgecount; k++) { |
| 2507 | if (Terrain_rotate_listcxx . . $ Terrain_rotate_list.[n[k]] != TS_FrameCountcxx . . $ TS_FrameCount.) { |
| 2508 | Terrain_rotate_listcxx . . $ Terrain_rotate_list.[n[k]] = TS_FrameCountcxx . . $ TS_FrameCount.; |
| 2509 | GlobalTransCountcxx . . $ GlobalTransCount.++; |
| 2510 | |
| 2511 | cx = n[k] % TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2512 | cz = n[k] / TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2513 | |
| 2514 | World_point_buffercxx . . $ World_point_buffer.[n[k]].p3_flagscxx . . $ g3Point#p3_flags. = PF_UVcxx . . $ `lib/3d.h:217:9`! | PF_UV2cxx . . $ `lib/3d.h:220:9`!; |
| 2515 | if (Terrain_segcxx . . $ Terrain_seg.[n[k]].modycxx . . $ terrain_segment#mody. == Terrain_segcxx . . $ Terrain_seg.[n[k]].ycxx . . $ terrain_segment#y.) { |
| 2516 | GetPreRotatedPointcxx . . $ GetPreRotatedPoint(64ae893c5b75a9e3).(&World_point_buffercxx . . $ World_point_buffer.[n[k]], cx, cz, Terrain_segcxx . . $ Terrain_seg.[n[k]].yposcxx . . $ terrain_segment#ypos.); |
| 2517 | } else { |
| 2518 | GetSpecialRotatedPointcxx . . $ GetSpecialRotatedPoint(2f08a9677e0d7483).(&World_point_buffercxx . . $ World_point_buffer.[n[k]], cx, cz, Terrain_segcxx . . $ Terrain_seg.[n[k]].modycxx . . $ terrain_segment#mody.); |
| 2519 | } |
| 2520 | |
| 2521 | if (Viewer_objectcxx . . $ Viewer_object.->effect_infocxx . . $ object#effect_info. && (Viewer_objectcxx . . $ Viewer_object.->effect_infocxx . . $ object#effect_info.->type_flagscxx . . $ effect_info_s#type_flags. & EF_DEFORMcxx . . $ `Descent3/object_external.h:198:9`!)) { |
| 2522 | float val = (((ps_randcxx . . $ ps_rand(b126dc7c1de90089).() % 1000) - 500.0f) / 500.0f) * Viewer_objectcxx . . $ Viewer_object.->effect_infocxx . . $ object#effect_info.->deform_timecxx . . $ effect_info_s#deform_time.; |
| 2523 | vectorcxx . . $ vector# jitterVec = Terrain_alter_veccxx . . $ Terrain_alter_vec. *cxx . . $ `operator*`(252247219a31502c). (Viewer_objectcxx . . $ Viewer_object.->effect_infocxx . . $ object#effect_info.->deform_rangecxx . . $ effect_info_s#deform_range. * val); |
| 2524 | World_point_buffercxx . . $ World_point_buffer.[n[k]].p3_veccxx . . $ g3Point#p3_vec. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). jitterVec; |
| 2525 | World_point_buffercxx . . $ World_point_buffer.[n[k]].p3_vecPreRotcxx . . $ g3Point#p3_vecPreRot. +=cxx . . $ `operator+=`(801a8d6f7ab7bef9). jitterVec; |
| 2526 | } |
| 2527 | g3_CodePointcxx . . $ g3_CodePoint(1c2cda054d3314c5).(&World_point_buffercxx . . $ World_point_buffer.[n[k]]); |
| 2528 | } |
| 2529 | } |
| 2530 | } |
| 2531 | } |
| 2532 | |
| 2533 | // Puts a 1 in upperleft,lowerright if those triangles are visible |
| 2534 | void TerrainCellVisiblecxx . . $ TerrainCellVisible(5768b2fa0fe719ec).(int index, int *upper_left, int *lower_right) { |
| 2535 | int seg = Terrain_listcxx . . $ Terrain_list.[index].segmentcxx . . $ terrain_render_info#segment.; |
| 2536 | int lod = Terrain_listcxx . . $ Terrain_list.[index].lodcxx . . $ terrain_render_info#lod.; |
| 2537 | int simplemul = 1 << ((MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) - lod); |
| 2538 | int cx, cz, smul_x, smul_z; |
| 2539 | |
| 2540 | vectorcxx . . $ vector# tempv; |
| 2541 | vectorcxx . . $ vector# *corner[4]; |
| 2542 | |
| 2543 | cx = seg % TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2544 | cz = seg / TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2545 | if (cx + simplemul == TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) |
| 2546 | smul_x = simplemul - 1; |
| 2547 | else |
| 2548 | smul_x = simplemul; |
| 2549 | if (cz + simplemul == TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!) |
| 2550 | smul_z = simplemul - 1; |
| 2551 | else |
| 2552 | smul_z = simplemul; |
| 2553 | |
| 2554 | // Note - this is upper left and proceeds clockwise |
| 2555 | corner[0] = &World_point_buffercxx . . $ World_point_buffer.[seg + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z)].p3_veccxx . . $ g3Point#p3_vec.; |
| 2556 | corner[1] = &World_point_buffercxx . . $ World_point_buffer.[seg + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z) + smul_x].p3_veccxx . . $ g3Point#p3_vec.; |
| 2557 | corner[2] = &World_point_buffercxx . . $ World_point_buffer.[seg].p3_veccxx . . $ g3Point#p3_vec.; |
| 2558 | corner[3] = &World_point_buffercxx . . $ World_point_buffer.[seg + smul_x].p3_veccxx . . $ g3Point#p3_vec.; |
| 2559 | |
| 2560 | vm_GetPerpcxx . . $ vm_GetPerp(f7eb4a62c434525d).(&tempv, corner[0], corner[1], corner[2]); |
| 2561 | if ((tempv *cxx . . $ `operator*`(4a721543d64e126a). *corner[1]) < 0) |
| 2562 | *upper_left = 1; |
| 2563 | else |
| 2564 | *upper_left = 0; |
| 2565 | |
| 2566 | // Now do lower right |
| 2567 | vm_GetPerpcxx . . $ vm_GetPerp(f7eb4a62c434525d).(&tempv, corner[2], corner[1], corner[3]); |
| 2568 | if ((tempv *cxx . . $ `operator*`(4a721543d64e126a). *corner[1]) < 0) |
| 2569 | *lower_right = 1; |
| 2570 | else |
| 2571 | *lower_right = 0; |
| 2572 | } |
| 2573 | |
| 2574 | void DisplayTerrainListcxx . . $ DisplayTerrainList(918ebd27a9ddbad3).(int cellcount, bool from_automap) { |
| 2575 | int total = 0, on, t, i, lod, simplemul; |
| 2576 | int bm_handle; |
| 2577 | bool draw_lightmap = false; |
| 2578 | int savecell; |
| 2579 | int obj_to_draw; |
| 2580 | Terrain_objects_drawncxx . . $ Terrain_objects_drawn. = 0; |
| 2581 | rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.); |
| 2582 | if (!UseHardwarecxx . . $ UseHardware.) |
| 2583 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_MONOcxx . . $ CM_MONO.); |
| 2584 | else { |
| 2585 | rend_SetColorModelcxx . . $ rend_SetColorModel(e3c5062d5af601c7).(CM_RGBcxx . . $ CM_RGB.); |
| 2586 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_LINEARcxx . . $ TT_LINEAR.); |
| 2587 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(ATF_CONSTANTcxx . . $ `lib/renderer.h:394:9`! + ATF_TEXTUREcxx . . $ `lib/renderer.h:395:9`!); |
| 2588 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 2589 | if (!StateLimitedcxx . . $ StateLimited. || UseMultitexturecxx . . $ UseMultitexture.) |
| 2590 | draw_lightmap = true; |
| 2591 | } |
| 2592 | RotateTerrainListcxx . . $ RotateTerrainList(918ebd27a9ddbad3).(cellcount, from_automap); |
| 2593 | if (!UseHardwarecxx . . $ UseHardware.) { |
| 2594 | SortTerrainListcxx . . $ SortTerrainList(d4f767463ce0a6b3).(cellcount); |
| 2595 | SortTerrainObjectsForRenderingcxx . . $ SortTerrainObjectsForRendering(d4f767463ce0a6b3).(cellcount); |
| 2596 | } |
| 2597 | // If state limited, sort by texture |
| 2598 | if (StateLimitedcxx . . $ StateLimited. || from_automap) |
| 2599 | SortStatescxx . . $ SortStates(b1f17b8c50be1530).(State_elementscxx . . $ State_elements., cellcount); |
| 2600 | if (from_automap) { |
| 2601 | savecell = cellcount; |
| 2602 | cellcount = 0; |
| 2603 | } |
| 2604 | |
| 2605 | for (i = 0; i < cellcount; i++) { |
| 2606 | int cx, cz; |
| 2607 | int seg_to_render; |
| 2608 | if (StateLimitedcxx . . $ StateLimited.) |
| 2609 | seg_to_render = State_elementscxx . . $ State_elements.[i].facenumcxx . . $ state_limited_element#facenum.; |
| 2610 | else |
| 2611 | seg_to_render = i; |
| 2612 | t = Terrain_listcxx . . $ Terrain_list.[seg_to_render].segmentcxx . . $ terrain_render_info#segment.; |
| 2613 | lod = Terrain_listcxx . . $ Terrain_list.[seg_to_render].lodcxx . . $ terrain_render_info#lod.; |
| 2614 | simplemul = 1 << ((MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) - lod); |
| 2615 | |
| 2616 | cx = t % TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2617 | cz = t / TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2618 | |
| 2619 | if (cx < TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! - simplemul && cz < TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`! - simplemul || lod != (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1)) { |
| 2620 | int ul, lr; // upper_left,lower_right |
| 2621 | if (Terrain_segcxx . . $ Terrain_seg.[t].flagscxx . . $ terrain_segment#flags. & TF_INVISIBLEcxx . . $ `Descent3/terrain.h:76:9`!) |
| 2622 | if (!Show_invisible_terraincxx . . $ Show_invisible_terrain.) |
| 2623 | goto draw_objects; // bad! No gotos! -JL |
| 2624 | // Check to see if these triangles are visible if they're the smallest lod |
| 2625 | TerrainCellVisiblecxx . . $ TerrainCellVisible(5768b2fa0fe719ec).(seg_to_render, &ul, &lr); |
| 2626 | |
| 2627 | total += (ul + lr); |
| 2628 | if (ul == 0 && lr == 0) |
| 2629 | goto draw_objects; |
| 2630 | |
| 2631 | bm_handle = GetTextureBitmapcxx . . $ GetTextureBitmap(6009f2e2e1989200).(Terrain_tex_segcxx . . $ Terrain_tex_seg.[Terrain_segcxx . . $ Terrain_seg.[t].texseg_indexcxx . . $ terrain_segment#texseg_index.].tex_indexcxx . . $ terrain_tex_segment#tex_index., 0); |
| 2632 | |
| 2633 | if (UseHardwarecxx . . $ UseHardware.) { |
| 2634 | if (draw_lightmap) |
| 2635 | on = DrawTerrainTrianglesHardwarecxx . . $ DrawTerrainTrianglesHardware(d4c1ccc1fe1a56c0).(seg_to_render, bm_handle, ul, lr); |
| 2636 | else |
| 2637 | on = DrawTerrainTrianglesHardwareNoLightcxx . . $ DrawTerrainTrianglesHardwareNoLight(d4c1ccc1fe1a56c0).(seg_to_render, bm_handle, ul, lr); |
| 2638 | |
| 2639 | } else |
| 2640 | on = DrawTerrainTrianglesSoftwarecxx . . $ DrawTerrainTrianglesSoftware(d4c1ccc1fe1a56c0).(seg_to_render, bm_handle, ul, lr); |
| 2641 | } |
| 2642 | |
| 2643 | draw_objects:; |
| 2644 | // Now draw any objects in this segment |
| 2645 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 2646 | if (!UseHardwarecxx . . $ UseHardware.) { |
| 2647 | obj_to_draw = Terrain_seg_render_objscxx . . $ Terrain_seg_render_objs.[t]; |
| 2648 | |
| 2649 | while (obj_to_draw != -1) { |
| 2650 | |
| 2651 | if (Objectscxx . . $ Objects.[obj_to_draw].typecxx . . $ object#type. != OBJ_ROOMcxx . . $ `Descent3/object_external.h:178:9`!) |
| 2652 | RenderObjectcxx . . $ RenderObject(419c470199a90a97).(&Objectscxx . . $ Objects.[obj_to_draw]); |
| 2653 | obj_to_draw = render_nextcxx . . $ render_next.[obj_to_draw]; |
| 2654 | } |
| 2655 | Terrain_seg_render_objscxx . . $ Terrain_seg_render_objs.[t] = -1; |
| 2656 | } |
| 2657 | #endif |
| 2658 | } |
| 2659 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 2660 | if (!UseHardware) { |
| 2661 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 2662 | for (i = 0; i < cellcount; i++) { |
| 2663 | t = Terrain_list[i].segment; |
| 2664 | Terrain_seg_render_objs[t] = -1; |
| 2665 | } |
| 2666 | #endif |
| 2667 | |
| 2668 | if ((View_mode == EDITOR_MODE) && OUTLINE_ON(OM_TERRAIN)) { |
| 2669 | for (i = 0; i < cellcount; i++) { |
| 2670 | t = Terrain_list[i].segment; |
| 2671 | if (TerrainSelected[t] && Terrain_rotate_list[t] == TS_FrameCount) |
| 2672 | TerrainDrawCurrentVert(t); |
| 2673 | } |
| 2674 | } |
| 2675 | } |
| 2676 | #endif |
| 2677 | // Draw lightmaps if this is state limited |
| 2678 | if ((UseHardwarecxx . . $ UseHardware. && !draw_lightmap) || from_automap) { |
| 2679 | if (from_automap) { |
| 2680 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_CONSTANTcxx . . $ `lib/renderer.h:400:9`!); |
| 2681 | cellcount = savecell; |
| 2682 | } else |
| 2683 | rend_SetAlphaTypecxx . . $ rend_SetAlphaType(4af4fd0e2b26c4ac).(AT_LIGHTMAP_BLENDcxx . . $ `lib/renderer.h:407:9`!); |
| 2684 | rend_SetAlphaValuecxx . . $ rend_SetAlphaValue(ac50b47256ae7414).(255); |
| 2685 | rend_SetLightingcxx . . $ rend_SetLighting(e55526c9d3dd1656).(LS_NONEcxx . . $ LS_NONE.); |
| 2686 | rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!); |
| 2687 | rend_SetTextureTypecxx . . $ rend_SetTextureType(cccd9781d96f97ff).(TT_PERSPECTIVEcxx . . $ TT_PERSPECTIVE.); |
| 2688 | rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.); |
| 2689 | rend_SetZBiascxx . . $ rend_SetZBias(9364e6e7bff7660).(-.5f); |
| 2690 | |
| 2691 | for (i = 0; i < cellcount; i++) { |
| 2692 | int ul, lr; |
| 2693 | int seg_to_render; |
| 2694 | seg_to_render = State_elementscxx . . $ State_elements.[i].facenumcxx . . $ state_limited_element#facenum.; |
| 2695 | TerrainCellVisiblecxx . . $ TerrainCellVisible(5768b2fa0fe719ec).(seg_to_render, &ul, &lr); |
| 2696 | if (ul == 0 && lr == 0) |
| 2697 | continue; |
| 2698 | DrawTerrainLightmapsHardwarecxx . . $ DrawTerrainLightmapsHardware(b1146eedae1e1d0b).(seg_to_render, ul, lr); |
| 2699 | } |
| 2700 | rend_SetZBiascxx . . $ rend_SetZBias(9364e6e7bff7660).(0); |
| 2701 | } |
| 2702 | |
| 2703 | rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!); |
| 2704 | rend_SetWrapTypecxx . . $ rend_SetWrapType(da524b148887c0e7).(WT_WRAPcxx . . $ WT_WRAP.); |
| 2705 | |
| 2706 | mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(2, 1, 0, "%5d cells", cellcount); |
| 2707 | mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(2, 2, 0, "%5d trans", GlobalTransCount); |
| 2708 | mprintf_atcxx . . $ `ddebug/mono.h:83:9`!(2, 3, 0, "Tdepth=%5d", TotalDepth); |
| 2709 | } |
| 2710 | // Arrays for drawing |
| 2711 | static int srccxx . . $ src.[256]; |
| 2712 | static g3Pointcxx . . $ g3Point# basecxx . . $ base.[256]; |
| 2713 | static g3Pointcxx . . $ g3Point# *slistcxx . . $ slist.[256]; |
| 2714 | // Draws the 2 triangles of the Terrainlist[index] (software) |
| 2715 | int DrawTerrainTrianglesSoftwarecxx . . $ DrawTerrainTrianglesSoftware(d4c1ccc1fe1a56c0).(int index, int bm_handle, int upper_left, int lower_right) { |
| 2716 | /* |
| 2717 | #if !defined(POSIX) |
| 2718 | int i,tlist[4],close=0,lit=0; |
| 2719 | float closest_z=9999; |
| 2720 | int color; |
| 2721 | int n=Terrain_list[index].segment; |
| 2722 | int lod=Terrain_list[index].lod; |
| 2723 | |
| 2724 | terrain_segment *tseg=&Terrain_seg[n]; |
| 2725 | terrain_tex_segment *texseg=&Terrain_tex_seg[tseg->texseg_index]; |
| 2726 | int rotation=texseg->rotation & 0x0F; |
| 2727 | int tile=texseg->rotation >> 4; |
| 2728 | int simplemul=1<<((MAX_TERRAIN_LOD-1)-lod); |
| 2729 | int cx,cz,smul_x,smul_z; |
| 2730 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 2731 | ddgr_color oldcolor; |
| 2732 | #endif |
| 2733 | cx=n%TERRAIN_WIDTH; |
| 2734 | cz=n/TERRAIN_WIDTH; |
| 2735 | int subx=cx % MAX_LOD_SIZE; |
| 2736 | int subz=(MAX_LOD_SIZE-1)-((cz+(simplemul-1)) % MAX_LOD_SIZE); |
| 2737 | if (cx+simplemul==TERRAIN_WIDTH) |
| 2738 | smul_x=simplemul-1; |
| 2739 | else |
| 2740 | smul_x=simplemul; |
| 2741 | if (cz+simplemul==TERRAIN_DEPTH) |
| 2742 | smul_z=simplemul-1; |
| 2743 | else |
| 2744 | smul_z=simplemul; |
| 2745 | |
| 2746 | // Note - this is upper left and proceeds lockwise |
| 2747 | tlist[0]=n+(TERRAIN_WIDTH*smul_z); |
| 2748 | tlist[1]=n+(TERRAIN_WIDTH*smul_z)+(smul_x); |
| 2749 | tlist[2]=n+(smul_x); |
| 2750 | tlist[3]=n; |
| 2751 | rend_SetOverlayType (OT_NONE); |
| 2752 | for (close=0,i=0;i<4;i++) |
| 2753 | { |
| 2754 | base[i]=*((g3Point *)&World_point_buffer[tlist[i]]); |
| 2755 | base[i].p3_flags|=(PF_L|PF_RGBA); |
| 2756 | base[i].p3_l=Ubyte_to_float[Terrain_seg[tlist[i]].l]; |
| 2757 | |
| 2758 | // only do perspective if all the points are inside our range |
| 2759 | if (!UseHardware) |
| 2760 | { |
| 2761 | if (base[i].p3_vec.z<TERRAIN_PERSPECTIVE_TEXTURE_DEPTH) |
| 2762 | close=1; |
| 2763 | if (base[i].p3_vec.z<closest_z) |
| 2764 | closest_z=base[i].p3_vec.z; |
| 2765 | } |
| 2766 | } |
| 2767 | base[0].p3_u=TerrainUSpeedup[rotation][subz*LOD_ROW_SIZE+subx]*tile; |
| 2768 | base[0].p3_v=TerrainVSpeedup[rotation][subz*LOD_ROW_SIZE+subx]*tile; |
| 2769 | base[1].p3_u=TerrainUSpeedup[rotation][subz*LOD_ROW_SIZE+subx+simplemul]*tile; |
| 2770 | base[1].p3_v=TerrainVSpeedup[rotation][subz*LOD_ROW_SIZE+subx+simplemul]*tile; |
| 2771 | base[2].p3_u=TerrainUSpeedup[rotation][((subz+simplemul)*LOD_ROW_SIZE)+subx+simplemul]*tile; |
| 2772 | base[2].p3_v=TerrainVSpeedup[rotation][((subz+simplemul)*LOD_ROW_SIZE)+subx+simplemul]*tile; |
| 2773 | base[3].p3_u=TerrainUSpeedup[rotation][((subz+simplemul)*LOD_ROW_SIZE)+subx]*tile; |
| 2774 | base[3].p3_v=TerrainVSpeedup[rotation][((subz+simplemul)*LOD_ROW_SIZE)+subx]*tile; |
| 2775 | |
| 2776 | rend_SetLighting (Lighting_on?LS_GOURAUD:LS_NONE); |
| 2777 | |
| 2778 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 2779 | if (TSearch_on) |
| 2780 | { |
| 2781 | rend_SetPixel(GR_RGB(0,255,0),TSearch_x,TSearch_y); |
| 2782 | oldcolor = rend_GetPixel(TSearch_x,TSearch_y); //will be different in |
| 2783 | 15/16-bit color |
| 2784 | } |
| 2785 | #endif |
| 2786 | |
| 2787 | // Make sure the triangle faces us and if so draw |
| 2788 | // Upper left triangle |
| 2789 | if (!upper_left) |
| 2790 | goto draw_lower_right; |
| 2791 | src[0]=0; |
| 2792 | src[1]=1; |
| 2793 | src[2]=3; |
| 2794 | |
| 2795 | for (lit=0,i=0;i<3;i++) |
| 2796 | { |
| 2797 | if (base[src[i]].p3_z<=Far_fog_border) |
| 2798 | lit=1; |
| 2799 | |
| 2800 | slist[i]=&base[src[i]]; |
| 2801 | } |
| 2802 | |
| 2803 | if (!lit && Lighting_on) |
| 2804 | { |
| 2805 | rend_SetTextureType(TT_FLAT); |
| 2806 | rend_SetFlatColor (0); |
| 2807 | g3_DrawPoly(3,slist,0); |
| 2808 | } |
| 2809 | else |
| 2810 | { |
| 2811 | // If we're past our texturing distance, flat shade! |
| 2812 | if (closest_z>Terrain_texture_distance) |
| 2813 | { |
| 2814 | rend_SetTextureType (TT_FLAT); |
| 2815 | int lightval=Ubyte_to_float [tseg->l]*(MAX_TEXTURE_SHADES-1); |
| 2816 | int pix=*bm_data(bm_handle,0); |
| 2817 | int fadepixel=(TexShadeTable16[lightval][pix>>8])+TexShadeTable8[lightval][pix & 0xFF]; |
| 2818 | color=GR_16_TO_COLOR (fadepixel); |
| 2819 | rend_SetFlatColor (color); |
| 2820 | g3_DrawPoly(3,slist,0); |
| 2821 | } |
| 2822 | else |
| 2823 | { |
| 2824 | if (close) |
| 2825 | rend_SetTextureType (TT_PERSPECTIVE); |
| 2826 | else |
| 2827 | rend_SetTextureType (TT_LINEAR); |
| 2828 | |
| 2829 | g3_DrawPoly(3,slist,bm_handle); |
| 2830 | } |
| 2831 | } |
| 2832 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 2833 | if (OUTLINE_ON(OM_TERRAIN)) |
| 2834 | DrawTerrainOutline(n,3, slist); |
| 2835 | #endif |
| 2836 | // Now do lower right triangle |
| 2837 | draw_lower_right: |
| 2838 | if (!lower_right) |
| 2839 | return 0; |
| 2840 | src[0]=3; |
| 2841 | src[1]=1; |
| 2842 | src[2]=2; |
| 2843 | for (lit=0,i=0;i<3;i++) |
| 2844 | { |
| 2845 | if (base[src[i]].p3_z<=Far_fog_border) |
| 2846 | lit=1; |
| 2847 | |
| 2848 | slist[i]=&base[src[i]]; |
| 2849 | } |
| 2850 | if (!lit && Lighting_on) |
| 2851 | { |
| 2852 | rend_SetTextureType(TT_FLAT); |
| 2853 | rend_SetFlatColor (0); |
| 2854 | g3_DrawPoly(3,slist,0); |
| 2855 | } |
| 2856 | else |
| 2857 | { |
| 2858 | // If we're past our texturing distance, flat shade! |
| 2859 | if (closest_z>Terrain_texture_distance) |
| 2860 | { |
| 2861 | rend_SetTextureType (TT_FLAT); |
| 2862 | int lightval=Ubyte_to_float[tseg->l]*(MAX_TEXTURE_SHADES-1); |
| 2863 | int pix=*bm_data(bm_handle,0); |
| 2864 | int fadepixel=(TexShadeTable16[lightval][pix>>8])+TexShadeTable8[lightval][pix & 0xFF]; |
| 2865 | color=GR_16_TO_COLOR (fadepixel); |
| 2866 | rend_SetFlatColor (color); |
| 2867 | g3_DrawPoly(3,slist,0); |
| 2868 | } |
| 2869 | else |
| 2870 | { |
| 2871 | if (close) |
| 2872 | rend_SetTextureType (TT_PERSPECTIVE); |
| 2873 | else |
| 2874 | rend_SetTextureType (TT_LINEAR); |
| 2875 | } |
| 2876 | |
| 2877 | g3_DrawPoly(3,slist,bm_handle); |
| 2878 | } |
| 2879 | |
| 2880 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 2881 | if (OUTLINE_ON(OM_TERRAIN)) |
| 2882 | DrawTerrainOutline(n,3, slist); |
| 2883 | #endif |
| 2884 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 2885 | if (TSearch_on) |
| 2886 | { |
| 2887 | if (rend_GetPixel(TSearch_x,TSearch_y) != oldcolor) |
| 2888 | { |
| 2889 | TSearch_seg = n; |
| 2890 | TSearch_found_type=TSEARCH_FOUND_TERRAIN; |
| 2891 | } |
| 2892 | } |
| 2893 | #endif |
| 2894 | #endif//__LINUX__ |
| 2895 | */ |
| 2896 | return 0; |
| 2897 | } |
| 2898 | // Draws the 2 triangles of the Terrainlist[index] (hardware) |
| 2899 | int DrawTerrainTrianglesHardwarecxx . . $ DrawTerrainTrianglesHardware(d4c1ccc1fe1a56c0).(int index, int bm_handle, int upper_left, int lower_right) { |
| 2900 | int i; |
| 2901 | int cur_seg; |
| 2902 | int n = Terrain_listcxx . . $ Terrain_list.[index].segmentcxx . . $ terrain_render_info#segment.; |
| 2903 | int lod = Terrain_listcxx . . $ Terrain_list.[index].lodcxx . . $ terrain_render_info#lod.; |
| 2904 | int bottom_start, left_start, right_start; |
| 2905 | int point_count = 0; |
| 2906 | int points_this_triangle = 0; |
| 2907 | |
| 2908 | terrain_segmentcxx . . $ terrain_segment# *tseg = &Terrain_segcxx . . $ Terrain_seg.[n]; |
| 2909 | terrain_tex_segmentcxx . . $ terrain_tex_segment# *texseg = &Terrain_tex_segcxx . . $ Terrain_tex_seg.[tseg->texseg_indexcxx . . $ terrain_segment#texseg_index.]; |
| 2910 | int rotator = texseg->rotationcxx . . $ terrain_tex_segment#rotation. & 0x0F; |
| 2911 | int tile = texseg->rotationcxx . . $ terrain_tex_segment#rotation. >> 4; |
| 2912 | int simplemul = 1 << ((MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) - lod); |
| 2913 | int cx, cz, smul_x, smul_z; |
| 2914 | cx = n % TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2915 | cz = n / TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 2916 | |
| 2917 | // Get lightmap coordinates |
| 2918 | float lightmap_u = (cx % 128) / 128.0; |
| 2919 | float lightmap_v = (128 - ((cz % 128) + simplemul)) / 128.0; |
| 2920 | float uvadjust; |
| 2921 | int draw_big_square = 0; |
| 2922 | int subx = cx % MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!; |
| 2923 | int subz = (MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`! - 1) - ((cz + (simplemul - 1)) % MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!); |
| 2924 | bool solid_square = 1; |
| 2925 | int testt = 0, testr = 0, testb = 0, testl = 0; |
| 2926 | // Check to make sure we don't access memory that is off the map |
| 2927 | if (cx + simplemul == TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) { |
| 2928 | smul_x = simplemul - 1; |
| 2929 | solid_square = 0; |
| 2930 | } else |
| 2931 | smul_x = simplemul; |
| 2932 | if (cz + simplemul == TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!) { |
| 2933 | solid_square = 0; |
| 2934 | smul_z = simplemul - 1; |
| 2935 | } else |
| 2936 | smul_z = simplemul; |
| 2937 | // Build a list of points for our polygon. We must do it this way to |
| 2938 | // prevent tjoint cracking |
| 2939 | // Do simpler operation if at highest level of detail |
| 2940 | if (lod == (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1)) { |
| 2941 | uvadjust = (simplemul / 128.0); |
| 2942 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z); |
| 2943 | basecxx . . $ base.[0] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 2944 | |
| 2945 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z) + smul_x; |
| 2946 | basecxx . . $ base.[1] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 2947 | |
| 2948 | cur_seg = n + smul_x; |
| 2949 | basecxx . . $ base.[2] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 2950 | |
| 2951 | basecxx . . $ base.[3] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[n]; |
| 2952 | |
| 2953 | basecxx . . $ base.[0].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx]; |
| 2954 | basecxx . . $ base.[0].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx]; |
| 2955 | basecxx . . $ base.[1].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + 1]; |
| 2956 | basecxx . . $ base.[1].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + 1]; |
| 2957 | basecxx . . $ base.[2].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][(subz + 1) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + 1]; |
| 2958 | basecxx . . $ base.[2].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][(subz + 1) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + 1]; |
| 2959 | basecxx . . $ base.[3].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][(subz + 1) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx]; |
| 2960 | basecxx . . $ base.[3].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][(subz + 1) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx]; |
| 2961 | |
| 2962 | basecxx . . $ base.[0].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u; |
| 2963 | basecxx . . $ base.[0].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v; |
| 2964 | basecxx . . $ base.[1].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u + uvadjust; |
| 2965 | basecxx . . $ base.[1].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v; |
| 2966 | basecxx . . $ base.[2].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u + uvadjust; |
| 2967 | basecxx . . $ base.[2].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v + uvadjust; |
| 2968 | |
| 2969 | basecxx . . $ base.[3].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u; |
| 2970 | basecxx . . $ base.[3].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v + uvadjust; |
| 2971 | } else { |
| 2972 | uvadjust = (simplemul / 128.0) / simplemul; |
| 2973 | float uvmul = uvadjust * simplemul; |
| 2974 | if (solid_square) { |
| 2975 | right_start = Terrain_listcxx . . $ Terrain_list.[index].top_countcxx . . $ terrain_render_info#top_count.; |
| 2976 | bottom_start = right_start + Terrain_listcxx . . $ Terrain_list.[index].right_countcxx . . $ terrain_render_info#right_count.; |
| 2977 | left_start = bottom_start + Terrain_listcxx . . $ Terrain_list.[index].bottom_countcxx . . $ terrain_render_info#bottom_count.; |
| 2978 | point_count = left_start + Terrain_listcxx . . $ Terrain_list.[index].left_countcxx . . $ terrain_render_info#left_count.; |
| 2979 | |
| 2980 | for (i = 0; i < simplemul; i++) { |
| 2981 | // Top edge |
| 2982 | if (Terrain_listcxx . . $ Terrain_list.[index].top_edgecxx . . $ terrain_render_info#top_edge. & (1 << i)) { |
| 2983 | cur_seg = n + i + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z); |
| 2984 | basecxx . . $ base.[testt] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 2985 | |
| 2986 | basecxx . . $ base.[testt].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + i]; |
| 2987 | basecxx . . $ base.[testt].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + i]; |
| 2988 | |
| 2989 | basecxx . . $ base.[testt].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u + (i * uvadjust); |
| 2990 | basecxx . . $ base.[testt].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v; |
| 2991 | slistcxx . . $ slist.[testt] = &basecxx . . $ base.[testt]; |
| 2992 | testt++; |
| 2993 | } |
| 2994 | // Right edge |
| 2995 | if (Terrain_listcxx . . $ Terrain_list.[index].right_edgecxx . . $ terrain_render_info#right_edge. & (1 << i)) { |
| 2996 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * (smul_z - i)) + smul_x; |
| 2997 | basecxx . . $ base.[right_start + testr] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 2998 | |
| 2999 | basecxx . . $ base.[right_start + testr].p3_ucxx . . $ `lib/3d.h:250:9`! = |
| 3000 | tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + simplemul]; |
| 3001 | basecxx . . $ base.[right_start + testr].p3_vcxx . . $ `lib/3d.h:251:9`! = |
| 3002 | tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + simplemul]; |
| 3003 | |
| 3004 | basecxx . . $ base.[right_start + testr].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u + uvmul; |
| 3005 | basecxx . . $ base.[right_start + testr].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v + (i * uvadjust); |
| 3006 | slistcxx . . $ slist.[right_start + testr] = &basecxx . . $ base.[right_start + testr]; |
| 3007 | testr++; |
| 3008 | } |
| 3009 | // Bottom edge |
| 3010 | if (Terrain_listcxx . . $ Terrain_list.[index].bottom_edgecxx . . $ terrain_render_info#bottom_edge. & (1 << i)) { |
| 3011 | cur_seg = n + (smul_x - i); |
| 3012 | basecxx . . $ base.[bottom_start + testb] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3013 | |
| 3014 | basecxx . . $ base.[bottom_start + testb].p3_ucxx . . $ `lib/3d.h:250:9`! = |
| 3015 | tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + simplemul) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + (subx + simplemul) - i]; |
| 3016 | basecxx . . $ base.[bottom_start + testb].p3_vcxx . . $ `lib/3d.h:251:9`! = |
| 3017 | tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + simplemul) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + (subx + simplemul) - i]; |
| 3018 | basecxx . . $ base.[bottom_start + testb].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u + uvmul - (i * uvadjust); |
| 3019 | basecxx . . $ base.[bottom_start + testb].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v + uvmul; |
| 3020 | slistcxx . . $ slist.[bottom_start + testb] = &basecxx . . $ base.[bottom_start + testb]; |
| 3021 | testb++; |
| 3022 | } |
| 3023 | // left edge |
| 3024 | if (Terrain_listcxx . . $ Terrain_list.[index].left_edgecxx . . $ terrain_render_info#left_edge. & (1 << i)) { |
| 3025 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * i); |
| 3026 | basecxx . . $ base.[left_start + testl] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3027 | |
| 3028 | basecxx . . $ base.[left_start + testl].p3_ucxx . . $ `lib/3d.h:250:9`! = |
| 3029 | tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + simplemul - i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx]; |
| 3030 | basecxx . . $ base.[left_start + testl].p3_vcxx . . $ `lib/3d.h:251:9`! = |
| 3031 | tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + simplemul - i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx]; |
| 3032 | |
| 3033 | basecxx . . $ base.[left_start + testl].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u; |
| 3034 | basecxx . . $ base.[left_start + testl].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v + uvmul - (i * uvadjust); |
| 3035 | slistcxx . . $ slist.[left_start + testl] = &basecxx . . $ base.[left_start + testl]; |
| 3036 | testl++; |
| 3037 | } |
| 3038 | } |
| 3039 | } else { |
| 3040 | right_start = Terrain_listcxx . . $ Terrain_list.[index].top_countcxx . . $ terrain_render_info#top_count.; |
| 3041 | bottom_start = right_start + Terrain_listcxx . . $ Terrain_list.[index].right_countcxx . . $ terrain_render_info#right_count.; |
| 3042 | left_start = bottom_start + Terrain_listcxx . . $ Terrain_list.[index].bottom_countcxx . . $ terrain_render_info#bottom_count.; |
| 3043 | point_count = left_start + Terrain_listcxx . . $ Terrain_list.[index].left_countcxx . . $ terrain_render_info#left_count.; |
| 3044 | |
| 3045 | for (i = 0; i < smul_x; i++) { |
| 3046 | // top edge |
| 3047 | if (Terrain_listcxx . . $ Terrain_list.[index].top_edgecxx . . $ terrain_render_info#top_edge. & (1 << i)) { |
| 3048 | cur_seg = n + i + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z); |
| 3049 | basecxx . . $ base.[testt] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3050 | |
| 3051 | basecxx . . $ base.[testt].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + i]; |
| 3052 | basecxx . . $ base.[testt].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!]; |
| 3053 | |
| 3054 | basecxx . . $ base.[testt].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u + (i * uvadjust); |
| 3055 | basecxx . . $ base.[testt].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v; |
| 3056 | slistcxx . . $ slist.[testt] = &basecxx . . $ base.[testt]; |
| 3057 | testt++; |
| 3058 | } |
| 3059 | // Bottom edge |
| 3060 | if (Terrain_listcxx . . $ Terrain_list.[index].bottom_edgecxx . . $ terrain_render_info#bottom_edge. & (1 << i)) { |
| 3061 | cur_seg = n + (smul_x - i); |
| 3062 | basecxx . . $ base.[bottom_start + testb] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3063 | |
| 3064 | basecxx . . $ base.[bottom_start + testb].p3_ucxx . . $ `lib/3d.h:250:9`! = |
| 3065 | tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + smul_z) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + smul_x - i]; |
| 3066 | basecxx . . $ base.[bottom_start + testb].p3_vcxx . . $ `lib/3d.h:251:9`! = |
| 3067 | tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + smul_z) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + smul_x - i]; |
| 3068 | basecxx . . $ base.[bottom_start + testb].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u + uvmul - (i * uvadjust); |
| 3069 | basecxx . . $ base.[bottom_start + testb].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v + uvmul; |
| 3070 | slistcxx . . $ slist.[bottom_start + testb] = &basecxx . . $ base.[bottom_start + testb]; |
| 3071 | testb++; |
| 3072 | } |
| 3073 | } |
| 3074 | |
| 3075 | for (i = 0; i < smul_z; i++) { |
| 3076 | // Right edge |
| 3077 | if (Terrain_listcxx . . $ Terrain_list.[index].right_edgecxx . . $ terrain_render_info#right_edge. & (1 << i)) { |
| 3078 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * (smul_z - i)) + smul_x; |
| 3079 | basecxx . . $ base.[right_start + testr] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3080 | |
| 3081 | basecxx . . $ base.[right_start + testr].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + smul_x]; |
| 3082 | basecxx . . $ base.[right_start + testr].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + smul_x]; |
| 3083 | |
| 3084 | basecxx . . $ base.[right_start + testr].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u + uvmul; |
| 3085 | basecxx . . $ base.[right_start + testr].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v + (i * uvadjust); |
| 3086 | slistcxx . . $ slist.[right_start + testr] = &basecxx . . $ base.[right_start + testr]; |
| 3087 | testr++; |
| 3088 | } |
| 3089 | // left edge |
| 3090 | if (Terrain_listcxx . . $ Terrain_list.[index].left_edgecxx . . $ terrain_render_info#left_edge. & (1 << i)) { |
| 3091 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * i); |
| 3092 | basecxx . . $ base.[left_start + testl] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3093 | |
| 3094 | basecxx . . $ base.[left_start + testl].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + smul_z - i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx]; |
| 3095 | basecxx . . $ base.[left_start + testl].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + smul_z - i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx]; |
| 3096 | |
| 3097 | basecxx . . $ base.[left_start + testl].p3_u2cxx . . $ `lib/3d.h:257:9`! = lightmap_u; |
| 3098 | basecxx . . $ base.[left_start + testl].p3_v2cxx . . $ `lib/3d.h:258:9`! = lightmap_v + uvmul - (i * uvadjust); |
| 3099 | slistcxx . . $ slist.[left_start + testl] = &basecxx . . $ base.[left_start + testl]; |
| 3100 | testl++; |
| 3101 | } |
| 3102 | } |
| 3103 | } |
| 3104 | } |
| 3105 | |
| 3106 | rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_BLENDcxx . . $ `lib/renderer.h:334:9`!); |
| 3107 | rend_SetOverlayMapcxx . . $ rend_SetOverlayMap(d4f767463ce0a6b3).(TerrainLightmapscxx . . $ TerrainLightmaps.[tseg->lm_quadcxx . . $ terrain_segment#lm_quad.]); |
| 3108 | |
| 3109 | // Make sure the triangle faces us and if so draw |
| 3110 | // Upper left triangle |
| 3111 | if (lod != (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1)) |
| 3112 | draw_big_square = 1; |
| 3113 | if (!upper_left && !draw_big_square) |
| 3114 | goto draw_lower_right; |
| 3115 | |
| 3116 | if (lod == (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1)) { |
| 3117 | slistcxx . . $ slist.[0] = &basecxx . . $ base.[0]; |
| 3118 | slistcxx . . $ slist.[1] = &basecxx . . $ base.[1]; |
| 3119 | slistcxx . . $ slist.[2] = &basecxx . . $ base.[3]; |
| 3120 | points_this_triangle = 3; |
| 3121 | } else { |
| 3122 | points_this_triangle = point_count; |
| 3123 | } |
| 3124 | |
| 3125 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(points_this_triangle, slistcxx . . $ slist., bm_handle); |
| 3126 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 3127 | if (OUTLINE_ONcxx . . $ `Descent3/render.h:197:9`!(OM_TERRAINcxx . . $ `Descent3/render.h:202:9`!)) |
| 3128 | DrawTerrainOutlinecxx . . $ DrawTerrainOutline(aafc6ca7b5565e1b).(n, points_this_triangle, slistcxx . . $ slist.); |
| 3129 | #endif |
| 3130 | // If we're LOD'd, we've already drawn our 1 polygon. Return! |
| 3131 | if (draw_big_square) |
| 3132 | return 0; |
| 3133 | |
| 3134 | // Now do lower right triangle |
| 3135 | draw_lower_right: |
| 3136 | if (!lower_right) |
| 3137 | return 0; |
| 3138 | slistcxx . . $ slist.[0] = &basecxx . . $ base.[3]; |
| 3139 | slistcxx . . $ slist.[1] = &basecxx . . $ base.[1]; |
| 3140 | slistcxx . . $ slist.[2] = &basecxx . . $ base.[2]; |
| 3141 | points_this_triangle = 3; |
| 3142 | |
| 3143 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(points_this_triangle, slistcxx . . $ slist., bm_handle); |
| 3144 | |
| 3145 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 3146 | if (OUTLINE_ONcxx . . $ `Descent3/render.h:197:9`!(OM_TERRAINcxx . . $ `Descent3/render.h:202:9`!)) |
| 3147 | DrawTerrainOutlinecxx . . $ DrawTerrainOutline(aafc6ca7b5565e1b).(n, points_this_triangle, slistcxx . . $ slist.); |
| 3148 | #endif |
| 3149 | return 0; |
| 3150 | } |
| 3151 | // Draws the 2 triangles of the Terrainlist[index] (hardware) |
| 3152 | int DrawTerrainTrianglesHardwareNoLightcxx . . $ DrawTerrainTrianglesHardwareNoLight(d4c1ccc1fe1a56c0).(int index, int bm_handle, int upper_left, int lower_right) { |
| 3153 | int i; |
| 3154 | int cur_seg; |
| 3155 | int n = Terrain_listcxx . . $ Terrain_list.[index].segmentcxx . . $ terrain_render_info#segment.; |
| 3156 | int lod = Terrain_listcxx . . $ Terrain_list.[index].lodcxx . . $ terrain_render_info#lod.; |
| 3157 | int bottom_start, left_start, right_start; |
| 3158 | int point_count = 0; |
| 3159 | int points_this_triangle = 0; |
| 3160 | |
| 3161 | terrain_segmentcxx . . $ terrain_segment# *tseg = &Terrain_segcxx . . $ Terrain_seg.[n]; |
| 3162 | terrain_tex_segmentcxx . . $ terrain_tex_segment# *texseg = &Terrain_tex_segcxx . . $ Terrain_tex_seg.[tseg->texseg_indexcxx . . $ terrain_segment#texseg_index.]; |
| 3163 | int rotator = texseg->rotationcxx . . $ terrain_tex_segment#rotation. & 0x0F; |
| 3164 | int tile = texseg->rotationcxx . . $ terrain_tex_segment#rotation. >> 4; |
| 3165 | int simplemul = 1 << ((MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) - lod); |
| 3166 | int cx, cz, smul_x, smul_z; |
| 3167 | cx = n % TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 3168 | cz = n / TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 3169 | |
| 3170 | int draw_big_square = 0; |
| 3171 | int subx = cx % MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!; |
| 3172 | int subz = (MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`! - 1) - ((cz + (simplemul - 1)) % MAX_LOD_SIZEcxx . . $ `Descent3/terrain.h:42:9`!); |
| 3173 | bool solid_square = 1; |
| 3174 | int testt = 0, testr = 0, testb = 0, testl = 0; |
| 3175 | // Check to make sure we don't access memory that is off the map |
| 3176 | if (cx + simplemul == TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) { |
| 3177 | smul_x = simplemul - 1; |
| 3178 | solid_square = 0; |
| 3179 | } else |
| 3180 | smul_x = simplemul; |
| 3181 | if (cz + simplemul == TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!) { |
| 3182 | solid_square = 0; |
| 3183 | smul_z = simplemul - 1; |
| 3184 | } else |
| 3185 | smul_z = simplemul; |
| 3186 | // Build a list of points for our polygon. We must do it this way to |
| 3187 | // prevent tjoint cracking |
| 3188 | // Do simpler operation if at highest level of detail |
| 3189 | if (lod == (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1)) { |
| 3190 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z); |
| 3191 | basecxx . . $ base.[0] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3192 | |
| 3193 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z) + smul_x; |
| 3194 | basecxx . . $ base.[1] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3195 | |
| 3196 | cur_seg = n + smul_x; |
| 3197 | basecxx . . $ base.[2] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3198 | |
| 3199 | basecxx . . $ base.[3] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[n]; |
| 3200 | |
| 3201 | basecxx . . $ base.[0].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx]; |
| 3202 | basecxx . . $ base.[0].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx]; |
| 3203 | basecxx . . $ base.[1].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + 1]; |
| 3204 | basecxx . . $ base.[1].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + 1]; |
| 3205 | basecxx . . $ base.[2].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][(subz + 1) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + 1]; |
| 3206 | basecxx . . $ base.[2].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][(subz + 1) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + 1]; |
| 3207 | basecxx . . $ base.[3].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][(subz + 1) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx]; |
| 3208 | basecxx . . $ base.[3].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][(subz + 1) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx]; |
| 3209 | } else { |
| 3210 | if (solid_square) { |
| 3211 | right_start = Terrain_listcxx . . $ Terrain_list.[index].top_countcxx . . $ terrain_render_info#top_count.; |
| 3212 | bottom_start = right_start + Terrain_listcxx . . $ Terrain_list.[index].right_countcxx . . $ terrain_render_info#right_count.; |
| 3213 | left_start = bottom_start + Terrain_listcxx . . $ Terrain_list.[index].bottom_countcxx . . $ terrain_render_info#bottom_count.; |
| 3214 | point_count = left_start + Terrain_listcxx . . $ Terrain_list.[index].left_countcxx . . $ terrain_render_info#left_count.; |
| 3215 | |
| 3216 | for (i = 0; i < simplemul; i++) { |
| 3217 | // Top edge |
| 3218 | if (Terrain_listcxx . . $ Terrain_list.[index].top_edgecxx . . $ terrain_render_info#top_edge. & (1 << i)) { |
| 3219 | cur_seg = n + i + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z); |
| 3220 | basecxx . . $ base.[testt] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3221 | |
| 3222 | basecxx . . $ base.[testt].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + i]; |
| 3223 | basecxx . . $ base.[testt].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + i]; |
| 3224 | |
| 3225 | slistcxx . . $ slist.[testt] = &basecxx . . $ base.[testt]; |
| 3226 | testt++; |
| 3227 | } |
| 3228 | // Right edge |
| 3229 | if (Terrain_listcxx . . $ Terrain_list.[index].right_edgecxx . . $ terrain_render_info#right_edge. & (1 << i)) { |
| 3230 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * (smul_z - i)) + smul_x; |
| 3231 | basecxx . . $ base.[right_start + testr] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3232 | |
| 3233 | basecxx . . $ base.[right_start + testr].p3_ucxx . . $ `lib/3d.h:250:9`! = |
| 3234 | tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + simplemul]; |
| 3235 | basecxx . . $ base.[right_start + testr].p3_vcxx . . $ `lib/3d.h:251:9`! = |
| 3236 | tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + simplemul]; |
| 3237 | |
| 3238 | slistcxx . . $ slist.[right_start + testr] = &basecxx . . $ base.[right_start + testr]; |
| 3239 | testr++; |
| 3240 | } |
| 3241 | // Bottom edge |
| 3242 | if (Terrain_listcxx . . $ Terrain_list.[index].bottom_edgecxx . . $ terrain_render_info#bottom_edge. & (1 << i)) { |
| 3243 | cur_seg = n + (smul_x - i); |
| 3244 | basecxx . . $ base.[bottom_start + testb] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3245 | |
| 3246 | basecxx . . $ base.[bottom_start + testb].p3_ucxx . . $ `lib/3d.h:250:9`! = |
| 3247 | tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + simplemul) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + simplemul - i]; |
| 3248 | basecxx . . $ base.[bottom_start + testb].p3_vcxx . . $ `lib/3d.h:251:9`! = |
| 3249 | tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + simplemul) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + simplemul - i]; |
| 3250 | slistcxx . . $ slist.[bottom_start + testb] = &basecxx . . $ base.[bottom_start + testb]; |
| 3251 | testb++; |
| 3252 | } |
| 3253 | // left edge |
| 3254 | if (Terrain_listcxx . . $ Terrain_list.[index].left_edgecxx . . $ terrain_render_info#left_edge. & (1 << i)) { |
| 3255 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * i); |
| 3256 | basecxx . . $ base.[left_start + testl] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3257 | |
| 3258 | basecxx . . $ base.[left_start + testl].p3_ucxx . . $ `lib/3d.h:250:9`! = |
| 3259 | tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + simplemul - i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx]; |
| 3260 | basecxx . . $ base.[left_start + testl].p3_vcxx . . $ `lib/3d.h:251:9`! = |
| 3261 | tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + simplemul - i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx]; |
| 3262 | |
| 3263 | slistcxx . . $ slist.[left_start + testl] = &basecxx . . $ base.[left_start + testl]; |
| 3264 | testl++; |
| 3265 | } |
| 3266 | } |
| 3267 | } else { |
| 3268 | right_start = Terrain_listcxx . . $ Terrain_list.[index].top_countcxx . . $ terrain_render_info#top_count.; |
| 3269 | bottom_start = right_start + Terrain_listcxx . . $ Terrain_list.[index].right_countcxx . . $ terrain_render_info#right_count.; |
| 3270 | left_start = bottom_start + Terrain_listcxx . . $ Terrain_list.[index].bottom_countcxx . . $ terrain_render_info#bottom_count.; |
| 3271 | point_count = left_start + Terrain_listcxx . . $ Terrain_list.[index].left_countcxx . . $ terrain_render_info#left_count.; |
| 3272 | |
| 3273 | for (i = 0; i < smul_x; i++) { |
| 3274 | // top edge |
| 3275 | if (Terrain_listcxx . . $ Terrain_list.[index].top_edgecxx . . $ terrain_render_info#top_edge. & (1 << i)) { |
| 3276 | cur_seg = n + i + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z); |
| 3277 | basecxx . . $ base.[testt] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3278 | |
| 3279 | basecxx . . $ base.[testt].p3_ucxx . . $ `lib/3d.h:250:9`! = tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + i]; |
| 3280 | basecxx . . $ base.[testt].p3_vcxx . . $ `lib/3d.h:251:9`! = tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][subz * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`! + subx + i]; |
| 3281 | |
| 3282 | slistcxx . . $ slist.[testt] = &basecxx . . $ base.[testt]; |
| 3283 | testt++; |
| 3284 | } |
| 3285 | // Bottom edge |
| 3286 | if (Terrain_listcxx . . $ Terrain_list.[index].bottom_edgecxx . . $ terrain_render_info#bottom_edge. & (1 << i)) { |
| 3287 | cur_seg = n + (smul_x - i); |
| 3288 | basecxx . . $ base.[bottom_start + testb] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3289 | |
| 3290 | basecxx . . $ base.[bottom_start + testb].p3_ucxx . . $ `lib/3d.h:250:9`! = |
| 3291 | tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + simplemul) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + simplemul - i]; |
| 3292 | basecxx . . $ base.[bottom_start + testb].p3_vcxx . . $ `lib/3d.h:251:9`! = |
| 3293 | tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + simplemul) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + simplemul - i]; |
| 3294 | |
| 3295 | slistcxx . . $ slist.[bottom_start + testb] = &basecxx . . $ base.[bottom_start + testb]; |
| 3296 | testb++; |
| 3297 | } |
| 3298 | } |
| 3299 | |
| 3300 | for (i = 0; i < smul_z; i++) { |
| 3301 | // Right edge |
| 3302 | if (Terrain_listcxx . . $ Terrain_list.[index].right_edgecxx . . $ terrain_render_info#right_edge. & (1 << i)) { |
| 3303 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * (smul_z - i)) + smul_x; |
| 3304 | basecxx . . $ base.[right_start + testr] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3305 | |
| 3306 | basecxx . . $ base.[right_start + testr].p3_ucxx . . $ `lib/3d.h:250:9`! = |
| 3307 | tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + simplemul]; |
| 3308 | basecxx . . $ base.[right_start + testr].p3_vcxx . . $ `lib/3d.h:251:9`! = |
| 3309 | tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx + simplemul]; |
| 3310 | |
| 3311 | slistcxx . . $ slist.[right_start + testr] = &basecxx . . $ base.[right_start + testr]; |
| 3312 | testr++; |
| 3313 | } |
| 3314 | // left edge |
| 3315 | if (Terrain_listcxx . . $ Terrain_list.[index].left_edgecxx . . $ terrain_render_info#left_edge. & (1 << i)) { |
| 3316 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * i); |
| 3317 | basecxx . . $ base.[left_start + testl] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3318 | |
| 3319 | basecxx . . $ base.[left_start + testl].p3_ucxx . . $ `lib/3d.h:250:9`! = |
| 3320 | tile * TerrainUSpeedupcxx . . $ TerrainUSpeedup.[rotator][((subz + simplemul - i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx]; |
| 3321 | basecxx . . $ base.[left_start + testl].p3_vcxx . . $ `lib/3d.h:251:9`! = |
| 3322 | tile * TerrainVSpeedupcxx . . $ TerrainVSpeedup.[rotator][((subz + simplemul - i) * LOD_ROW_SIZEcxx . . $ `Descent3/terrainrender.cpp:827:9`!) + subx]; |
| 3323 | slistcxx . . $ slist.[left_start + testl] = &basecxx . . $ base.[left_start + testl]; |
| 3324 | testl++; |
| 3325 | } |
| 3326 | } |
| 3327 | } |
| 3328 | } |
| 3329 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 3330 | ddgr_color oldcolor; |
| 3331 | if (TSearch_on) { |
| 3332 | rend_SetPixel(GR_RGB(0, 255, 0), TSearch_x, TSearch_y); |
| 3333 | oldcolor = rend_GetPixel(TSearch_x, TSearch_y); // will be different in 15/16-bit color |
| 3334 | } |
| 3335 | #endif |
| 3336 | |
| 3337 | rend_SetOverlayTypecxx . . $ rend_SetOverlayType(ac50b47256ae7414).(OT_NONEcxx . . $ `lib/renderer.h:333:9`!); |
| 3338 | |
| 3339 | // Make sure the triangle faces us and if so draw |
| 3340 | // Upper left triangle |
| 3341 | if (lod != (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1)) |
| 3342 | draw_big_square = 1; |
| 3343 | if (!upper_left && !draw_big_square) |
| 3344 | goto draw_lower_right; |
| 3345 | |
| 3346 | if (lod == (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1)) { |
| 3347 | slistcxx . . $ slist.[0] = &basecxx . . $ base.[0]; |
| 3348 | slistcxx . . $ slist.[1] = &basecxx . . $ base.[1]; |
| 3349 | slistcxx . . $ slist.[2] = &basecxx . . $ base.[3]; |
| 3350 | points_this_triangle = 3; |
| 3351 | } else { |
| 3352 | points_this_triangle = point_count; |
| 3353 | } |
| 3354 | |
| 3355 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(points_this_triangle, slistcxx . . $ slist., bm_handle); |
| 3356 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 3357 | if (OUTLINE_ONcxx . . $ `Descent3/render.h:197:9`!(OM_TERRAINcxx . . $ `Descent3/render.h:202:9`!)) |
| 3358 | DrawTerrainOutlinecxx . . $ DrawTerrainOutline(aafc6ca7b5565e1b).(n, points_this_triangle, slistcxx . . $ slist.); |
| 3359 | #endif |
| 3360 | // If we're LOD'd, we've already drawn our 1 polygon. Return! |
| 3361 | if (draw_big_square) |
| 3362 | return 0; |
| 3363 | |
| 3364 | // Now do lower right triangle |
| 3365 | draw_lower_right: |
| 3366 | if (!lower_right) |
| 3367 | return 0; |
| 3368 | slistcxx . . $ slist.[0] = &basecxx . . $ base.[3]; |
| 3369 | slistcxx . . $ slist.[1] = &basecxx . . $ base.[1]; |
| 3370 | slistcxx . . $ slist.[2] = &basecxx . . $ base.[2]; |
| 3371 | points_this_triangle = 3; |
| 3372 | |
| 3373 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(points_this_triangle, slistcxx . . $ slist., bm_handle); |
| 3374 | #if (defined(EDITOR) || defined(NEWEDITOR)) |
| 3375 | if (TSearch_on) { |
| 3376 | if (rend_GetPixel(TSearch_x, TSearch_y) != oldcolor) { |
| 3377 | TSearch_seg = n; |
| 3378 | TSearch_found_type = TSEARCH_FOUND_TERRAIN; |
| 3379 | } |
| 3380 | } |
| 3381 | #endif |
| 3382 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 3383 | if (OUTLINE_ONcxx . . $ `Descent3/render.h:197:9`!(OM_TERRAINcxx . . $ `Descent3/render.h:202:9`!)) |
| 3384 | DrawTerrainOutlinecxx . . $ DrawTerrainOutline(aafc6ca7b5565e1b).(n, points_this_triangle, slistcxx . . $ slist.); |
| 3385 | #endif |
| 3386 | return 0; |
| 3387 | } |
| 3388 | // Draws the 2 triangles of the Terrainlist[index] (hardware) |
| 3389 | void DrawTerrainLightmapsHardwarecxx . . $ DrawTerrainLightmapsHardware(b1146eedae1e1d0b).(int index, int upper_left, int lower_right) { |
| 3390 | int i; |
| 3391 | int cur_seg; |
| 3392 | int n = Terrain_listcxx . . $ Terrain_list.[index].segmentcxx . . $ terrain_render_info#segment.; |
| 3393 | int lod = Terrain_listcxx . . $ Terrain_list.[index].lodcxx . . $ terrain_render_info#lod.; |
| 3394 | int bottom_start, left_start, right_start; |
| 3395 | int point_count = 0; |
| 3396 | int points_this_triangle = 0; |
| 3397 | |
| 3398 | terrain_segmentcxx . . $ terrain_segment# *tseg = &Terrain_segcxx . . $ Terrain_seg.[n]; |
| 3399 | int simplemul = 1 << ((MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1) - lod); |
| 3400 | int cx, cz, smul_x, smul_z; |
| 3401 | cx = n % TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 3402 | cz = n / TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!; |
| 3403 | |
| 3404 | // Get lightmap coordinates |
| 3405 | float lightmap_u = (cx % 128) / 128.0; |
| 3406 | float lightmap_v = (128 - ((cz % 128) + simplemul)) / 128.0; |
| 3407 | float uvadjust; |
| 3408 | int draw_big_square = 0; |
| 3409 | bool solid_square = 1; |
| 3410 | int testt = 0, testr = 0, testb = 0, testl = 0; |
| 3411 | // Check to make sure we don't access memory that is off the map |
| 3412 | if (cx + simplemul == TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`!) { |
| 3413 | smul_x = simplemul - 1; |
| 3414 | solid_square = 0; |
| 3415 | } else |
| 3416 | smul_x = simplemul; |
| 3417 | if (cz + simplemul == TERRAIN_DEPTHcxx . . $ `Descent3/terrain.h:32:9`!) { |
| 3418 | solid_square = 0; |
| 3419 | smul_z = simplemul - 1; |
| 3420 | } else |
| 3421 | smul_z = simplemul; |
| 3422 | // Build a list of points for our polygon. We must do it this way to |
| 3423 | // prevent tjoint cracking |
| 3424 | // Do simpler operation if at highest level of detail |
| 3425 | if (lod == (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1)) { |
| 3426 | uvadjust = (simplemul / 128.0); |
| 3427 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z); |
| 3428 | basecxx . . $ base.[0] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3429 | |
| 3430 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z) + smul_x; |
| 3431 | basecxx . . $ base.[1] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3432 | |
| 3433 | cur_seg = n + smul_x; |
| 3434 | basecxx . . $ base.[2] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3435 | |
| 3436 | basecxx . . $ base.[3] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[n]; |
| 3437 | |
| 3438 | basecxx . . $ base.[0].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u; |
| 3439 | basecxx . . $ base.[0].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v; |
| 3440 | basecxx . . $ base.[1].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u + uvadjust; |
| 3441 | basecxx . . $ base.[1].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v; |
| 3442 | basecxx . . $ base.[2].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u + uvadjust; |
| 3443 | basecxx . . $ base.[2].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v + uvadjust; |
| 3444 | |
| 3445 | basecxx . . $ base.[3].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u; |
| 3446 | basecxx . . $ base.[3].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v + uvadjust; |
| 3447 | } else { |
| 3448 | uvadjust = (simplemul / 128.0) / simplemul; |
| 3449 | float uvmul = uvadjust * simplemul; |
| 3450 | if (solid_square) { |
| 3451 | right_start = Terrain_listcxx . . $ Terrain_list.[index].top_countcxx . . $ terrain_render_info#top_count.; |
| 3452 | bottom_start = right_start + Terrain_listcxx . . $ Terrain_list.[index].right_countcxx . . $ terrain_render_info#right_count.; |
| 3453 | left_start = bottom_start + Terrain_listcxx . . $ Terrain_list.[index].bottom_countcxx . . $ terrain_render_info#bottom_count.; |
| 3454 | point_count = left_start + Terrain_listcxx . . $ Terrain_list.[index].left_countcxx . . $ terrain_render_info#left_count.; |
| 3455 | |
| 3456 | for (i = 0; i < simplemul; i++) { |
| 3457 | // Top edge |
| 3458 | if (Terrain_listcxx . . $ Terrain_list.[index].top_edgecxx . . $ terrain_render_info#top_edge. & (1 << i)) { |
| 3459 | cur_seg = n + i + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z); |
| 3460 | basecxx . . $ base.[testt] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3461 | |
| 3462 | basecxx . . $ base.[testt].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u + (i * uvadjust); |
| 3463 | basecxx . . $ base.[testt].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v; |
| 3464 | slistcxx . . $ slist.[testt] = &basecxx . . $ base.[testt]; |
| 3465 | testt++; |
| 3466 | } |
| 3467 | // Right edge |
| 3468 | if (Terrain_listcxx . . $ Terrain_list.[index].right_edgecxx . . $ terrain_render_info#right_edge. & (1 << i)) { |
| 3469 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * (smul_z - i)) + smul_x; |
| 3470 | basecxx . . $ base.[right_start + testr] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3471 | |
| 3472 | basecxx . . $ base.[right_start + testr].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u + uvmul; |
| 3473 | basecxx . . $ base.[right_start + testr].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v + (i * uvadjust); |
| 3474 | slistcxx . . $ slist.[right_start + testr] = &basecxx . . $ base.[right_start + testr]; |
| 3475 | testr++; |
| 3476 | } |
| 3477 | // Bottom edge |
| 3478 | if (Terrain_listcxx . . $ Terrain_list.[index].bottom_edgecxx . . $ terrain_render_info#bottom_edge. & (1 << i)) { |
| 3479 | cur_seg = n + (smul_x - i); |
| 3480 | basecxx . . $ base.[bottom_start + testb] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3481 | |
| 3482 | basecxx . . $ base.[bottom_start + testb].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u + uvmul - (i * uvadjust); |
| 3483 | basecxx . . $ base.[bottom_start + testb].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v + uvmul; |
| 3484 | slistcxx . . $ slist.[bottom_start + testb] = &basecxx . . $ base.[bottom_start + testb]; |
| 3485 | testb++; |
| 3486 | } |
| 3487 | // left edge |
| 3488 | if (Terrain_listcxx . . $ Terrain_list.[index].left_edgecxx . . $ terrain_render_info#left_edge. & (1 << i)) { |
| 3489 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * i); |
| 3490 | basecxx . . $ base.[left_start + testl] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3491 | |
| 3492 | basecxx . . $ base.[left_start + testl].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u; |
| 3493 | basecxx . . $ base.[left_start + testl].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v + uvmul - (i * uvadjust); |
| 3494 | slistcxx . . $ slist.[left_start + testl] = &basecxx . . $ base.[left_start + testl]; |
| 3495 | testl++; |
| 3496 | } |
| 3497 | } |
| 3498 | } else { |
| 3499 | right_start = Terrain_listcxx . . $ Terrain_list.[index].top_countcxx . . $ terrain_render_info#top_count.; |
| 3500 | bottom_start = right_start + Terrain_listcxx . . $ Terrain_list.[index].right_countcxx . . $ terrain_render_info#right_count.; |
| 3501 | left_start = bottom_start + Terrain_listcxx . . $ Terrain_list.[index].bottom_countcxx . . $ terrain_render_info#bottom_count.; |
| 3502 | point_count = left_start + Terrain_listcxx . . $ Terrain_list.[index].left_countcxx . . $ terrain_render_info#left_count.; |
| 3503 | |
| 3504 | for (i = 0; i < smul_x; i++) { |
| 3505 | // top edge |
| 3506 | if (Terrain_listcxx . . $ Terrain_list.[index].top_edgecxx . . $ terrain_render_info#top_edge. & (1 << i)) { |
| 3507 | cur_seg = n + i + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * smul_z); |
| 3508 | basecxx . . $ base.[testt] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3509 | |
| 3510 | basecxx . . $ base.[testt].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u + (i * uvadjust); |
| 3511 | basecxx . . $ base.[testt].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v; |
| 3512 | slistcxx . . $ slist.[testt] = &basecxx . . $ base.[testt]; |
| 3513 | testt++; |
| 3514 | } |
| 3515 | // Bottom edge |
| 3516 | if (Terrain_listcxx . . $ Terrain_list.[index].bottom_edgecxx . . $ terrain_render_info#bottom_edge. & (1 << i)) { |
| 3517 | cur_seg = n + (smul_x - i); |
| 3518 | basecxx . . $ base.[bottom_start + testb] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3519 | |
| 3520 | basecxx . . $ base.[bottom_start + testb].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u + uvmul - (i * uvadjust); |
| 3521 | basecxx . . $ base.[bottom_start + testb].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v + uvmul; |
| 3522 | slistcxx . . $ slist.[bottom_start + testb] = &basecxx . . $ base.[bottom_start + testb]; |
| 3523 | testb++; |
| 3524 | } |
| 3525 | } |
| 3526 | |
| 3527 | for (i = 0; i < smul_z; i++) { |
| 3528 | // Right edge |
| 3529 | if (Terrain_listcxx . . $ Terrain_list.[index].right_edgecxx . . $ terrain_render_info#right_edge. & (1 << i)) { |
| 3530 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * (smul_z - i)) + smul_x; |
| 3531 | basecxx . . $ base.[right_start + testr] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3532 | |
| 3533 | basecxx . . $ base.[right_start + testr].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u + uvmul; |
| 3534 | basecxx . . $ base.[right_start + testr].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v + (i * uvadjust); |
| 3535 | slistcxx . . $ slist.[right_start + testr] = &basecxx . . $ base.[right_start + testr]; |
| 3536 | testr++; |
| 3537 | } |
| 3538 | // left edge |
| 3539 | if (Terrain_listcxx . . $ Terrain_list.[index].left_edgecxx . . $ terrain_render_info#left_edge. & (1 << i)) { |
| 3540 | cur_seg = n + (TERRAIN_WIDTHcxx . . $ `Descent3/terrain.h:31:9`! * i); |
| 3541 | basecxx . . $ base.[left_start + testl] =cxx . . $ g3Point#`operator=`(c45224b80d125eec). World_point_buffercxx . . $ World_point_buffer.[cur_seg]; |
| 3542 | |
| 3543 | basecxx . . $ base.[left_start + testl].p3_ucxx . . $ `lib/3d.h:250:9`! = lightmap_u; |
| 3544 | basecxx . . $ base.[left_start + testl].p3_vcxx . . $ `lib/3d.h:251:9`! = lightmap_v + uvmul - (i * uvadjust); |
| 3545 | slistcxx . . $ slist.[left_start + testl] = &basecxx . . $ base.[left_start + testl]; |
| 3546 | testl++; |
| 3547 | } |
| 3548 | } |
| 3549 | } |
| 3550 | } |
| 3551 | |
| 3552 | // Make sure the triangle faces us and if so draw |
| 3553 | // Upper left triangle |
| 3554 | if (lod != (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1)) |
| 3555 | draw_big_square = 1; |
| 3556 | if (!upper_left && !draw_big_square) |
| 3557 | goto draw_lower_right; |
| 3558 | |
| 3559 | if (lod == (MAX_TERRAIN_LODcxx . . $ `Descent3/terrain.h:38:9`! - 1)) { |
| 3560 | slistcxx . . $ slist.[0] = &basecxx . . $ base.[0]; |
| 3561 | slistcxx . . $ slist.[1] = &basecxx . . $ base.[1]; |
| 3562 | slistcxx . . $ slist.[2] = &basecxx . . $ base.[3]; |
| 3563 | points_this_triangle = 3; |
| 3564 | } else { |
| 3565 | points_this_triangle = point_count; |
| 3566 | } |
| 3567 | |
| 3568 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(points_this_triangle, slistcxx . . $ slist., TerrainLightmapscxx . . $ TerrainLightmaps.[tseg->lm_quadcxx . . $ terrain_segment#lm_quad.], MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!); |
| 3569 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 3570 | if (OUTLINE_ONcxx . . $ `Descent3/render.h:197:9`!(OM_TERRAINcxx . . $ `Descent3/render.h:202:9`!)) |
| 3571 | DrawTerrainOutlinecxx . . $ DrawTerrainOutline(aafc6ca7b5565e1b).(n, points_this_triangle, slistcxx . . $ slist.); |
| 3572 | #endif |
| 3573 | // If we're LOD'd, we've already drawn our 1 polygon. Return! |
| 3574 | if (draw_big_square) |
| 3575 | return; |
| 3576 | |
| 3577 | // Now do lower right triangle |
| 3578 | draw_lower_right: |
| 3579 | if (!lower_right) |
| 3580 | return; |
| 3581 | slistcxx . . $ slist.[0] = &basecxx . . $ base.[3]; |
| 3582 | slistcxx . . $ slist.[1] = &basecxx . . $ base.[1]; |
| 3583 | slistcxx . . $ slist.[2] = &basecxx . . $ base.[2]; |
| 3584 | points_this_triangle = 3; |
| 3585 | |
| 3586 | g3_DrawPolycxx . . $ g3_DrawPoly(eaf0a58e8bd7fbdc).(points_this_triangle, slistcxx . . $ slist., TerrainLightmapscxx . . $ TerrainLightmaps.[tseg->lm_quadcxx . . $ terrain_segment#lm_quad.], MAP_TYPE_LIGHTMAPcxx . . $ `lib/renderer.h:363:9`!); |
| 3587 | |
| 3588 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 3589 | if (OUTLINE_ONcxx . . $ `Descent3/render.h:197:9`!(OM_TERRAINcxx . . $ `Descent3/render.h:202:9`!)) |
| 3590 | DrawTerrainOutlinecxx . . $ DrawTerrainOutline(aafc6ca7b5565e1b).(n, points_this_triangle, slistcxx . . $ slist.); |
| 3591 | #endif |
| 3592 | } |
| 3593 | // Adds object obj to terrain segment n. |
| 3594 | // This object will be rendered immediately following the rendering of this |
| 3595 | // terrain segment |
| 3596 | int AddRenderObjectToTerrainSegcxx . . $ AddRenderObjectToTerrainSeg(9b79fb6aee4c0440).(int n, int objnum) { |
| 3597 | // Uses a linked list to keep track of what objects are in this segment |
| 3598 | #if (!defined(RELEASE) || defined(NEWEDITOR)) |
| 3599 | if (Terrain_seg_render_objscxx . . $ Terrain_seg_render_objs.[n] == objnum) |
| 3600 | return 0; |
| 3601 | // New object points at first in list |
| 3602 | render_nextcxx . . $ render_next.[objnum] = Terrain_seg_render_objscxx . . $ Terrain_seg_render_objs.[n]; |
| 3603 | // New object becomes first in list |
| 3604 | Terrain_seg_render_objscxx . . $ Terrain_seg_render_objs.[n] = objnum; |
| 3605 | #endif |
| 3606 | |
| 3607 | return (0); |
| 3608 | } |