| 445 | } |
| 446 | |
| 447 | void TCAMRenderRoom(int roomnum) { |
| 448 | ASSERT(Rooms[roomnum].used); |
| 449 | room *rp = &Rooms[roomnum]; |
| 450 | static int first = 1; |
| 451 | static float lm_red[32], lm_green[32], lm_blue[32]; |
| 452 | float nearz; |
| 453 | int i; |
| 454 | |
| 455 | if (first) { |
| 456 | first = 0; |
| 457 | for (int i = 0; i < 32; i++) { |
| 458 | lm_red[i] = ((float)i / 31.0); |
| 459 | lm_green[i] = ((float)i / 31.0); |
| 460 | lm_blue[i] = ((float)i / 31.0); |
| 461 | } |
| 462 | } |
| 463 | |
| 464 | if ((rp->flags & RF_EXTERNAL) && !AM_terrain) |
| 465 | return; |
| 466 | |
| 467 | if (!IsRoomVisible(rp, &nearz)) |
| 468 | return; |
| 469 | |
| 470 | // rotate all the points for this room |
| 471 | for (i = 0; i < rp->num_verts; i++) { |
| 472 | g3_RotatePoint(&AM_rotated_points[i], &rp->verts[i]); |
| 473 | g3_ProjectPoint(&AM_rotated_points[i]); |
| 474 | } |
| 475 | |
| 476 | for (i = 0; i < rp->num_faces; i++) { |
| 477 | g3Point *pointlist[MAX_VERTS_PER_FACE]; |
| 478 | g3Point pointbuffer[MAX_VERTS_PER_FACE]; |
| 479 | |
| 480 | face *fp = &rp->faces[i]; |
| 481 | |
| 482 | // See if this face is backfaced |
| 483 | vector subvec = rp->verts[fp->face_verts[0]] - AM_view_pos; |
| 484 | if (subvec * fp->normal > 0) |
| 485 | continue; // backfaced |
| 486 | |
| 487 | int black_face = 0, wacky_face = 0; |
| 488 | |
| 489 | if (fp->portal_num != -1) { |
| 490 | if (!AutomapVisMap[rp->portals[fp->portal_num].croom]) { |
| 491 | // Don't give away secret rooms |
| 492 | if (Rooms[rp->portals[fp->portal_num].croom].flags & RF_SECRET) |
| 493 | black_face = 1; |
| 494 | else |
| 495 | wacky_face = 1; |
| 496 | } else |
| 497 | continue; |
| 498 | } |
| 499 | |
| 500 | if (nearz > 600) { |
| 501 | if (Small_faces[roomnum][i] != 0) |
| 502 | continue; |
| 503 | } else if (nearz > 300) { |
| 504 | if (Small_faces[roomnum][i] == 2) |
no test coverage detected