MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / GetFreeDynamicLightmap

Function GetFreeDynamicLightmap

Descent3/lighting.cpp:193–214  ·  view source on GitHub ↗

Returns an index into the Dynamic_lightmaps array. Index returned is marked as unused

Source from the content-addressed store, hash-verified

191
192// Returns an index into the Dynamic_lightmaps array. Index returned is marked as unused
193int GetFreeDynamicLightmap(int w, int h) {
194 int total = w * h * 2;
195
196 if (Num_dynamic_lightmaps == MAX_DYNAMIC_LIGHTMAPS)
197 return -1;
198
199 if (total + Cur_dynamic_mem_ptr > DYNAMIC_LIGHTMAP_MEMORY) {
200 mprintf(0, "Ran out of lightmap memory (%d)\n", DYNAMIC_LIGHTMAP_MEMORY);
201 return -1;
202 }
203
204 int n = Num_dynamic_lightmaps++;
205 ASSERT(Dynamic_lightmaps[n].used == 0);
206
207 Dynamic_lightmaps[n].used = 1;
208 Dynamic_lightmaps[n].mem_ptr = &Dynamic_lightmap_memory[Cur_dynamic_mem_ptr / 2];
209 ASSERT(Dynamic_lightmaps[n].mem_ptr);
210
211 Cur_dynamic_mem_ptr += total;
212
213 return n;
214}
215
216// Makes all the edges of dynamic lighting blend into the body of the lightmap
217void BlendLightingEdges(lightmap_info *lmi_ptr) {

Callers 3

ApplyLightingToSubmodelFunction · 0.85
ApplyLightingToRoomsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected