| 738 | } |
| 739 | |
| 740 | void CheckFogPortalExtents(int roomnum, int portalnum) { |
| 741 | room *rp = &Rooms[roomnum]; |
| 742 | ASSERT(rp->flags & RF_FOG); |
| 743 | |
| 744 | int i, found_room = -1; |
| 745 | for (i = 0; i < Num_fogged_rooms_this_frame; ++i) { |
| 746 | if (Fog_portal_data[i].roomnum != roomnum) |
| 747 | continue; |
| 748 | |
| 749 | found_room = i; |
| 750 | break; |
| 751 | } |
| 752 | |
| 753 | if (found_room == -1) { |
| 754 | // Couldn't find this room in our list, so make a new one |
| 755 | if (Num_fogged_rooms_this_frame >= MAX_FOGGED_ROOMS_PER_FRAME) { |
| 756 | mprintf(0, "Too many fogged rooms in view cone!\n"); |
| 757 | return; |
| 758 | } |
| 759 | |
| 760 | found_room = Num_fogged_rooms_this_frame++; |
| 761 | Fog_portal_data[found_room].close_face = NULL; |
| 762 | Fog_portal_data[found_room].close_dist = 10000000.0f; |
| 763 | Fog_portal_data[found_room].roomnum = roomnum; |
| 764 | } |
| 765 | |
| 766 | // get the portal face |
| 767 | int fn = rp->portals[portalnum].portal_face; |
| 768 | face *fp = &rp->faces[fn]; |
| 769 | |
| 770 | // calculate the plane equation for the portal |
| 771 | vector *vec = &rp->verts[fp->face_verts[0]]; |
| 772 | float distance = -vm_DotProduct(&fp->normal, vec); |
| 773 | |
| 774 | // calculate the distance from the camera to the portal |
| 775 | distance = vm_DotProduct(&fp->normal, &Viewer_eye) + distance; |
| 776 | if (distance < Fog_portal_data[found_room].close_dist) { |
| 777 | // this portal is closer to the camera than the previous |
| 778 | Fog_portal_data[found_room].close_dist = distance; |
| 779 | Fog_portal_data[found_room].close_face = fp; |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | g3Point Combined_portal_points[MAX_VERTS_PER_FACE * 5]; |
| 784 | void BuildRoomListSub(int start_room_num, clip_wnd *wnd, int depth) { |
no test coverage detected