2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
\r
5 This file is part of GtkRadiant.
\r
7 GtkRadiant is free software; you can redistribute it and/or modify
\r
8 it under the terms of the GNU General Public License as published by
\r
9 the Free Software Foundation; either version 2 of the License, or
\r
10 (at your option) any later version.
\r
12 GtkRadiant is distributed in the hope that it will be useful,
\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 GNU General Public License for more details.
\r
17 You should have received a copy of the GNU General Public License
\r
18 along with GtkRadiant; if not, write to the Free Software
\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
29 #include "mathlib.h"
\r
30 #include "bspfile.h"
\r
34 #ifdef NDEBUG // Don't show in a Release build
\r
35 #pragma warning(disable : 4305) // truncate from double to float
\r
36 #pragma warning(disable : 4244) // conversion from double to float
\r
37 #pragma warning(disable : 4018) // signed/unsigned mismatch
\r
41 #define MAX_PORTALS 32768
\r
43 #define PORTALFILE "PRT1"
\r
45 #define ON_EPSILON 0.1
\r
53 #define MAX_POINTS_ON_WINDING 64
\r
54 #define MAX_POINTS_ON_FIXED_WINDING 12
\r
58 qboolean original; // don't free, it's part of the portal
\r
60 vec3_t points[MAX_POINTS_ON_FIXED_WINDING]; // variable sized
\r
63 winding_t *NewWinding (int points);
\r
64 void FreeWinding (winding_t *w);
\r
65 winding_t *CopyWinding (winding_t *w);
\r
68 typedef enum {stat_none, stat_working, stat_done} vstatus_t;
\r
71 plane_t plane; // normal pointing into neighbor
\r
72 int leaf; // neighbor
\r
74 vec3_t origin; // for fast clip testing
\r
79 byte *portalfront; // [portals], preliminary
\r
80 byte *portalflood; // [portals], intermediate
\r
81 byte *portalvis; // [portals], final
\r
83 int nummightsee; // bit count on portalflood for sort
\r
86 typedef struct seperating_plane_s
\r
88 struct seperating_plane_s *next;
\r
89 plane_t plane; // from portal is on positive side
\r
93 typedef struct passage_s
\r
95 struct passage_s *next;
\r
96 int from, to; // leaf numbers
\r
100 #define MAX_PORTALS_ON_LEAF 128
\r
101 typedef struct leaf_s
\r
104 passage_t *passages;
\r
105 portal_t *portals[MAX_PORTALS_ON_LEAF];
\r
109 typedef struct pstack_s
\r
111 byte mightsee[MAX_PORTALS/8]; // bit string
\r
112 struct pstack_s *next;
\r
114 portal_t *portal; // portal exiting
\r
118 winding_t windings[3]; // source, pass, temp in any order
\r
119 int freewindings[3];
\r
121 plane_t portalplane;
\r
128 pstack_t pstack_head;
\r
133 extern int numportals;
\r
134 extern int portalclusters;
\r
136 extern portal_t *portals;
\r
137 extern leaf_t *leafs;
\r
139 extern int c_portaltest, c_portalpass, c_portalcheck;
\r
140 extern int c_portalskip, c_leafskip;
\r
141 extern int c_vistest, c_mighttest;
\r
142 extern int c_chains;
\r
144 extern byte *vismap, *vismap_p, *vismap_end; // past visfile
\r
146 extern int testlevel;
\r
148 extern byte *uncompressed;
\r
150 extern int leafbytes, leaflongs;
\r
151 extern int portalbytes, portallongs;
\r
154 void LeafFlow (int leafnum);
\r
157 void BasePortalVis (int portalnum);
\r
158 void BetterPortalVis (int portalnum);
\r
159 void PortalFlow (int portalnum);
\r
161 extern portal_t *sorted_portals[MAX_MAP_PORTALS*2];
\r
163 int CountBits (byte *bits, int numbits);
\r
165 //=============================================================================
\r
169 extern char *mapname;
\r