Sets up fog if this room is fogged
| 2193 | |
| 2194 | // Sets up fog if this room is fogged |
| 2195 | void SetupRoomFog(room *rp, vector *eye, matrix *orient, int viewer_room) { |
| 2196 | if ((rp->flags & RF_FOG) == 0) |
| 2197 | return; |
| 2198 | |
| 2199 | if (!Detail_settings.Fog_enabled) { |
| 2200 | // fog is disabled |
| 2201 | Room_fog_plane_check = -1; |
| 2202 | return; |
| 2203 | } |
| 2204 | |
| 2205 | if (viewer_room == (rp - Rooms)) { |
| 2206 | // viewer is in the room |
| 2207 | vector *vec = eye; |
| 2208 | Room_fog_plane_check = 1; |
| 2209 | Room_fog_distance = -vm_DotProduct(&orient->fvec, vec); |
| 2210 | Room_fog_plane = orient->fvec; |
| 2211 | return; |
| 2212 | } |
| 2213 | |
| 2214 | // find the 'fogroom' number (we should have put it in here if we will render the room) |
| 2215 | int found_room = -1; |
| 2216 | for (int i = 0; i < Num_fogged_rooms_this_frame && found_room == -1; i++) { |
| 2217 | if (Fog_portal_data[i].roomnum == rp - Rooms) { |
| 2218 | found_room = i; |
| 2219 | break; |
| 2220 | } |
| 2221 | } |
| 2222 | |
| 2223 | if (found_room == -1 || Fog_portal_data[found_room].close_face == NULL) { |
| 2224 | // we won't be rendering this room |
| 2225 | Room_fog_plane_check = -1; |
| 2226 | return; |
| 2227 | } |
| 2228 | |
| 2229 | // Use the closest face |
| 2230 | face *close_face = Fog_portal_data[found_room].close_face; |
| 2231 | Room_fog_plane_check = 0; |
| 2232 | Room_fog_plane = close_face->normal; |
| 2233 | Room_fog_portal_vert = rp->verts[close_face->face_verts[0]]; |
| 2234 | Room_fog_distance = -vm_DotProduct(&Room_fog_plane, &Room_fog_portal_vert); |
| 2235 | Room_fog_eye_distance = (*eye * Room_fog_plane) + Room_fog_distance; |
| 2236 | } |
| 2237 | |
| 2238 | // Renders the faces in a room without worrying about sorting. Used in the game when Z-buffering is active |
| 2239 | void RenderRoomUnsorted(room *rp) { |
no test coverage detected