| 729 | } |
| 730 | |
| 731 | void ComputeSurfaceRes(rad_surface *surf, room *rp, int facenum) { |
| 732 | int i; |
| 733 | float left = 1.1f, right = -1, top = 1.1f, bottom = -1; |
| 734 | face *fp = &rp->faces[facenum]; |
| 735 | int lw = lmi_w(fp->lmi_handle); |
| 736 | int lh = lmi_h(fp->lmi_handle); |
| 737 | |
| 738 | for (i = 0; i < fp->num_verts; i++) { |
| 739 | if (fp->face_uvls[i].u2 < left) |
| 740 | left = fp->face_uvls[i].u2; |
| 741 | if (fp->face_uvls[i].u2 > right) |
| 742 | right = fp->face_uvls[i].u2; |
| 743 | if (fp->face_uvls[i].v2 < top) |
| 744 | top = fp->face_uvls[i].v2; |
| 745 | if (fp->face_uvls[i].v2 > bottom) |
| 746 | bottom = fp->face_uvls[i].v2; |
| 747 | } |
| 748 | |
| 749 | float left_result = (left * lw) + .0001; |
| 750 | float right_result = (right * lw) + .0001; |
| 751 | float top_result = (top * lh) + .0001; |
| 752 | float bottom_result = (bottom * lh) + .0001; |
| 753 | |
| 754 | surf->x1 = floor(left_result); |
| 755 | surf->x2 = floor(right_result); |
| 756 | |
| 757 | surf->y1 = floor(top_result); |
| 758 | surf->y2 = floor(bottom_result); |
| 759 | |
| 760 | surf->xresolution = (surf->x2 - surf->x1); |
| 761 | surf->yresolution = (surf->y2 - surf->y1); |
| 762 | |
| 763 | // Adjust for a accuracy errors |
| 764 | if (((right_result) - (float)surf->x2) > .005) |
| 765 | surf->xresolution++; |
| 766 | |
| 767 | if (((bottom_result) - (float)surf->y2) > .005) |
| 768 | surf->yresolution++; |
| 769 | |
| 770 | if (((top_result) - (float)surf->y1) > .99) |
| 771 | surf->y1++; |
| 772 | |
| 773 | if (((left_result) - (float)surf->x1) > .99) |
| 774 | surf->x1++; |
| 775 | |
| 776 | ASSERT((surf->x1 + surf->xresolution) <= lw); |
| 777 | ASSERT((surf->y1 + surf->yresolution) <= lh); |
| 778 | } |
| 779 | |
| 780 | // Take the computed volume spectra of a room and save it in the room struct |
| 781 | void AssignVolumeSpectraToRoom(int roomnum) { |
no test coverage detected