| 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 |
|
| 29 |
|
| 30 |
#include "globaldefs.h" |
| 31 |
#include "cmdlib.h" |
| 32 |
#include "mathlib.h" |
| 33 |
#include "bspfile.h" |
| 34 |
#include "polylib.h" |
| 35 |
#include "q2_threads.h" |
| 36 |
#include "lbmlib.h" |
| 37 |
#include "inout.h" |
| 38 |
|
| 39 |
#if GDEF_OS_WINDOWS |
| 40 |
#include <windows.h> |
| 41 |
#endif |
| 42 |
|
| 43 |
#if GDEF_COMPILER_MSVC |
| 44 |
#ifdef NDEBUG |
| 45 |
#pragma warning(disable : 4305) // truncate from double to float |
| 46 |
#pragma warning(disable : 4244) // conversion from double to float |
| 47 |
#pragma warning(disable : 4018) // signed/unsigned mismatch |
| 48 |
#endif |
| 49 |
#endif |
| 50 |
|
| 51 |
typedef enum |
| 52 |
{ |
| 53 |
emit_surface, |
| 54 |
emit_point, |
| 55 |
emit_spotlight |
| 56 |
} emittype_t; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
typedef struct directlight_s |
| 61 |
{ |
| 62 |
struct directlight_s *next; |
| 63 |
emittype_t type; |
| 64 |
|
| 65 |
float intensity; |
| 66 |
int style; |
| 67 |
vec3_t origin; |
| 68 |
vec3_t color; |
| 69 |
vec3_t normal; |
| 70 |
float stopdot; |
| 71 |
} directlight_t; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
typedef struct |
| 78 |
{ |
| 79 |
unsigned short patch; |
| 80 |
unsigned short transfer; |
| 81 |
} transfer_t; |
| 82 |
|
| 83 |
|
| 84 |
#define MAX_PATCHES 65000 // larger will cause 32 bit overflows |
| 85 |
|
| 86 |
typedef struct patch_s |
| 87 |
{ |
| 88 |
winding_t *winding; |
| 89 |
struct patch_s *next; |
| 90 |
int numtransfers; |
| 91 |
transfer_t *transfers; |
| 92 |
|
| 93 |
int cluster; |
| 94 |
vec3_t origin; |
| 95 |
dplane_t *plane; |
| 96 |
|
| 97 |
qboolean sky; |
| 98 |
|
| 99 |
vec3_t totallight; |
| 100 |
|
| 101 |
|
| 102 |
float area; |
| 103 |
|
| 104 |
|
| 105 |
vec3_t reflectivity; |
| 106 |
vec3_t baselight; |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
vec3_t samplelight; |
| 111 |
int samples; |
| 112 |
} patch_t; |
| 113 |
|
| 114 |
extern patch_t *face_patches[MAX_MAP_FACES]; |
| 115 |
extern entity_t *face_entity[MAX_MAP_FACES]; |
| 116 |
extern vec3_t face_offset[MAX_MAP_FACES]; |
| 117 |
extern patch_t patches[MAX_PATCHES]; |
| 118 |
extern unsigned num_patches; |
| 119 |
|
| 120 |
extern int leafparents[MAX_MAP_LEAFS]; |
| 121 |
extern int nodeparents[MAX_MAP_NODES]; |
| 122 |
|
| 123 |
extern float lightscale; |
| 124 |
|
| 125 |
|
| 126 |
void MakeShadowSplits( void ); |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
void BuildVisMatrix( void ); |
| 132 |
qboolean CheckVisBit( unsigned p1, unsigned p2 ); |
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
extern float ambient, maxlight; |
| 137 |
|
| 138 |
void LinkPlaneFaces( void ); |
| 139 |
|
| 140 |
extern qboolean extrasamples; |
| 141 |
extern int numbounce; |
| 142 |
|
| 143 |
extern directlight_t *directlights[MAX_MAP_LEAFS]; |
| 144 |
|
| 145 |
extern byte nodehit[MAX_MAP_NODES]; |
| 146 |
|
| 147 |
void BuildLightmaps( void ); |
| 148 |
|
| 149 |
void BuildFacelights( int facenum ); |
| 150 |
|
| 151 |
void FinalLightFace( int facenum ); |
| 152 |
|
| 153 |
qboolean PvsForOrigin( vec3_t org, byte *pvs ); |
| 154 |
|
| 155 |
int TestLine_r( int node, vec3_t start, vec3_t stop ); |
| 156 |
|
| 157 |
void CreateDirectLights( void ); |
| 158 |
|
| 159 |
dleaf_t *Rad_PointInLeaf( vec3_t point ); |
| 160 |
|
| 161 |
|
| 162 |
extern dplane_t backplanes[MAX_MAP_PLANES]; |
| 163 |
extern int fakeplanes; |
| 164 |
|
| 165 |
extern float subdiv; |
| 166 |
|
| 167 |
extern float direct_scale; |
| 168 |
extern float entity_scale; |
| 169 |
|
| 170 |
int PointInLeafnum( vec3_t point ); |
| 171 |
void MakeTnodes( dmodel_t *bm ); |
| 172 |
void MakePatches( void ); |
| 173 |
void SubdividePatches( void ); |
| 174 |
void PairEdges( void ); |
| 175 |
void CalcTextureReflectivity_Quake2( void ); |
| 176 |
void CalcTextureReflectivity_Heretic2( void ); |
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
extern char *mapname; |
| 183 |
extern char game[64]; |