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

Function BuildSingleBSPTree

Descent3/bsp.cpp:939–1062  ·  view source on GitHub ↗

Builds a bsp tree for a single room

Source from the content-addressed store, hash-verified

937
938// Builds a bsp tree for a single room
939void BuildSingleBSPTree(int roomnum) {
940 int i, t, k, j, x;
941 int numpolys = 0;
942
943 if (!UseBSP)
944 return;
945
946 // Free up any BSP trees that we might have lying around
947 InitDefaultBSP();
948
949 MineBSP.root = NewBSPNode();
950 ASSERT(MineBSP.root);
951
952 mprintf(0, "Building BSP Tree...\n");
953
954 // Go through the whole mine and add each polygon to the possible BSP
955 // partition list. Don't include portals...
956
957 i = roomnum;
958 bsppolygon *newpoly;
959
960 for (t = 0; t <= Highest_object_index; t++) {
961 object *obj = &Objects[t];
962
963 if (obj->type == OBJ_NONE)
964 continue;
965
966 if (OBJECT_OUTSIDE(obj))
967 continue;
968 if (obj->roomnum != i)
969 continue;
970
971 if (obj->lighting_render_type == LRT_LIGHTMAPS) {
972 poly_model *po = &Poly_models[obj->rtype.pobj_info.model_num];
973 if (!po->new_style)
974 continue;
975
976 for (k = 0; k < po->n_models; k++) {
977 bsp_info *sm = &po->submodel[k];
978
979 if (IsNonRenderableSubmodel(po, k))
980 continue;
981
982 for (j = 0; j < sm->num_faces; j++) {
983 vector world_verts[64];
984 newpoly = NewPolygon(i, t, sm->faces[j].nverts);
985 if (!newpoly) {
986 mprintf(0, "Couldn't get a new polygon!\n");
987 Int3();
988 return;
989 }
990
991 for (x = 0; x < sm->faces[j].nverts; x++)
992 GetObjectPointInWorld(&world_verts[x], obj, k, sm->faces[j].vertnums[x]);
993
994 vector norm;
995
996 vm_GetNormal(&norm, &world_verts[0], &world_verts[1], &world_verts[2]);

Callers 1

Calls 10

InitDefaultBSPFunction · 0.85
NewBSPNodeFunction · 0.85
IsNonRenderableSubmodelFunction · 0.85
NewPolygonFunction · 0.85
GetObjectPointInWorldFunction · 0.85
CalculatePolygonPlaneFunction · 0.85
AddListItemFunction · 0.85
BuildBSPNodeFunction · 0.85
DestroyListFunction · 0.85
vm_GetNormalFunction · 0.50

Tested by

no test coverage detected