For rendering...combines all portals if they are on the same plane
| 320 | |
| 321 | // For rendering...combines all portals if they are on the same plane |
| 322 | void CheckCombinePortals(int terrain) { |
| 323 | ClearCombinePortals(terrain); |
| 324 | |
| 325 | int combine_count = 0; |
| 326 | mprintf(0, "Combining portals..."); |
| 327 | |
| 328 | for (int i = 0; i <= Highest_room_index; i++) { |
| 329 | room *rp = &Rooms[i]; |
| 330 | |
| 331 | if (!rp->used) |
| 332 | continue; |
| 333 | |
| 334 | if (terrain && !(rp->flags & RF_EXTERNAL)) |
| 335 | continue; |
| 336 | |
| 337 | if (!terrain && (rp->flags & RF_EXTERNAL)) |
| 338 | continue; |
| 339 | |
| 340 | for (int t = 0; t < rp->num_portals; t++) { |
| 341 | portal *portal_a = &rp->portals[t]; |
| 342 | face *face_a = &rp->faces[portal_a->portal_face]; |
| 343 | |
| 344 | if (portal_a->flags & PF_COMBINED) |
| 345 | continue; |
| 346 | |
| 347 | // Don't combine if face is breakable |
| 348 | if (GameTextures[face_a->tmap].flags & TF_BREAKABLE) |
| 349 | continue; |
| 350 | |
| 351 | float dist_a = vm_DotProduct(&rp->verts[face_a->face_verts[0]], &face_a->normal); |
| 352 | |
| 353 | for (int k = 0; k < rp->num_portals; k++) { |
| 354 | portal *portal_b = &rp->portals[k]; |
| 355 | face *face_b = &rp->faces[portal_b->portal_face]; |
| 356 | |
| 357 | if (portal_b->flags & PF_COMBINED) |
| 358 | continue; |
| 359 | |
| 360 | // Don't combine if one portal is render-faces and the other is not |
| 361 | if ((portal_a->flags & PF_RENDER_FACES) != (portal_b->flags & PF_RENDER_FACES)) |
| 362 | continue; |
| 363 | |
| 364 | // Don't combine if face is breakable |
| 365 | if (GameTextures[face_b->tmap].flags & TF_BREAKABLE) |
| 366 | continue; |
| 367 | |
| 368 | if (t == k) |
| 369 | continue; |
| 370 | |
| 371 | // Check to see if the portals connect to the same room |
| 372 | if (portal_a->croom != portal_b->croom) |
| 373 | continue; |
| 374 | |
| 375 | /*// Check to see if they share a normal |
| 376 | float dp=vm_DotProduct (&face_a->normal,&face_b->normal); |
| 377 | |
| 378 | if (dp < .95f) |
| 379 | continue; |
no test coverage detected