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

Function ClearDynamicLightmaps

Descent3/lighting.cpp:1370–1463  ·  view source on GitHub ↗

Clears the used flag for the dynamic lightmaps and restores colors on the terrain

Source from the content-addressed store, hash-verified

1368
1369// Clears the used flag for the dynamic lightmaps and restores colors on the terrain
1370void ClearDynamicLightmaps() {
1371 int i;
1372
1373 // First clear dynamic lightmap list
1374 for (i = 0; i < Num_dynamic_lightmaps; i++)
1375 Dynamic_lightmaps[i].used = 0;
1376
1377 // Reset volume lights
1378 for (i = 0; i < Num_volume_objects; i++) {
1379 object *obj = &Objects[Dynamic_volume_object_list[i].objnum];
1380 if (obj->type == OBJ_NONE || obj->handle != Dynamic_volume_object_list[i].handle)
1381 continue; // object was destroyed this frame
1382
1383 obj->effect_info->type_flags &= ~EF_SPECULAR;
1384 obj->effect_info->dynamic_this_frame = 0;
1385 obj->effect_info->dynamic_red = 0;
1386 obj->effect_info->dynamic_green = 0;
1387 obj->effect_info->dynamic_blue = 0;
1388 }
1389
1390 Num_volume_objects = 0;
1391
1392 // Reset specular faces
1393 for (i = 0; i < Num_specular_faces; i++) {
1394 int n = Specular_face_list[i];
1395 SpecialFaces[n].flags = 0;
1396 // LightmapInfo[n].spec_map=-1;
1397 }
1398
1399 Num_specular_faces = 0;
1400
1401 // Clear diffuse faces
1402 for (i = 0; i < Num_dynamic_faces; i++) {
1403 if (LightmapInfo[Dynamic_face_list[i].lmi_handle].used == 0)
1404 continue; // this face was killed last frame. This can happen with objects
1405
1406 int dynamic_handle = LightmapInfo[Dynamic_face_list[i].lmi_handle].dynamic;
1407 int lmi_handle = Dynamic_face_list[i].lmi_handle;
1408 int lm_handle = LightmapInfo[lmi_handle].lm_handle;
1409 lightmap_info *lmi_ptr = &LightmapInfo[lmi_handle];
1410
1411 uint16_t *src_data = Dynamic_lightmaps[dynamic_handle].mem_ptr;
1412 uint16_t *dest_data = (uint16_t *)lm_data(lm_handle);
1413
1414 int lmw = lm_w(lm_handle);
1415
1416 dest_data += (lmi_ptr->y1 * lmw);
1417
1418 for (int y = 0; y < lmi_ptr->height; y++, dest_data += lmw) {
1419 for (int x = 0; x < lmi_ptr->width; x++) {
1420 dest_data[lmi_ptr->x1 + x] = src_data[y * lmi_ptr->width + x];
1421 }
1422 }
1423
1424 GameLightmaps[lm_handle].flags |= (LF_LIMITS | LF_CHANGED);
1425 LightmapInfo[lmi_handle].dynamic = BAD_LMI_INDEX;
1426 }
1427

Callers 1

GameRenderFrameFunction · 0.85

Calls 4

lm_dataFunction · 0.85
lm_wFunction · 0.85
GR_RGB16Function · 0.85
BlendAllLightingEdgesFunction · 0.85

Tested by

no test coverage detected