| 474 | } |
| 475 | |
| 476 | void DrawRadiosityPoly(int nv, g3Point **pointlist, int id) { |
| 477 | int i; |
| 478 | g3Codes cc; |
| 479 | bool was_clipped = 0; |
| 480 | int triangulate = 1; |
| 481 | |
| 482 | ASSERT(id >= 0 && id <= rad_NumElements); |
| 483 | |
| 484 | if (triangulate) { |
| 485 | if (nv > 3) { |
| 486 | g3Point *tripoints[3]; |
| 487 | |
| 488 | tripoints[0] = pointlist[0]; |
| 489 | tripoints[2] = pointlist[1]; |
| 490 | |
| 491 | for (i = 0; i < nv - 2; i++) { |
| 492 | tripoints[1] = tripoints[2]; |
| 493 | tripoints[2] = pointlist[2 + i]; |
| 494 | DrawRadiosityPoly(3, tripoints, id); |
| 495 | } |
| 496 | |
| 497 | return; |
| 498 | } |
| 499 | } |
| 500 | |
| 501 | // Initialize |
| 502 | cc.cc_or = 0; |
| 503 | cc.cc_and = 0xff; |
| 504 | |
| 505 | // Get codes for this polygon, and copy uvls into points |
| 506 | for (i = 0; i < nv; i++) { |
| 507 | uint8_t c; |
| 508 | |
| 509 | c = pointlist[i]->p3_codes; |
| 510 | |
| 511 | cc.cc_and &= c; |
| 512 | cc.cc_or |= c; |
| 513 | } |
| 514 | |
| 515 | // All points off grid? |
| 516 | if (cc.cc_and) |
| 517 | return; |
| 518 | |
| 519 | // One or more point off screen, so clip |
| 520 | if (cc.cc_or) { |
| 521 | |
| 522 | // Clip the polygon, getting pointer to new buffer |
| 523 | pointlist = g3_ClipPolygon(pointlist, &nv, &cc); |
| 524 | |
| 525 | // Flag as clipped so temp points will be freed |
| 526 | was_clipped = 1; |
| 527 | |
| 528 | // Check for polygon clipped away, or clip otherwise failed |
| 529 | if ((nv == 0) || (cc.cc_or & CC_BEHIND) || cc.cc_and) |
| 530 | goto free_points; |
| 531 | } |
| 532 | |
| 533 | // Make list of 2d coords |
no test coverage detected