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

Function ClearObjectLightmaps

Descent3/object_lighting.cpp:458–497  ·  view source on GitHub ↗

Frees all the memory associated with this objects lightmap

Source from the content-addressed store, hash-verified

456
457// Frees all the memory associated with this objects lightmap
458void ClearObjectLightmaps(object *obj) {
459 int Mnum, Fnum;
460
461 if (obj->lm_object.used == 1) {
462 obj->lm_object.used = 0;
463 poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num];
464 ASSERT(pm->n_models < MAX_SUBOBJECTS);
465
466 mprintf(1, "CLEAR %d %s", obj->handle, obj->name);
467
468 int faceCount = 0;
469 for (Mnum = 0; Mnum < pm->n_models; Mnum++) {
470 if (!IsNonRenderableSubmodel(pm, Mnum)) {
471 mprintf(1, " %X\n", obj->lm_object.lightmap_faces[Mnum][0].u2);
472 mem_free(obj->lm_object.lightmap_faces[Mnum][0].u2);
473 break;
474 }
475 }
476 for (Mnum = 0; Mnum < pm->n_models; Mnum++) {
477 if (IsNonRenderableSubmodel(pm, Mnum))
478 continue;
479
480 for (Fnum = 0; Fnum < pm->submodel[Mnum].num_faces; Fnum++) {
481 lightmap_object_face *lof = &obj->lm_object.lightmap_faces[Mnum][Fnum];
482
483 if (lof->lmi_handle != BAD_LMI_INDEX) {
484 FreeLightmapInfo(lof->lmi_handle);
485 lof->lmi_handle = BAD_LMI_INDEX;
486 }
487 lof->num_verts = 0;
488 }
489
490 if (obj->lm_object.num_faces[Mnum]) {
491 mem_free(obj->lm_object.lightmap_faces[Mnum]);
492 obj->lm_object.lightmap_faces[Mnum] = NULL;
493 }
494 obj->lm_object.num_faces[Mnum] = 0;
495 }
496 }
497}
498
499// Frees all the memory associated with lightmap objects
500void ClearAllObjectLightmaps(int terrain) {

Callers 4

ClearAllObjectLightmapsFunction · 0.85
ReadObjectFunction · 0.85
ObjDeleteFunction · 0.85

Calls 2

IsNonRenderableSubmodelFunction · 0.85
FreeLightmapInfoFunction · 0.85

Tested by

no test coverage detected