diff --git a/include/qbsp/brush.hh b/include/qbsp/brush.hh index d90cc1a5..1cac2765 100644 --- a/include/qbsp/brush.hh +++ b/include/qbsp/brush.hh @@ -34,8 +34,8 @@ struct side_t int planenum; planeside_t planeside; // which side is the front of the face int texinfo; - twosided contents; - twosided lmshift; + + int16_t lmshift; qvec3d origin; vec_t radius; diff --git a/include/qbsp/qbsp.hh b/include/qbsp/qbsp.hh index d6350889..2ea7c86b 100644 --- a/include/qbsp/qbsp.hh +++ b/include/qbsp/qbsp.hh @@ -334,8 +334,8 @@ struct face_t : face_fragment_t int planenum; planeside_t planeside; // which side is the front of the face int texinfo; - twosided contents; - twosided lmshift; + contentflags_t contents; // contents on the front of the face + int16_t lmshift; qvec3d origin; vec_t radius; diff --git a/qbsp/brush.cc b/qbsp/brush.cc index 47b36c71..db96de81 100644 --- a/qbsp/brush.cc +++ b/qbsp/brush.cc @@ -1014,7 +1014,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int brush->lmshift = lmshift; for (auto &face : brush->sides) - face.lmshift = { (short) lmshift, (short) lmshift }; + face.lmshift = lmshift; if (classname == std::string_view("func_areaportal")) { brush->func_areaportal = const_cast(src); // FIXME: get rid of consts on src in the callers? diff --git a/qbsp/csg4.cc b/qbsp/csg4.cc index faee9661..4e6194ea 100644 --- a/qbsp/csg4.cc +++ b/qbsp/csg4.cc @@ -142,8 +142,6 @@ face_t *MirrorFace(const face_t *face) face_t *newface = NewFaceFromFace(face); newface->w = face->w.flip(); newface->planeside = static_cast(face->planeside ^ 1); - newface->contents.swap(); - newface->lmshift.swap(); return newface; } diff --git a/qbsp/exportobj.cc b/qbsp/exportobj.cc index 282b0410..b5e03561 100644 --- a/qbsp/exportobj.cc +++ b/qbsp/exportobj.cc @@ -73,7 +73,7 @@ static void ExportObjFace(std::ofstream &f, const face_t *face, int *vertcount) } // fixme-brushbsp - fmt::print(f, "usemtl contents{}\n", face->contents[0].native); + fmt::print(f, "usemtl contents{}\n", face->contents.native); f << 'f'; for (int i = 0; i < face->w.size(); i++) { // .obj vertexes start from 1 diff --git a/qbsp/merge.cc b/qbsp/merge.cc index af1a8f4d..e76d7abc 100644 --- a/qbsp/merge.cc +++ b/qbsp/merge.cc @@ -70,7 +70,7 @@ static face_t *TryMerge(face_t *f1, face_t *f2) if (!f1->w.size() || !f2->w.size() || f1->planeside != f2->planeside || f1->texinfo != f2->texinfo || /*!f1->contents[0].equals(options.target_game, f2->contents[0]) || !f1->contents[1].equals(options.target_game, f2->contents[1]) || */ - f1->lmshift[0] != f2->lmshift[0] || f1->lmshift[1] != f2->lmshift[1]) + f1->lmshift != f2->lmshift) return NULL; // find a common edge diff --git a/qbsp/surfaces.cc b/qbsp/surfaces.cc index bcb59e7c..a87cb864 100644 --- a/qbsp/surfaces.cc +++ b/qbsp/surfaces.cc @@ -39,7 +39,7 @@ static bool ShouldOmitFace(face_t *f) return true; // HACK: to save a few faces, don't output the interior faces of sky brushes - if (f->contents[0].is_sky(options.target_game)) { + if (f->contents.is_sky(options.target_game)) { return true; } @@ -81,7 +81,7 @@ std::list SubdivideFace(face_t *f) // one lightmap block will always be added at the end, for smooth interpolation // engines that do support scaling will support 256*256 blocks (at whatever scale). - lmshift = f->lmshift[0]; + lmshift = f->lmshift; if (lmshift > 4) lmshift = 4; // no bugging out with legacy lighting @@ -292,7 +292,7 @@ Returns a global edge number, possibly negative to indicate a backwards edge. */ inline size_t GetEdge(mapentity_t *entity, const qvec3d &p1, const qvec3d &p2, const face_t *face) { - if (!face->contents[0].is_valid(options.target_game, false)) + if (!face->contents.is_valid(options.target_game, false)) FError("Face with invalid contents"); size_t v1 = GetVertex(p1); @@ -304,7 +304,7 @@ inline size_t GetEdge(mapentity_t *entity, const qvec3d &p1, const qvec3d &p2, c auto it = hashedges.find(edge_hash_key); if (it != hashedges.end()) { for (const int i : it->second) { - if (pEdgeFaces1[i] == NULL && pEdgeFaces0[i]->contents[0].native == face->contents[0].native) { + if (pEdgeFaces1[i] == NULL && pEdgeFaces0[i]->contents.native == face->contents.native) { pEdgeFaces1[i] = face; return -i; } @@ -392,7 +392,7 @@ static void EmitFaceFragment(mapentity_t *entity, face_t *face, face_fragment_t mface_t &out = map.bsp.dfaces.emplace_back(); // emit lmshift - map.exported_lmshifts.push_back(face->lmshift[1]); + map.exported_lmshifts.push_back(face->lmshift); Q_assert(map.bsp.dfaces.size() == map.exported_lmshifts.size()); out.planenum = ExportMapPlane(face->planenum); @@ -458,7 +458,7 @@ static void CountFace(mapentity_t *entity, face_t *f, size_t &facesCount, size_t if (ShouldOmitFace(f)) return; - if (f->lmshift[1] != 4) + if (f->lmshift != 4) map.needslmshifts = true; facesCount++; @@ -632,15 +632,12 @@ static face_t *FaceFromPortal(portal_t *p, int pside) if (pside) { f->w = p->winding->flip(); - // fixme-brushbsp: was just `f->contents` on qbsp3 - f->contents[0] = p->nodes[1]->contents; - f->contents[1] = p->nodes[0]->contents; + f->contents = p->nodes[1]->contents; } else { f->w = *p->winding; - f->contents[0] = p->nodes[0]->contents; - f->contents[1] = p->nodes[1]->contents; + f->contents = p->nodes[0]->contents; } UpdateFaceSphere(f);