2 ===========================================================================
3 Copyright (C) 1997-2006 Id Software, Inc.
5 This file is part of Quake 2 Tools source code.
7 Quake 2 Tools source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
12 Quake 2 Tools source code is distributed in the hope that it will be
13 useful, 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 Quake 2 Tools source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
23 #include "globaldefs.h"
44 typedef struct directlight_s
46 struct directlight_s *next;
53 vec3_t normal; // for surfaces and spotlights
54 float stopdot; // for spotlights
58 // the sum of all tranfer->transfer values for a given patch
59 // should equal exactly 0x10000, showing that all radiance
60 // reaches other patches
64 unsigned short transfer;
68 #define MAX_PATCHES 65000 // larger will cause 32 bit overflows
70 typedef struct patch_s
73 struct patch_s *next; // next in face
75 transfer_t *transfers;
77 int cluster; // for pvs checking
83 vec3_t totallight; // accumulated by radiosity
84 // does NOT include light
85 // accounted for by direct lighting
88 // illuminance * reflectivity = radiosity
90 vec3_t baselight; // emissivity only
92 // each style 0 lightmap sample in the patch will be
93 // added up to get the average illuminance of the entire patch
95 int samples; // for averaging direct light
98 extern patch_t *face_patches[MAX_MAP_FACES];
99 extern entity_t *face_entity[MAX_MAP_FACES];
100 extern vec3_t face_offset[MAX_MAP_FACES]; // for rotating bmodels
101 extern patch_t patches[MAX_PATCHES];
102 extern unsigned num_patches;
104 extern int leafparents[MAX_MAP_LEAFS];
105 extern int nodeparents[MAX_MAP_NODES];
107 extern float lightscale;
110 void MakeShadowSplits (void);
112 //==============================================
115 void BuildVisMatrix (void);
116 qboolean CheckVisBit (unsigned p1, unsigned p2);
118 //==============================================
120 extern float ambient, maxlight;
122 void LinkPlaneFaces (void);
124 extern qboolean extrasamples;
125 extern int numbounce;
127 extern directlight_t *directlights[MAX_MAP_LEAFS];
129 extern byte nodehit[MAX_MAP_NODES];
131 void BuildLightmaps (void);
133 void BuildFacelights (int facenum);
135 void FinalLightFace (int facenum);
137 qboolean PvsForOrigin (vec3_t org, byte *pvs);
139 int TestLine_r (int node, vec3_t start, vec3_t stop);
141 void CreateDirectLights (void);
143 dleaf_t *PointInLeaf (vec3_t point);
146 extern dplane_t backplanes[MAX_MAP_PLANES];
147 extern int fakeplanes; // created planes for origin offset
151 extern float direct_scale;
152 extern float entity_scale;
154 int PointInLeafnum (vec3_t point);
155 void MakeTnodes (dmodel_t *bm);
156 void MakePatches (void);
157 void SubdividePatches (void);
158 void PairEdges (void);
159 void CalcTextureReflectivity (void);