Computes the the mines UVs Faces can now share one lightmap, so this routine goes through and tries to combine as many faces as it can into one lightmap
| 2913 | // Faces can now share one lightmap, so this routine goes through and tries to |
| 2914 | // combine as many faces as it can into one lightmap |
| 2915 | void ComputeAllRoomLightmapUVs(int external) { |
| 2916 | int i, t, k; |
| 2917 | int not_combined = 0; |
| 2918 | |
| 2919 | for (i = 0; i < MAX_ROOMS; i++) { |
| 2920 | if (Rooms[i].used) { |
| 2921 | if (Rooms[i].flags & RF_NO_LIGHT) |
| 2922 | continue; |
| 2923 | |
| 2924 | if (external && !(Rooms[i].flags & RF_EXTERNAL)) |
| 2925 | continue; |
| 2926 | |
| 2927 | if (!external && (Rooms[i].flags & RF_EXTERNAL)) |
| 2928 | continue; |
| 2929 | |
| 2930 | RoomsAlreadyCombined[i] = (uint8_t *)mem_malloc(Rooms[i].num_faces); |
| 2931 | ASSERT(RoomsAlreadyCombined[i]); |
| 2932 | for (k = 0; k < Rooms[i].num_faces; k++) |
| 2933 | RoomsAlreadyCombined[i][k] = 0; |
| 2934 | } |
| 2935 | } |
| 2936 | |
| 2937 | for (i = 0; i < MAX_ROOMS; i++) { |
| 2938 | if (Rooms[i].used) { |
| 2939 | if (Rooms[i].flags & RF_NO_LIGHT) |
| 2940 | continue; |
| 2941 | |
| 2942 | if (external && !(Rooms[i].flags & RF_EXTERNAL)) |
| 2943 | continue; |
| 2944 | |
| 2945 | if (!external && (Rooms[i].flags & RF_EXTERNAL)) |
| 2946 | continue; |
| 2947 | |
| 2948 | for (t = 0; t < Rooms[i].num_faces; t++) { |
| 2949 | if (*(RoomsAlreadyCombined[i] + t) == 0) |
| 2950 | TestLightAdjacency(i, t, external); |
| 2951 | } |
| 2952 | } |
| 2953 | } |
| 2954 | |
| 2955 | // Now build lightmaps for any faces that couldn't be combined |
| 2956 | for (i = 0; i < MAX_ROOMS; i++) { |
| 2957 | if (Rooms[i].used) { |
| 2958 | if (Rooms[i].flags & RF_NO_LIGHT) |
| 2959 | continue; |
| 2960 | |
| 2961 | if (external && !(Rooms[i].flags & RF_EXTERNAL)) |
| 2962 | continue; |
| 2963 | |
| 2964 | if (!external && (Rooms[i].flags & RF_EXTERNAL)) |
| 2965 | continue; |
| 2966 | |
| 2967 | for (t = 0; t < Rooms[i].num_faces; t++) { |
| 2968 | if (!RoomsAlreadyCombined[i][t]) { |
| 2969 | vector verts[MAX_VERTS_PER_FACE * 5]; |
| 2970 | int room_list[2], face_list[2]; |
| 2971 | for (k = 0; k < Rooms[i].faces[t].num_verts; k++) |
| 2972 | verts[k] = Rooms[i].verts[Rooms[i].faces[t].face_verts[k]]; |
no test coverage detected