diff --git a/qbsp/qbsp.c b/qbsp/qbsp.c index a62e4bce..9306f0c9 100644 --- a/qbsp/qbsp.c +++ b/qbsp/qbsp.c @@ -37,7 +37,7 @@ ProcessEntity static void ProcessEntity(mapentity_t *ent, const int hullnum) { - int i, numportals; + int i, numportals, firstface; surface_t *surfs; node_t *nodes; const char *classname; @@ -180,8 +180,9 @@ ProcessEntity(mapentity_t *ent, const int hullnum) } ExportNodePlanes(nodes); - MakeFaceEdges(ent, nodes); - ExportDrawNodes(ent, nodes); + + firstface = MakeFaceEdges(ent, nodes); + ExportDrawNodes(ent, nodes, firstface); } map.cTotal[BSPMODEL]++; diff --git a/qbsp/qbsp.h b/qbsp/qbsp.h index d8120e9c..b569797f 100644 --- a/qbsp/qbsp.h +++ b/qbsp/qbsp.h @@ -653,9 +653,9 @@ surface_t *CSGFaces(const mapentity_t *ent); int PortalizeWorld(const mapentity_t *ent, node_t *headnode, const int hullnum); void TJunc(const mapentity_t *ent, node_t *headnode); node_t *SolidBSP(const mapentity_t *ent, surface_t *surfhead, bool midsplit); -void MakeFaceEdges(mapentity_t *ent, node_t *headnode); +int MakeFaceEdges(mapentity_t *ent, node_t *headnode); void ExportClipNodes(mapentity_t *ent, node_t *headnode, const int hullnum); -void ExportDrawNodes(mapentity_t *ent, node_t *headnode); +void ExportDrawNodes(mapentity_t *ent, node_t *headnode, int firstface); // util.c diff --git a/qbsp/surfaces.c b/qbsp/surfaces.c index 83304743..b742db04 100644 --- a/qbsp/surfaces.c +++ b/qbsp/surfaces.c @@ -436,10 +436,10 @@ CountData_r(mapentity_t *ent, node_t *node) MakeFaceEdges ================ */ -void +int MakeFaceEdges(mapentity_t *ent, node_t *headnode) { - int i; + int i, firstface; void *pTemp; struct lumpdata *surfedges = &ent->lumps[BSPSURFEDGE]; struct lumpdata *edges = &ent->lumps[BSPEDGE]; @@ -475,6 +475,7 @@ MakeFaceEdges(mapentity_t *ent, node_t *headnode) c_tryedges = 0; iNodes = 0; + firstface = map.cTotal[BSPFACE]; MakeFaceEdges_r(ent, headnode); FreeMem(pHashverts, HASHVERT, vertices->count); @@ -502,4 +503,6 @@ MakeFaceEdges(mapentity_t *ent, node_t *headnode) Message(msgProgress, "GrowRegions"); GrowNodeRegion_r(ent, headnode); + + return firstface; } diff --git a/qbsp/writebsp.c b/qbsp/writebsp.c index 9765358d..3fe792a3 100644 --- a/qbsp/writebsp.c +++ b/qbsp/writebsp.c @@ -23,8 +23,6 @@ #include "qbsp.h" #include "wad.h" -static int firstface; - static void ExportNodePlanes_r(node_t *node, int *planemap) { @@ -379,7 +377,7 @@ ExportDrawNodes ================== */ void -ExportDrawNodes(mapentity_t *entity, node_t *headnode) +ExportDrawNodes(mapentity_t *entity, node_t *headnode, int firstface) { int i; dmodel_t *dmodel; @@ -405,7 +403,6 @@ ExportDrawNodes(mapentity_t *entity, node_t *headnode) dmodel->headnode[0] = map.cTotal[BSPNODE]; dmodel->firstface = firstface; dmodel->numfaces = map.cTotal[BSPFACE] - firstface; - firstface = map.cTotal[BSPFACE]; if (headnode->contents < 0) ExportLeaf(entity, headnode); @@ -434,8 +431,6 @@ BeginBSPFile void BeginBSPFile(void) { - firstface = 0; - // First edge must remain unused because 0 can't be negated pWorldEnt->lumps[BSPEDGE].count++; pWorldEnt->lumps[BSPEDGE].index++;