From ef613a69a90a36689b4b328345d28af8df2c1ec0 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Thu, 4 Aug 2022 21:34:11 -0600 Subject: [PATCH 1/3] tests: update aabb_contains to account for new behaviour --- tests/test_light.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_light.cc b/tests/test_light.cc index 8866a2a1..cb55709d 100644 --- a/tests/test_light.cc +++ b/tests/test_light.cc @@ -794,11 +794,11 @@ TEST_CASE("aabb_contains", "[mathlib]") { const aabb3f b1(qvec3f(1, 1, 1), qvec3f(10, 10, 10)); - const aabb3f yes1(qvec3f(1, 1, 1), qvec3f(2, 2, 2)); - const aabb3f yes2(qvec3f(9, 9, 9), qvec3f(10, 10, 10)); + const aabb3f yes1(qvec3f(4, 4, 4), qvec3f(15, 15, 15)); + const aabb3f yes2(qvec3f(10, 10, 10), qvec3f(15, 15, 15)); /// just touching at one point (10, 10, 10) - const aabb3f no1(qvec3f(-1, 1, 1), qvec3f(2, 2, 2)); - const aabb3f no2(qvec3f(9, 9, 9), qvec3f(10.5, 10, 10)); + const aabb3f no1(qvec3f(-1, 1, 1), qvec3f(0.5, 10, 10)); + const aabb3f no2(qvec3f(10.5, 1, 1), qvec3f(20, 10, 10)); CHECK(b1.contains(yes1)); CHECK(b1.contains(yes2)); From 84cbd48777393d8ad7b5dcc41184602e1849ddbe Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Thu, 4 Aug 2022 21:37:32 -0600 Subject: [PATCH 2/3] test_qbsp: use "-tjunc rotate" on a face count sensitive test --- tests/test_qbsp.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test_qbsp.cc b/tests/test_qbsp.cc index 70973fc4..6624e469 100644 --- a/tests/test_qbsp.cc +++ b/tests/test_qbsp.cc @@ -854,7 +854,7 @@ TEST_CASE("noclipfaces_mirrorinside", "[testmaps_q1]") TEST_CASE("detail_illusionary_intersecting", "[testmaps_q1]") { - const auto [bsp, bspx, prt] = LoadTestmapQ1("qbsp_detail_illusionary_intersecting.map"); + const auto [bsp, bspx, prt] = LoadTestmapQ1("qbsp_detail_illusionary_intersecting.map", {"-tjunc", "rotate"}); REQUIRE(prt.has_value()); @@ -880,7 +880,7 @@ TEST_CASE("detail_illusionary_intersecting", "[testmaps_q1]") TEST_CASE("detail_illusionary_noclipfaces_intersecting", "[testmaps_q1]") { - const auto [bsp, bspx, prt] = LoadTestmapQ1("qbsp_detail_illusionary_noclipfaces_intersecting.map"); + const auto [bsp, bspx, prt] = LoadTestmapQ1("qbsp_detail_illusionary_noclipfaces_intersecting.map", {"-tjunc", "rotate"}); REQUIRE(prt.has_value()); From c1e52b0d622eeafe7189e799796571843e6717e7 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 5 Aug 2022 01:45:42 -0600 Subject: [PATCH 3/3] qbsp: fix FindPortalSide generating unwanted mirrored inside faces due to the `// see how close the match is` block being uncommented --- qbsp/portals.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/qbsp/portals.cc b/qbsp/portals.cc index 82d8dd38..8a0236d6 100644 --- a/qbsp/portals.cc +++ b/qbsp/portals.cc @@ -790,6 +790,7 @@ static void FindPortalSide(portal_t *p) // bestside[0] is the brushside visible on portal side[0] which is the positive side of the plane, always side_t *bestside[2] = {nullptr, nullptr}; + side_t *exactside[2] = {nullptr, nullptr}; float bestdot = 0; const qbsp_plane_t &p1 = p->onnode->get_plane(); @@ -825,13 +826,14 @@ static void FindPortalSide(portal_t *p) // see which way(s) we want to generate faces - we could be a brush on either side of // the portal, generating either a outward face (common case) or an inward face (liquids) or both. if (generate_outside_face) { - if (!bestside[!j]) { - bestside[!j] = &side; + // since we are iterating the brushes from highest priority (last) to lowest, take the first exactside we find + if (!exactside[!j]) { + exactside[!j] = &side; } } if (generate_inside_face) { - if (!bestside[j]) { - bestside[j] = &side; + if (!exactside[j]) { + exactside[j] = &side; } } @@ -842,12 +844,24 @@ static void FindPortalSide(portal_t *p) double dot = qv::dot(p1.get_normal(), p2.get_normal()); if (dot > bestdot) { bestdot = dot; - bestside[j] = &side; + if (generate_outside_face) { + bestside[!j] = &side; + } + if (generate_inside_face) { + bestside[j] = &side; + } } } } } + // take exact sides over best sides + for (int i = 0; i < 2; ++i) { + if (exactside[i]) { + bestside[i] = exactside[i]; + } + } + if (!bestside[0] && !bestside[1]) logging::print("WARNING: side not found for portal\n");