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

Function TestObjectLightAdjacency

editor/editor_object_lighting.cpp:846–943  ·  view source on GitHub ↗

Given a submodel and a face, goes through the entire object and checks to see if this face can share a lightmap with any other face

Source from the content-addressed store, hash-verified

844// Given a submodel and a face, goes through the entire object and checks to see
845// if this face can share a lightmap with any other face
846int TestObjectLightAdjacency(object *obj, int subnum, int facenum, int lmi_type) {
847 int i, t, k;
848 poly_model *pm = &Poly_models[obj->rtype.pobj_info.model_num];
849 bsp_info *a_sm = &pm->submodel[subnum];
850 polyface *afp = &a_sm->faces[facenum];
851 vector anormal;
852
853 vector averts[MAX_VERTS_PER_FACE * 5];
854 vector bverts[MAX_VERTS_PER_FACE * 5];
855 vector dest_verts[MAX_VERTS_PER_FACE * 5];
856
857 int face_combine_list[MAX_COMBINES];
858 int submodel_combine_list[MAX_COMBINES];
859
860 if (afp->texnum == -1)
861 return 0;
862 int tex = pm->textures[afp->texnum];
863
864 if (GameTextures[tex].r > 0 || GameTextures[tex].g > 0 || GameTextures[tex].b > 0)
865 return 0;
866
867 // Setup our 'base' face
868
869 int anv = afp->nverts;
870 int total_faces = 1;
871
872 submodel_combine_list[0] = subnum;
873 face_combine_list[0] = facenum;
874
875 for (i = 0; i < afp->nverts; i++)
876 GetObjectPointInWorld(&averts[i], obj, subnum, afp->vertnums[i]);
877 vm_GetNormal(&anormal, &averts[0], &averts[1], &averts[2]);
878
879StartOver:
880
881 // Go through each room and find an adjacent face
882 for (i = 0; i < pm->n_models; i++) {
883 bsp_info *bsm = &pm->submodel[i];
884
885 if (IsNonRenderableSubmodel(pm, i))
886 continue;
887
888 if (bsm != a_sm) // only combine faces in the same submodel
889 continue;
890
891 for (t = 0; t < bsm->num_faces; t++) {
892 if (total_faces >= MAX_COMBINES - 1)
893 continue;
894
895 if (bsm == a_sm && t == facenum)
896 continue; // don't do self
897
898 // Don't do if already spoken fore
899 if (ObjectsAlreadyCombined[i][t])
900 continue;
901
902 polyface *bfp = &bsm->faces[t];
903 vector bnormal;

Callers 1

CombineObjectLightmapUVsFunction · 0.85

Calls 5

GetObjectPointInWorldFunction · 0.85
IsNonRenderableSubmodelFunction · 0.85
CombineLightFacesFunction · 0.85
BuildObjectLightmapUVsFunction · 0.85
vm_GetNormalFunction · 0.50

Tested by

no test coverage detected