From 3232c22795660930619ae3ab3398ce16e5ac1785 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 9 Mar 2013 14:32:51 +0900 Subject: [PATCH] Implement mightsee updates from tyrutils. It doesn't seem to make much difference, but I suspect that's my set code not being optimal for the job. --- tools/qfvis/source/flow.c | 2 -- tools/qfvis/source/qfvis.c | 59 +++++++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/tools/qfvis/source/flow.c b/tools/qfvis/source/flow.c index 9c814d2a9..cc0d6cd60 100644 --- a/tools/qfvis/source/flow.c +++ b/tools/qfvis/source/flow.c @@ -430,6 +430,4 @@ PortalFlow (portal_t *portal) data.pstack_head.mightsee = portal->mightsee; RecursiveClusterFlow (portal->cluster, &data.pstack_head); - - portal->status = stat_done; } diff --git a/tools/qfvis/source/qfvis.c b/tools/qfvis/source/qfvis.c index 12f7069e0..9ddfb4a33 100644 --- a/tools/qfvis/source/qfvis.c +++ b/tools/qfvis/source/qfvis.c @@ -76,6 +76,7 @@ int c_portaltest; int c_portalpass; int c_portalcheck; int c_vistest; +int c_mightseeupdate; int portal_count; int numportals; @@ -278,6 +279,60 @@ GetNextPortal (void) return p; } +static void +UpdateMightsee (cluster_t *source, cluster_t *dest) +{ + int i, clusternum; + portal_t *portal; + + clusternum = dest - clusters; + for (i = 0; i < source->numportals; i++) { + portal = source->portals[i]; + if (portal->status != stat_none) + continue; + if (set_is_member (portal->mightsee, clusternum)) { + set_remove (portal->mightsee, clusternum); + portal->nummightsee--; + c_mightseeupdate++; + } + } +} + +static void +PortalCompleted (portal_t *completed) +{ + portal_t *portal; + cluster_t *cluster; + set_t *changed; + set_iter_t *ci; + int i, j; + + completed->status = stat_done; + LOCK; + changed = set_new_size (portalclusters); + cluster = &clusters[completed->cluster]; + for (i = 0; i < cluster->numportals; i++) { + portal = cluster->portals[i]; + if (portal->status != stat_done) + continue; + set_assign (changed, portal->mightsee); + set_difference (changed, portal->visbits); + for (j = 0; j < cluster->numportals; j++) { + if (j == i) + continue; + if (cluster->portals[j]->status == stat_done) + set_difference (changed, cluster->portals[j]->visbits); + else + set_difference (changed, cluster->portals[j]->mightsee); + } + for (ci = set_first (changed); ci; ci = set_next (ci)) { + UpdateMightsee (&clusters[ci->element], cluster); + } + } + set_delete (changed); + UNLOCK; +} + static void * LeafThread (void *_thread) { @@ -293,6 +348,8 @@ LeafThread (void *_thread) working[thread] = (int) (portal - portals); PortalFlow (portal); + PortalCompleted (portal); + if (options.verbosity > 1) printf ("portal:%5i mightsee:%5i cansee:%5i %5d/%d\n", (int) (portal - portals), @@ -499,7 +556,7 @@ CalcPortalVis (void) if (options.verbosity > 0) { printf ("portalcheck: %i portaltest: %i portalpass: %i\n", c_portalcheck, c_portaltest, c_portalpass); - printf ("c_vistest: %i c_mighttest: %i\n", c_vistest, c_mighttest); + printf ("c_vistest: %i c_mighttest: %i c_mightseeupdate: %i\n", c_vistest, c_mighttest, c_mightseeupdate); } }