Debian Codegraph @

tools/quake2/q2map/qrad.h

raw symbols SCIP
1 /*
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.
3 For a list of contributors, see the accompanying CONTRIBUTORS file.
4
5 This file is part of GtkRadiant.
6
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.
11
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.
16
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
20 */
21 /* Files:
22
23 lightmap.c
24 patches.c
25 qrad.c
26 trace.c
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 // 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
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; // for surfaces and spotlights
70 float stopdot; // for spotlights
71 } directlight_t;
72
73
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
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; // next in face
90 int numtransfers;
91 transfer_t *transfers;
92
93 int cluster; // for pvs checking
94 vec3_t origin;
95 dplane_t *plane;
96
97 qboolean sky;
98
99 vec3_t totallight; // accumulated by radiosity
100 // does NOT include light
101 // accounted for by direct lighting
102 float area;
103
104 // illuminance * reflectivity = radiosity
105 vec3_t reflectivity;
106 vec3_t baselight; // emissivity only
107
108 // each style 0 lightmap sample in the patch will be
109 // added up to get the average illuminance of the entire patch
110 vec3_t samplelight;
111 int samples; // for averaging direct light
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]; // for rotating bmodels
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; // created planes for origin offset
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 // externs
181
182 extern char *mapname;
183 extern char game[64];