2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
\r
5 This file is part of GtkRadiant.
\r
7 GtkRadiant is free software; you can redistribute it and/or modify
\r
8 it under the terms of the GNU General Public License as published by
\r
9 the Free Software Foundation; either version 2 of the License, or
\r
10 (at your option) any later version.
\r
12 GtkRadiant is distributed in the hope that it will be useful,
\r
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
15 GNU General Public License for more details.
\r
17 You should have received a copy of the GNU General Public License
\r
18 along with GtkRadiant; if not, write to the Free Software
\r
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
32 #include "mathlib.h"
\r
33 #include "bspfile.h"
\r
34 #include "polylib.h"
\r
35 #include "q2_threads.h"
\r
40 #include <windows.h>
\r
44 #ifdef NDEBUG // Don't show in a Release build
\r
45 #pragma warning(disable : 4305) // truncate from double to float
\r
46 #pragma warning(disable : 4244) // conversion from double to float
\r
47 #pragma warning(disable : 4018) // signed/unsigned mismatch
\r
60 typedef struct directlight_s
\r
62 struct directlight_s *next;
\r
69 vec3_t normal; // for surfaces and spotlights
\r
70 float stopdot; // for spotlights
\r
74 // the sum of all tranfer->transfer values for a given patch
\r
75 // should equal exactly 0x10000, showing that all radiance
\r
76 // reaches other patches
\r
79 unsigned short patch;
\r
80 unsigned short transfer;
\r
84 #define MAX_PATCHES 65000 // larger will cause 32 bit overflows
\r
86 typedef struct patch_s
\r
89 struct patch_s *next; // next in face
\r
91 transfer_t *transfers;
\r
93 int cluster; // for pvs checking
\r
99 vec3_t totallight; // accumulated by radiosity
\r
100 // does NOT include light
\r
101 // accounted for by direct lighting
\r
104 // illuminance * reflectivity = radiosity
\r
105 vec3_t reflectivity;
\r
106 vec3_t baselight; // emissivity only
\r
108 // each style 0 lightmap sample in the patch will be
\r
109 // added up to get the average illuminance of the entire patch
\r
110 vec3_t samplelight;
\r
111 int samples; // for averaging direct light
\r
114 extern patch_t *face_patches[MAX_MAP_FACES];
\r
115 extern entity_t *face_entity[MAX_MAP_FACES];
\r
116 extern vec3_t face_offset[MAX_MAP_FACES]; // for rotating bmodels
\r
117 extern patch_t patches[MAX_PATCHES];
\r
118 extern unsigned num_patches;
\r
120 extern int leafparents[MAX_MAP_LEAFS];
\r
121 extern int nodeparents[MAX_MAP_NODES];
\r
123 extern float lightscale;
\r
126 void MakeShadowSplits (void);
\r
128 //==============================================
\r
131 void BuildVisMatrix (void);
\r
132 qboolean CheckVisBit (unsigned p1, unsigned p2);
\r
134 //==============================================
\r
136 extern float ambient, maxlight;
\r
138 void LinkPlaneFaces (void);
\r
140 extern qboolean extrasamples;
\r
141 extern int numbounce;
\r
143 extern directlight_t *directlights[MAX_MAP_LEAFS];
\r
145 extern byte nodehit[MAX_MAP_NODES];
\r
147 void BuildLightmaps (void);
\r
149 void BuildFacelights (int facenum);
\r
151 void FinalLightFace (int facenum);
\r
153 qboolean PvsForOrigin (vec3_t org, byte *pvs);
\r
155 int TestLine_r (int node, vec3_t start, vec3_t stop);
\r
157 void CreateDirectLights (void);
\r
159 dleaf_t *Rad_PointInLeaf (vec3_t point);
\r
162 extern dplane_t backplanes[MAX_MAP_PLANES];
\r
163 extern int fakeplanes; // created planes for origin offset
\r
165 extern float subdiv;
\r
167 extern float direct_scale;
\r
168 extern float entity_scale;
\r
170 int PointInLeafnum (vec3_t point);
\r
171 void MakeTnodes (dmodel_t *bm);
\r
172 void MakePatches (void);
\r
173 void SubdividePatches (void);
\r
174 void PairEdges (void);
\r
175 void (*CalcTextureReflectivity) (void);
\r
176 void CalcTextureReflectivity_Quake2(void);
\r
177 void CalcTextureReflectivity_Heretic2(void);
\r
179 //=============================================================================
\r
183 extern char *mapname;
\r
184 extern char game[64];
\r