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 ===========================================================================
43 typedef struct directlight_s
45 struct directlight_s *next;
52 vec3_t normal; // for surfaces and spotlights
53 float stopdot; // for spotlights
57 // the sum of all tranfer->transfer values for a given patch
58 // should equal exactly 0x10000, showing that all radiance
59 // reaches other patches
63 unsigned short transfer;
67 #define MAX_PATCHES 65000 // larger will cause 32 bit overflows
69 typedef struct patch_s
72 struct patch_s *next; // next in face
74 transfer_t *transfers;
76 int cluster; // for pvs checking
82 vec3_t totallight; // accumulated by radiosity
83 // does NOT include light
84 // accounted for by direct lighting
87 // illuminance * reflectivity = radiosity
89 vec3_t baselight; // emissivity only
91 // each style 0 lightmap sample in the patch will be
92 // added up to get the average illuminance of the entire patch
94 int samples; // for averaging direct light
97 extern patch_t *face_patches[MAX_MAP_FACES];
98 extern entity_t *face_entity[MAX_MAP_FACES];
99 extern vec3_t face_offset[MAX_MAP_FACES]; // for rotating bmodels
100 extern patch_t patches[MAX_PATCHES];
101 extern unsigned num_patches;
103 extern int leafparents[MAX_MAP_LEAFS];
104 extern int nodeparents[MAX_MAP_NODES];
106 extern float lightscale;
109 void MakeShadowSplits (void);
111 //==============================================
114 void BuildVisMatrix (void);
115 qboolean CheckVisBit (unsigned p1, unsigned p2);
117 //==============================================
119 extern float ambient, maxlight;
121 void LinkPlaneFaces (void);
123 extern qboolean extrasamples;
124 extern int numbounce;
126 extern directlight_t *directlights[MAX_MAP_LEAFS];
128 extern byte nodehit[MAX_MAP_NODES];
130 void BuildLightmaps (void);
132 void BuildFacelights (int facenum);
134 void FinalLightFace (int facenum);
136 qboolean PvsForOrigin (vec3_t org, byte *pvs);
138 int TestLine_r (int node, vec3_t start, vec3_t stop);
140 void CreateDirectLights (void);
142 dleaf_t *PointInLeaf (vec3_t point);
145 extern dplane_t backplanes[MAX_MAP_PLANES];
146 extern int fakeplanes; // created planes for origin offset
150 extern float direct_scale;
151 extern float entity_scale;
153 int PointInLeafnum (vec3_t point);
154 void MakeTnodes (dmodel_t *bm);
155 void MakePatches (void);
156 void SubdividePatches (void);
157 void PairEdges (void);
158 void CalcTextureReflectivity (void);