]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/q2map/qvis.h
set eol-style
[xonotic/netradiant.git] / tools / quake2 / q2map / qvis.h
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 GtkRadiant is distributed in the hope that it will be useful,
13 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.
16
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20 */
21 /* Files:
22
23 flow.c
24 qvis3.c
25
26 */
27
28 #include "cmdlib.h"
29 #include "mathlib.h"
30 #include "bspfile.h"
31 #include "inout.h"
32
33 #ifdef _WIN32
34         #ifdef NDEBUG                                                   // Don't show in a Release build
35                 #pragma warning(disable : 4305)     // truncate from double to float
36                 #pragma warning(disable : 4244)     // conversion from double to float
37                 #pragma warning(disable : 4018)     // signed/unsigned mismatch
38         #endif
39 #endif
40
41 #define MAX_PORTALS     32768
42
43 #define PORTALFILE      "PRT1"
44
45 #define ON_EPSILON      0.1
46
47 typedef struct
48 {
49         vec3_t          normal;
50         float           dist;
51 } plane_t;
52
53 #define MAX_POINTS_ON_WINDING   64
54 #define MAX_POINTS_ON_FIXED_WINDING     12
55
56 typedef struct
57 {
58         qboolean        original;                       // don't free, it's part of the portal
59         int             numpoints;
60         vec3_t  points[MAX_POINTS_ON_FIXED_WINDING];                    // variable sized
61 } winding_t;
62
63 winding_t       *NewWinding (int points);
64 void            FreeWinding (winding_t *w);
65 winding_t       *CopyWinding (winding_t *w);
66
67
68 typedef enum {stat_none, stat_working, stat_done} vstatus_t;
69 typedef struct
70 {
71         plane_t         plane;  // normal pointing into neighbor
72         int                     leaf;   // neighbor
73         
74         vec3_t          origin; // for fast clip testing
75         float           radius;
76
77         winding_t       *winding;
78         vstatus_t       status;
79         byte            *portalfront;   // [portals], preliminary
80         byte            *portalflood;   // [portals], intermediate
81         byte            *portalvis;             // [portals], final
82
83         int                     nummightsee;    // bit count on portalflood for sort
84 } portal_t;
85
86 typedef struct seperating_plane_s
87 {
88         struct seperating_plane_s *next;
89         plane_t         plane;          // from portal is on positive side
90 } sep_t;
91
92
93 typedef struct passage_s
94 {
95         struct passage_s        *next;
96         int                     from, to;               // leaf numbers
97         sep_t                           *planes;
98 } passage_t;
99
100 #define MAX_PORTALS_ON_LEAF             128
101 typedef struct leaf_s
102 {
103         int                     numportals;
104         passage_t       *passages;
105         portal_t        *portals[MAX_PORTALS_ON_LEAF];
106 } leaf_t;
107
108         
109 typedef struct pstack_s
110 {
111         byte            mightsee[MAX_PORTALS/8];                // bit string
112         struct pstack_s *next;
113         leaf_t          *leaf;
114         portal_t        *portal;        // portal exiting
115         winding_t       *source;
116         winding_t       *pass;
117
118         winding_t       windings[3];    // source, pass, temp in any order
119         int                     freewindings[3];
120
121         plane_t         portalplane;
122 } pstack_t;
123
124 typedef struct
125 {
126         portal_t        *base;
127         int                     c_chains;
128         pstack_t        pstack_head;
129 } threaddata_t;
130
131
132
133 extern  int                     numportals;
134 extern  int                     portalclusters;
135
136 extern  portal_t        *portals;
137 extern  leaf_t          *leafs;
138
139 extern  int                     c_portaltest, c_portalpass, c_portalcheck;
140 extern  int                     c_portalskip, c_leafskip;
141 extern  int                     c_vistest, c_mighttest;
142 extern  int                     c_chains;
143
144 extern  byte    *vismap, *vismap_p, *vismap_end;        // past visfile
145
146 extern  int                     testlevel;
147
148 extern  byte            *uncompressed;
149
150 extern  int             leafbytes, leaflongs;
151 extern  int             portalbytes, portallongs;
152
153
154 void LeafFlow (int leafnum);
155
156
157 void BasePortalVis (int portalnum);
158 void BetterPortalVis (int portalnum);
159 void PortalFlow (int portalnum);
160
161 extern  portal_t        *sorted_portals[MAX_MAP_PORTALS*2];
162
163 int CountBits (byte *bits, int numbits);
164
165 //=============================================================================
166
167 // externs
168
169 extern char     *mapname;