]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/q2map/qvis.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / tools / quake2 / q2map / qvis.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \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
11 \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
16 \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
20 */\r
21 /* Files:\r
22 \r
23 flow.c\r
24 qvis3.c\r
25 \r
26 */\r
27 \r
28 #include "cmdlib.h"\r
29 #include "mathlib.h"\r
30 #include "bspfile.h"\r
31 #include "inout.h"\r
32 \r
33 #ifdef _WIN32\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
38         #endif\r
39 #endif\r
40 \r
41 #define MAX_PORTALS     32768\r
42 \r
43 #define PORTALFILE      "PRT1"\r
44 \r
45 #define ON_EPSILON      0.1\r
46 \r
47 typedef struct\r
48 {\r
49         vec3_t          normal;\r
50         float           dist;\r
51 } plane_t;\r
52 \r
53 #define MAX_POINTS_ON_WINDING   64\r
54 #define MAX_POINTS_ON_FIXED_WINDING     12\r
55 \r
56 typedef struct\r
57 {\r
58         qboolean        original;                       // don't free, it's part of the portal\r
59         int             numpoints;\r
60         vec3_t  points[MAX_POINTS_ON_FIXED_WINDING];                    // variable sized\r
61 } winding_t;\r
62 \r
63 winding_t       *NewWinding (int points);\r
64 void            FreeWinding (winding_t *w);\r
65 winding_t       *CopyWinding (winding_t *w);\r
66 \r
67 \r
68 typedef enum {stat_none, stat_working, stat_done} vstatus_t;\r
69 typedef struct\r
70 {\r
71         plane_t         plane;  // normal pointing into neighbor\r
72         int                     leaf;   // neighbor\r
73         \r
74         vec3_t          origin; // for fast clip testing\r
75         float           radius;\r
76 \r
77         winding_t       *winding;\r
78         vstatus_t       status;\r
79         byte            *portalfront;   // [portals], preliminary\r
80         byte            *portalflood;   // [portals], intermediate\r
81         byte            *portalvis;             // [portals], final\r
82 \r
83         int                     nummightsee;    // bit count on portalflood for sort\r
84 } portal_t;\r
85 \r
86 typedef struct seperating_plane_s\r
87 {\r
88         struct seperating_plane_s *next;\r
89         plane_t         plane;          // from portal is on positive side\r
90 } sep_t;\r
91 \r
92 \r
93 typedef struct passage_s\r
94 {\r
95         struct passage_s        *next;\r
96         int                     from, to;               // leaf numbers\r
97         sep_t                           *planes;\r
98 } passage_t;\r
99 \r
100 #define MAX_PORTALS_ON_LEAF             128\r
101 typedef struct leaf_s\r
102 {\r
103         int                     numportals;\r
104         passage_t       *passages;\r
105         portal_t        *portals[MAX_PORTALS_ON_LEAF];\r
106 } leaf_t;\r
107 \r
108         \r
109 typedef struct pstack_s\r
110 {\r
111         byte            mightsee[MAX_PORTALS/8];                // bit string\r
112         struct pstack_s *next;\r
113         leaf_t          *leaf;\r
114         portal_t        *portal;        // portal exiting\r
115         winding_t       *source;\r
116         winding_t       *pass;\r
117 \r
118         winding_t       windings[3];    // source, pass, temp in any order\r
119         int                     freewindings[3];\r
120 \r
121         plane_t         portalplane;\r
122 } pstack_t;\r
123 \r
124 typedef struct\r
125 {\r
126         portal_t        *base;\r
127         int                     c_chains;\r
128         pstack_t        pstack_head;\r
129 } threaddata_t;\r
130 \r
131 \r
132 \r
133 extern  int                     numportals;\r
134 extern  int                     portalclusters;\r
135 \r
136 extern  portal_t        *portals;\r
137 extern  leaf_t          *leafs;\r
138 \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
143 \r
144 extern  byte    *vismap, *vismap_p, *vismap_end;        // past visfile\r
145 \r
146 extern  int                     testlevel;\r
147 \r
148 extern  byte            *uncompressed;\r
149 \r
150 extern  int             leafbytes, leaflongs;\r
151 extern  int             portalbytes, portallongs;\r
152 \r
153 \r
154 void LeafFlow (int leafnum);\r
155 \r
156 \r
157 void BasePortalVis (int portalnum);\r
158 void BetterPortalVis (int portalnum);\r
159 void PortalFlow (int portalnum);\r
160 \r
161 extern  portal_t        *sorted_portals[MAX_MAP_PORTALS*2];\r
162 \r
163 int CountBits (byte *bits, int numbits);\r
164 \r
165 //=============================================================================\r
166 \r
167 // externs\r
168 \r
169 extern char     *mapname;\r