| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 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; |
| 45 |
int numpoints; |
| 46 |
vec3_t points[MAX_POINTS_ON_FIXED_WINDING]; |
| 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; |
| 58 |
int leaf; |
| 59 |
|
| 60 |
vec3_t origin; |
| 61 |
float radius; |
| 62 |
|
| 63 |
winding_t *winding; |
| 64 |
vstatus_t status; |
| 65 |
byte *portalfront; |
| 66 |
byte *portalflood; |
| 67 |
byte *portalvis; |
| 68 |
|
| 69 |
int nummightsee; |
| 70 |
} portal_t; |
| 71 |
|
| 72 |
typedef struct seperating_plane_s |
| 73 |
{ |
| 74 |
struct seperating_plane_s *next; |
| 75 |
plane_t plane; |
| 76 |
} sep_t; |
| 77 |
|
| 78 |
|
| 79 |
typedef struct passage_s |
| 80 |
{ |
| 81 |
struct passage_s *next; |
| 82 |
int from, to; |
| 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]; |
| 98 |
struct pstack_s *next; |
| 99 |
leaf_t *leaf; |
| 100 |
portal_t *portal; |
| 101 |
winding_t *source; |
| 102 |
winding_t *pass; |
| 103 |
|
| 104 |
winding_t windings[3]; |
| 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; |
| 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); |