2 Copyright (C) 1999-2006 Id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 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.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
35 #include "q2_threads.h"
44 #ifdef NDEBUG // Don't show in a Release build
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
60 typedef struct directlight_s
62 struct directlight_s *next;
69 vec3_t normal; // for surfaces and spotlights
70 float stopdot; // for spotlights
74 // the sum of all tranfer->transfer values for a given patch
75 // should equal exactly 0x10000, showing that all radiance
76 // reaches other patches
80 unsigned short transfer;
84 #define MAX_PATCHES 65000 // larger will cause 32 bit overflows
86 typedef struct patch_s
89 struct patch_s *next; // next in face
91 transfer_t *transfers;
93 int cluster; // for pvs checking
99 vec3_t totallight; // accumulated by radiosity
100 // does NOT include light
101 // accounted for by direct lighting
104 // illuminance * reflectivity = radiosity
106 vec3_t baselight; // emissivity only
108 // each style 0 lightmap sample in the patch will be
109 // added up to get the average illuminance of the entire patch
111 int samples; // for averaging direct light
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]; // for rotating bmodels
117 extern patch_t patches[MAX_PATCHES];
118 extern unsigned num_patches;
120 extern int leafparents[MAX_MAP_LEAFS];
121 extern int nodeparents[MAX_MAP_NODES];
123 extern float lightscale;
126 void MakeShadowSplits (void);
128 //==============================================
131 void BuildVisMatrix (void);
132 qboolean CheckVisBit (unsigned p1, unsigned p2);
134 //==============================================
136 extern float ambient, maxlight;
138 void LinkPlaneFaces (void);
140 extern qboolean extrasamples;
141 extern int numbounce;
143 extern directlight_t *directlights[MAX_MAP_LEAFS];
145 extern byte nodehit[MAX_MAP_NODES];
147 void BuildLightmaps (void);
149 void BuildFacelights (int facenum);
151 void FinalLightFace (int facenum);
153 qboolean PvsForOrigin (vec3_t org, byte *pvs);
155 int TestLine_r (int node, vec3_t start, vec3_t stop);
157 void CreateDirectLights (void);
159 dleaf_t *Rad_PointInLeaf (vec3_t point);
162 extern dplane_t backplanes[MAX_MAP_PLANES];
163 extern int fakeplanes; // created planes for origin offset
167 extern float direct_scale;
168 extern float entity_scale;
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) (void);
176 void CalcTextureReflectivity_Quake2(void);
177 void CalcTextureReflectivity_Heretic2(void);
179 //=============================================================================
183 extern char *mapname;
184 extern char game[64];