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

Function TestLightAdjacency

editor/editor_lighting.cpp:2803–2910  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

2801// Given a roomnumber and a face, goes through the entire mine and checks to see
2802// if this face can share a lightmap with any other face
2803int TestLightAdjacency(int roomnum, int facenum, int external) {
2804
2805 int i, t, k;
2806 room *arp = &Rooms[roomnum];
2807 face *afp = &arp->faces[facenum];
2808
2809 vector averts[MAX_VERTS_PER_FACE * 5];
2810 vector bverts[MAX_VERTS_PER_FACE * 5];
2811 vector dest_verts[MAX_VERTS_PER_FACE * 5];
2812
2813 int face_combine_list[MAX_COMBINES];
2814 int room_combine_list[MAX_COMBINES];
2815
2816 ASSERT(roomnum >= 0 && roomnum < MAX_ROOMS);
2817
2818 if (!AllowCombining)
2819 return 0;
2820
2821 // if (GameTextures[afp->tmap].r>0 || GameTextures[afp->tmap].g>0 || GameTextures[afp->tmap].b>0)
2822 // return 0;
2823
2824 // Don't combine portals!
2825 if (afp->portal_num != -1)
2826 return 0;
2827
2828 // Setup our 'base' face
2829
2830 int anv = afp->num_verts;
2831 int total_faces = 1;
2832
2833 room_combine_list[0] = roomnum;
2834 face_combine_list[0] = facenum;
2835
2836 for (i = 0; i < afp->num_verts; i++)
2837 averts[i] = arp->verts[afp->face_verts[i]];
2838
2839StartOver:
2840
2841 // Go through each room and find an adjacent face
2842 for (i = roomnum; i < MAX_ROOMS; i++) {
2843 if (!Rooms[i].used)
2844 continue;
2845
2846 if (Rooms[i].flags & RF_NO_LIGHT)
2847 continue;
2848
2849 if (external && !(Rooms[i].flags & RF_EXTERNAL))
2850 continue;
2851
2852 if (!external && (Rooms[i].flags & RF_EXTERNAL))
2853 continue;
2854
2855 /*if (i!=roomnum) // Only combine faces in the same room
2856 continue;*/
2857
2858 for (t = 0; t < Rooms[i].num_faces; t++) {
2859 if (total_faces >= MAX_COMBINES - 1)
2860 continue;

Callers 1

Calls 2

CombineLightFacesFunction · 0.85
BuildLightmapUVsFunction · 0.85

Tested by

no test coverage detected