From 74e1a0f6f02a2a469ebf6d7c05c175096cfe01a3 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 24 Mar 2019 20:46:27 -0600 Subject: [PATCH] vis: fix for microleafs blocking vis Fixes #261 --- vis/flow.cc | 11 +++++++---- vis/vis.cc | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/vis/flow.cc b/vis/flow.cc index d5060790..85dd94ce 100644 --- a/vis/flow.cc +++ b/vis/flow.cc @@ -168,8 +168,11 @@ RecursiveLeafFlow(int leafnum, threaddata_t *thread, pstack_t *prevstack) */ err = CheckStack(leaf, thread); if (err) { - logprint("WARNING: %s: recursion on leaf %d\n", __func__, leafnum); - LogLeaf(leaf); + // ericw -- this seems harmless and the fix for https://github.com/ericwa/ericw-tools/issues/261 + // causes it to happen a lot. + + //logprint("WARNING: %s: recursion on leaf %d\n", __func__, leafnum); + //LogLeaf(leaf); return; } @@ -457,7 +460,7 @@ BasePortalThread(void *dummy) for (j = 0; j < tw->numpoints; j++) { d = DotProduct(tw->points[j], p->plane.normal) - p->plane.dist; - if (d > ON_EPSILON) + if (d > -ON_EPSILON) // ericw -- changed from > ON_EPSILON for https://github.com/ericwa/ericw-tools/issues/261 break; } if (j == tw->numpoints) @@ -470,7 +473,7 @@ BasePortalThread(void *dummy) for (j = 0; j < w->numpoints; j++) { d = DotProduct(w->points[j], tp->plane.normal) - tp->plane.dist; - if (d < -ON_EPSILON) + if (d < ON_EPSILON) // ericw -- changed from < -ON_EPSILON for https://github.com/ericwa/ericw-tools/issues/261 break; } if (j == w->numpoints) diff --git a/vis/vis.cc b/vis/vis.cc index 672274de..a61b9c2d 100644 --- a/vis/vis.cc +++ b/vis/vis.cc @@ -283,6 +283,12 @@ ClipStackWinding(winding_t *in, pstack_t *stack, plane_t *split) sides[i] = sides[0]; dists[i] = dists[0]; + // ericw -- coplanar portals: return without clipping. Otherwise when two portals are less than ON_EPSILON apart, + // one will get fully clipped away and we can't see through it causing https://github.com/ericwa/ericw-tools/issues/261 + if (counts[SIDE_ON] == in->numpoints) { + return in; + } + if (!counts[0]) { FreeStackWinding(in, stack); return NULL; @@ -654,8 +660,12 @@ ClusterFlow(int clusternum, leafbits_t *buffer) for (j = 0; j < numblocks; j++) buffer->bits[j] |= p->visbits->bits[j]; } - if (TestLeafBit(buffer, clusternum)) - logprint("WARNING: Leaf portals saw into cluster (%i)\n", clusternum); + + // ericw -- this seems harmless and the fix for https://github.com/ericwa/ericw-tools/issues/261 + // causes it to happen a lot. + //if (TestLeafBit(buffer, clusternum)) + // logprint("WARNING: Leaf portals saw into cluster (%i)\n", clusternum); + SetLeafBit(buffer, clusternum); /*