From c55112b47f29f2ccfe2760b33f9c42ffd2da87df Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Mon, 23 Aug 2021 23:18:43 -0600 Subject: [PATCH] qbsp: refactor lmshifts lump export --- include/qbsp/map.hh | 4 ++++ qbsp/surfaces.cc | 19 +++++-------------- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/include/qbsp/map.hh b/include/qbsp/map.hh index 35a9a4a6..dce8291f 100644 --- a/include/qbsp/map.hh +++ b/include/qbsp/map.hh @@ -170,6 +170,10 @@ typedef struct mapdata_s { std::string exported_entities; std::string exported_texdata; + // bspx data + std::vector exported_lmshifts; + bool needslmshifts = false; + // helpers std::string texinfoTextureName(int texinfo) const { int mt = mtexinfos.at(texinfo).miptex; diff --git a/qbsp/surfaces.cc b/qbsp/surfaces.cc index 3127f194..9d9da2aa 100644 --- a/qbsp/surfaces.cc +++ b/qbsp/surfaces.cc @@ -23,8 +23,6 @@ #include #include -static int needlmshifts; - /* =============== SubdivideFace @@ -391,7 +389,6 @@ EmitFace static void EmitFace(mapentity_t *entity, face_t *face) { - struct lumpdata *lmshifts = &entity->lumps[BSPX_LMSHIFT]; bsp29_dface_t *out; int i; @@ -403,11 +400,10 @@ EmitFace(mapentity_t *entity, face_t *face) face->outputnumber = static_cast(map.exported_faces.size()); map.exported_faces.push_back({}); - if (lmshifts->data) { - const int localfacenumber = face->outputnumber - entity->firstoutputfacenumber; - ((unsigned char*)lmshifts->data)[localfacenumber] = face->lmshift[1]; - } - + // emit lmshift + map.exported_lmshifts.push_back(face->lmshift[1]); + Q_assert(map.exported_faces.size() == map.exported_lmshifts.size()); + out = &map.exported_faces.at(face->outputnumber); out->planenum = ExportMapPlane(face->planenum); out->side = face->planeside; @@ -459,7 +455,7 @@ CountFace(mapentity_t *entity, face_t *f, int *facesCount, int *vertexesCount) return; if (f->lmshift[1] != 4) - needlmshifts = true; + map.needslmshifts = true; (*facesCount)++; (*vertexesCount) += f->w.numpoints; @@ -499,8 +495,6 @@ MakeFaceEdges(mapentity_t *entity, node_t *headnode) Message(msgProgress, "MakeFaceEdges"); - needlmshifts = false; - Q_assert(entity->firstoutputfacenumber == -1); entity->firstoutputfacenumber = static_cast(map.exported_faces.size()); @@ -517,9 +511,6 @@ MakeFaceEdges(mapentity_t *entity, node_t *headnode) pEdgeFaces0.clear(); pEdgeFaces1.clear(); - lmshifts->count = needlmshifts?facesCount:0; - lmshifts->data = needlmshifts?AllocMem(OTHER, sizeof(uint8_t) * lmshifts->count, true):NULL; - Message(msgProgress, "GrowRegions"); GrowNodeRegion(entity, headnode);