From c94d44ae61c4e3e18d88a0f49bf7957cc0c69f1a Mon Sep 17 00:00:00 2001 From: Erika Date: Mon, 7 Aug 2023 20:32:07 +0100 Subject: [PATCH] possible alternate fix for #261 Eric: gmsp3v2.bsp vis: 51.96s -> 18.57s (32 threads) --- vis/flow.cc | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/vis/flow.cc b/vis/flow.cc index 39b704d9..711f23d8 100644 --- a/vis/flow.cc +++ b/vis/flow.cc @@ -388,29 +388,42 @@ static void BasePortalThread(size_t portalnum) if (d < -tw.radius) continue; + int cctp = 0; size_t j; for (j = 0; j < tw.size(); j++) { d = p.plane.distance_to(tw[j]); - if (d > -VIS_ON_EPSILON) // ericw -- changed from > ON_EPSILON for - // https://github.com/ericwa/ericw-tools/issues/261 + cctp += d > -VIS_ON_EPSILON; + if (d > VIS_ON_EPSILON) break; } - if (j == tw.size()) - continue; // no points on front + if (j == tw.size()) { + if (cctp != tw.size()) + continue; // no points on front + } else + cctp = 0; // Quick test - completely on front? d = tp.plane.distance_to(w.origin); if (d > w.radius) continue; + int ccp = 0; for (j = 0; j < w.size(); j++) { d = tp.plane.distance_to(w[j]); - if (d < VIS_ON_EPSILON) // ericw -- changed from < -ON_EPSILON for - // https://github.com/ericwa/ericw-tools/issues/261 + ccp += d < VIS_ON_EPSILON; + if (d < -VIS_ON_EPSILON) break; } - if (j == w.size()) - continue; // no points on back + if (j == w.size()) { + if (ccp != w.size()) + continue; // no points on back + } else + ccp = 0; + + // coplanarity check + if (cctp != 0 || ccp != 0) + if (qv::dot(p.plane.normal, tp.plane.normal) < -0.99) + continue; if (vis_options.visdist.value() > 0) { if (tp.winding->distFromPortal(p) > vis_options.visdist.value() ||