Take the computed volume spectra of a room and save it in the room struct
| 779 | |
| 780 | // Take the computed volume spectra of a room and save it in the room struct |
| 781 | void AssignVolumeSpectraToRoom(int roomnum) { |
| 782 | ASSERT(Rooms[roomnum].used); |
| 783 | ASSERT(!(Rooms[roomnum].flags & RF_EXTERNAL)); |
| 784 | ASSERT(!(Rooms[roomnum].flags & RF_NO_LIGHT)); |
| 785 | |
| 786 | room *rp = &Rooms[roomnum]; |
| 787 | |
| 788 | int i, t, j; |
| 789 | int w = rp->volume_width; |
| 790 | int h = rp->volume_height; |
| 791 | int d = rp->volume_depth; |
| 792 | |
| 793 | for (i = 0; i < d; i++) { |
| 794 | for (t = 0; t < h; t++) { |
| 795 | for (j = 0; j < w; j++) { |
| 796 | spectra *this_spectra = &Volume_elements[roomnum][(i * w * h) + (t * w) + j].color; |
| 797 | |
| 798 | if (this_spectra->r < 0) { |
| 799 | Int3(); // Shouldn't hit this |
| 800 | rp->volume_lights[(i * w * h) + (t * w) + j] = INVISIBLE_VOLUME_ELEMENT; |
| 801 | } else { |
| 802 | float rmax = GetMaxColor(this_spectra); |
| 803 | |
| 804 | if (rmax > 1.0 && rmax > 0.0) { |
| 805 | this_spectra->r /= rmax; |
| 806 | this_spectra->g /= rmax; |
| 807 | this_spectra->b /= rmax; |
| 808 | } |
| 809 | |
| 810 | int r = (this_spectra->r * 7); |
| 811 | r <<= 5; |
| 812 | int g = (this_spectra->g * 7); |
| 813 | g <<= 2; |
| 814 | int b = (this_spectra->b * 3); |
| 815 | |
| 816 | uint8_t volume_color = r | g | b; |
| 817 | |
| 818 | if (!UseVolumeLights) |
| 819 | rp->volume_lights[(i * w * h) + (t * w) + j] = 255; |
| 820 | else |
| 821 | rp->volume_lights[(i * w * h) + (t * w) + j] = volume_color; |
| 822 | } |
| 823 | } |
| 824 | } |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | // Returns 0 if there are bad faces in this level |
| 829 | int CheckForBadFaces(int roomnum) { |
no test coverage detected