diff --git a/include/qbsp/qbsp.hh b/include/qbsp/qbsp.hh index 26378411..3a57110b 100644 --- a/include/qbsp/qbsp.hh +++ b/include/qbsp/qbsp.hh @@ -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 { diff --git a/qbsp/portals.cc b/qbsp/portals.cc index ade67ad6..eec6ff8e 100644 --- a/qbsp/portals.cc +++ b/qbsp/portals.cc @@ -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; - } -} + } + } } } diff --git a/qbsp/qbsp.cc b/qbsp/qbsp.cc index 609da121..b71bcb3d 100644 --- a/qbsp/qbsp.cc +++ b/qbsp/qbsp.cc @@ -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();