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

Function BuildBSPTree

Descent3/bsp.cpp:780–936  ·  view source on GitHub ↗

Builds a bsp tree for the indoor rooms

Source from the content-addressed store, hash-verified

778
779// Builds a bsp tree for the indoor rooms
780void BuildBSPTree() {
781 int i, t, k, j, x;
782 int numpolys = 0;
783 int check;
784
785 if (!UseBSP)
786 return;
787
788 // Check to see if we even need to build a new tree
789 check = BSPGetMineChecksum();
790
791 if (check == BSPChecksum) {
792 mprintf(0, "BSP tree already built!\n");
793 return; // The BSP tree has already been built for this mine
794 }
795
796 BSPChecksum = check;
797
798 // Free up any BSP trees that we might have lying around
799 InitDefaultBSP();
800
801 MineBSP.root = NewBSPNode();
802 ASSERT(MineBSP.root);
803
804 mprintf(0, "Building BSP Tree...\n");
805
806 mprintf(0, "Adding polygons to tree\n");
807
808 // Go through the whole mine and add each polygon to the possible BSP
809 // partition list. Don't include portals...
810 for (i = 0; i <= Highest_room_index; i++) {
811 bsppolygon *newpoly;
812
813 if (Rooms[i].used == 0 || (Rooms[i].flags & RF_EXTERNAL))
814 continue;
815
816 room *rp = &Rooms[i];
817
818 for (t = rp->objects; (t != -1); t = Objects[t].next) {
819 object *obj = &Objects[t];
820
821 if (obj->type == OBJ_NONE)
822 continue;
823
824 if (OBJECT_OUTSIDE(obj))
825 continue;
826
827 if (obj->lighting_render_type == LRT_LIGHTMAPS) {
828 poly_model *po = &Poly_models[obj->rtype.pobj_info.model_num];
829
830 if (!po->new_style)
831 continue;
832
833 for (k = 0; k < po->n_models; k++) {
834 bsp_info *sm = &po->submodel[k];
835
836 if (IsNonRenderableSubmodel(po, k))
837 continue;

Callers 1

DoRadiosityForRoomsFunction · 0.85

Calls 11

BSPGetMineChecksumFunction · 0.85
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