Merge branch 'brushbsp-plane3-bevel' of https://github.com/ericwa/ericw-tools into brushbsp-plane3-bevel

This commit is contained in:
Jonathan 2022-08-05 06:59:45 -04:00
commit c611153b78
3 changed files with 25 additions and 11 deletions

View File

@ -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");

View File

@ -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));

View File

@ -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());