Create edge information for the portals.

This commit is contained in:
Bill Currie 2011-11-15 20:21:49 +09:00
parent 662c04dfdc
commit 297275e3de
3 changed files with 25 additions and 2 deletions

View file

@ -123,6 +123,7 @@ typedef struct clipport_s {
struct clipport_s *next[2]; ///< front, back struct clipport_s *next[2]; ///< front, back
struct clipleaf_s *leafs[2]; ///< front, back struct clipleaf_s *leafs[2]; ///< front, back
struct winding_s *winding; struct winding_s *winding;
struct winding_s *edges; ///< unit vectors along edges
} clipport_t; } clipport_t;
typedef struct clipleaf_s { typedef struct clipleaf_s {

View file

@ -171,11 +171,27 @@ nodeleaf_t *
MOD_BuildBrushes (hull_t *hull) MOD_BuildBrushes (hull_t *hull)
{ {
int numnodes = hull->lastclipnode + 1; int numnodes = hull->lastclipnode + 1;
int i, j, side;
nodeleaf_t *nodeleafs; nodeleaf_t *nodeleafs;
clipleaf_t *root; // this will be carved into all the actual leafs clipleaf_t *root; // this will be carved into all the actual leafs
nodeleafs = calloc (numnodes, sizeof (nodeleaf_t)); nodeleafs = calloc (numnodes, sizeof (nodeleaf_t));
root = alloc_leaf (); root = alloc_leaf ();
carve_leaf (hull, nodeleafs, root, hull->firstclipnode); 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; return nodeleafs;
} }

View file

@ -451,8 +451,14 @@ run_test (test_t *test)
portal_list = collect_portals (leaf->portals, portal_list); 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) { if (i != test->expect.num_portals) {
res = 1; res = 1;
printf ("bad portal count: %d %d\n", test->expect.num_portals, i); printf ("bad portal count: %d %d\n", test->expect.num_portals, i);