| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 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 |
| 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; |
| 60 |
int numpoints; |
| 61 |
vec3_t points[MAX_POINTS_ON_FIXED_WINDING]; |
| 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; |
| 73 |
int leaf; |
| 74 |
|
| 75 |
vec3_t origin; |
| 76 |
float radius; |
| 77 |
|
| 78 |
winding_t *winding; |
| 79 |
vstatus_t status; |
| 80 |
byte *portalfront; |
| 81 |
byte *portalflood; |
| 82 |
byte *portalvis; |
| 83 |
|
| 84 |
int nummightsee; |
| 85 |
} portal_t; |
| 86 |
|
| 87 |
typedef struct seperating_plane_s |
| 88 |
{ |
| 89 |
struct seperating_plane_s *next; |
| 90 |
plane_t plane; |
| 91 |
} sep_t; |
| 92 |
|
| 93 |
|
| 94 |
typedef struct passage_s |
| 95 |
{ |
| 96 |
struct passage_s *next; |
| 97 |
int from, to; |
| 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]; |
| 113 |
struct pstack_s *next; |
| 114 |
leaf_t *leaf; |
| 115 |
portal_t *portal; |
| 116 |
winding_t *source; |
| 117 |
winding_t *pass; |
| 118 |
|
| 119 |
winding_t windings[3]; |
| 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; |
| 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 |
|
| 169 |
|
| 170 |
extern char *mapname; |