Calculates radiosity for the outdoor surfaces
| 1817 | |
| 1818 | // Calculates radiosity for the outdoor surfaces |
| 1819 | void DoRadiosityForTerrain() { |
| 1820 | int i, t, raynum = 0; |
| 1821 | int extra_surfaces = 0, total_surfaces = 0; |
| 1822 | int surf_index = 0; |
| 1823 | spectra *terrain_sums[2]; |
| 1824 | int room_surf_start, obj_surf_start; |
| 1825 | |
| 1826 | int do_dynamic = 0; |
| 1827 | int lit = 0; |
| 1828 | |
| 1829 | // First make sure there is even a light source |
| 1830 | for (i = 0; i < Terrain_sky.num_satellites; i++) { |
| 1831 | int tmap = Terrain_sky.satellite_texture[i]; |
| 1832 | if (Terrain_sky.satellite_r[i] > 0 || Terrain_sky.satellite_g[i] > 0 || Terrain_sky.satellite_b[i] > 0) |
| 1833 | lit = 1; |
| 1834 | } |
| 1835 | |
| 1836 | if (!lit) { |
| 1837 | OutrageMessageBox("No moons/suns cast light so there is no point in running terrain radiosity!"); |
| 1838 | return; |
| 1839 | } |
| 1840 | |
| 1841 | for (i = 0; i < Terrain_sky.num_satellites; i++) { |
| 1842 | TerrainLightSpeedup[i] = (uint8_t *)mem_malloc(TERRAIN_WIDTH * TERRAIN_DEPTH); |
| 1843 | ASSERT(TerrainLightSpeedup[i]); |
| 1844 | } |
| 1845 | |
| 1846 | if ((MessageBox(NULL, |
| 1847 | "Do you wish to calculate dynamic terrain lighting when radiosity is completed? (Note: Dynamic " |
| 1848 | "lighting takes a long time)", |
| 1849 | "Question", MB_YESNO)) == IDYES) |
| 1850 | do_dynamic = 1; |
| 1851 | |
| 1852 | if (!Ignore_terrain) |
| 1853 | ComputeTerrainSpeedTable(); |
| 1854 | |
| 1855 | extra_surfaces += Terrain_sky.num_satellites; |
| 1856 | extra_surfaces += GetTotalObjectFaces(1); |
| 1857 | |
| 1858 | // Get our external rooms ready |
| 1859 | ClearAllRoomLightmaps(1); |
| 1860 | ComputeAllRoomLightmapUVs(1); |
| 1861 | |
| 1862 | // count how many faces we'll need |
| 1863 | for (i = 0; i < MAX_ROOMS; i++) { |
| 1864 | if (Rooms[i].used && (Rooms[i].flags & RF_EXTERNAL)) |
| 1865 | extra_surfaces += Rooms[i].num_faces; |
| 1866 | } |
| 1867 | |
| 1868 | if (!Ignore_terrain) |
| 1869 | total_surfaces = ((AREA_X) * (AREA_Z) * 2); |
| 1870 | total_surfaces += extra_surfaces; |
| 1871 | |
| 1872 | // Get our object lightmaps ready |
| 1873 | ClearAllObjectLightmaps(1); |
| 1874 | |
| 1875 | // Allocate memory |
| 1876 | terrain_sums[0] = (spectra *)mem_malloc(TERRAIN_WIDTH * TERRAIN_DEPTH * sizeof(spectra)); |
no test coverage detected