Renders all the mirrored rooms for this frame
| 3308 | } |
| 3309 | // Renders all the mirrored rooms for this frame |
| 3310 | void RenderMirrorRooms() { |
| 3311 | int i; |
| 3312 | if (!UseHardware || !Detail_settings.Mirrored_surfaces) |
| 3313 | return; |
| 3314 | if (Num_mirror_rooms == 0) |
| 3315 | return; |
| 3316 | for (i = 0; i < Num_mirror_rooms; i++) { |
| 3317 | room *rp = &Rooms[Mirror_rooms[i]]; |
| 3318 | // Reset mirrors |
| 3319 | Render_mirror_for_room = false; |
| 3320 | bool do_mirror_face = false; |
| 3321 | rp->flags &= ~RF_MIRROR_VISIBLE; |
| 3322 | // Make sure its really ok to render this mirrored room |
| 3323 | if (rp->mirror_face != -1) |
| 3324 | do_mirror_face = true; |
| 3325 | if (rp->mirror_face >= rp->num_faces) |
| 3326 | do_mirror_face = false; |
| 3327 | if (do_mirror_face) { |
| 3328 | if (!(GameTextures[rp->faces[rp->mirror_face].tmap].flags & TF_ALPHA)) |
| 3329 | do_mirror_face = false; |
| 3330 | } |
| 3331 | if (do_mirror_face) { |
| 3332 | int on_screen = 0; |
| 3333 | // See if any of the faces that share the mirror texture are on the screen |
| 3334 | for (int k = 0; k < rp->num_mirror_faces && on_screen == 0; k++) { |
| 3335 | face *fp = &rp->faces[rp->mirror_faces_list[k]]; |
| 3336 | |
| 3337 | // See if this face is on screen |
| 3338 | int anded = 0xff; |
| 3339 | g3Point pnt; |
| 3340 | for (int t = 0; t < fp->num_verts; t++) |
| 3341 | anded &= g3_RotatePoint(&pnt, &rp->verts[fp->face_verts[t]]); |
| 3342 | if (!anded) |
| 3343 | on_screen = 1; |
| 3344 | } |
| 3345 | if (!on_screen) |
| 3346 | do_mirror_face = false; |
| 3347 | } |
| 3348 | if (do_mirror_face) // This room has a mirror...render it first |
| 3349 | { |
| 3350 | Render_mirror_for_room = true; |
| 3351 | Mirror_room = rp - Rooms; |
| 3352 | |
| 3353 | BuildMirroredRoomList(); |
| 3354 | for (int t = Num_mirrored_rooms - 1; t >= 0; t--) |
| 3355 | RenderMirroredRoom(&Rooms[Mirrored_room_list[t]]); |
| 3356 | Render_mirror_for_room = false; |
| 3357 | } |
| 3358 | } |
| 3359 | // Do z buffer trick |
| 3360 | rend_ClearZBuffer(); |
| 3361 | rend_SetZBufferWriteMask(1); |
| 3362 | rend_SetZBufferState(1); |
| 3363 | // Draw mirror faces now |
| 3364 | for (i = 0; i < Num_mirror_rooms; i++) { |
| 3365 | room *rp = &Rooms[Mirror_rooms[i]]; |
| 3366 | face *fp = &rp->faces[rp->mirror_face]; |
| 3367 | g3Point save_points[MAX_VERTS_PER_FACE]; |
no test coverage detected