add optional vertex snapping to match qbsp3

This commit is contained in:
Jonathan 2022-07-28 03:56:12 -04:00
parent 3fc6225fee
commit 64cd39c229
3 changed files with 31 additions and 4 deletions

View File

@ -286,6 +286,7 @@ public:
[](setting_int32 &setting) {
return setting.value() == 0 || setting.value() >= 3;
}, this, "maxedges", 64, &map_development_group, "the max number of edges/vertices on a single face before it is split into another face"};
setting_invertible_bool snapvertices{this, "snapvertices", false, &common_format_group, "round vertice locations; this is mainly for compatibility with older Quake II tools."};
void setParameters(int argc, const char **argv) override
{

View File

@ -744,6 +744,7 @@ static void FindPortalSide(portal_t *p)
if (!(generate_outside_face || generate_inside_face)) {
continue;
}
for (auto &side : brush->sides)
{
if (side.bevel)
@ -762,7 +763,7 @@ static void FindPortalSide(portal_t *p)
if (generate_outside_face) {
if (!bestside[!j]) {
bestside[!j] = &side;
}
}
}
if (generate_inside_face) {
if (!bestside[j]) {
@ -780,9 +781,9 @@ static void FindPortalSide(portal_t *p)
// bestdot = dot;
// bestside[j] = &side;
// }
}
}
}
}
if (!bestside[0] && !bestside[1])
logging::print("WARNING: side not found for portal\n");
@ -824,8 +825,8 @@ static void MarkVisibleSides_r(node_t *node)
for (int i = 0; i < 2; ++i) {
if (p->sides[i]) {
p->sides[i]->visible = true;
}
}
}
}
}
}

View File

@ -1032,6 +1032,28 @@ static void LoadSecondaryTextures()
LoadTextureData();
}
/*
=================
SnapVertices
If specified, rounds all of the vertex locations to integers.
=================
*/
static void SnapVertices()
{
if (!qbsp_options.snapvertices.value()) {
return;
}
logging::print(logging::flag::PROGRESS, "---- {} ----\n", __func__);
for (auto &v : map.bsp.dvertexes) {
for (auto &vv : v) {
vv = floor(vv);
}
}
}
/*
=================
ProcessFile
@ -1070,6 +1092,9 @@ void ProcessFile()
// create hulls!
CreateHulls();
// snap vertices
SnapVertices();
WriteEntitiesToString();
BSPX_CreateBrushList();
FinishBSPFile();