2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
5 This file is part of Quake 2 Tools source code.
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
27 #define MAX_PORTALS 32768
29 #define PORTALFILE "PRT1"
31 #define ON_EPSILON 0.1
39 #define MAX_POINTS_ON_WINDING 64
40 #define MAX_POINTS_ON_FIXED_WINDING 12
44 qboolean original; // don't free, it's part of the portal
46 vec3_t points[MAX_POINTS_ON_FIXED_WINDING]; // variable sized
49 winding_t *NewWinding (int points);
50 void FreeWinding (winding_t *w);
51 winding_t *CopyWinding (winding_t *w);
54 typedef enum {stat_none, stat_working, stat_done} vstatus_t;
57 plane_t plane; // normal pointing into neighbor
60 vec3_t origin; // for fast clip testing
65 byte *portalfront; // [portals], preliminary
66 byte *portalflood; // [portals], intermediate
67 byte *portalvis; // [portals], final
69 int nummightsee; // bit count on portalflood for sort
72 typedef struct seperating_plane_s
74 struct seperating_plane_s *next;
75 plane_t plane; // from portal is on positive side
79 typedef struct passage_s
81 struct passage_s *next;
82 int from, to; // leaf numbers
86 #define MAX_PORTALS_ON_LEAF 128
91 portal_t *portals[MAX_PORTALS_ON_LEAF];
95 typedef struct pstack_s
97 byte mightsee[MAX_PORTALS/8]; // bit string
98 struct pstack_s *next;
100 portal_t *portal; // portal exiting
104 winding_t windings[3]; // source, pass, temp in any order
114 pstack_t pstack_head;
119 extern int numportals;
120 extern int portalclusters;
122 extern portal_t *portals;
123 extern leaf_t *leafs;
125 extern int c_portaltest, c_portalpass, c_portalcheck;
126 extern int c_portalskip, c_leafskip;
127 extern int c_vistest, c_mighttest;
130 extern byte *vismap, *vismap_p, *vismap_end; // past visfile
132 extern int testlevel;
134 extern byte *uncompressed;
136 extern int leafbytes, leaflongs;
137 extern int portalbytes, portallongs;
140 void LeafFlow (int leafnum);
143 void BasePortalVis (int portalnum);
144 void BetterPortalVis (int portalnum);
145 void PortalFlow (int portalnum);
147 extern portal_t *sorted_portals[MAX_MAP_PORTALS*2];
149 int CountBits (byte *bits, int numbits);