Debian Codegraph @

tools/quake2/q2map/qvis.h

raw symbols SCIP
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 "globaldefs.h"
29 #include "cmdlib.h"
30 #include "mathlib.h"
31 #include "bspfile.h"
32 #include "inout.h"
33
34 #if GDEF_COMPILER_MSVC
35 #ifdef NDEBUG // Don't show in a Release build
36 #pragma warning(disable : 4305) // truncate from double to float
37 #pragma warning(disable : 4244) // conversion from double to float
38 #pragma warning(disable : 4018) // signed/unsigned mismatch
39 #endif
40 #endif
41
42 #define MAX_PORTALS 32768
43
44 #define PORTALFILE "PRT1"
45
46 #define ON_EPSILON 0.1
47
48 typedef struct
49 {
50 vec3_t normal;
51 float dist;
52 } plane_t;
53
54 #define MAX_POINTS_ON_WINDING 64
55 #define MAX_POINTS_ON_FIXED_WINDING 12
56
57 typedef struct
58 {
59 qboolean original; // don't free, it's part of the portal
60 int numpoints;
61 vec3_t points[MAX_POINTS_ON_FIXED_WINDING]; // variable sized
62 } winding_t;
63
64 winding_t *NewWinding( int points );
65 void FreeWinding( winding_t *w );
66 winding_t *CopyWinding( winding_t *w );
67
68
69 typedef enum {stat_none, stat_working, stat_done} vstatus_t;
70 typedef struct
71 {
72 plane_t plane; // normal pointing into neighbor
73 int leaf; // neighbor
74
75 vec3_t origin; // for fast clip testing
76 float radius;
77
78 winding_t *winding;
79 vstatus_t status;
80 byte *portalfront; // [portals], preliminary
81 byte *portalflood; // [portals], intermediate
82 byte *portalvis; // [portals], final
83
84 int nummightsee; // bit count on portalflood for sort
85 } portal_t;
86
87 typedef struct seperating_plane_s
88 {
89 struct seperating_plane_s *next;
90 plane_t plane; // from portal is on positive side
91 } sep_t;
92
93
94 typedef struct passage_s
95 {
96 struct passage_s *next;
97 int from, to; // leaf numbers
98 sep_t *planes;
99 } passage_t;
100
101 #define MAX_PORTALS_ON_LEAF 128
102 typedef struct leaf_s
103 {
104 int numportals;
105 passage_t *passages;
106 portal_t *portals[MAX_PORTALS_ON_LEAF];
107 } leaf_t;
108
109
110 typedef struct pstack_s
111 {
112 byte mightsee[MAX_PORTALS / 8]; // bit string
113 struct pstack_s *next;
114 leaf_t *leaf;
115 portal_t *portal; // portal exiting
116 winding_t *source;
117 winding_t *pass;
118
119 winding_t windings[3]; // source, pass, temp in any order
120 int freewindings[3];
121
122 plane_t portalplane;
123 } pstack_t;
124
125 typedef struct
126 {
127 portal_t *base;
128 int c_chains;
129 pstack_t pstack_head;
130 } threaddata_t;
131
132
133
134 extern int numportals;
135 extern int portalclusters;
136
137 extern portal_t *portals;
138 extern leaf_t *leafs;
139
140 extern int c_portaltest, c_portalpass, c_portalcheck;
141 extern int c_portalskip, c_leafskip;
142 extern int c_vistest, c_mighttest;
143 extern int c_chains;
144
145 extern byte *vismap, *vismap_p, *vismap_end; // past visfile
146
147 extern int testlevel;
148
149 extern byte *uncompressed;
150
151 extern int leafbytes, leaflongs;
152 extern int portalbytes, portallongs;
153
154
155 void LeafFlow( int leafnum );
156
157
158 void BasePortalVis( int portalnum );
159 void BetterPortalVis( int portalnum );
160 void PortalFlow( int portalnum );
161
162 extern portal_t *sorted_portals[MAX_MAP_PORTALS * 2];
163
164 int CountBits( byte *bits, int numbits );
165
166 //=============================================================================
167
168 // externs
169
170 extern char *mapname;