]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake2/q2map/qrad.h
transfer from internal tree r5311 branches/1.4-gpl
[xonotic/netradiant.git] / tools / quake2 / q2map / qrad.h
1 /*\r
2 Copyright (C) 1999-2007 id Software, Inc. and contributors.\r
3 For a list of contributors, see the accompanying CONTRIBUTORS file.\r
4 \r
5 This file is part of GtkRadiant.\r
6 \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
11 \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
16 \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
20 */\r
21 /* Files:\r
22 \r
23 lightmap.c\r
24 patches.c\r
25 qrad.c\r
26 trace.c\r
27 \r
28 */\r
29 \r
30 \r
31 #include "cmdlib.h"\r
32 #include "mathlib.h"\r
33 #include "bspfile.h"\r
34 #include "polylib.h"\r
35 #include "q2_threads.h"\r
36 #include "lbmlib.h"\r
37 #include "inout.h"\r
38 \r
39 #ifdef _WIN32\r
40 #include <windows.h>\r
41 #endif\r
42 \r
43 #ifdef _WIN32\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
48         #endif\r
49 #endif\r
50 \r
51 typedef enum\r
52 {\r
53         emit_surface,\r
54         emit_point,\r
55         emit_spotlight\r
56 } emittype_t;\r
57 \r
58 \r
59 \r
60 typedef struct directlight_s\r
61 {\r
62         struct directlight_s *next;\r
63         emittype_t      type;\r
64 \r
65         float           intensity;\r
66         int                     style;\r
67         vec3_t          origin;\r
68         vec3_t          color;\r
69         vec3_t          normal;         // for surfaces and spotlights\r
70         float           stopdot;                // for spotlights\r
71 } directlight_t;\r
72 \r
73 \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
77 typedef struct\r
78 {\r
79         unsigned short  patch;\r
80         unsigned short  transfer;\r
81 } transfer_t;\r
82 \r
83 \r
84 #define MAX_PATCHES     65000                   // larger will cause 32 bit overflows\r
85 \r
86 typedef struct patch_s\r
87 {\r
88         winding_t       *winding;\r
89         struct patch_s          *next;          // next in face\r
90         int                     numtransfers;\r
91         transfer_t      *transfers;\r
92 \r
93         int                     cluster;                        // for pvs checking\r
94         vec3_t          origin;\r
95         dplane_t        *plane;\r
96 \r
97         qboolean        sky;\r
98 \r
99         vec3_t          totallight;                     // accumulated by radiosity\r
100                                                                         // does NOT include light\r
101                                                                         // accounted for by direct lighting\r
102         float           area;\r
103 \r
104         // illuminance * reflectivity = radiosity\r
105         vec3_t          reflectivity;\r
106         vec3_t          baselight;                      // emissivity only\r
107 \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
112 } patch_t;\r
113 \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
119 \r
120 extern  int             leafparents[MAX_MAP_LEAFS];\r
121 extern  int             nodeparents[MAX_MAP_NODES];\r
122 \r
123 extern  float   lightscale;\r
124 \r
125 \r
126 void MakeShadowSplits (void);\r
127 \r
128 //==============================================\r
129 \r
130 \r
131 void BuildVisMatrix (void);\r
132 qboolean CheckVisBit (unsigned p1, unsigned p2);\r
133 \r
134 //==============================================\r
135 \r
136 extern  float ambient, maxlight;\r
137 \r
138 void LinkPlaneFaces (void);\r
139 \r
140 extern  qboolean        extrasamples;\r
141 extern int numbounce;\r
142 \r
143 extern  directlight_t   *directlights[MAX_MAP_LEAFS];\r
144 \r
145 extern  byte    nodehit[MAX_MAP_NODES];\r
146 \r
147 void BuildLightmaps (void);\r
148 \r
149 void BuildFacelights (int facenum);\r
150 \r
151 void FinalLightFace (int facenum);\r
152 \r
153 qboolean PvsForOrigin (vec3_t org, byte *pvs);\r
154 \r
155 int TestLine_r (int node, vec3_t start, vec3_t stop);\r
156 \r
157 void CreateDirectLights (void);\r
158 \r
159 dleaf_t         *Rad_PointInLeaf (vec3_t point);\r
160 \r
161 \r
162 extern  dplane_t        backplanes[MAX_MAP_PLANES];\r
163 extern  int                     fakeplanes;                                     // created planes for origin offset \r
164 \r
165 extern  float   subdiv;\r
166 \r
167 extern  float   direct_scale;\r
168 extern  float   entity_scale;\r
169 \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
178 \r
179 //=============================================================================\r
180 \r
181 // externs\r
182 \r
183 extern char     *mapname;\r
184 extern char     game[64];\r