]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/extra/bsp/qvis3/vis.h
Q2Tools source - didn't import this in initially
[xonotic/netradiant.git] / tools / quake2 / extra / bsp / qvis3 / vis.h
1 /*
2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
4
5 This file is part of Quake 2 Tools source code.
6
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.
11
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.
16
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 ===========================================================================
21 */
22
23 #include "cmdlib.h"
24 #include "mathlib.h"
25 #include "bspfile.h"
26
27 #define MAX_PORTALS     32768
28
29 #define PORTALFILE      "PRT1"
30
31 #define ON_EPSILON      0.1
32
33 typedef struct
34 {
35         vec3_t          normal;
36         float           dist;
37 } plane_t;
38
39 #define MAX_POINTS_ON_WINDING   64
40 #define MAX_POINTS_ON_FIXED_WINDING     12
41
42 typedef struct
43 {
44         qboolean        original;                       // don't free, it's part of the portal
45         int             numpoints;
46         vec3_t  points[MAX_POINTS_ON_FIXED_WINDING];                    // variable sized
47 } winding_t;
48
49 winding_t       *NewWinding (int points);
50 void            FreeWinding (winding_t *w);
51 winding_t       *CopyWinding (winding_t *w);
52
53
54 typedef enum {stat_none, stat_working, stat_done} vstatus_t;
55 typedef struct
56 {
57         plane_t         plane;  // normal pointing into neighbor
58         int                     leaf;   // neighbor
59         
60         vec3_t          origin; // for fast clip testing
61         float           radius;
62
63         winding_t       *winding;
64         vstatus_t       status;
65         byte            *portalfront;   // [portals], preliminary
66         byte            *portalflood;   // [portals], intermediate
67         byte            *portalvis;             // [portals], final
68
69         int                     nummightsee;    // bit count on portalflood for sort
70 } portal_t;
71
72 typedef struct seperating_plane_s
73 {
74         struct seperating_plane_s *next;
75         plane_t         plane;          // from portal is on positive side
76 } sep_t;
77
78
79 typedef struct passage_s
80 {
81         struct passage_s        *next;
82         int                     from, to;               // leaf numbers
83         sep_t                           *planes;
84 } passage_t;
85
86 #define MAX_PORTALS_ON_LEAF             128
87 typedef struct leaf_s
88 {
89         int                     numportals;
90         passage_t       *passages;
91         portal_t        *portals[MAX_PORTALS_ON_LEAF];
92 } leaf_t;
93
94         
95 typedef struct pstack_s
96 {
97         byte            mightsee[MAX_PORTALS/8];                // bit string
98         struct pstack_s *next;
99         leaf_t          *leaf;
100         portal_t        *portal;        // portal exiting
101         winding_t       *source;
102         winding_t       *pass;
103
104         winding_t       windings[3];    // source, pass, temp in any order
105         int                     freewindings[3];
106
107         plane_t         portalplane;
108 } pstack_t;
109
110 typedef struct
111 {
112         portal_t        *base;
113         int                     c_chains;
114         pstack_t        pstack_head;
115 } threaddata_t;
116
117
118
119 extern  int                     numportals;
120 extern  int                     portalclusters;
121
122 extern  portal_t        *portals;
123 extern  leaf_t          *leafs;
124
125 extern  int                     c_portaltest, c_portalpass, c_portalcheck;
126 extern  int                     c_portalskip, c_leafskip;
127 extern  int                     c_vistest, c_mighttest;
128 extern  int                     c_chains;
129
130 extern  byte    *vismap, *vismap_p, *vismap_end;        // past visfile
131
132 extern  int                     testlevel;
133
134 extern  byte            *uncompressed;
135
136 extern  int             leafbytes, leaflongs;
137 extern  int             portalbytes, portallongs;
138
139
140 void LeafFlow (int leafnum);
141
142
143 void BasePortalVis (int portalnum);
144 void BetterPortalVis (int portalnum);
145 void PortalFlow (int portalnum);
146
147 extern  portal_t        *sorted_portals[MAX_MAP_PORTALS*2];
148
149 int CountBits (byte *bits, int numbits);