qbsp: face_t: make contents, lmshifts single sided

side_t: same, also remove contents (unused)
This commit is contained in:
Eric Wasylishen 2022-06-24 01:14:11 -06:00
parent 2452d5edda
commit aabd1c27dc
7 changed files with 15 additions and 20 deletions

View File

@ -34,8 +34,8 @@ struct side_t
int planenum; int planenum;
planeside_t planeside; // which side is the front of the face planeside_t planeside; // which side is the front of the face
int texinfo; int texinfo;
twosided<contentflags_t> contents;
twosided<int16_t> lmshift; int16_t lmshift;
qvec3d origin; qvec3d origin;
vec_t radius; vec_t radius;

View File

@ -334,8 +334,8 @@ struct face_t : face_fragment_t
int planenum; int planenum;
planeside_t planeside; // which side is the front of the face planeside_t planeside; // which side is the front of the face
int texinfo; int texinfo;
twosided<contentflags_t> contents; contentflags_t contents; // contents on the front of the face
twosided<int16_t> lmshift; int16_t lmshift;
qvec3d origin; qvec3d origin;
vec_t radius; vec_t radius;

View File

@ -1014,7 +1014,7 @@ static void Brush_LoadEntity(mapentity_t *dst, const mapentity_t *src, const int
brush->lmshift = lmshift; brush->lmshift = lmshift;
for (auto &face : brush->sides) for (auto &face : brush->sides)
face.lmshift = { (short) lmshift, (short) lmshift }; face.lmshift = lmshift;
if (classname == std::string_view("func_areaportal")) { if (classname == std::string_view("func_areaportal")) {
brush->func_areaportal = const_cast<mapentity_t *>(src); // FIXME: get rid of consts on src in the callers? brush->func_areaportal = const_cast<mapentity_t *>(src); // FIXME: get rid of consts on src in the callers?

View File

@ -142,8 +142,6 @@ face_t *MirrorFace(const face_t *face)
face_t *newface = NewFaceFromFace(face); face_t *newface = NewFaceFromFace(face);
newface->w = face->w.flip(); newface->w = face->w.flip();
newface->planeside = static_cast<planeside_t>(face->planeside ^ 1); newface->planeside = static_cast<planeside_t>(face->planeside ^ 1);
newface->contents.swap();
newface->lmshift.swap();
return newface; return newface;
} }

View File

@ -73,7 +73,7 @@ static void ExportObjFace(std::ofstream &f, const face_t *face, int *vertcount)
} }
// fixme-brushbsp // fixme-brushbsp
fmt::print(f, "usemtl contents{}\n", face->contents[0].native); fmt::print(f, "usemtl contents{}\n", face->contents.native);
f << 'f'; f << 'f';
for (int i = 0; i < face->w.size(); i++) { for (int i = 0; i < face->w.size(); i++) {
// .obj vertexes start from 1 // .obj vertexes start from 1

View File

@ -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 || 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->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; return NULL;
// find a common edge // find a common edge

View File

@ -39,7 +39,7 @@ static bool ShouldOmitFace(face_t *f)
return true; return true;
// HACK: to save a few faces, don't output the interior faces of sky brushes // 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; return true;
} }
@ -81,7 +81,7 @@ std::list<face_t *> SubdivideFace(face_t *f)
// one lightmap block will always be added at the end, for smooth interpolation // 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). // engines that do support scaling will support 256*256 blocks (at whatever scale).
lmshift = f->lmshift[0]; lmshift = f->lmshift;
if (lmshift > 4) if (lmshift > 4)
lmshift = 4; // no bugging out with legacy lighting 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) 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"); FError("Face with invalid contents");
size_t v1 = GetVertex(p1); 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); auto it = hashedges.find(edge_hash_key);
if (it != hashedges.end()) { if (it != hashedges.end()) {
for (const int i : it->second) { 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; pEdgeFaces1[i] = face;
return -i; 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(); mface_t &out = map.bsp.dfaces.emplace_back();
// emit lmshift // 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()); Q_assert(map.bsp.dfaces.size() == map.exported_lmshifts.size());
out.planenum = ExportMapPlane(face->planenum); 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)) if (ShouldOmitFace(f))
return; return;
if (f->lmshift[1] != 4) if (f->lmshift != 4)
map.needslmshifts = true; map.needslmshifts = true;
facesCount++; facesCount++;
@ -632,15 +632,12 @@ static face_t *FaceFromPortal(portal_t *p, int pside)
if (pside) if (pside)
{ {
f->w = p->winding->flip(); f->w = p->winding->flip();
// fixme-brushbsp: was just `f->contents` on qbsp3 f->contents = p->nodes[1]->contents;
f->contents[0] = p->nodes[1]->contents;
f->contents[1] = p->nodes[0]->contents;
} }
else else
{ {
f->w = *p->winding; f->w = *p->winding;
f->contents[0] = p->nodes[0]->contents; f->contents = p->nodes[0]->contents;
f->contents[1] = p->nodes[1]->contents;
} }
UpdateFaceSphere(f); UpdateFaceSphere(f);