From 297275e3de7baed90bc2c9e6c26f55349202cd29 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 15 Nov 2011 20:21:49 +0900 Subject: [PATCH] Create edge information for the portals. --- include/world.h | 1 + libs/models/portal.c | 16 ++++++++++++++++ libs/models/test/testclip.c | 10 ++++++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/world.h b/include/world.h index 0b9bf1b06..81d053833 100644 --- a/include/world.h +++ b/include/world.h @@ -123,6 +123,7 @@ typedef struct clipport_s { struct clipport_s *next[2]; ///< front, back struct clipleaf_s *leafs[2]; ///< front, back struct winding_s *winding; + struct winding_s *edges; ///< unit vectors along edges } clipport_t; typedef struct clipleaf_s { diff --git a/libs/models/portal.c b/libs/models/portal.c index 21678d5ce..f6d312ff9 100644 --- a/libs/models/portal.c +++ b/libs/models/portal.c @@ -171,11 +171,27 @@ nodeleaf_t * MOD_BuildBrushes (hull_t *hull) { int numnodes = hull->lastclipnode + 1; + int i, j, side; nodeleaf_t *nodeleafs; clipleaf_t *root; // this will be carved into all the actual leafs nodeleafs = calloc (numnodes, sizeof (nodeleaf_t)); root = alloc_leaf (); carve_leaf (hull, nodeleafs, root, hull->firstclipnode); + for (i = 0; i < numnodes; i++) { + for (j = 0; j < 2; j++) { + clipleaf_t *leaf = nodeleafs[i].leafs[j]; + clipport_t *p; + + if (!leaf) + continue; + for (p = leaf->portals; p; p = p->next[side]) { + side = p->leafs[1] == leaf; + if (p->edges) + continue; + p->edges = WindingVectors (p->winding); + } + } + } return nodeleafs; } diff --git a/libs/models/test/testclip.c b/libs/models/test/testclip.c index cbfeb4e34..c9b89276d 100644 --- a/libs/models/test/testclip.c +++ b/libs/models/test/testclip.c @@ -451,8 +451,14 @@ run_test (test_t *test) portal_list = collect_portals (leaf->portals, portal_list); } } - for (i = 0, p = portal_list; p; i++, p = p->next) - ; + for (i = 0, p = portal_list; p; i++, p = p->next) { + if (!p->portal->winding || !p->portal->edges) { + res = 1; + printf ("portal with missing vertex/edge information\n"); + } + } + if (res) + goto nodeleaf_bail; if (i != test->expect.num_portals) { res = 1; printf ("bad portal count: %d %d\n", test->expect.num_portals, i);