]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - tools/quake3/q3map2/q3map2_fsr_newfiles/q3map2_fsr_svn158.patch
VorteX: KeyExists function, cast shadows from func_wall by default in prophecy and dq
[xonotic/netradiant.git] / tools / quake3 / q3map2 / q3map2_fsr_newfiles / q3map2_fsr_svn158.patch
1 Index: game_ef.h\r
2 ===================================================================\r
3 --- game_ef.h   (revision 158)\r
4 +++ game_ef.h   (working copy)\r
5 @@ -113,7 +113,16 @@\r
6         qfalse,                         /* wolf lighting model? */
7         128,                            /* lightmap width/height */
8         1.0f,                           /* lightmap gamma */
9 +       1.0f,                           /* lightmap exposure */
10         1.0f,                           /* lightmap compensate */
11 +       1.0f,                           /* lightgrid scale */
12 +       1.0f,                           /* lightgrid ambient scale */
13 +       qfalse,                         /* disable shader lightstyles hack */
14 +       qfalse,                         /* keep light entities on bsp */
15 +       8,                                      /* default patchMeta subdivisions tolerance */
16 +       qfalse,                         /* patch casting enabled */
17 +       qfalse,                         /* compile deluxemaps */
18 +       0,                                      /* deluxemaps default mode */
19         "IBSP",                         /* bsp file prefix */
20         46,                                     /* bsp file version */
21         qfalse,                         /* cod-style lump len/ofs order */
22 Index: game_etut.h\r
23 ===================================================================\r
24 --- game_etut.h (revision 158)\r
25 +++ game_etut.h (working copy)\r
26 @@ -148,7 +148,16 @@\r
27         qfalse,                         /* wolf lighting model? */
28         128,                            /* lightmap width/height */
29         2.2f,                           /* lightmap gamma */
30 +       1.0f,                           /* lightmap exposure */
31         1.0f,                           /* lightmap compensate */
32 +       1.0f,                           /* lightgrid scale */
33 +       1.0f,                           /* lightgrid ambient scale */
34 +       qfalse,                         /* disable shader lightstyles hack */
35 +       qfalse,                         /* keep light entities on bsp */
36 +       8,                                      /* default patchMeta subdivisions tolerance */
37 +       qfalse,                         /* patch casting enabled */
38 +       qfalse,                         /* compile deluxemaps */
39 +       0,                                      /* deluxemaps default mode */
40         "IBSP",                         /* bsp file prefix */
41         47,                                     /* bsp file version */
42         qfalse,                         /* cod-style lump len/ofs order */
43 Index: game_ja.h\r
44 ===================================================================\r
45 --- game_ja.h   (revision 158)\r
46 +++ game_ja.h   (working copy)\r
47 @@ -67,7 +67,16 @@\r
48         qfalse,                         /* wolf lighting model? */
49         128,                            /* lightmap width/height */
50         1.0f,                           /* lightmap gamma */
51 +       1.0f,                           /* lightmap exposure */
52         1.0f,                           /* lightmap compensate */
53 +       1.0f,                           /* lightgrid scale */
54 +       1.0f,                           /* lightgrid ambient scale */
55 +       qfalse,                         /* disable shader lightstyles hack */
56 +       qfalse,                         /* keep light entities on bsp */
57 +       8,                                      /* default patchMeta subdivisions tolerance */
58 +       qfalse,                         /* patch casting enabled */
59 +       qfalse,                         /* compile deluxemaps */
60 +       0,                                      /* deluxemaps default mode */
61         "RBSP",                         /* bsp file prefix */
62         1,                                      /* bsp file version */
63         qfalse,                         /* cod-style lump len/ofs order */
64 Index: game_jk2.h\r
65 ===================================================================\r
66 --- game_jk2.h  (revision 158)\r
67 +++ game_jk2.h  (working copy)\r
68 @@ -64,7 +64,16 @@\r
69         qfalse,                         /* wolf lighting model? */
70         128,                            /* lightmap width/height */
71         1.0f,                           /* lightmap gamma */
72 +       1.0f,                           /* lightmap exposure */
73         1.0f,                           /* lightmap compensate */
74 +       1.0f,                           /* lightgrid scale */
75 +       1.0f,                           /* lightgrid ambient scale */
76 +       qfalse,                         /* disable shader lightstyles hack */
77 +       qfalse,                         /* keep light entities on bsp */
78 +       8,                                      /* default patchMeta subdivisions tolerance */
79 +       qfalse,                         /* patch casting enabled */
80 +       qfalse,                         /* compile deluxemaps */
81 +       0,                                      /* deluxemaps default mode */
82         "RBSP",                         /* bsp file prefix */
83         1,                                      /* bsp file version */
84         qfalse,                         /* cod-style lump len/ofs order */
85 Index: game_qfusion.h\r
86 ===================================================================\r
87 --- game_qfusion.h      (revision 158)\r
88 +++ game_qfusion.h      (working copy)\r
89 @@ -1,195 +1,204 @@\r
90 -/* -------------------------------------------------------------------------------
91 -
92 -This code is based on source provided under the terms of the Id Software 
93 -LIMITED USE SOFTWARE LICENSE AGREEMENT, a copy of which is included with the
94 -GtkRadiant sources (see LICENSE_ID). If you did not receive a copy of 
95 -LICENSE_ID, please contact Id Software immediately at info@idsoftware.com.
96 -
97 -All changes and additions to the original source which have been developed by
98 -other contributors (see CONTRIBUTORS) are provided under the terms of the
99 -license the contributors choose (see LICENSE), to the extent permitted by the
100 -LICENSE_ID. If you did not receive a copy of the contributor license,
101 -please contact the GtkRadiant maintainers at info@gtkradiant.com immediately.
102 -
103 -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
104 -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
105 -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
106 -DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
107 -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
108 -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
109 -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
110 -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
111 -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
112 -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
113 -
114 -----------------------------------------------------------------------------------
115 -
116 -This code has been altered significantly from its original form, to support
117 -several games based on the Quake III Arena engine, in the form of "Q3Map2."
118 -
119 -------------------------------------------------------------------------------- */
120 -
121 -
122 -
123 -/* marker */
124 -#ifndef GAME_QFUSION_H
125 -#define GAME_QFUSION_H
126 -
127 -
128 -
129 -/* -------------------------------------------------------------------------------
130 -
131 -content and surface flags
132 -
133 -------------------------------------------------------------------------------- */
134 -
135 -/* game flags */
136 -#define F_CONT_SOLID                           1                       /* an eye is never valid in a solid */
137 -#define F_CONT_LAVA                                    8
138 -#define F_CONT_SLIME                           16
139 -#define F_CONT_WATER                           32
140 -#define F_CONT_FOG                                     64
141 -
142 -#define F_CONT_AREAPORTAL                      0x8000
143 -
144 -#define F_CONT_PLAYERCLIP                      0x10000
145 -#define F_CONT_MONSTERCLIP                     0x20000
146 -#define F_CONT_TELEPORTER                      0x40000
147 -#define F_CONT_JUMPPAD                         0x80000
148 -#define F_CONT_CLUSTERPORTAL           0x100000
149 -#define F_CONT_DONOTENTER                      0x200000
150 -#define F_CONT_BOTCLIP                         0x400000
151 -
152 -#define F_CONT_ORIGIN                          0x1000000       /* removed before bsping an entity */
153 -
154 -#define F_CONT_BODY                                    0x2000000       /* should never be on a brush, only in game */
155 -#define F_CONT_CORPSE                          0x4000000
156 -#define F_CONT_DETAIL                          0x8000000       /* brushes not used for the bsp */
157 -#define F_CONT_STRUCTURAL                      0x10000000      /* brushes used for the bsp */
158 -#define F_CONT_TRANSLUCENT                     0x20000000      /* don't consume surface fragments inside */
159 -#define F_CONT_TRIGGER                         0x40000000
160 -#define F_CONT_NODROP                          0x80000000      /* don't leave bodies or items (death fog, lava) */
161 -
162 -#define F_SURF_NODAMAGE                                0x1                     /* never give falling damage */
163 -#define F_SURF_SLICK                           0x2                     /* effects game physics */
164 -#define F_SURF_SKY                                     0x4                     /* lighting from environment map */
165 -#define F_SURF_LADDER                          0x8
166 -#define F_SURF_NOIMPACT                                0x10            /* don't make missile explosions */
167 -#define F_SURF_NOMARKS                         0x20            /* don't leave missile marks */
168 -#define F_SURF_FLESH                           0x40            /* make flesh sounds and effects */
169 -#define F_SURF_NODRAW                          0x80            /* don't generate a drawsurface at all */
170 -#define F_SURF_HINT                                    0x100           /* make a primary bsp splitter */
171 -#define F_SURF_SKIP                                    0x200           /* completely ignore, allowing non-closed brushes */
172 -#define F_SURF_NOLIGHTMAP                      0x400           /* surface doesn't need a lightmap */
173 -#define F_SURF_POINTLIGHT                      0x800           /* generate lighting info at vertexes */
174 -#define F_SURF_METALSTEPS                      0x1000          /* clanking footsteps */
175 -#define F_SURF_NOSTEPS                         0x2000          /* no footstep sounds */
176 -#define F_SURF_NONSOLID                                0x4000          /* don't collide against curves with this set */
177 -#define F_SURF_LIGHTFILTER                     0x8000          /* act as a light filter during q3map -light */
178 -#define F_SURF_ALPHASHADOW                     0x10000         /* do per-pixel light shadow casting in q3map */
179 -#define F_SURF_NODLIGHT                                0x20000         /* don't dlight even if solid (solid lava, skies) */
180 -#define F_SURF_DUST                                    0x40000         /* leave a dust trail when walking on this surface */
181 -
182 -/* ydnar flags */
183 -#define F_SURF_VERTEXLIT                       (F_SURF_POINTLIGHT | F_SURF_NOLIGHTMAP)
184 -
185 -
186 -
187 -/* -------------------------------------------------------------------------------
188 -
189 -game_t struct
190 -
191 -------------------------------------------------------------------------------- */
192 -
193 -{
194 -       "qfusion",                      /* -game x */
195 -       "baseq3",                       /* default base game data dir */
196 -       ".q3a",                         /* unix home sub-dir */
197 -       "quake",                        /* magic path word */
198 -       "scripts",                      /* shader directory */
199 -       2048,                           /* max lightmapped surface verts */
200 -       2048,                           /* max surface verts */
201 -       12288,                          /* max surface indexes */
202 -       qtrue,                          /* flares */
203 -       "flareshader",          /* default flare shader */
204 -       qfalse,                         /* wolf lighting model? */
205 -       512,                            /* lightmap width/height */
206 -       1.0f,                           /* lightmap gamma */
207 -       1.0f,                           /* lightmap compensate */
208 -       "FBSP",                         /* bsp file prefix */
209 -       1,                                      /* bsp file version */
210 -       qfalse,                         /* cod-style lump len/ofs order */
211 -       LoadRBSPFile,           /* bsp load function */
212 -       WriteRBSPFile,          /* bsp write function */
213 -
214 -       {
215 -               /* name                         contentFlags                            contentFlagsClear                       surfaceFlags                            surfaceFlagsClear                       compileFlags                            compileFlagsClear */
216 -               
217 -               /* default */
218 -               { "default",            F_CONT_SOLID,                           -1,                                                     0,                                                      -1,                                                     C_SOLID,                                        -1 },
219 -               
220 -               
221 -               /* ydnar */
222 -               { "lightgrid",          0,                                                      0,                                                      0,                                                      0,                                                      C_LIGHTGRID,                            0 },
223 -               { "antiportal",         0,                                                      0,                                                      0,                                                      0,                                                      C_ANTIPORTAL,                           0 },
224 -               { "skip",                       0,                                                      0,                                                      0,                                                      0,                                                      C_SKIP,                                         0 },
225 -               
226 -               
227 -               /* compiler */
228 -               { "origin",                     F_CONT_ORIGIN,                          F_CONT_SOLID,                           0,                                                      0,                                                      C_ORIGIN | C_TRANSLUCENT,       C_SOLID },
229 -               { "areaportal",         F_CONT_AREAPORTAL,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_AREAPORTAL | C_TRANSLUCENT,   C_SOLID },
230 -               { "trans",                      F_CONT_TRANSLUCENT,                     0,                                                      0,                                                      0,                                                      C_TRANSLUCENT,                          0 },
231 -               { "detail",                     F_CONT_DETAIL,                          0,                                                      0,                                                      0,                                                      C_DETAIL,                                       0 },
232 -               { "structural",         F_CONT_STRUCTURAL,                      0,                                                      0,                                                      0,                                                      C_STRUCTURAL,                           0 },
233 -               { "hint",                       0,                                                      0,                                                      F_SURF_HINT,                            0,                                                      C_HINT,                                         0 },
234 -               { "nodraw",                     0,                                                      0,                                                      F_SURF_NODRAW,                          0,                                                      C_NODRAW,                                       0 },
235 -               
236 -               { "alphashadow",        0,                                                      0,                                                      F_SURF_ALPHASHADOW,                     0,                                                      C_ALPHASHADOW | C_TRANSLUCENT,  0 },
237 -               { "lightfilter",        0,                                                      0,                                                      F_SURF_LIGHTFILTER,                     0,                                                      C_LIGHTFILTER | C_TRANSLUCENT,  0 },
238 -               { "nolightmap",         0,                                                      0,                                                      F_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },
239 -               { "pointlight",         0,                                                      0,                                                      F_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },
240 -               
241 -               
242 -               /* game */
243 -               { "nonsolid",           0,                                                      F_CONT_SOLID,                           F_SURF_NONSOLID,                        0,                                                      0,                                                      C_SOLID },
244 -               
245 -               { "trigger",            F_CONT_TRIGGER,                         F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
246 -               
247 -               { "water",                      F_CONT_WATER,                           F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
248 -               { "slime",                      F_CONT_SLIME,                           F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
249 -               { "lava",                       F_CONT_LAVA,                            F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
250 -               
251 -               { "playerclip",         F_CONT_PLAYERCLIP,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },
252 -               { "monsterclip",        F_CONT_MONSTERCLIP,                     F_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },
253 -               { "nodrop",                     F_CONT_NODROP,                          F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
254 -               
255 -               { "clusterportal",      F_CONT_CLUSTERPORTAL,           F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
256 -               { "donotenter",         F_CONT_DONOTENTER,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
257 -               { "botclip",            F_CONT_BOTCLIP,                         F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
258 -               
259 -               { "fog",                        F_CONT_FOG,                                     F_CONT_SOLID,                           0,                                                      0,                                                      C_FOG,                                          C_SOLID },
260 -               { "sky",                        0,                                                      0,                                                      F_SURF_SKY,                                     0,                                                      C_SKY,                                          0 },
261 -               
262 -               { "slick",                      0,                                                      0,                                                      F_SURF_SLICK,                           0,                                                      0,                                                      0 },
263 -               
264 -               { "noimpact",           0,                                                      0,                                                      F_SURF_NOIMPACT,                        0,                                                      0,                                                      0 },
265 -               { "nomarks",            0,                                                      0,                                                      F_SURF_NOMARKS,                         0,                                                      C_NOMARKS,                                      0 },
266 -               { "ladder",                     0,                                                      0,                                                      F_SURF_LADDER,                          0,                                                      0,                                                      0 },
267 -               { "nodamage",           0,                                                      0,                                                      F_SURF_NODAMAGE,                        0,                                                      0,                                                      0 },
268 -               { "metalsteps",         0,                                                      0,                                                      F_SURF_METALSTEPS,                      0,                                                      0,                                                      0 },
269 -               { "flesh",                      0,                                                      0,                                                      F_SURF_FLESH,                           0,                                                      0,                                                      0 },
270 -               { "nosteps",            0,                                                      0,                                                      F_SURF_NOSTEPS,                         0,                                                      0,                                                      0 },
271 -               { "nodlight",           0,                                                      0,                                                      F_SURF_NODLIGHT,                        0,                                                      0,                                                      0 },
272 -               { "dust",                       0,                                                      0,                                                      F_SURF_DUST,                            0,                                                      0,                                                      0 },
273 -               
274 -               
275 -               /* null */
276 -               { NULL, 0, 0, 0, 0, 0, 0 }
277 -       }
278 -}
279 -
280 -
281 -
282 -/* end marker */
283 -#endif
284 -
285 +/* -------------------------------------------------------------------------------\r
286 +\r
287 +This code is based on source provided under the terms of the Id Software \r
288 +LIMITED USE SOFTWARE LICENSE AGREEMENT, a copy of which is included with the\r
289 +GtkRadiant sources (see LICENSE_ID). If you did not receive a copy of \r
290 +LICENSE_ID, please contact Id Software immediately at info@idsoftware.com.\r
291 +\r
292 +All changes and additions to the original source which have been developed by\r
293 +other contributors (see CONTRIBUTORS) are provided under the terms of the\r
294 +license the contributors choose (see LICENSE), to the extent permitted by the\r
295 +LICENSE_ID. If you did not receive a copy of the contributor license,\r
296 +please contact the GtkRadiant maintainers at info@gtkradiant.com immediately.\r
297 +\r
298 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''\r
299 +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
300 +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\r
301 +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY\r
302 +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r
303 +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\r
304 +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\r
305 +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
306 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
307 +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
308 +\r
309 +----------------------------------------------------------------------------------\r
310 +\r
311 +This code has been altered significantly from its original form, to support\r
312 +several games based on the Quake III Arena engine, in the form of "Q3Map2."\r
313 +\r
314 +------------------------------------------------------------------------------- */\r
315 +\r
316 +\r
317 +\r
318 +/* marker */\r
319 +#ifndef GAME_QFUSION_H\r
320 +#define GAME_QFUSION_H\r
321 +\r
322 +\r
323 +\r
324 +/* -------------------------------------------------------------------------------\r
325 +\r
326 +content and surface flags\r
327 +\r
328 +------------------------------------------------------------------------------- */\r
329 +\r
330 +/* game flags */\r
331 +#define F_CONT_SOLID                           1                       /* an eye is never valid in a solid */\r
332 +#define F_CONT_LAVA                                    8\r
333 +#define F_CONT_SLIME                           16\r
334 +#define F_CONT_WATER                           32\r
335 +#define F_CONT_FOG                                     64\r
336 +\r
337 +#define F_CONT_AREAPORTAL                      0x8000\r
338 +\r
339 +#define F_CONT_PLAYERCLIP                      0x10000\r
340 +#define F_CONT_MONSTERCLIP                     0x20000\r
341 +#define F_CONT_TELEPORTER                      0x40000\r
342 +#define F_CONT_JUMPPAD                         0x80000\r
343 +#define F_CONT_CLUSTERPORTAL           0x100000\r
344 +#define F_CONT_DONOTENTER                      0x200000\r
345 +#define F_CONT_BOTCLIP                         0x400000\r
346 +\r
347 +#define F_CONT_ORIGIN                          0x1000000       /* removed before bsping an entity */\r
348 +\r
349 +#define F_CONT_BODY                                    0x2000000       /* should never be on a brush, only in game */\r
350 +#define F_CONT_CORPSE                          0x4000000\r
351 +#define F_CONT_DETAIL                          0x8000000       /* brushes not used for the bsp */\r
352 +#define F_CONT_STRUCTURAL                      0x10000000      /* brushes used for the bsp */\r
353 +#define F_CONT_TRANSLUCENT                     0x20000000      /* don't consume surface fragments inside */\r
354 +#define F_CONT_TRIGGER                         0x40000000\r
355 +#define F_CONT_NODROP                          0x80000000      /* don't leave bodies or items (death fog, lava) */\r
356 +\r
357 +#define F_SURF_NODAMAGE                                0x1                     /* never give falling damage */\r
358 +#define F_SURF_SLICK                           0x2                     /* effects game physics */\r
359 +#define F_SURF_SKY                                     0x4                     /* lighting from environment map */\r
360 +#define F_SURF_LADDER                          0x8\r
361 +#define F_SURF_NOIMPACT                                0x10            /* don't make missile explosions */\r
362 +#define F_SURF_NOMARKS                         0x20            /* don't leave missile marks */\r
363 +#define F_SURF_FLESH                           0x40            /* make flesh sounds and effects */\r
364 +#define F_SURF_NODRAW                          0x80            /* don't generate a drawsurface at all */\r
365 +#define F_SURF_HINT                                    0x100           /* make a primary bsp splitter */\r
366 +#define F_SURF_SKIP                                    0x200           /* completely ignore, allowing non-closed brushes */\r
367 +#define F_SURF_NOLIGHTMAP                      0x400           /* surface doesn't need a lightmap */\r
368 +#define F_SURF_POINTLIGHT                      0x800           /* generate lighting info at vertexes */\r
369 +#define F_SURF_METALSTEPS                      0x1000          /* clanking footsteps */\r
370 +#define F_SURF_NOSTEPS                         0x2000          /* no footstep sounds */\r
371 +#define F_SURF_NONSOLID                                0x4000          /* don't collide against curves with this set */\r
372 +#define F_SURF_LIGHTFILTER                     0x8000          /* act as a light filter during q3map -light */\r
373 +#define F_SURF_ALPHASHADOW                     0x10000         /* do per-pixel light shadow casting in q3map */\r
374 +#define F_SURF_NODLIGHT                                0x20000         /* don't dlight even if solid (solid lava, skies) */\r
375 +#define F_SURF_DUST                                    0x40000         /* leave a dust trail when walking on this surface */\r
376 +\r
377 +/* ydnar flags */\r
378 +#define F_SURF_VERTEXLIT                       (F_SURF_POINTLIGHT | F_SURF_NOLIGHTMAP)\r
379 +\r
380 +\r
381 +\r
382 +/* -------------------------------------------------------------------------------\r
383 +\r
384 +game_t struct\r
385 +\r
386 +------------------------------------------------------------------------------- */\r
387 +\r
388 +{\r
389 +       "qfusion",                      /* -game x */\r
390 +       "baseq3",                       /* default base game data dir */\r
391 +       ".q3a",                         /* unix home sub-dir */\r
392 +       "quake",                        /* magic path word */\r
393 +       "scripts",                      /* shader directory */\r
394 +       2048,                           /* max lightmapped surface verts */\r
395 +       2048,                           /* max surface verts */\r
396 +       12288,                          /* max surface indexes */\r
397 +       qtrue,                          /* flares */\r
398 +       "flareshader",          /* default flare shader */\r
399 +       qfalse,                         /* wolf lighting model? */\r
400 +       512,                            /* lightmap width/height */\r
401 +       1.0f,                           /* lightmap gamma */\r
402 +       1.0f,                           /* lightmap exposure */\r
403 +       1.0f,                           /* lightmap compensate */\r
404 +       1.0f,                           /* lightgrid scale */\r
405 +       1.0f,                           /* lightgrid ambient scale */\r
406 +       qfalse,                         /* disable shader lightstyles hack */\r
407 +       qfalse,                         /* keep light entities on bsp */\r
408 +       8,                                      /* default patchMeta subdivisions tolerance */\r
409 +       qfalse,                         /* patch casting enabled */\r
410 +       qfalse,                         /* compile deluxemaps */\r
411 +       0,                                      /* deluxemaps default mode */\r
412 +       "FBSP",                         /* bsp file prefix */\r
413 +       1,                                      /* bsp file version */\r
414 +       qfalse,                         /* cod-style lump len/ofs order */\r
415 +       LoadRBSPFile,           /* bsp load function */\r
416 +       WriteRBSPFile,          /* bsp write function */\r
417 +\r
418 +       {\r
419 +               /* name                         contentFlags                            contentFlagsClear                       surfaceFlags                            surfaceFlagsClear                       compileFlags                            compileFlagsClear */\r
420 +               \r
421 +               /* default */\r
422 +               { "default",            F_CONT_SOLID,                           -1,                                                     0,                                                      -1,                                                     C_SOLID,                                        -1 },\r
423 +               \r
424 +               \r
425 +               /* ydnar */\r
426 +               { "lightgrid",          0,                                                      0,                                                      0,                                                      0,                                                      C_LIGHTGRID,                            0 },\r
427 +               { "antiportal",         0,                                                      0,                                                      0,                                                      0,                                                      C_ANTIPORTAL,                           0 },\r
428 +               { "skip",                       0,                                                      0,                                                      0,                                                      0,                                                      C_SKIP,                                         0 },\r
429 +               \r
430 +               \r
431 +               /* compiler */\r
432 +               { "origin",                     F_CONT_ORIGIN,                          F_CONT_SOLID,                           0,                                                      0,                                                      C_ORIGIN | C_TRANSLUCENT,       C_SOLID },\r
433 +               { "areaportal",         F_CONT_AREAPORTAL,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_AREAPORTAL | C_TRANSLUCENT,   C_SOLID },\r
434 +               { "trans",                      F_CONT_TRANSLUCENT,                     0,                                                      0,                                                      0,                                                      C_TRANSLUCENT,                          0 },\r
435 +               { "detail",                     F_CONT_DETAIL,                          0,                                                      0,                                                      0,                                                      C_DETAIL,                                       0 },\r
436 +               { "structural",         F_CONT_STRUCTURAL,                      0,                                                      0,                                                      0,                                                      C_STRUCTURAL,                           0 },\r
437 +               { "hint",                       0,                                                      0,                                                      F_SURF_HINT,                            0,                                                      C_HINT,                                         0 },\r
438 +               { "nodraw",                     0,                                                      0,                                                      F_SURF_NODRAW,                          0,                                                      C_NODRAW,                                       0 },\r
439 +               \r
440 +               { "alphashadow",        0,                                                      0,                                                      F_SURF_ALPHASHADOW,                     0,                                                      C_ALPHASHADOW | C_TRANSLUCENT,  0 },\r
441 +               { "lightfilter",        0,                                                      0,                                                      F_SURF_LIGHTFILTER,                     0,                                                      C_LIGHTFILTER | C_TRANSLUCENT,  0 },\r
442 +               { "nolightmap",         0,                                                      0,                                                      F_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },\r
443 +               { "pointlight",         0,                                                      0,                                                      F_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },\r
444 +               \r
445 +               \r
446 +               /* game */\r
447 +               { "nonsolid",           0,                                                      F_CONT_SOLID,                           F_SURF_NONSOLID,                        0,                                                      0,                                                      C_SOLID },\r
448 +               \r
449 +               { "trigger",            F_CONT_TRIGGER,                         F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
450 +               \r
451 +               { "water",                      F_CONT_WATER,                           F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
452 +               { "slime",                      F_CONT_SLIME,                           F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
453 +               { "lava",                       F_CONT_LAVA,                            F_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
454 +               \r
455 +               { "playerclip",         F_CONT_PLAYERCLIP,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },\r
456 +               { "monsterclip",        F_CONT_MONSTERCLIP,                     F_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },\r
457 +               { "nodrop",                     F_CONT_NODROP,                          F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
458 +               \r
459 +               { "clusterportal",      F_CONT_CLUSTERPORTAL,           F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
460 +               { "donotenter",         F_CONT_DONOTENTER,                      F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
461 +               { "botclip",            F_CONT_BOTCLIP,                         F_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
462 +               \r
463 +               { "fog",                        F_CONT_FOG,                                     F_CONT_SOLID,                           0,                                                      0,                                                      C_FOG,                                          C_SOLID },\r
464 +               { "sky",                        0,                                                      0,                                                      F_SURF_SKY,                                     0,                                                      C_SKY,                                          0 },\r
465 +               \r
466 +               { "slick",                      0,                                                      0,                                                      F_SURF_SLICK,                           0,                                                      0,                                                      0 },\r
467 +               \r
468 +               { "noimpact",           0,                                                      0,                                                      F_SURF_NOIMPACT,                        0,                                                      0,                                                      0 },\r
469 +               { "nomarks",            0,                                                      0,                                                      F_SURF_NOMARKS,                         0,                                                      C_NOMARKS,                                      0 },\r
470 +               { "ladder",                     0,                                                      0,                                                      F_SURF_LADDER,                          0,                                                      0,                                                      0 },\r
471 +               { "nodamage",           0,                                                      0,                                                      F_SURF_NODAMAGE,                        0,                                                      0,                                                      0 },\r
472 +               { "metalsteps",         0,                                                      0,                                                      F_SURF_METALSTEPS,                      0,                                                      0,                                                      0 },\r
473 +               { "flesh",                      0,                                                      0,                                                      F_SURF_FLESH,                           0,                                                      0,                                                      0 },\r
474 +               { "nosteps",            0,                                                      0,                                                      F_SURF_NOSTEPS,                         0,                                                      0,                                                      0 },\r
475 +               { "nodlight",           0,                                                      0,                                                      F_SURF_NODLIGHT,                        0,                                                      0,                                                      0 },\r
476 +               { "dust",                       0,                                                      0,                                                      F_SURF_DUST,                            0,                                                      0,                                                      0 },\r
477 +               \r
478 +               \r
479 +               /* null */\r
480 +               { NULL, 0, 0, 0, 0, 0, 0 }\r
481 +       }\r
482 +}\r
483 +\r
484 +\r
485 +\r
486 +/* end marker */\r
487 +#endif\r
488 +\r
489 Index: game_quake3.h\r
490 ===================================================================\r
491 --- game_quake3.h       (revision 158)\r
492 +++ game_quake3.h       (working copy)\r
493 @@ -112,7 +112,16 @@\r
494         qfalse,                         /* wolf lighting model? */
495         128,                            /* lightmap width/height */
496         1.0f,                           /* lightmap gamma */
497 +       1.0f,                           /* lightmap exposure */
498         1.0f,                           /* lightmap compensate */
499 +       1.0f,                           /* lightgrid scale */
500 +       1.0f,                           /* lightgrid ambient scale */
501 +       qfalse,                         /* disable shader lightstyles hack */
502 +       qfalse,                         /* keep light entities on bsp */
503 +       8,                                      /* default patchMeta subdivisions tolerance */
504 +       qfalse,                         /* patch casting enabled */
505 +       qfalse,                         /* compile deluxemaps */
506 +       0,                                      /* deluxemaps default mode */
507         "IBSP",                         /* bsp file prefix */
508         46,                                     /* bsp file version */
509         qfalse,                         /* cod-style lump len/ofs order */
510 Index: game_sof2.h\r
511 ===================================================================\r
512 --- game_sof2.h (revision 158)\r
513 +++ game_sof2.h (working copy)\r
514 @@ -139,7 +139,16 @@\r
515         qfalse,                                 /* wolf lighting model? */
516         128,                                    /* lightmap width/height */
517         1.0f,                                   /* lightmap gamma */
518 +       1.0f,                                   /* lightmap exposure */
519         1.0f,                                   /* lightmap compensate */
520 +       1.0f,                           /* lightgrid scale */
521 +       1.0f,                           /* lightgrid ambient scale */
522 +       qfalse,                         /* disable shader lightstyles hack */
523 +       qfalse,                         /* keep light entities on bsp */
524 +       8,                                      /* default patchMeta subdivisions tolerance */
525 +       qfalse,                         /* patch casting enabled */
526 +       qfalse,                         /* compile deluxemaps */
527 +       0,                                      /* deluxemaps default mode */
528         "RBSP",                                 /* bsp file prefix */
529         1,                                              /* bsp file version */
530         qfalse,                                 /* cod-style lump len/ofs order */
531 Index: game_tenebrae.h\r
532 ===================================================================\r
533 --- game_tenebrae.h     (revision 158)\r
534 +++ game_tenebrae.h     (working copy)\r
535 @@ -112,7 +112,16 @@\r
536         qfalse,                         /* wolf lighting model? */
537         512,                            /* lightmap width/height */
538         2.0f,                           /* lightmap gamma */
539 +       1.0f,                           /* lightmap exposure */
540         1.0f,                           /* lightmap compensate */
541 +       1.0f,                           /* lightgrid scale */
542 +       1.0f,                           /* lightgrid ambient scale */
543 +       qtrue,                          /* disable shader lightstyles hack */
544 +       qfalse,                         /* keep light entities on bsp */
545 +       8,                                      /* default patchMeta subdivisions tolerance */
546 +       qfalse,                         /* patch casting enabled */
547 +       qtrue,                          /* compile deluxemaps */
548 +       0,                                      /* deluxemaps default mode */
549         "IBSP",                         /* bsp file prefix */
550         46,                                     /* bsp file version */
551         qfalse,                         /* cod-style lump len/ofs order */
552 Index: game_tremulous.h\r
553 ===================================================================\r
554 --- game_tremulous.h    (revision 158)\r
555 +++ game_tremulous.h    (working copy)\r
556 @@ -1,160 +1,169 @@\r
557 -/* -------------------------------------------------------------------------------
558 -
559 -Copyright (C) 1999-2006 Id Software, Inc. and contributors.
560 -For a list of contributors, see the accompanying CONTRIBUTORS file.
561 -
562 -This file is part of GtkRadiant.
563 -
564 -GtkRadiant is free software; you can redistribute it and/or modify
565 -it under the terms of the GNU General Public License as published by
566 -the Free Software Foundation; either version 2 of the License, or
567 -(at your option) any later version.
568 -
569 -GtkRadiant is distributed in the hope that it will be useful,
570 -but WITHOUT ANY WARRANTY; without even the implied warranty of
571 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
572 -GNU General Public License for more details.
573 -
574 -You should have received a copy of the GNU General Public License
575 -along with GtkRadiant; if not, write to the Free Software
576 -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
577 -
578 -----------------------------------------------------------------------------------
579 -
580 -This code has been altered significantly from its original form, to support
581 -several games based on the Quake III Arena engine, in the form of "Q3Map2."
582 -
583 -------------------------------------------------------------------------------- */
584 -
585 -/* Tremulous support, by LinuxManMikeC */
586 -
587 -
588 -/* marker */
589 -#ifndef GAME_TREMULOUS_H
590 -#define GAME_TREMULOUS_H
591 -
592 -
593 -
594 -/* -------------------------------------------------------------------------------
595 -
596 -content and surface flags - also uses defines from game_quake3.h
597 -
598 -------------------------------------------------------------------------------- */
599 -#define TREM_CONT_NOALIENBUILD         0x1000
600 -#define TREM_CONT_NOHUMANBUILD         0x2000
601 -#define TREM_CONT_NOBUILD              0x4000
602 -  
603 -#define TREM_SURF_NOALIENBUILDSURFACE  0x80000 
604 -#define TREM_SURF_NOHUMANBUILDSURFACE  0x100000
605 -#define TREM_SURF_NOBUILDSURFACE       0x200000
606 -
607 -
608 -
609 -/* -------------------------------------------------------------------------------
610 -
611 -game_t struct
612 -
613 -------------------------------------------------------------------------------- */
614 -
615 -{
616 -       "tremulous",                    /* -game x */
617 -       "base",                 /* default base game data dir */
618 -       ".tremulous",                           /* unix home sub-dir */
619 -       "tremulous",                    /* magic path word - think this is right for trem*/
620 -       "scripts",                      /* shader directory */
621 -       64,                                     /* max lightmapped surface verts */
622 -       999,                            /* max surface verts */
623 -       6000,                           /* max surface indexes */
624 -       qfalse,                         /* flares */
625 -       "flareshader",          /* default flare shader */
626 -       qfalse,                         /* wolf lighting model? */
627 -       128,                            /* lightmap width/height */
628 -       1.0f,                           /* lightmap gamma */
629 -       1.0f,                           /* lightmap compensate */
630 -       "IBSP",                         /* bsp file prefix */
631 -       46,                                     /* bsp file version */
632 -       qfalse,                         /* cod-style lump len/ofs order */
633 -       LoadIBSPFile,           /* bsp load function */
634 -       WriteIBSPFile,          /* bsp write function */
635 -
636 -       {
637 -               /* name                         contentFlags                            contentFlagsClear                       surfaceFlags                            surfaceFlagsClear                       compileFlags                            compileFlagsClear */
638 -               
639 -               /* default */
640 -               { "default",            Q_CONT_SOLID,                           -1,                                                     0,                                                      -1,                                                     C_SOLID,                                        -1 },
641 -               
642 -               
643 -               /* ydnar */
644 -               { "lightgrid",          0,                                                      0,                                                      0,                                                      0,                                                      C_LIGHTGRID,                            0 },
645 -               { "antiportal",         0,                                                      0,                                                      0,                                                      0,                                                      C_ANTIPORTAL,                           0 },
646 -               { "skip",                       0,                                                      0,                                                      0,                                                      0,                                                      C_SKIP,                                         0 },
647 -               
648 -               
649 -               /* compiler */
650 -               { "origin",                     Q_CONT_ORIGIN,                          Q_CONT_SOLID,                           0,                                                      0,                                                      C_ORIGIN | C_TRANSLUCENT,       C_SOLID },
651 -               { "areaportal",         Q_CONT_AREAPORTAL,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_AREAPORTAL | C_TRANSLUCENT,   C_SOLID },
652 -               { "trans",                      Q_CONT_TRANSLUCENT,                     0,                                                      0,                                                      0,                                                      C_TRANSLUCENT,                          0 },
653 -               { "detail",                     Q_CONT_DETAIL,                          0,                                                      0,                                                      0,                                                      C_DETAIL,                                       0 },
654 -               { "structural",         Q_CONT_STRUCTURAL,                      0,                                                      0,                                                      0,                                                      C_STRUCTURAL,                           0 },
655 -               { "hint",                       0,                                                      0,                                                      Q_SURF_HINT,                            0,                                                      C_HINT,                                         0 },
656 -               { "nodraw",                     0,                                                      0,                                                      Q_SURF_NODRAW,                          0,                                                      C_NODRAW,                                       0 },
657 -               
658 -               { "alphashadow",        0,                                                      0,                                                      Q_SURF_ALPHASHADOW,                     0,                                                      C_ALPHASHADOW | C_TRANSLUCENT,  0 },
659 -               { "lightfilter",        0,                                                      0,                                                      Q_SURF_LIGHTFILTER,                     0,                                                      C_LIGHTFILTER | C_TRANSLUCENT,  0 },
660 -               { "nolightmap",         0,                                                      0,                                                      Q_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },
661 -               { "pointlight",         0,                                                      0,                                                      Q_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },
662 -               
663 -               
664 -               /* game */
665 -               { "nonsolid",           0,                                                      Q_CONT_SOLID,                           Q_SURF_NONSOLID,                        0,                                                      0,                                                      C_SOLID },
666 -               
667 -               { "trigger",            Q_CONT_TRIGGER,                         Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
668 -               
669 -               { "water",                      Q_CONT_WATER,                           Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
670 -               { "slime",                      Q_CONT_SLIME,                           Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
671 -               { "lava",                       Q_CONT_LAVA,                            Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },
672 -               
673 -               { "playerclip",         Q_CONT_PLAYERCLIP,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },
674 -               { "monsterclip",        Q_CONT_MONSTERCLIP,                     Q_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },
675 -               { "nodrop",                     Q_CONT_NODROP,                          Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
676 -               
677 -               { "clusterportal",      Q_CONT_CLUSTERPORTAL,           Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
678 -               { "donotenter",         Q_CONT_DONOTENTER,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
679 -               { "botclip",            Q_CONT_BOTCLIP,                         Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },
680 -               
681 -               { "fog",                        Q_CONT_FOG,                                     Q_CONT_SOLID,                           0,                                                      0,                                                      C_FOG,                                          C_SOLID },
682 -               { "sky",                        0,                                                      0,                                                      Q_SURF_SKY,                                     0,                                                      C_SKY,                                          0 },
683 -               
684 -               { "slick",                      0,                                                      0,                                                      Q_SURF_SLICK,                           0,                                                      0,                                                      0 },
685 -               
686 -               { "noimpact",           0,                                                      0,                                                      Q_SURF_NOIMPACT,                        0,                                                      0,                                                      0 },
687 -               { "nomarks",            0,                                                      0,                                                      Q_SURF_NOMARKS,                         0,                                                      C_NOMARKS,                                      0 },
688 -               { "ladder",                     0,                                                      0,                                                      Q_SURF_LADDER,                          0,                                                      0,                                                      0 },
689 -               { "nodamage",           0,                                                      0,                                                      Q_SURF_NODAMAGE,                        0,                                                      0,                                                      0 },
690 -               { "metalsteps",         0,                                                      0,                                                      Q_SURF_METALSTEPS,                      0,                                                      0,                                                      0 },
691 -               { "flesh",                      0,                                                      0,                                                      Q_SURF_FLESH,                           0,                                                      0,                                                      0 },
692 -               { "nosteps",            0,                                                      0,                                                      Q_SURF_NOSTEPS,                         0,                                                      0,                                                      0 },
693 -               { "nodlight",           0,                                                      0,                                                      Q_SURF_NODLIGHT,                        0,                                                      0,                                                      0 },
694 -               { "dust",                       0,                                                      0,                                                      Q_SURF_DUST,                            0,                                                      0,                                                      0 },
695 -               
696 -               
697 -               /* tremulous */
698 -               {"noalienbuild",                        TREM_CONT_NOALIENBUILD,0,0,0,0,0},
699 -               {"nohumanbuild",                        TREM_CONT_NOHUMANBUILD,0,0,0,0,0},
700 -               {"nobuild",                                     TREM_CONT_NOBUILD,0,0,0,0,0},
701 -               
702 -               {"noalienbuildsurface", 0,0,TREM_SURF_NOALIENBUILDSURFACE,0,0,0},
703 -               {"nohumanbuildsurface", 0,0,TREM_SURF_NOHUMANBUILDSURFACE,0,0,0},
704 -               {"nobuildsurface",              0,0,TREM_SURF_NOBUILDSURFACE,0,0,0},
705 -               
706 -               
707 -               /* null */
708 -               { NULL, 0, 0, 0, 0, 0, 0 }
709 -       }
710 -}
711 -
712 -
713 -
714 -/* end marker */
715 -#endif
716 -
717 +/* -------------------------------------------------------------------------------\r
718 +\r
719 +Copyright (C) 1999-2006 Id Software, Inc. and contributors.\r
720 +For a list of contributors, see the accompanying CONTRIBUTORS file.\r
721 +\r
722 +This file is part of GtkRadiant.\r
723 +\r
724 +GtkRadiant is free software; you can redistribute it and/or modify\r
725 +it under the terms of the GNU General Public License as published by\r
726 +the Free Software Foundation; either version 2 of the License, or\r
727 +(at your option) any later version.\r
728 +\r
729 +GtkRadiant is distributed in the hope that it will be useful,\r
730 +but WITHOUT ANY WARRANTY; without even the implied warranty of\r
731 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
732 +GNU General Public License for more details.\r
733 +\r
734 +You should have received a copy of the GNU General Public License\r
735 +along with GtkRadiant; if not, write to the Free Software\r
736 +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA\r
737 +\r
738 +----------------------------------------------------------------------------------\r
739 +\r
740 +This code has been altered significantly from its original form, to support\r
741 +several games based on the Quake III Arena engine, in the form of "Q3Map2."\r
742 +\r
743 +------------------------------------------------------------------------------- */\r
744 +\r
745 +/* Tremulous support, by LinuxManMikeC */\r
746 +\r
747 +\r
748 +/* marker */\r
749 +#ifndef GAME_TREMULOUS_H\r
750 +#define GAME_TREMULOUS_H\r
751 +\r
752 +\r
753 +\r
754 +/* -------------------------------------------------------------------------------\r
755 +\r
756 +content and surface flags - also uses defines from game_quake3.h\r
757 +\r
758 +------------------------------------------------------------------------------- */\r
759 +#define TREM_CONT_NOALIENBUILD         0x1000\r
760 +#define TREM_CONT_NOHUMANBUILD         0x2000\r
761 +#define TREM_CONT_NOBUILD              0x4000\r
762 +  \r
763 +#define TREM_SURF_NOALIENBUILDSURFACE  0x80000 \r
764 +#define TREM_SURF_NOHUMANBUILDSURFACE  0x100000\r
765 +#define TREM_SURF_NOBUILDSURFACE       0x200000\r
766 +\r
767 +\r
768 +\r
769 +/* -------------------------------------------------------------------------------\r
770 +\r
771 +game_t struct\r
772 +\r
773 +------------------------------------------------------------------------------- */\r
774 +\r
775 +{\r
776 +       "tremulous",                    /* -game x */\r
777 +       "base",                 /* default base game data dir */\r
778 +       ".tremulous",                           /* unix home sub-dir */\r
779 +       "tremulous",                    /* magic path word - think this is right for trem*/\r
780 +       "scripts",                      /* shader directory */\r
781 +       64,                                     /* max lightmapped surface verts */\r
782 +       999,                            /* max surface verts */\r
783 +       6000,                           /* max surface indexes */\r
784 +       qfalse,                         /* flares */\r
785 +       "flareshader",          /* default flare shader */\r
786 +       qfalse,                         /* wolf lighting model? */\r
787 +       128,                            /* lightmap width/height */\r
788 +       1.0f,                           /* lightmap gamma */\r
789 +       1.0f,                           /* lightmap exposure */\r
790 +       1.0f,                           /* lightmap compensate */\r
791 +       1.0f,                           /* lightgrid scale */\r
792 +       1.0f,                           /* lightgrid ambient scale */\r
793 +       qfalse,                         /* disable shader lightstyles hack */\r
794 +       qfalse,                         /* keep light entities on bsp */\r
795 +       8,                                      /* default patchMeta subdivisions tolerance */\r
796 +       qfalse,                         /* patch casting enabled */\r
797 +       qfalse,                         /* compile deluxemaps */\r
798 +       0,                                      /* deluxemaps default mode */\r
799 +       "IBSP",                         /* bsp file prefix */\r
800 +       46,                                     /* bsp file version */\r
801 +       qfalse,                         /* cod-style lump len/ofs order */\r
802 +       LoadIBSPFile,           /* bsp load function */\r
803 +       WriteIBSPFile,          /* bsp write function */\r
804 +\r
805 +       {\r
806 +               /* name                         contentFlags                            contentFlagsClear                       surfaceFlags                            surfaceFlagsClear                       compileFlags                            compileFlagsClear */\r
807 +               \r
808 +               /* default */\r
809 +               { "default",            Q_CONT_SOLID,                           -1,                                                     0,                                                      -1,                                                     C_SOLID,                                        -1 },\r
810 +               \r
811 +               \r
812 +               /* ydnar */\r
813 +               { "lightgrid",          0,                                                      0,                                                      0,                                                      0,                                                      C_LIGHTGRID,                            0 },\r
814 +               { "antiportal",         0,                                                      0,                                                      0,                                                      0,                                                      C_ANTIPORTAL,                           0 },\r
815 +               { "skip",                       0,                                                      0,                                                      0,                                                      0,                                                      C_SKIP,                                         0 },\r
816 +               \r
817 +               \r
818 +               /* compiler */\r
819 +               { "origin",                     Q_CONT_ORIGIN,                          Q_CONT_SOLID,                           0,                                                      0,                                                      C_ORIGIN | C_TRANSLUCENT,       C_SOLID },\r
820 +               { "areaportal",         Q_CONT_AREAPORTAL,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_AREAPORTAL | C_TRANSLUCENT,   C_SOLID },\r
821 +               { "trans",                      Q_CONT_TRANSLUCENT,                     0,                                                      0,                                                      0,                                                      C_TRANSLUCENT,                          0 },\r
822 +               { "detail",                     Q_CONT_DETAIL,                          0,                                                      0,                                                      0,                                                      C_DETAIL,                                       0 },\r
823 +               { "structural",         Q_CONT_STRUCTURAL,                      0,                                                      0,                                                      0,                                                      C_STRUCTURAL,                           0 },\r
824 +               { "hint",                       0,                                                      0,                                                      Q_SURF_HINT,                            0,                                                      C_HINT,                                         0 },\r
825 +               { "nodraw",                     0,                                                      0,                                                      Q_SURF_NODRAW,                          0,                                                      C_NODRAW,                                       0 },\r
826 +               \r
827 +               { "alphashadow",        0,                                                      0,                                                      Q_SURF_ALPHASHADOW,                     0,                                                      C_ALPHASHADOW | C_TRANSLUCENT,  0 },\r
828 +               { "lightfilter",        0,                                                      0,                                                      Q_SURF_LIGHTFILTER,                     0,                                                      C_LIGHTFILTER | C_TRANSLUCENT,  0 },\r
829 +               { "nolightmap",         0,                                                      0,                                                      Q_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },\r
830 +               { "pointlight",         0,                                                      0,                                                      Q_SURF_VERTEXLIT,                       0,                                                      C_VERTEXLIT,                            0 },\r
831 +               \r
832 +               \r
833 +               /* game */\r
834 +               { "nonsolid",           0,                                                      Q_CONT_SOLID,                           Q_SURF_NONSOLID,                        0,                                                      0,                                                      C_SOLID },\r
835 +               \r
836 +               { "trigger",            Q_CONT_TRIGGER,                         Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
837 +               \r
838 +               { "water",                      Q_CONT_WATER,                           Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
839 +               { "slime",                      Q_CONT_SLIME,                           Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
840 +               { "lava",                       Q_CONT_LAVA,                            Q_CONT_SOLID,                           0,                                                      0,                                                      C_LIQUID | C_TRANSLUCENT,       C_SOLID },\r
841 +               \r
842 +               { "playerclip",         Q_CONT_PLAYERCLIP,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },\r
843 +               { "monsterclip",        Q_CONT_MONSTERCLIP,                     Q_CONT_SOLID,                           0,                                                      0,                                                      C_DETAIL | C_TRANSLUCENT,       C_SOLID },\r
844 +               { "nodrop",                     Q_CONT_NODROP,                          Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
845 +               \r
846 +               { "clusterportal",      Q_CONT_CLUSTERPORTAL,           Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
847 +               { "donotenter",         Q_CONT_DONOTENTER,                      Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
848 +               { "botclip",            Q_CONT_BOTCLIP,                         Q_CONT_SOLID,                           0,                                                      0,                                                      C_TRANSLUCENT,                          C_SOLID },\r
849 +               \r
850 +               { "fog",                        Q_CONT_FOG,                                     Q_CONT_SOLID,                           0,                                                      0,                                                      C_FOG,                                          C_SOLID },\r
851 +               { "sky",                        0,                                                      0,                                                      Q_SURF_SKY,                                     0,                                                      C_SKY,                                          0 },\r
852 +               \r
853 +               { "slick",                      0,                                                      0,                                                      Q_SURF_SLICK,                           0,                                                      0,                                                      0 },\r
854 +               \r
855 +               { "noimpact",           0,                                                      0,                                                      Q_SURF_NOIMPACT,                        0,                                                      0,                                                      0 },\r
856 +               { "nomarks",            0,                                                      0,                                                      Q_SURF_NOMARKS,                         0,                                                      C_NOMARKS,                                      0 },\r
857 +               { "ladder",                     0,                                                      0,                                                      Q_SURF_LADDER,                          0,                                                      0,                                                      0 },\r
858 +               { "nodamage",           0,                                                      0,                                                      Q_SURF_NODAMAGE,                        0,                                                      0,                                                      0 },\r
859 +               { "metalsteps",         0,                                                      0,                                                      Q_SURF_METALSTEPS,                      0,                                                      0,                                                      0 },\r
860 +               { "flesh",                      0,                                                      0,                                                      Q_SURF_FLESH,                           0,                                                      0,                                                      0 },\r
861 +               { "nosteps",            0,                                                      0,                                                      Q_SURF_NOSTEPS,                         0,                                                      0,                                                      0 },\r
862 +               { "nodlight",           0,                                                      0,                                                      Q_SURF_NODLIGHT,                        0,                                                      0,                                                      0 },\r
863 +               { "dust",                       0,                                                      0,                                                      Q_SURF_DUST,                            0,                                                      0,                                                      0 },\r
864 +               \r
865 +               \r
866 +               /* tremulous */\r
867 +               {"noalienbuild",                        TREM_CONT_NOALIENBUILD,0,0,0,0,0},\r
868 +               {"nohumanbuild",                        TREM_CONT_NOHUMANBUILD,0,0,0,0,0},\r
869 +               {"nobuild",                                     TREM_CONT_NOBUILD,0,0,0,0,0},\r
870 +               \r
871 +               {"noalienbuildsurface", 0,0,TREM_SURF_NOALIENBUILDSURFACE,0,0,0},\r
872 +               {"nohumanbuildsurface", 0,0,TREM_SURF_NOHUMANBUILDSURFACE,0,0,0},\r
873 +               {"nobuildsurface",              0,0,TREM_SURF_NOBUILDSURFACE,0,0,0},\r
874 +               \r
875 +               \r
876 +               /* null */\r
877 +               { NULL, 0, 0, 0, 0, 0, 0 }\r
878 +       }\r
879 +}\r
880 +\r
881 +\r
882 +\r
883 +/* end marker */\r
884 +#endif\r
885 +\r
886 Index: game_wolf.h\r
887 ===================================================================\r
888 --- game_wolf.h (revision 158)\r
889 +++ game_wolf.h (working copy)\r
890 @@ -129,7 +129,16 @@\r
891         qtrue,                          /* wolf lighting model? */
892         128,                            /* lightmap width/height */
893         1.0f,                           /* lightmap gamma */
894 +       1.0f,                           /* lightmap exposure */
895         1.0f,                           /* lightmap compensate */
896 +       1.0f,                           /* lightgrid scale */
897 +       1.0f,                           /* lightgrid ambient scale */
898 +       qfalse,                         /* disable shader lightstyles hack */
899 +       qfalse,                         /* keep light entities on bsp */
900 +       8,                                      /* default patchMeta subdivisions tolerance */
901 +       qfalse,                         /* patch casting enabled */
902 +       qfalse,                         /* compile deluxemaps */
903 +       0,                                      /* deluxemaps default mode */
904         "IBSP",                         /* bsp file prefix */
905         47,                                     /* bsp file version */
906         qfalse,                         /* cod-style lump len/ofs order */
907 Index: game_wolfet.h\r
908 ===================================================================\r
909 --- game_wolfet.h       (revision 158)\r
910 +++ game_wolfet.h       (working copy)\r
911 @@ -66,7 +66,16 @@\r
912         qtrue,                          /* wolf lighting model? */
913         128,                            /* lightmap width/height */
914         1.0f,                           /* lightmap gamma */
915 +       1.0f,                           /* lightmap exposure */
916         1.0f,                           /* lightmap compensate */
917 +       1.0f,                           /* lightgrid scale */
918 +       1.0f,                           /* lightgrid ambient scale */
919 +       qfalse,                         /* disable shader lightstyles hack */
920 +       qfalse,                         /* keep light entities on bsp */
921 +       8,                                      /* default patchMeta subdivisions tolerance */
922 +       qfalse,                         /* patch casting enabled */
923 +       qfalse,                         /* compile deluxemaps */
924 +       0,                                      /* deluxemaps default mode */
925         "IBSP",                         /* bsp file prefix */
926         47,                                     /* bsp file version */
927         qfalse,                         /* cod-style lump len/ofs order */
928 Index: light.c\r
929 ===================================================================\r
930 --- light.c     (revision 158)\r
931 +++ light.c     (working copy)\r
932 @@ -313,7 +313,15 @@\r
933                         flags |= LIGHT_GRID;
934                         flags &= ~LIGHT_SURFACES;
935                 }
936 -               
937 +
938 +               /* vortex: unnormalized? */
939 +               if (spawnflags & 32)
940 +                       flags |= LIGHT_UNNORMALIZED;
941 +
942 +               /* vortex: distance atten? */
943 +               if (spawnflags & 64)
944 +                       flags |= LIGHT_ATTEN_DISTANCE;
945 +
946                 /* store the flags */
947                 light->flags = flags;
948                 
949 @@ -357,12 +365,13 @@\r
950                 intensity *= scale;
951                 
952                 /* ydnar: get deviance and samples */
953 +               /* VorteX: now set start value for _samples when _deviance is found */
954                 deviance = FloatForKey( e, "_deviance" );
955                 if( deviance == 0.0f )
956                         deviance = FloatForKey( e, "_deviation" );
957                 if( deviance == 0.0f )
958                         deviance = FloatForKey( e, "_jitter" );
959 -               numSamples = IntForKey( e, "_samples" );
960 +               numSamples = max(IntForKey( e, "_samples" ), deviance);
961                 if( deviance < 0.0f || numSamples < 1 )
962                 {
963                         deviance = 0.0f;
964 @@ -385,14 +394,16 @@\r
965                 if( _color && _color[ 0 ] )
966                 {
967                         sscanf( _color, "%f %f %f", &light->color[ 0 ], &light->color[ 1 ], &light->color[ 2 ] );
968 -                       ColorNormalize( light->color, light->color );
969 +                       if (!(light->flags & LIGHT_UNNORMALIZED))
970 +                       {
971 +                               ColorNormalize( light->color, light->color );
972 +                       }
973                 }
974                 else
975                         light->color[ 0 ] = light->color[ 1 ] = light->color[ 2 ] = 1.0f;
976 -               
977 +
978                 intensity = intensity * pointScale;
979                 light->photons = intensity;
980 -               
981                 light->type = EMIT_POINT;
982                 
983                 /* set falloff threshold */
984 @@ -741,6 +752,7 @@\r
985         
986         /* clear color */
987         VectorClear( trace->color );
988 +       VectorClear( trace->colorNoShadow );
989         
990         /* ydnar: early out */
991         if( !(light->flags & LIGHT_SURFACES) || light->envelope <= 0.0f )
992 @@ -766,7 +778,6 @@\r
993                 float           d;
994                 vec3_t          pushedOrigin;
995                 
996 -               
997                 /* project sample point into light plane */
998                 d = DotProduct( trace->origin, light->normal ) - light->dist;
999                 if( d < 3.0f )
1000 @@ -881,8 +892,7 @@\r
1001                 {
1002                         float   distByNormal, radiusAtDist, sampleRadius;
1003                         vec3_t  pointAtDist, distToSample;
1004 -                       
1005 -                       
1006 +       
1007                         /* do cone calculation */
1008                         distByNormal = -DotProduct( trace->displacement, light->normal );
1009                         if( distByNormal < 0.0f )
1010 @@ -922,6 +932,9 @@\r
1011                 add = light->photons * angle;
1012                 if( add <= 0.0f )
1013                         return 0;
1014 +
1015 +               /* VorteX: set noShadow color */
1016 +               VectorScale(light->color, add, trace->colorNoShadow);
1017                 
1018                 /* setup trace */
1019                 trace->testAll = qtrue;
1020 @@ -942,6 +955,9 @@\r
1021                 /* return to sender */
1022                 return 1;
1023         }
1024 +
1025 +       /* VorteX: set noShadow color */
1026 +       VectorScale(light->color, add, trace->colorNoShadow);
1027         
1028         /* ydnar: changed to a variable number */
1029         if( add <= 0.0f || (add <= light->falloffTolerance && (light->flags & LIGHT_FAST_ACTUAL)) )
1030 @@ -1378,6 +1394,56 @@\r
1031                         break;
1032         }
1033         
1034 +       /////// Floodlighting for point //////////////////
1035 +       //do our floodlight ambient occlusion loop, and add a single contribution based on the brightest dir
1036 +       if (floodlighty)
1037 +       {
1038 +               int q;
1039 +               float addSize,f;
1040 +               vec3_t col,dir;
1041 +               col[0]=col[1]=col[2]=floodlightIntensity;
1042 +               dir[0]=dir[1]=0;
1043 +               dir[2]=1;
1044 +      
1045 +               trace.testOcclusion = qtrue;
1046 +               trace.forceSunlight = qfalse;
1047 +               trace.inhibitRadius = DEFAULT_INHIBIT_RADIUS;
1048 +               trace.testAll = qtrue;     
1049 +      
1050 +               for (q=0;q<2;q++)
1051 +               {
1052 +                       if (q==0) //upper hemisphere
1053 +                       {
1054 +                               trace.normal[0]=0;
1055 +                               trace.normal[1]=0;
1056 +                               trace.normal[2]=1;
1057 +                       }
1058 +                       else //lower hemisphere
1059 +                       {
1060 +                               trace.normal[0]=0;
1061 +                               trace.normal[1]=0;
1062 +                               trace.normal[2]=-1;
1063 +                       }
1064 +
1065 +                       f = FloodLightForSample(&trace, floodlightDistance, floodlight_lowquality);
1066 +
1067 +                       contributions[ numCon ].color[0]=col[0]*f;
1068 +                       contributions[ numCon ].color[1]=col[1]*f;
1069 +                       contributions[ numCon ].color[2]=col[2]*f;
1070 +
1071 +                       contributions[ numCon ].dir[0]=dir[0];
1072 +                       contributions[ numCon ].dir[1]=dir[1];
1073 +                       contributions[ numCon ].dir[2]=dir[2];
1074 +
1075 +                       contributions[ numCon ].style = 0;
1076 +                       numCon++;               
1077 +                       /* push average direction around */
1078 +                       addSize = VectorLength( col );
1079 +                       VectorMA( gp->dir, addSize, dir, gp->dir );
1080 +               }
1081 +       }
1082 +       /////////////////////
1083 +
1084         /* normalize to get primary light direction */
1085         VectorNormalize( gp->dir, gp->dir );
1086         
1087 @@ -1420,6 +1486,9 @@\r
1088                 
1089                 /* ambient light will be at 1/4 the value of directed light */
1090                 /* (ydnar: nuke this in favor of more dramatic lighting?) */
1091 +               /* (PM: how about actually making it work? d=1 when it got here for single lights/sun :P */
1092 +//             d = 0.25f;
1093 +               /* (Hobbes: always setting it to .25 is hardly any better) */
1094                 d = 0.25f * (1.0f - d);
1095                 VectorMA( gp->ambient[ j ], d, contributions[ i ].color, gp->ambient[ j ] );
1096         }
1097 @@ -1437,8 +1506,10 @@\r
1098                 for( j = 0; j < 3; j++ )
1099                         if( color[ j ] < minGridLight[ j ] )
1100                                 color[ j ] = minGridLight[ j ];
1101 -               ColorToBytes( color, bgp->ambient[ i ], 1.0f );
1102 -               ColorToBytes( gp->directed[ i ], bgp->directed[ i ], 1.0f );
1103 +
1104 +               /* vortex: apply gridscale and gridambientscale here */
1105 +               ColorToBytes( color, bgp->ambient[ i ], gridScale*gridAmbientScale );
1106 +               ColorToBytes( gp->directed[ i ], bgp->directed[ i ], gridScale );
1107         }
1108         
1109         /* debug code */
1110 @@ -1654,14 +1725,12 @@\r
1111         if( dirty )
1112         {
1113                 Sys_Printf( "--- DirtyRawLightmap ---\n" );
1114 -
1115 -
1116 -
1117 -
1118                 RunThreadsOnIndividual( numRawLightmaps, qtrue, DirtyRawLightmap );
1119         }
1120 -       
1121  
1122 +       /* floodlight pass */
1123 +       FloodlightRawLightmaps();
1124 +
1125         /* ydnar: set up light envelopes */
1126         SetupEnvelopes( qfalse, fast );
1127         
1128 @@ -1774,12 +1843,64 @@\r
1129         
1130         /* note it */
1131         Sys_Printf( "--- Light ---\n" );
1132 -       
1133 +       Sys_Printf( "--- ProcessGameSpecific ---\n" );
1134 +
1135         /* set standard game flags */
1136         wolfLight = game->wolfLight;
1137 +       if (wolfLight == qtrue)
1138 +               Sys_Printf( " lightning model: wolf\n" );
1139 +       else
1140 +               Sys_Printf( " lightning model: quake3\n" );
1141 +
1142         lmCustomSize = game->lightmapSize;
1143 +       Sys_Printf( " lightmap size: %d x %d pixels\n", lmCustomSize, lmCustomSize );
1144 +
1145         lightmapGamma = game->lightmapGamma;
1146 +       Sys_Printf( " lightning gamma: %f\n", lightmapGamma );
1147 +
1148         lightmapCompensate = game->lightmapCompensate;
1149 +       Sys_Printf( " lightning compensation: %f\n", lightmapCompensate );
1150 +
1151 +       lightmapExposure = game->lightmapExposure;
1152 +       Sys_Printf( " lightning exposure: %f\n", lightmapExposure );
1153 +
1154 +       gridScale = game->gridScale;
1155 +       Sys_Printf( " lightgrid scale: %f\n", gridScale );
1156 +
1157 +       gridAmbientScale = game->gridAmbientScale;
1158 +       Sys_Printf( " lightgrid ambient scale: %f\n", gridAmbientScale );
1159 +
1160 +       noStyles = game->noStyles;
1161 +       if (noStyles == qtrue)
1162 +               Sys_Printf( " shader lightstyles hack: disabled\n" );
1163 +       else
1164 +               Sys_Printf( " shader lightstyles hack: enabled\n" );
1165 +
1166 +       keepLights = game->keepLights;
1167 +       if (keepLights == qtrue)
1168 +               Sys_Printf( " keep lights: enabled\n" );
1169 +       else
1170 +               Sys_Printf( " keep lights: disabled\n" );
1171 +
1172 +       patchShadows = game->patchShadows;
1173 +       if (patchShadows == qtrue)
1174 +               Sys_Printf( " patch shadows: enabled\n" );
1175 +       else
1176 +               Sys_Printf( " patch shadows: disabled\n" );
1177 +
1178 +       deluxemap = game->deluxeMap;
1179 +       deluxemode = game->deluxeMode;
1180 +       if (deluxemap == qtrue)
1181 +       {
1182 +               if (deluxemode)
1183 +                       Sys_Printf( " deluxemapping: enabled with tangentspace deluxemaps\n" );
1184 +               else
1185 +                       Sys_Printf( " deluxemapping: enabled with modelspace deluxemaps\n" );
1186 +       }
1187 +       else
1188 +               Sys_Printf( " deluxemapping: disabled\n" );
1189 +
1190 +       Sys_Printf( "--- ProcessCommandLine ---\n" );
1191         
1192         /* process commandline arguments */
1193         for( i = 1; i < (argc - 1); i++ )
1194 @@ -1827,6 +1948,22 @@\r
1195                         Sys_Printf( "All light scaled by %f\n", f );
1196                         i++;
1197                 }
1198 +
1199 +               else if( !strcmp( argv[ i ], "-gridscale" ) )
1200 +               {
1201 +                       f = atof( argv[ i + 1 ] );
1202 +                       Sys_Printf( "Grid lightning scaled by %f\n", f );
1203 +                       gridScale *= f;
1204 +                       i++;
1205 +               }
1206 +
1207 +               else if( !strcmp( argv[ i ], "-gridambientscale" ) )
1208 +               {
1209 +                       f = atof( argv[ i + 1 ] );
1210 +                       Sys_Printf( "Grid ambient lightning scaled by %f\n", f );
1211 +                       gridAmbientScale *= f;
1212 +                       i++;
1213 +               }
1214                 
1215                 else if( !strcmp( argv[ i ], "-gamma" ) )
1216                 {
1217 @@ -1836,6 +1973,14 @@\r
1218                         i++;
1219                 }
1220                 
1221 +               else if( !strcmp( argv[ i ], "-exposure" ) )
1222 +               {
1223 +                       f = atof( argv[ i + 1 ] );
1224 +                       lightmapExposure = f;
1225 +                       Sys_Printf( "Lighting exposure set to %f\n", lightmapExposure );
1226 +                       i++;
1227 +               }
1228 +               
1229                 else if( !strcmp( argv[ i ], "-compensate" ) )
1230                 {
1231                         f = atof( argv[ i + 1 ] );
1232 @@ -1889,12 +2034,6 @@\r
1233                         Sys_Printf( "Dark lightmap seams enabled\n" );
1234                 }
1235                 
1236 -
1237 -
1238 -
1239 -
1240 -
1241 -
1242                 else if( !strcmp( argv[ i ], "-shadeangle" ) )
1243                 {
1244                         shadeAngleDegrees = atof( argv[ i + 1 ] );
1245 @@ -1927,13 +2066,28 @@\r
1246                                 Sys_Printf( "Approximating lightmaps within a byte tolerance of %d\n", approximateTolerance );
1247                         i++;
1248                 }
1249 -               
1250                 else if( !strcmp( argv[ i ], "-deluxe" ) || !strcmp( argv[ i ], "-deluxemap" ) )
1251                 {
1252                         deluxemap = qtrue;
1253                         Sys_Printf( "Generating deluxemaps for average light direction\n" );
1254                 }
1255 -               
1256 +               else if( !strcmp( argv[ i ], "-deluxemode" ))
1257 +               {
1258 +                       deluxemode = atoi( argv[ i + 1 ] );
1259 +                       if (deluxemode == 0 || deluxemode > 1 || deluxemode < 0)
1260 +                       {
1261 +                               Sys_Printf( "Generating modelspace deluxemaps\n" );
1262 +                               deluxemode = 0;
1263 +                       }
1264 +                       else 
1265 +                               Sys_Printf( "Generating tangentspace deluxemaps\n" );
1266 +                       i++;
1267 +               }
1268 +               else if( !strcmp( argv[ i ], "-nodeluxe" ) || !strcmp( argv[ i ], "-nodeluxemap" ) )
1269 +               {
1270 +                       deluxemap = qfalse;
1271 +                       Sys_Printf( "Disabling generating of deluxemaps for average light direction\n" );
1272 +               }
1273                 else if( !strcmp( argv[ i ], "-external" ) )
1274                 {
1275                         externalLightmaps = qtrue;
1276 @@ -2151,6 +2305,12 @@\r
1277                         i++;
1278                         Sys_Printf( "Default lightmap sample size set to %dx%d units\n", sampleSize, sampleSize );
1279                 }
1280 +               else if( !strcmp( argv[ i ],  "-samplescale" ) )
1281 +               {
1282 +                       sampleScale = atoi( argv[ i + 1 ] );
1283 +                       i++;
1284 +                       Sys_Printf( "Lightmaps sample scale set to %d\n", sampleScale);
1285 +               }
1286                 else if( !strcmp( argv[ i ], "-novertex" ) )
1287                 {
1288                         noVertexLighting = qtrue;
1289 @@ -2186,11 +2346,36 @@\r
1290                         noStyles = qtrue;
1291                         Sys_Printf( "Disabling lightstyles\n" );
1292                 }
1293 +               else if( !strcmp( argv[ i ], "-style" ) || !strcmp( argv[ i ], "-styles" ) )
1294 +               {
1295 +                       noStyles = qfalse;
1296 +                       Sys_Printf( "Enabling lightstyles\n" );
1297 +               }
1298 +               else if( !strcmp( argv[ i ], "-keeplights" ))
1299 +               {
1300 +                       keepLights = qtrue;
1301 +                       Sys_Printf( "Leaving light entities on map after compile\n" );
1302 +               }
1303                 else if( !strcmp( argv[ i ], "-cpma" ) )
1304                 {
1305                         cpmaHack = qtrue;
1306                         Sys_Printf( "Enabling Challenge Pro Mode Asstacular Vertex Lighting Mode (tm)\n" );
1307                 }
1308 +               else if( !strcmp( argv[ i ], "-floodlight" ) )
1309 +               {
1310 +                       floodlighty = qtrue;
1311 +                       Sys_Printf( "FloodLighting enabled\n" );
1312 +               }
1313 +               else if( !strcmp( argv[ i ], "-debugnormals" ) )
1314 +               {
1315 +                       debugnormals = qtrue;
1316 +                       Sys_Printf( "DebugNormals enabled\n" );
1317 +               }
1318 +               else if( !strcmp( argv[ i ], "-lowquality" ) )
1319 +               {
1320 +                       floodlight_lowquality = qtrue;
1321 +                       Sys_Printf( "Low Quality FloodLighting enabled\n" );
1322 +               }
1323                 
1324                 /* r7: dirtmapping */
1325                 else if( !strcmp( argv[ i ], "-dirty" ) )
1326 @@ -2212,6 +2397,7 @@\r
1327                                 Sys_Printf( "Enabling randomized dirtmapping\n" );
1328                         else
1329                                 Sys_Printf( "Enabling ordered dir mapping\n" );
1330 +                       i++;
1331                 }
1332                 else if( !strcmp( argv[ i ], "-dirtdepth" ) )
1333                 {
1334 @@ -2219,6 +2405,7 @@\r
1335                         if( dirtDepth <= 0.0f )
1336                                 dirtDepth = 128.0f;
1337                         Sys_Printf( "Dirtmapping depth set to %.1f\n", dirtDepth );
1338 +                       i++;
1339                 }
1340                 else if( !strcmp( argv[ i ], "-dirtscale" ) )
1341                 {
1342 @@ -2226,6 +2413,7 @@\r
1343                         if( dirtScale <= 0.0f )
1344                                 dirtScale = 1.0f;
1345                         Sys_Printf( "Dirtmapping scale set to %.1f\n", dirtScale );
1346 +                       i++;
1347                 }
1348                 else if( !strcmp( argv[ i ], "-dirtgain" ) )
1349                 {
1350 @@ -2233,6 +2421,7 @@\r
1351                         if( dirtGain <= 0.0f )
1352                                 dirtGain = 1.0f;
1353                         Sys_Printf( "Dirtmapping gain set to %.1f\n", dirtGain );
1354 +                       i++;
1355                 }
1356                 
1357                 /* unhandled args */
1358 @@ -2279,6 +2468,7 @@\r
1359         /* ydnar: set up optimization */
1360         SetupBrushes();
1361         SetupDirt();
1362 +       SetupFloodLight();
1363         SetupSurfaceLightmaps();
1364         
1365         /* initialize the surface facet tracing */
1366 Index: light_bounce.c\r
1367 ===================================================================\r
1368 --- light_bounce.c      (revision 158)\r
1369 +++ light_bounce.c      (working copy)\r
1370 @@ -510,7 +510,7 @@\r
1371                         break;
1372                 
1373                 case MST_TRIANGLE_SOUP:
1374 -                       numTriangleDiffuseLights;
1375 +                       numTriangleDiffuseLights++;
1376                         break;
1377                 
1378                 case MST_PATCH:
1379 Index: light_trace.c\r
1380 ===================================================================\r
1381 --- light_trace.c       (revision 158)\r
1382 +++ light_trace.c       (working copy)\r
1383 @@ -56,7 +56,7 @@\r
1384  #define GROW_TRACE_NODES               16384           //%     16384
1385  #define GROW_NODE_ITEMS                        16                      //%     256
1386  
1387 -#define MAX_TW_VERTS                   12
1388 +#define MAX_TW_VERTS                   24 // vortex: increased from 12 to 24 for ability co compile some insane maps with large curve count
1389  
1390  #define        TRACE_ON_EPSILON                0.1f
1391  
1392 Index: light_ydnar.c\r
1393 ===================================================================\r
1394 --- light_ydnar.c       (revision 158)\r
1395 +++ light_ydnar.c       (working copy)\r
1396 @@ -49,6 +49,7 @@\r
1397         int             i;
1398         float   max, gamma;
1399         vec3_t  sample;
1400 +       float   inv, dif;
1401         
1402         
1403         /* ydnar: scaling necessary for simulating r_overbrightBits on external lightmaps */
1404 @@ -72,16 +73,51 @@\r
1405                 /* gamma */
1406                 sample[ i ] = pow( sample[ i ] / 255.0f, gamma ) * 255.0f;
1407         }
1408 +
1409 +       if (lightmapExposure == 1)
1410 +       {
1411 +               /* clamp with color normalization */
1412 +               max = sample[ 0 ];
1413 +               if( sample[ 1 ] > max )
1414 +                       max = sample[ 1 ];
1415 +               if( sample[ 2 ] > max )
1416 +                       max = sample[ 2 ];
1417 +               if( max > 255.0f )
1418 +                       VectorScale( sample, (255.0f / max), sample );
1419 +       }
1420 +       else
1421 +       {
1422 +               if (lightmapExposure==0)
1423 +               {
1424 +                       lightmapExposure=1.0f;
1425 +               }
1426 +               inv=1.f/lightmapExposure;
1427 +               //Exposure
1428 +       
1429 +               max = sample[ 0 ];
1430 +               if( sample[ 1 ] > max )
1431 +                       max = sample[ 1 ];
1432 +               if( sample[ 2 ] > max )
1433 +                       max = sample[ 2 ];  
1434 +      
1435 +               dif = (1-  exp(-max * inv) )  *  255;
1436 +
1437 +               if (max >0) 
1438 +               {
1439 +                       dif = dif / max;
1440 +               }
1441 +               else
1442 +               {
1443 +                       dif = 0;
1444 +               }
1445 +
1446 +               for (i=0;i<3;i++)
1447 +               {
1448 +                       sample[i]*=dif;
1449 +               }
1450 +       }
1451 +
1452         
1453 -       /* clamp with color normalization */
1454 -       max = sample[ 0 ];
1455 -       if( sample[ 1 ] > max )
1456 -               max = sample[ 1 ];
1457 -       if( sample[ 2 ] > max )
1458 -               max = sample[ 2 ];
1459 -       if( max > 255.0f )
1460 -               VectorScale( sample, (255.0f / max), sample );
1461 -       
1462         /* compensate for ingame overbrighting/bitshifting */
1463         VectorScale( sample, (1.0f / lightmapCompensate), sample );
1464         
1465 @@ -384,7 +420,7 @@\r
1466  #define NUDGE                  0.5f
1467  #define BOGUS_NUDGE            -99999.0f
1468  
1469 -static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t *dv, vec4_t plane, float pass, vec3_t stv[ 3 ], vec3_t ttv[ 3 ] )
1470 +static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t *dv, vec4_t plane, float pass, vec3_t stv[ 3 ], vec3_t ttv[ 3 ], vec3_t worldverts[ 3 ] )
1471  {
1472         int                             i, x, y, numClusters, *clusters, pointCluster, *cluster;
1473         float                   *luxel, *origin, *normal, d, lightmapSampleOffset;
1474 @@ -392,6 +428,12 @@\r
1475         vec3_t                  pNormal;
1476         vec3_t                  vecs[ 3 ];
1477         vec3_t                  nudged;
1478 +       vec3_t                  cverts[ 3 ];
1479 +       vec3_t                  temp;
1480 +       vec4_t                  sideplane, hostplane;
1481 +       vec3_t                  origintwo;
1482 +       int                             j, next;
1483 +       float                   e;
1484         float                   *nudge;
1485         static float    nudges[][ 2 ] =
1486                                         {
1487 @@ -485,6 +527,51 @@\r
1488         /* non axial lightmap projection (explicit xyz) */
1489         else
1490                 VectorCopy( dv->xyz, origin );
1491 +
1492 +       //////////////////////
1493 +       //27's test to make sure samples stay within the triangle boundaries
1494 +       //1) Test the sample origin to see if it lays on the wrong side of any edge (x/y)
1495 +       //2) if it does, nudge it onto the correct side.
1496 +
1497 +       if (worldverts!=NULL)
1498 +       {
1499 +               for (j=0;j<3;j++)
1500 +               {
1501 +                       VectorCopy(worldverts[j],cverts[j]);    
1502 +               }
1503 +               PlaneFromPoints(hostplane,cverts[0],cverts[1],cverts[2]);
1504 +
1505 +               for (j=0;j<3;j++)
1506 +               {
1507 +                       for (i=0;i<3;i++)
1508 +                       {
1509 +                               //build plane using 2 edges and a normal
1510 +                               next=(i+1)%3;
1511 +
1512 +                               VectorCopy(cverts[next],temp);
1513 +                               VectorAdd(temp,hostplane,temp);
1514 +                               PlaneFromPoints(sideplane,cverts[i],cverts[ next ], temp);
1515 +
1516 +                               //planetest sample point  
1517 +                               e=DotProduct(origin,sideplane);
1518 +                               e=e-sideplane[3];
1519 +                               if (e>0)
1520 +                               {
1521 +                                       //we're bad.
1522 +                                       //VectorClear(origin);
1523 +                                       //Move the sample point back inside triangle bounds
1524 +                                       origin[0]-=sideplane[0]*(e+1);
1525 +                                       origin[1]-=sideplane[1]*(e+1);
1526 +                                       origin[2]-=sideplane[2]*(e+1);
1527 +#ifdef DEBUG_27_1
1528 +                                       VectorClear(origin);
1529 +#endif 
1530 +                               }
1531 +                       }
1532 +               }
1533 +       }
1534 +
1535 +       ////////////////////////
1536         
1537         /* planar surfaces have precalculated lightmap vectors for nudging */
1538         if( lm->plane != NULL )
1539 @@ -516,8 +603,13 @@\r
1540         else
1541                 origin[ lm->axisNum ] += lightmapSampleOffset;
1542         
1543 +       VectorCopy(origin,origintwo);
1544 +       origintwo[0]+=vecs[2][0];
1545 +       origintwo[1]+=vecs[2][1];
1546 +       origintwo[2]+=vecs[2][2];
1547 +       
1548         /* get cluster */
1549 -       pointCluster = ClusterForPointExtFilter( origin, LUXEL_EPSILON, numClusters, clusters );
1550 +       pointCluster = ClusterForPointExtFilter( origintwo, LUXEL_EPSILON, numClusters, clusters );
1551         
1552         /* another retarded hack, storing nudge count in luxel[ 1 ] */
1553         luxel[ 1 ] = 0.0f;      
1554 @@ -533,14 +625,14 @@\r
1555                         for( i = 0; i < 3; i++ )
1556                         {
1557                                 /* set nudged point*/
1558 -                               nudged[ i ] = origin[ i ] + (nudge[ 0 ] * vecs[ 0 ][ i ]) + (nudge[ 1 ] * vecs[ 1 ][ i ]);
1559 +                               nudged[ i ] = origintwo[ i ] + (nudge[ 0 ] * vecs[ 0 ][ i ]) + (nudge[ 1 ] * vecs[ 1 ][ i ]);
1560                         }
1561                         nudge += 2;
1562                         
1563                         /* get pvs cluster */
1564                         pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters ); //% + 0.625 );
1565 -                       if( pointCluster >= 0 ) 
1566 -                               VectorCopy( nudged, origin );
1567 +                       //if( pointCluster >= 0 )       
1568 +                       //      VectorCopy( nudged, origin );
1569                         luxel[ 1 ] += 1.0f;
1570                 }
1571         }
1572 @@ -550,8 +642,8 @@\r
1573         {
1574                 VectorMA( dv->xyz, lightmapSampleOffset, dv->normal, nudged );
1575                 pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters );
1576 -               if( pointCluster >= 0 )
1577 -                       VectorCopy( nudged, origin );
1578 +               //if( pointCluster >= 0 )
1579 +               //      VectorCopy( nudged, origin );
1580                 luxel[ 1 ] += 1.0f;
1581         }
1582         
1583 @@ -597,7 +689,7 @@\r
1584  than the distance between two luxels (thanks jc :)
1585  */
1586  
1587 -static void MapTriangle_r( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t *dv[ 3 ], vec4_t plane, vec3_t stv[ 3 ], vec3_t ttv[ 3 ] )
1588 +static void MapTriangle_r( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t *dv[ 3 ], vec4_t plane, vec3_t stv[ 3 ], vec3_t ttv[ 3 ], vec3_t worldverts[ 3 ] )
1589  {
1590         bspDrawVert_t   mid, *dv2[ 3 ];
1591         int                             max;
1592 @@ -645,7 +737,7 @@\r
1593         
1594         /* split the longest edge and map it */
1595         LerpDrawVert( dv[ max ], dv[ (max + 1) % 3 ], &mid );
1596 -       MapSingleLuxel( lm, info, &mid, plane, 1, stv, ttv );
1597 +       MapSingleLuxel( lm, info, &mid, plane, 1, stv, ttv, worldverts );
1598         
1599         /* push the point up a little bit to account for fp creep (fixme: revisit this) */
1600         //%     VectorMA( mid.xyz, 2.0f, mid.normal, mid.xyz );
1601 @@ -653,12 +745,12 @@\r
1602         /* recurse to first triangle */
1603         VectorCopy( dv, dv2 );
1604         dv2[ max ] = &mid;
1605 -       MapTriangle_r( lm, info, dv2, plane, stv, ttv );
1606 +       MapTriangle_r( lm, info, dv2, plane, stv, ttv, worldverts );
1607         
1608         /* recurse to second triangle */
1609         VectorCopy( dv, dv2 );
1610         dv2[ (max + 1) % 3 ] = &mid;
1611 -       MapTriangle_r( lm, info, dv2, plane, stv, ttv );
1612 +       MapTriangle_r( lm, info, dv2, plane, stv, ttv, worldverts );
1613  }
1614  
1615  
1616 @@ -674,8 +766,8 @@\r
1617         int                             i;
1618         vec4_t                  plane;
1619         vec3_t                  *stv, *ttv, stvStatic[ 3 ], ttvStatic[ 3 ];
1620 +       vec3_t                  worldverts[ 3 ];
1621         
1622 -       
1623         /* get plane if possible */
1624         if( lm->plane != NULL )
1625         {
1626 @@ -699,16 +791,20 @@\r
1627                 ttv = NULL;
1628         }
1629         
1630 +       VectorCopy( dv[ 0 ]->xyz, worldverts[ 0 ] );
1631 +       VectorCopy( dv[ 1 ]->xyz, worldverts[ 1 ] );
1632 +       VectorCopy( dv[ 2 ]->xyz, worldverts[ 2 ] );
1633 +       
1634         /* map the vertexes */
1635 -       MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv );
1636 -       MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv );
1637 -       MapSingleLuxel( lm, info, dv[ 2 ], plane, 1, stv, ttv );
1638 +       MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv, worldverts );
1639 +       MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv, worldverts );
1640 +       MapSingleLuxel( lm, info, dv[ 2 ], plane, 1, stv, ttv, worldverts );
1641         
1642         /* 2002-11-20: prefer axial triangle edges */
1643         if( mapNonAxial )
1644         {
1645                 /* subdivide the triangle */
1646 -               MapTriangle_r( lm, info, dv, plane, stv, ttv );
1647 +               MapTriangle_r( lm, info, dv, plane, stv, ttv, worldverts );
1648                 return qtrue;
1649         }
1650         
1651 @@ -730,7 +826,7 @@\r
1652                         dv2[ 2 ] = dv[ (i + 1) % 3 ];
1653                         
1654                         /* map the degenerate triangle */
1655 -                       MapTriangle_r( lm, info, dv2, plane, stv, ttv );
1656 +                       MapTriangle_r( lm, info, dv2, plane, stv, ttv, worldverts );
1657                 }
1658         }
1659         
1660 @@ -792,8 +888,8 @@\r
1661         LerpDrawVert( dv[ max + 2 ], dv[ (max + 3) % 4 ], &mid[ 1 ] );
1662         
1663         /* map the vertexes */
1664 -       MapSingleLuxel( lm, info, &mid[ 0 ], plane, 1, stv, ttv );
1665 -       MapSingleLuxel( lm, info, &mid[ 1 ], plane, 1, stv, ttv );
1666 +       MapSingleLuxel( lm, info, &mid[ 0 ], plane, 1, stv, ttv, NULL );
1667 +       MapSingleLuxel( lm, info, &mid[ 1 ], plane, 1, stv, ttv, NULL );
1668         
1669         /* 0 and 2 */
1670         if( max == 0 )
1671 @@ -848,7 +944,6 @@\r
1672         vec4_t                  plane;
1673         vec3_t                  *stv, *ttv, stvStatic[ 4 ], ttvStatic[ 4 ];
1674         
1675 -       
1676         /* get plane if possible */
1677         if( lm->plane != NULL )
1678         {
1679 @@ -878,18 +973,16 @@\r
1680         }
1681         
1682         /* map the vertexes */
1683 -       MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv );
1684 -       MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv );
1685 -       MapSingleLuxel( lm, info, dv[ 2 ], plane, 1, stv, ttv );
1686 -       MapSingleLuxel( lm, info, dv[ 3 ], plane, 1, stv, ttv );
1687 +       MapSingleLuxel( lm, info, dv[ 0 ], plane, 1, stv, ttv, NULL );
1688 +       MapSingleLuxel( lm, info, dv[ 1 ], plane, 1, stv, ttv, NULL );
1689 +       MapSingleLuxel( lm, info, dv[ 2 ], plane, 1, stv, ttv, NULL );
1690 +       MapSingleLuxel( lm, info, dv[ 3 ], plane, 1, stv, ttv, NULL );
1691         
1692         /* subdivide the quad */
1693         MapQuad_r( lm, info, dv, plane, stv, ttv );
1694         return qtrue;
1695  }
1696  
1697 -
1698 -
1699  /*
1700  MapRawLightmap()
1701  maps the locations, normals, and pvs clusters for a raw lightmap
1702 @@ -941,7 +1034,7 @@\r
1703                 num = lightSurfaces[ lm->firstLightSurface + n ];
1704                 ds = &bspDrawSurfaces[ num ];
1705                 info = &surfaceInfos[ num ];
1706 -               
1707 +
1708                 /* bail if no lightmap to calculate */
1709                 if( info->lm != lm )
1710                 {
1711 @@ -1173,7 +1266,7 @@\r
1712                                         continue;
1713                                 
1714                                 /* map the fake vert */
1715 -                               MapSingleLuxel( lm, NULL, &fake, lm->plane, pass, NULL, NULL );
1716 +                               MapSingleLuxel( lm, NULL, &fake, lm->plane, pass, NULL, NULL, NULL );
1717                         }
1718                 }
1719         }
1720 @@ -1596,7 +1689,6 @@\r
1721         
1722         VectorSubtract( origin2, origin, originVecs[ 0 ] );
1723         //%     VectorSubtract( normal2, normal, normalVecs[ 0 ] );
1724 -       
1725         /* calulate y vector */
1726         if( (y < (lm->sh - 1) && bx >= 0.0f) || (y == 0 && bx <= 0.0f) )
1727         {
1728 @@ -1660,7 +1752,6 @@\r
1729         float           biasDirs[ 4 ][ 2 ] = { { -1.0f, -1.0f }, { 1.0f, -1.0f }, { -1.0f, 1.0f }, { 1.0f, 1.0f } };
1730         vec3_t          color, total;
1731         
1732 -       
1733         /* limit check */
1734         if( lightLuxel[ 3 ] >= lightSamples )
1735                 return;
1736 @@ -1693,7 +1784,6 @@\r
1737                 VectorCopy( normal[ b ], trace->normal );
1738                 
1739                 /* sample light */
1740 -
1741                 LightContributionToSample( trace );
1742                 
1743                 /* add to totals (fixme: make contrast function) */
1744 @@ -1768,7 +1858,6 @@\r
1745         trace_t                         trace;
1746         float                           stackLightLuxels[ STACK_LL_SIZE ];
1747         
1748 -       
1749         /* bail if this number exceeds the number of raw lightmaps */
1750         if( rawLightmapNum >= numRawLightmaps )
1751                 return;
1752 @@ -1904,7 +1993,7 @@\r
1753                                 else
1754                                 {
1755                                         VectorCopy( ambientColor, luxel );
1756 -                                       if( deluxemap )
1757 +                                       if( deluxemap)
1758                                                 VectorScale( normal, 0.00390625f, deluxel );
1759                                         luxel[ 3 ] = 1.0f;
1760                                 }
1761 @@ -1963,28 +2052,39 @@\r
1762                                         deluxel = SUPER_DELUXEL( x, y );
1763                                         origin = SUPER_ORIGIN( x, y );
1764                                         normal = SUPER_NORMAL( x, y );
1765 -                                       
1766 -                                       /* set contribution count */
1767 -                                       lightLuxel[ 3 ] = 1.0f;
1768 -                                       
1769 -                                       /* setup trace */
1770 -                                       trace.cluster = *cluster;
1771 -                                       VectorCopy( origin, trace.origin );
1772 -                                       VectorCopy( normal, trace.normal );
1773 -                                       
1774 -                                       /* get light for this sample */
1775 -                                       LightContributionToSample( &trace );
1776 -                                       VectorCopy( trace.color, lightLuxel );
1777 -                                       
1778 -                                       /* add to count */
1779 -                                       if( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] )
1780 +
1781 +                                       ////////// 27's temp hack for testing edge clipping ////
1782 +                                       if( origin[0]==0 && origin[1]==0 && origin[2]==0 )
1783 +                                       {
1784 +                                               lightLuxel[ 1 ] = 255;
1785 +                                               lightLuxel[ 3 ] = 1.0f;
1786                                                 totalLighted++;
1787 +                                       }
1788 +                                       else
1789 +                                       {
1790 +                                               /* set contribution count */
1791 +                                               lightLuxel[ 3 ] = 1.0f;
1792 +                                               
1793 +                                               /* setup trace */
1794 +                                               trace.cluster = *cluster;
1795 +                                               VectorCopy( origin, trace.origin );
1796 +                                               VectorCopy( normal, trace.normal );
1797 +                                               
1798 +                                               /* get light for this sample */
1799 +                                               LightContributionToSample( &trace );
1800 +                                               VectorCopy( trace.color, lightLuxel );
1801 +                                               
1802 +                                               /* add to count */
1803 +                                               if( trace.color[ 0 ] || trace.color[ 1 ] || trace.color[ 2 ] )
1804 +                                                       totalLighted++;
1805 +                                       }
1806                                         
1807                                         /* add to light direction map (fixme: use luxel normal as starting point for deluxel?) */
1808                                         if( deluxemap )
1809                                         {
1810 +                                               /* vortex: use noShadow color */
1811                                                 /* color to grayscale (photoshop rgb weighting) */
1812 -                                               brightness = trace.color[ 0 ] * 0.3f + trace.color[ 1 ] * 0.59f + trace.color[ 2 ] * 0.11f;
1813 +                                               brightness = trace.colorNoShadow[ 0 ] * 0.3f + trace.colorNoShadow[ 1 ] * 0.59f + trace.colorNoShadow[ 2 ] * 0.11f;
1814                                                 brightness *= (1.0 / 255.0);
1815                                                 VectorScale( trace.direction, brightness, trace.direction );
1816                                                 VectorAdd( deluxel, trace.direction, deluxel );
1817 @@ -2222,6 +2322,38 @@\r
1818         /* free light list */
1819         FreeTraceLights( &trace );
1820         
1821 +       /* floodlight pass */
1822 +       FloodlightIlluminateLightmap(lm);
1823 +
1824 +       if (debugnormals)
1825 +       {
1826 +               for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
1827 +               {
1828 +                       /* early out */
1829 +                       if( lm->superLuxels[ lightmapNum ] == NULL )
1830 +                               continue;
1831 +                       
1832 +                       for( y = 0; y < lm->sh; y++ )
1833 +                       {
1834 +                               for( x = 0; x < lm->sw; x++ )
1835 +                               {
1836 +                                       /* get cluster */
1837 +                                       cluster = SUPER_CLUSTER( x, y );
1838 +                                       //%     if( *cluster < 0 )
1839 +                                       //%             continue;
1840 +                                       
1841 +                                       /* get particulars */
1842 +                                       luxel = SUPER_LUXEL( lightmapNum, x, y );
1843 +                                       normal = SUPER_NORMAL (  x, y );
1844 +               
1845 +                                       luxel[0]=(normal[0]*127)+127;
1846 +                                       luxel[1]=(normal[1]*127)+127;
1847 +                                       luxel[2]=(normal[2]*127)+127;
1848 +                               }
1849 +                       }
1850 +               }
1851 +       }
1852 +       
1853         /*      -----------------------------------------------------------------
1854                 dirt pass
1855                 ----------------------------------------------------------------- */
1856 @@ -2263,7 +2395,7 @@\r
1857         /* -----------------------------------------------------------------
1858            filter pass
1859            ----------------------------------------------------------------- */
1860 -       
1861 +
1862         /* walk lightmaps */
1863         for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
1864         {
1865 @@ -3112,7 +3244,7 @@\r
1866         int                     i, x, y, z, x1, y1, z1;
1867         light_t         *light, *light2, **owner;
1868         bspLeaf_t       *leaf;
1869 -       vec3_t          origin, dir, mins, maxs, nullVector = { 0, 0, 0 };
1870 +       vec3_t          origin, dir, mins, maxs;
1871         float           radius, intensity;
1872         light_t         *buckets[ 256 ];
1873         
1874 @@ -3587,7 +3719,430 @@\r
1875         CreateTraceLightsForBounds( mins, maxs, normal, info->numSurfaceClusters, &surfaceClusters[ info->firstSurfaceCluster ], LIGHT_SURFACES, trace );
1876  }
1877  
1878 +/////////////////////////////////////////////////////////////
1879  
1880 +#define FLOODLIGHT_CONE_ANGLE                  88      /* degrees */
1881 +#define FLOODLIGHT_NUM_ANGLE_STEPS             16
1882 +#define FLOODLIGHT_NUM_ELEVATION_STEPS 4
1883 +#define FLOODLIGHT_NUM_VECTORS                 (FLOODLIGHT_NUM_ANGLE_STEPS * FLOODLIGHT_NUM_ELEVATION_STEPS)
1884  
1885 +static vec3_t  floodVectors[ FLOODLIGHT_NUM_VECTORS ];
1886 +static int             numFloodVectors = 0;
1887  
1888 +void SetupFloodLight( void )
1889 +{
1890 +       int             i, j;
1891 +       float   angle, elevation, angleStep, elevationStep;
1892 +       const char      *value;
1893 +       double v1,v2,v3,v4,v5;
1894 +       
1895 +       /* note it */
1896 +       Sys_FPrintf( SYS_VRB, "--- SetupFloodLight ---\n" );
1897 +       
1898 +       /* calculate angular steps */
1899 +       angleStep = DEG2RAD( 360.0f / FLOODLIGHT_NUM_ANGLE_STEPS );
1900 +       elevationStep = DEG2RAD( FLOODLIGHT_CONE_ANGLE / FLOODLIGHT_NUM_ELEVATION_STEPS );
1901 +       
1902 +       /* iterate angle */
1903 +       angle = 0.0f;
1904 +       for( i = 0, angle = 0.0f; i < FLOODLIGHT_NUM_ANGLE_STEPS; i++, angle += angleStep )
1905 +       {
1906 +               /* iterate elevation */
1907 +               for( j = 0, elevation = elevationStep * 0.5f; j < FLOODLIGHT_NUM_ELEVATION_STEPS; j++, elevation += elevationStep )
1908 +               {
1909 +                       floodVectors[ numFloodVectors ][ 0 ] = sin( elevation ) * cos( angle );
1910 +                       floodVectors[ numFloodVectors ][ 1 ] = sin( elevation ) * sin( angle );
1911 +                       floodVectors[ numFloodVectors ][ 2 ] = cos( elevation );
1912 +                       numFloodVectors++;
1913 +               }
1914 +       }
1915 +       
1916 +       /* emit some statistics */
1917 +       Sys_FPrintf( SYS_VRB, "%9d numFloodVectors\n", numFloodVectors );
1918  
1919 +    /* floodlight */
1920 +       value = ValueForKey( &entities[ 0 ], "_floodlight" );
1921 +       
1922 +       if( value[ 0 ] != '\0' )
1923 +       {
1924 +               v1=v2=v3=0;
1925 +               v4=floodlightDistance;
1926 +               v5=floodlightIntensity;
1927 +               
1928 +               sscanf( value, "%lf %lf %lf %lf %lf", &v1, &v2, &v3, &v4, &v5);
1929 +               
1930 +               floodlightRGB[0]=v1;
1931 +               floodlightRGB[1]=v2;
1932 +               floodlightRGB[2]=v3;
1933 +               
1934 +               if (VectorLength(floodlightRGB)==0)
1935 +               {
1936 +                       VectorSet(floodlightRGB,240,240,255);
1937 +               }
1938 +               
1939 +               if (v4<1) v4=1024;
1940 +               if (v5<1) v5=128;
1941 +               
1942 +               floodlightDistance = v4;
1943 +               floodlightIntensity = v5;
1944 +    
1945 +               floodlighty = qtrue;
1946 +               Sys_Printf( "FloodLighting enabled via worldspawn _floodlight key.\n" );
1947 +       }
1948 +       else
1949 +       {
1950 +               VectorSet(floodlightRGB,240,240,255);
1951 +               //floodlighty = qtrue;
1952 +               //Sys_Printf( "FloodLighting enabled via worldspawn _floodlight key.\n" );
1953 +       }
1954 +       VectorNormalize(floodlightRGB,floodlightRGB);
1955 +}
1956 +
1957 +/*
1958 +FloodLightForSample()
1959 +calculates floodlight value for a given sample
1960 +once again, kudos to the dirtmapping coder
1961 +*/
1962 +
1963 +float FloodLightForSample( trace_t *trace , float floodLightDistance, qboolean floodLightLowQuality)
1964 +{
1965 +       int             i;
1966 +       float   d;
1967 +       float   contribution;
1968 +       int     sub = 0;
1969 +       float   gatherLight, outLight;
1970 +       vec3_t  normal, worldUp, myUp, myRt, direction, displacement;
1971 +       float   dd;
1972 +       int     vecs = 0;
1973
1974 +       gatherLight=0;
1975 +       /* dummy check */
1976 +       //if( !dirty )
1977 +       //      return 1.0f;
1978 +       if( trace == NULL || trace->cluster < 0 )
1979 +               return 0.0f;
1980 +       
1981 +
1982 +       /* setup */
1983 +       dd = floodLightDistance;
1984 +       VectorCopy( trace->normal, normal );
1985 +       
1986 +       /* check if the normal is aligned to the world-up */
1987 +       if( normal[ 0 ] == 0.0f && normal[ 1 ] == 0.0f )
1988 +       {
1989 +               if( normal[ 2 ] == 1.0f )               
1990 +               {
1991 +                       VectorSet( myRt, 1.0f, 0.0f, 0.0f );
1992 +                       VectorSet( myUp, 0.0f, 1.0f, 0.0f );
1993 +               }
1994 +               else if( normal[ 2 ] == -1.0f )
1995 +               {
1996 +                       VectorSet( myRt, -1.0f, 0.0f, 0.0f );
1997 +                       VectorSet( myUp,  0.0f, 1.0f, 0.0f );
1998 +               }
1999 +       }
2000 +       else
2001 +       {
2002 +               VectorSet( worldUp, 0.0f, 0.0f, 1.0f );
2003 +               CrossProduct( normal, worldUp, myRt );
2004 +               VectorNormalize( myRt, myRt );
2005 +               CrossProduct( myRt, normal, myUp );
2006 +               VectorNormalize( myUp, myUp );
2007 +       }
2008 +
2009 +       /* vortex: optimise floodLightLowQuality a bit */
2010 +       if ( floodLightLowQuality == qtrue )
2011 +    {
2012 +               /* iterate through ordered vectors */
2013 +               for( i = 0; i < numFloodVectors; i++ )
2014 +                       if (rand()%10 != 0 ) continue;
2015 +       }
2016 +       else
2017 +       {
2018 +               /* iterate through ordered vectors */
2019 +               for( i = 0; i < numFloodVectors; i++ )
2020 +               {
2021 +                       vecs++;
2022 +                
2023 +                       /* transform vector into tangent space */
2024 +                       direction[ 0 ] = myRt[ 0 ] * floodVectors[ i ][ 0 ] + myUp[ 0 ] * floodVectors[ i ][ 1 ] + normal[ 0 ] * floodVectors[ i ][ 2 ];
2025 +                       direction[ 1 ] = myRt[ 1 ] * floodVectors[ i ][ 0 ] + myUp[ 1 ] * floodVectors[ i ][ 1 ] + normal[ 1 ] * floodVectors[ i ][ 2 ];
2026 +                       direction[ 2 ] = myRt[ 2 ] * floodVectors[ i ][ 0 ] + myUp[ 2 ] * floodVectors[ i ][ 1 ] + normal[ 2 ] * floodVectors[ i ][ 2 ];
2027 +
2028 +                       /* set endpoint */
2029 +                       VectorMA( trace->origin, dd, direction, trace->end );
2030 +
2031 +                       //VectorMA( trace->origin, 1, direction, trace->origin );
2032 +                               
2033 +                       SetupTrace( trace );
2034 +                       /* trace */
2035 +                       TraceLine( trace );
2036 +                       contribution=1;
2037 +
2038 +                       if (trace->compileFlags & C_SKY )
2039 +                       {
2040 +                               contribution=1.0f;
2041 +                       }
2042 +                       else if ( trace->opaque )
2043 +                       {
2044 +                               VectorSubtract( trace->hit, trace->origin, displacement );
2045 +                               d=VectorLength( displacement );
2046 +
2047 +                               // d=trace->distance;            
2048 +                               //if (d>256) gatherDirt+=1;
2049 +                               contribution=d/dd;
2050 +                               if (contribution>1) contribution=1.0f; 
2051 +                    
2052 +                               //gatherDirt += 1.0f - ooDepth * VectorLength( displacement );
2053 +                       }
2054 +                
2055 +                       gatherLight+=contribution;
2056 +               }
2057 +       }
2058 +   
2059 +       /* early out */
2060 +       if( gatherLight <= 0.0f )
2061 +               return 0.0f;
2062 +       
2063 +       sub=vecs;
2064 +
2065 +       if (sub<1) sub=1;
2066 +       gatherLight/=(sub);
2067 +
2068 +       outLight=gatherLight;
2069 +       if( outLight > 1.0f )
2070 +               outLight = 1.0f;
2071 +       
2072 +       /* return to sender */
2073 +       return outLight;
2074 +}
2075 +
2076 +/*
2077 +FloodLightRawLightmap
2078 +lighttracer style ambient occlusion light hack.
2079 +Kudos to the dirtmapping author for most of this source.
2080 +VorteX: modified to floodlight up custom surfaces (q3map_floodLight)
2081 +VorteX: fixed problems with deluxemapping
2082 +*/
2083 +
2084 +// floodlight pass on a lightmap
2085 +void FloodLightRawLightmapPass( rawLightmap_t *lm , vec3_t lmFloodLightRGB, float lmFloodLightIntensity, float lmFloodLightDistance, qboolean lmFloodLightLowQuality, float floodlightDirectionScale)
2086 +{
2087 +       int                                     i, x, y, *cluster;
2088 +       float                           *origin, *normal, *floodlight, floodLightAmount;
2089 +       surfaceInfo_t           *info;
2090 +       trace_t                         trace;
2091 +       // int sx, sy;
2092 +       // float samples, average, *floodlight2;
2093 +       
2094 +       memset(&trace,0,sizeof(trace_t));
2095 +
2096 +       /* setup trace */
2097 +       trace.testOcclusion = qtrue;
2098 +       trace.forceSunlight = qfalse;
2099 +       trace.twoSided = qtrue;
2100 +       trace.recvShadows = lm->recvShadows;
2101 +       trace.numSurfaces = lm->numLightSurfaces;
2102 +       trace.surfaces = &lightSurfaces[ lm->firstLightSurface ];
2103 +       trace.inhibitRadius = DEFAULT_INHIBIT_RADIUS;
2104 +       trace.testAll = qfalse;
2105 +       trace.distance = 1024;
2106 +       
2107 +       /* twosided lighting (may or may not be a good idea for lightmapped stuff) */
2108 +       //trace.twoSided = qfalse;
2109 +       for( i = 0; i < trace.numSurfaces; i++ )
2110 +       {
2111 +               /* get surface */
2112 +               info = &surfaceInfos[ trace.surfaces[ i ] ];
2113 +               
2114 +               /* check twosidedness */
2115 +               if( info->si->twoSided )
2116 +               {
2117 +                       trace.twoSided = qtrue;
2118 +                       break;
2119 +               }
2120 +       }
2121 +       
2122 +       /* gather floodlight */
2123 +       for( y = 0; y < lm->sh; y++ )
2124 +       {
2125 +               for( x = 0; x < lm->sw; x++ )
2126 +               {
2127 +                       /* get luxel */
2128 +                       cluster = SUPER_CLUSTER( x, y );
2129 +                       origin = SUPER_ORIGIN( x, y );
2130 +                       normal = SUPER_NORMAL( x, y );
2131 +                       floodlight = SUPER_FLOODLIGHT( x, y );
2132 +                       
2133 +                       /* set default dirt */
2134 +                       *floodlight = 0.0f;
2135 +                       
2136 +                       /* only look at mapped luxels */
2137 +                       if( *cluster < 0 )
2138 +                               continue;
2139 +                       
2140 +                       /* copy to trace */
2141 +                       trace.cluster = *cluster;
2142 +                       VectorCopy( origin, trace.origin );
2143 +                       VectorCopy( normal, trace.normal );
2144 +   
2145 +                       /* get floodlight */
2146 +                       floodLightAmount = FloodLightForSample( &trace , lmFloodLightDistance, lmFloodLightLowQuality)*lmFloodLightIntensity;
2147 +                       
2148 +                       /* add floodlight */
2149 +                       floodlight[0] += lmFloodLightRGB[0]*floodLightAmount;
2150 +                       floodlight[1] += lmFloodLightRGB[1]*floodLightAmount;
2151 +                       floodlight[2] += lmFloodLightRGB[2]*floodLightAmount;
2152 +                       floodlight[3] += floodlightDirectionScale;
2153 +               }
2154 +       }
2155 +       
2156 +       /* testing no filtering */
2157 +       return;
2158 +
2159 +#if 0
2160 +       
2161 +       /* filter "dirt" */
2162 +       for( y = 0; y < lm->sh; y++ )
2163 +       {
2164 +               for( x = 0; x < lm->sw; x++ )
2165 +               {
2166 +                       /* get luxel */
2167 +                       cluster = SUPER_CLUSTER( x, y );
2168 +                       floodlight = SUPER_FLOODLIGHT(x, y );
2169 +                       
2170 +                       /* filter dirt by adjacency to unmapped luxels */
2171 +                       average = *floodlight;
2172 +                       samples = 1.0f;
2173 +                       for( sy = (y - 1); sy <= (y + 1); sy++ )
2174 +                       {
2175 +                               if( sy < 0 || sy >= lm->sh )
2176 +                                       continue;
2177 +                               
2178 +                               for( sx = (x - 1); sx <= (x + 1); sx++ )
2179 +                               {
2180 +                                       if( sx < 0 || sx >= lm->sw || (sx == x && sy == y) )
2181 +                                               continue;
2182 +                                       
2183 +                                       /* get neighboring luxel */
2184 +                                       cluster = SUPER_CLUSTER( sx, sy );
2185 +                                       floodlight2 = SUPER_FLOODLIGHT( sx, sy );
2186 +                                       if( *cluster < 0 || *floodlight2 <= 0.0f )
2187 +                                               continue;
2188 +                                       
2189 +                                       /* add it */
2190 +                                       average += *floodlight2;
2191 +                                       samples += 1.0f;
2192 +                               }
2193 +                               
2194 +                               /* bail */
2195 +                               if( samples <= 0.0f )
2196 +                                       break;
2197 +                       }
2198 +                       
2199 +                       /* bail */
2200 +                       if( samples <= 0.0f )
2201 +                               continue;
2202 +                       
2203 +                       /* scale dirt */
2204 +                       *floodlight = average / samples;
2205 +               }
2206 +       }
2207 +#endif
2208 +}
2209 +
2210 +void FloodLightRawLightmap( int rawLightmapNum )
2211 +{
2212 +       rawLightmap_t           *lm;
2213 +
2214 +       /* bail if this number exceeds the number of raw lightmaps */
2215 +       if( rawLightmapNum >= numRawLightmaps )
2216 +               return;
2217 +       /* get lightmap */
2218 +       lm = &rawLightmaps[ rawLightmapNum ];
2219 +
2220 +       /* global pass */
2221 +       if (floodlighty && floodlightIntensity)
2222 +               FloodLightRawLightmapPass(lm, floodlightRGB, floodlightIntensity, floodlightDistance, floodlight_lowquality, 0);
2223 +
2224 +       /* custom pass */
2225 +       if (lm->floodlightIntensity)
2226 +       {
2227 +               FloodLightRawLightmapPass(lm, lm->floodlightRGB, lm->floodlightIntensity, lm->floodlightDistance, qfalse, lm->floodlightDirectionScale);
2228 +               numSurfacesFloodlighten += 1;
2229 +       }
2230 +}
2231 +
2232 +void FloodlightRawLightmaps()
2233 +{
2234 +       Sys_Printf( "--- FloodlightRawLightmap ---\n" );
2235 +       numSurfacesFloodlighten = 0;
2236 +       RunThreadsOnIndividual( numRawLightmaps, qtrue, FloodLightRawLightmap );
2237 +       Sys_Printf( "%9d custom lightmaps floodlighted\n", numSurfacesFloodlighten );
2238 +}
2239 +
2240 +/*
2241 +FloodLightIlluminate()
2242 +illuminate floodlight into lightmap luxels
2243 +*/
2244 +
2245 +void FloodlightIlluminateLightmap( rawLightmap_t *lm )
2246 +{
2247 +       float                           *luxel, *floodlight, *deluxel, *normal;
2248 +       int                                     *cluster;
2249 +       float                           brightness;
2250 +       vec3_t                          lightvector;
2251 +       int                                     x, y, lightmapNum;
2252 +
2253 +       /* walk lightmaps */
2254 +       for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
2255 +       {
2256 +               /* early out */
2257 +               if( lm->superLuxels[ lightmapNum ] == NULL )
2258 +                       continue;
2259 +
2260 +               /* apply floodlight to each luxel */
2261 +               for( y = 0; y < lm->sh; y++ )
2262 +               {
2263 +                       for( x = 0; x < lm->sw; x++ )
2264 +                       {
2265 +                               /* get floodlight */
2266 +                               floodlight = SUPER_FLOODLIGHT( x, y );
2267 +                               if (!floodlight[0] && !floodlight[1] && !floodlight[2])
2268 +                                       continue;
2269 +                                               
2270 +                               /* get cluster */
2271 +                               cluster = SUPER_CLUSTER( x, y );
2272 +
2273 +                               /* only process mapped luxels */
2274 +                               if( *cluster < 0 )
2275 +                                       continue;
2276 +
2277 +                               /* get particulars */
2278 +                               luxel = SUPER_LUXEL( lightmapNum, x, y );
2279 +                               deluxel = SUPER_DELUXEL( x, y );
2280 +
2281 +                               /* add to lightmap */
2282 +                               luxel[0]+=floodlight[0];
2283 +                               luxel[1]+=floodlight[1];
2284 +                               luxel[2]+=floodlight[2];
2285 +
2286 +                               if (luxel[3]==0) luxel[3]=1;
2287 +
2288 +                               /* add to deluxemap */
2289 +                               if (deluxemap && floodlight[3] > 0)
2290 +                               {
2291 +                                       normal = SUPER_NORMAL( x, y );
2292 +                                       brightness = floodlight[ 0 ] * 0.3f + floodlight[ 1 ] * 0.59f + floodlight[ 2 ] * 0.11f;
2293 +                                       brightness *= ( 1.0f / 255.0f ) * floodlight[3];
2294 +                                       VectorScale( normal, brightness, lightvector );
2295 +                                       VectorAdd( deluxel, lightvector, deluxel );
2296 +                               }
2297 +                       }
2298 +               }
2299 +       }
2300 +}
2301 +
2302 +
2303 +
2304 +
2305 Index: lightmaps_ydnar.c\r
2306 ===================================================================\r
2307 --- lightmaps_ydnar.c   (revision 158)\r
2308 +++ lightmaps_ydnar.c   (working copy)\r
2309 @@ -414,6 +414,12 @@\r
2310                 lm->superNormals = safe_malloc( size );
2311         memset( lm->superNormals, 0, size );
2312         
2313 +       /* allocate floodlight map storage */
2314 +       size = lm->sw * lm->sh * SUPER_FLOODLIGHT_SIZE * sizeof( float );
2315 +       if( lm->superFloodLight == NULL )
2316 +               lm->superFloodLight = safe_malloc( size );
2317 +       memset( lm->superFloodLight, 0, size );
2318 +       
2319         /* allocate cluster map storage */
2320         size = lm->sw * lm->sh * sizeof( int );
2321         if( lm->superClusters == NULL )
2322 @@ -1087,17 +1093,25 @@\r
2323                 /* allocate a new raw lightmap */
2324                 lm = &rawLightmaps[ numRawLightmaps ];
2325                 numRawLightmaps++;
2326 -               
2327 +       
2328                 /* set it up */
2329                 lm->splotchFix = info->si->splotchFix;
2330                 lm->firstLightSurface = numLightSurfaces;
2331                 lm->numLightSurfaces = 0;
2332 -               lm->sampleSize = info->sampleSize;
2333 -               lm->actualSampleSize = info->sampleSize;
2334 +               /* vortex: multiply lightmap sample size by -samplescale */
2335 +               if (sampleScale > 0)
2336 +                       lm->sampleSize = info->sampleSize*sampleScale;
2337 +               else
2338 +                       lm->sampleSize = info->sampleSize;
2339 +               lm->actualSampleSize = lm->sampleSize;
2340                 lm->entityNum = info->entityNum;
2341                 lm->recvShadows = info->recvShadows;
2342                 lm->brightness = info->si->lmBrightness;
2343                 lm->filterRadius = info->si->lmFilterRadius;
2344 +               VectorCopy(info->si->floodlightRGB, lm->floodlightRGB);
2345 +               lm->floodlightDistance = info->si->floodlightDistance;
2346 +               lm->floodlightIntensity = info->si->floodlightIntensity;
2347 +               lm->floodlightDirectionScale = info->si->floodlightDirectionScale;
2348                 VectorCopy( info->axis, lm->axis );
2349                 lm->plane = info->plane;        
2350                 VectorCopy( info->mins, lm->mins );
2351 @@ -2254,7 +2268,6 @@\r
2352         char                            *rgbGenValues[ 256 ];
2353         char                            *alphaGenValues[ 256 ];
2354         
2355 -       
2356         /* note it */
2357         Sys_Printf( "--- StoreSurfaceLightmaps ---\n");
2358         
2359 @@ -2269,7 +2282,7 @@\r
2360            ----------------------------------------------------------------- */
2361         
2362         /* note it */
2363 -       Sys_FPrintf( SYS_VRB, "Subsampling..." );
2364 +       Sys_Printf( "Subsampling..." );
2365         
2366         /* walk the list of raw lightmaps */
2367         numUsed = 0;
2368 @@ -2437,11 +2450,11 @@\r
2369                                         /* get luxels */
2370                                         luxel = SUPER_LUXEL( lightmapNum, x, y );
2371                                         deluxel = SUPER_DELUXEL( x, y );
2372 -                                       
2373 +
2374                                         /* copy light direction */
2375                                         if( deluxemap && lightmapNum == 0 )
2376                                                 VectorCopy( deluxel, dirSample );
2377 -                                       
2378 +
2379                                         /* is this a valid sample? */
2380                                         if( luxel[ 3 ] > 0.0f )
2381                                         {
2382 @@ -2521,7 +2534,7 @@\r
2383                                         /* store the sample in the bsp luxels */
2384                                         bspLuxel = BSP_LUXEL( lightmapNum, x, y );
2385                                         bspDeluxel = BSP_DELUXEL( x, y );
2386 -                                       
2387 +
2388                                         VectorAdd( bspLuxel, sample, bspLuxel );
2389                                         if( deluxemap && lightmapNum == 0 )
2390                                                 VectorAdd( bspDeluxel, dirSample, bspDeluxel );
2391 @@ -2562,7 +2575,7 @@\r
2392                                         }
2393                                 }
2394                         }
2395 -                       
2396 +
2397                         /* wrap bsp luxels if necessary */
2398                         if( lm->wrap[ 0 ] )
2399                         {
2400 @@ -2604,15 +2617,144 @@\r
2401                         }
2402                 }
2403         }
2404 -       
2405 +
2406         /* -----------------------------------------------------------------
2407 +          convert modelspace deluxemaps to tangentspace
2408 +          ----------------------------------------------------------------- */
2409 +       /* note it */
2410 +       if( !bouncing )
2411 +       {
2412 +               if( deluxemap && deluxemode == 1)
2413 +               {
2414 +                       vec3_t  worldUp, myNormal, myTangent, myBinormal;
2415 +                       float dist;
2416 +
2417 +                       Sys_Printf( "converting..." );
2418 +
2419 +                       for( i = 0; i < numRawLightmaps; i++ )
2420 +                       {
2421 +                               /* get lightmap */
2422 +                               lm = &rawLightmaps[ i ];
2423 +
2424 +                               /* walk lightmap samples */
2425 +                               for( y = 0; y < lm->sh; y++ )
2426 +                               {
2427 +                                       for( x = 0; x < lm->sw; x++ )
2428 +                                       {
2429 +                                               /* get normal and deluxel */
2430 +                                               normal = SUPER_NORMAL(x, y);
2431 +                                               cluster = SUPER_CLUSTER(x, y);
2432 +                                               bspDeluxel = BSP_DELUXEL( x, y );
2433 +                                               deluxel = SUPER_DELUXEL( x, y ); 
2434 +
2435 +                                               /* get normal */
2436 +                                               VectorSet( myNormal, normal[0], normal[1], normal[2] );
2437 +               
2438 +                                               /* get tangent vectors */
2439 +                                               if( myNormal[ 0 ] == 0.0f && myNormal[ 1 ] == 0.0f )
2440 +                                               {
2441 +                                                       if( myNormal[ 2 ] == 1.0f )             
2442 +                                                       {
2443 +                                                               VectorSet( myTangent, 1.0f, 0.0f, 0.0f );
2444 +                                                               VectorSet( myBinormal, 0.0f, 1.0f, 0.0f );
2445 +                                                       }
2446 +                                                       else if( myNormal[ 2 ] == -1.0f )
2447 +                                                       {
2448 +                                                               VectorSet( myTangent, -1.0f, 0.0f, 0.0f );
2449 +                                                               VectorSet( myBinormal,  0.0f, 1.0f, 0.0f );
2450 +                                                       }
2451 +                                               }
2452 +                                               else
2453 +                                               {
2454 +                                                       VectorSet( worldUp, 0.0f, 0.0f, 1.0f );
2455 +                                                       CrossProduct( myNormal, worldUp, myTangent );
2456 +                                                       VectorNormalize( myTangent, myTangent );
2457 +                                                       CrossProduct( myTangent, myNormal, myBinormal );
2458 +                                                       VectorNormalize( myBinormal, myBinormal );
2459 +                                               }
2460 +
2461 +                                               /* project onto plane */
2462 +                                               dist = -DotProduct(myTangent, myNormal); 
2463 +                                               VectorMA(myTangent, dist, myNormal, myTangent);
2464 +                                               dist = -DotProduct(myBinormal, myNormal); 
2465 +                                               VectorMA(myBinormal, dist, myNormal, myBinormal);
2466 +
2467 +                                               /* renormalize */
2468 +                                               VectorNormalize( myTangent, myTangent );
2469 +                                               VectorNormalize( myBinormal, myBinormal );
2470 +
2471 +                                               /* convert modelspace deluxel to tangentspace */
2472 +                                               dirSample[0] = bspDeluxel[0];
2473 +                                               dirSample[1] = bspDeluxel[1];
2474 +                                               dirSample[2] = bspDeluxel[2];
2475 +                                               VectorNormalize(dirSample, dirSample);
2476 +
2477 +                                               /* fix tangents to world matrix */
2478 +                                               if (myNormal[0] > 0 || myNormal[1] < 0 || myNormal[2] < 0)
2479 +                                                       VectorNegate(myTangent, myTangent);
2480 +
2481 +                                               /* build tangentspace vectors */
2482 +                                               bspDeluxel[0] = DotProduct(dirSample, myTangent);
2483 +                                               bspDeluxel[1] = DotProduct(dirSample, myBinormal);
2484 +                                               bspDeluxel[2] = DotProduct(dirSample, myNormal);
2485 +                                       }
2486 +                               }
2487 +                       }
2488 +               }
2489 +       }
2490 +
2491 +       /* -----------------------------------------------------------------
2492 +          blend lightmaps
2493 +          ----------------------------------------------------------------- */
2494 +
2495 +#ifdef sdfsdfwq312323
2496 +       /* note it */
2497 +       Sys_Printf( "blending..." );
2498 +
2499 +       for( i = 0; i < numRawLightmaps; i++ )
2500 +       {
2501 +               vec3_t  myColor;
2502 +               float myBrightness;
2503 +
2504 +               /* get lightmap */
2505 +               lm = &rawLightmaps[ i ];
2506 +
2507 +               /* walk individual lightmaps */
2508 +               for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ )
2509 +               {
2510 +                       /* early outs */
2511 +                       if( lm->superLuxels[ lightmapNum ] == NULL )
2512 +                               continue;
2513 +
2514 +                       /* walk lightmap samples */
2515 +                       for( y = 0; y < lm->sh; y++ )
2516 +                       {
2517 +                               for( x = 0; x < lm->sw; x++ )
2518 +                               {
2519 +                                       /* get luxel */
2520 +                                       bspLuxel = BSP_LUXEL( lightmapNum, x, y );
2521 +
2522 +                                       /* get color */
2523 +                                       VectorNormalize(bspLuxel, myColor);
2524 +                                       myBrightness = VectorLength(bspLuxel);
2525 +                                       myBrightness *= (1 / 127.0f);
2526 +                                       myBrightness = myBrightness*myBrightness;
2527 +                                       myBrightness *= 127.0f;
2528 +                                       VectorScale(myColor, myBrightness, bspLuxel);
2529 +                               }
2530 +                       }
2531 +               }
2532 +       }
2533 +#endif
2534 +
2535 +       /* -----------------------------------------------------------------
2536            collapse non-unique lightmaps
2537            ----------------------------------------------------------------- */
2538         
2539         if( noCollapse == qfalse && deluxemap == qfalse )
2540         {
2541                 /* note it */
2542 -               Sys_FPrintf( SYS_VRB, "collapsing..." );
2543 +               Sys_Printf( "collapsing..." );
2544                 
2545                 /* set all twin refs to null */
2546                 for( i = 0; i < numRawLightmaps; i++ )
2547 @@ -2674,13 +2816,13 @@\r
2548                         }
2549                 }
2550         }
2551 -       
2552 +
2553         /* -----------------------------------------------------------------
2554            sort raw lightmaps by shader
2555            ----------------------------------------------------------------- */
2556         
2557         /* note it */
2558 -       Sys_FPrintf( SYS_VRB, "sorting..." );
2559 +       Sys_Printf( "sorting..." );
2560         
2561         /* allocate a new sorted list */
2562         if( sortLightmaps == NULL )
2563 @@ -2696,7 +2838,7 @@\r
2564            ----------------------------------------------------------------- */
2565         
2566         /* note it */
2567 -       Sys_FPrintf( SYS_VRB, "allocating..." );
2568 +       Sys_Printf( "allocating..." );
2569         
2570         /* kill all existing output lightmaps */
2571         if( outLightmaps != NULL )
2572 @@ -2749,7 +2891,7 @@\r
2573            ----------------------------------------------------------------- */
2574         
2575         /* note it */
2576 -       Sys_FPrintf( SYS_VRB, "storing..." );
2577 +       Sys_Printf( "storing..." );
2578         
2579         /* count the bsp lightmaps and allocate space */
2580         if( bspLightBytes != NULL )
2581 @@ -2817,7 +2959,7 @@\r
2582         }
2583         
2584         if( numExtLightmaps > 0 )
2585 -               Sys_FPrintf( SYS_VRB, "\n" );
2586 +               Sys_Printf( SYS_VRB, "\n" );
2587         
2588         /* delete unused external lightmaps */
2589         for( i = numExtLightmaps; i; i++ )
2590 @@ -2836,7 +2978,7 @@\r
2591            ----------------------------------------------------------------- */
2592         
2593         /* note it */
2594 -       Sys_FPrintf( SYS_VRB, "projecting..." );
2595 +       Sys_Printf( "projecting..." );
2596         
2597         /* walk the list of surfaces */
2598         for( i = 0; i < numBSPDrawSurfaces; i++ )
2599 @@ -3108,7 +3250,7 @@\r
2600         }
2601         
2602         /* finish */
2603 -       Sys_FPrintf( SYS_VRB, "done.\n" );
2604 +       Sys_Printf( "done.\n" );
2605         
2606         /* calc num stored */
2607         numStored = numBSPLightBytes / 3;
2608 Index: main.c\r
2609 ===================================================================\r
2610 --- main.c      (revision 158)\r
2611 +++ main.c      (working copy)\r
2612 @@ -604,7 +604,7 @@\r
2613         
2614         /* set exit call */
2615         atexit( ExitQ3Map );
2616 -       
2617 +
2618         /* read general options first */
2619         for( i = 1; i < argc; i++ )
2620         {
2621 @@ -680,6 +680,10 @@\r
2622         
2623         /* ydnar: new path initialization */
2624         InitPaths( &argc, argv );
2625 +
2626 +       /* set game options */
2627 +       if (!patchSubdivisions)
2628 +               patchSubdivisions = game->patchSubdivisions;
2629         
2630         /* check if we have enough options left to attempt something */
2631         if( argc < 2 )
2632 Index: q3map2.h\r
2633 ===================================================================\r
2634 --- q3map2.h    (revision 158)\r
2635 +++ q3map2.h    (working copy)\r
2636 @@ -35,8 +35,8 @@\r
2637  
2638  
2639  /* version */
2640 -#define Q3MAP_VERSION  "2.5.17"
2641 -#define Q3MAP_MOTD             "Last one turns the lights off"
2642 +#define Q3MAP_VERSION  "2.5.17 base : FS_20g base : R5"
2643 +#define Q3MAP_MOTD             "Sorry, it doesn't match my furniture."
2644  
2645  
2646  
2647 @@ -235,6 +235,7 @@\r
2648  #define LIGHT_FAST_TEMP                        512
2649  #define LIGHT_FAST_ACTUAL              (LIGHT_FAST | LIGHT_FAST_TEMP)
2650  #define LIGHT_NEGATIVE                 1024
2651 +#define LIGHT_UNNORMALIZED             2048    /* vortex: do not normalize _color */
2652  
2653  #define LIGHT_SUN_DEFAULT              (LIGHT_ATTEN_ANGLE | LIGHT_GRID | LIGHT_SURFACES)
2654  #define LIGHT_AREA_DEFAULT             (LIGHT_ATTEN_ANGLE | LIGHT_ATTEN_DISTANCE | LIGHT_GRID | LIGHT_SURFACES)        /* q3a and wolf are the same */
2655 @@ -267,6 +268,7 @@\r
2656  #define SUPER_NORMAL_SIZE              4
2657  #define SUPER_DELUXEL_SIZE             3
2658  #define BSP_DELUXEL_SIZE               3
2659 +#define SUPER_FLOODLIGHT_SIZE  4
2660  
2661  #define VERTEX_LUXEL( s, v )   (vertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
2662  #define RAD_VERTEX_LUXEL( s, v )(radVertexLuxels[ s ] + ((v) * VERTEX_LUXEL_SIZE))
2663 @@ -279,9 +281,8 @@\r
2664  #define SUPER_ORIGIN( x, y )   (lm->superOrigins + ((((y) * lm->sw) + (x)) * SUPER_ORIGIN_SIZE))
2665  #define SUPER_NORMAL( x, y )   (lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE))
2666  #define SUPER_DIRT( x, y )             (lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE) + 3)   /* stash dirtyness in normal[ 3 ] */
2667 +#define SUPER_FLOODLIGHT(x, y )        (lm->superFloodLight + ((((y) * lm->sw) + (x)) * SUPER_FLOODLIGHT_SIZE))
2668  
2669 -
2670 -
2671  /* -------------------------------------------------------------------------------
2672  
2673  abstracted bsp file
2674 @@ -543,7 +544,16 @@\r
2675         qboolean                        wolfLight;                                              /* when true, lights work like wolf q3map  */
2676         int                                     lightmapSize;                                   /* bsp lightmap width/height */
2677         float                           lightmapGamma;                                  /* default lightmap gamma */
2678 +       float                           lightmapExposure;                               /* default lightmap exposure */
2679         float                           lightmapCompensate;                             /* default lightmap compensate value */
2680 +       float                           gridScale;                                              /* vortex: default lightgrid scale (affects both directional and ambient spectres) */
2681 +       float                           gridAmbientScale;                               /* vortex: default lightgrid ambient spectre scale */
2682 +       qboolean                        noStyles;                                               /* use lightstyles hack or not */
2683 +       qboolean                        keepLights;                                             /* keep light entities on bsp */
2684 +       int                                     patchSubdivisions;                              /* default patch subdivisions tolerance */
2685 +       qboolean                        patchShadows;                                   /* patch casting enabled */
2686 +       qboolean                        deluxeMap;                                              /* compile deluxemaps */
2687 +       int                                     deluxeMode;                                             /* deluxemap mode (0 - modelspace, 1 - tangentspace with renormalization, 2 - tangentspace without renormalization) */
2688         char                            *bspIdent;                                              /* 4-letter bsp file prefix */
2689         int                                     bspVersion;                                             /* bsp version to use */
2690         qboolean                        lumpSwap;                                               /* cod-style len/ofs order */
2691 @@ -662,6 +672,7 @@\r
2692         char                            *backShader;                                    /* for surfaces that generate different front and back passes */
2693         char                            *cloneShader;                                   /* ydnar: for cloning of a surface */
2694         char                            *remapShader;                                   /* ydnar: remap a shader in final stage */
2695 +       char                            *deprecateShader;                               /* vortex: shader is deprecated and replaced by this on use */
2696  
2697         surfaceModel_t          *surfaceModel;                                  /* ydnar: for distribution of models */
2698         foliage_t                       *foliage;                                               /* ydnar/splash damage: wolf et foliage */
2699 @@ -737,7 +748,13 @@\r
2700         
2701         vec3_t                          color;                                                  /* normalized color */
2702         vec3_t                          averageColor;
2703 -       byte                            lightStyle;
2704 +       byte                            lightStyle;                                     
2705 +
2706 +       /* vortex: per-surface floodlight */
2707 +       float                           floodlightDirectionScale;
2708 +       vec3_t                          floodlightRGB; 
2709 +       float                           floodlightIntensity;
2710 +       float                           floodlightDistance;
2711         
2712         qb_t                            lmMergable;                                             /* ydnar */
2713         int                                     lmCustomWidth, lmCustomHeight;  /* ydnar */
2714 @@ -1013,7 +1030,7 @@\r
2715         int                                     maxIterations;
2716         int                                     patchWidth, patchHeight;
2717         vec3_t                          bounds[ 2 ];
2718 -       
2719 +
2720         /* ydnar/sd: for foliage */
2721         int                                     numFoliageInstances;
2722         
2723 @@ -1061,6 +1078,7 @@\r
2724         int                                     mapEntityNum, firstDrawSurf;
2725         int                                     firstBrush, numBrushes;         /* only valid during BSP compile */
2726         epair_t                         *epairs;
2727 +       qboolean                        forceNormalSmoothing; /* vortex: true if entity has _smoothnormals/_sn/_smooth key */
2728  }
2729  entity_t;
2730  
2731 @@ -1296,7 +1314,8 @@\r
2732         
2733         /* input and output */
2734         vec3_t                          color;                  /* starts out at full color, may be reduced if transparent surfaces are crossed */
2735 -       
2736 +       vec3_t                          colorNoShadow;  /* result color with no shadow casting */
2737 +
2738         /* output */
2739         vec3_t                          hit;
2740         int                                     compileFlags;   /* for determining surface compile flags traced through */
2741 @@ -1367,6 +1386,13 @@\r
2742         int                                             numLightClusters, *lightClusters;
2743         
2744         int                                             sampleSize, actualSampleSize, axisNum;
2745 +
2746 +       /* vortex: per-surface floodlight */
2747 +       float                                   floodlightDirectionScale;
2748 +       vec3_t                                  floodlightRGB; 
2749 +       float                                   floodlightIntensity;
2750 +       float                                   floodlightDistance;
2751 +
2752         int                                             entityNum;
2753         int                                             recvShadows;
2754         vec3_t                                  mins, maxs, axis, origin, *vecs;
2755 @@ -1389,9 +1415,9 @@\r
2756         float                                   *superOrigins;
2757         float                                   *superNormals;
2758         int                                             *superClusters;
2759 -       
2760         float                                   *superDeluxels; /* average light direction */
2761         float                                   *bspDeluxels;
2762 +       float                                   *superFloodLight; /* floodlight color */
2763  }
2764  rawLightmap_t;
2765  
2766 @@ -1421,8 +1447,6 @@\r
2767  }
2768  surfaceInfo_t;
2769  
2770 -
2771 -
2772  /* -------------------------------------------------------------------------------
2773  
2774  prototypes
2775 @@ -1556,6 +1580,7 @@\r
2776  void                                           ParsePatch( qboolean onlyLights );
2777  mesh_t                                         *SubdivideMesh( mesh_t in, float maxError, float minLength );
2778  void                                           PatchMapDrawSurfs( entity_t *e );
2779 +void                                           TriangulatePatchSurface( entity_t *e , mapDrawSurface_t *ds );
2780  
2781  
2782  /* tjunction.c */
2783 @@ -1610,6 +1635,8 @@\r
2784  void                                           AddEntitySurfaceModels( entity_t *e );
2785  int                                                    AddSurfaceModels( mapDrawSurface_t *ds );
2786  void                                           FilterDrawsurfsIntoTree( entity_t *e, tree_t *tree );
2787 +void                                           EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds );
2788 +static void                                    EmitTriangleSurface( mapDrawSurface_t *ds );
2789  
2790  
2791  /* surface_fur.c */
2792 @@ -1704,6 +1732,12 @@\r
2793  float                                          DirtForSample( trace_t *trace );
2794  void                                           DirtyRawLightmap( int num );
2795  
2796 +void                                           SetupFloodLight();
2797 +void                                           FloodlightRawLightmaps();
2798 +void                                           FloodlightIlluminateLightmap( rawLightmap_t *lm );
2799 +float                                          FloodLightForSample( trace_t *trace , float floodLightDistance, qboolean floodLightLowQuality);
2800 +void                                           FloodLightRawLightmap( int num );
2801 +
2802  void                                           IlluminateRawLightmap( int num );
2803  void                                           IlluminateVertexes( int num );
2804  
2805 @@ -1731,7 +1765,6 @@\r
2806  void                                           StitchSurfaceLightmaps( void );
2807  void                                           StoreSurfaceLightmaps( void );
2808  
2809 -
2810  /* image.c */
2811  void                                           ImageFree( image_t *image );
2812  image_t                                                *ImageFind( const char *filename );
2813 @@ -1845,6 +1879,12 @@\r
2814                                                                 ,
2815                                                                 #include "game_qfusion.h"       /* qfusion game */
2816                                                                 ,
2817 +                                                               #include "game_darkplaces.h"    /* vortex: darkplaces q1 engine */
2818 +                                                               ,
2819 +                                                               #include "game_dq.h"    /* vortex: deluxe quake game ( darkplaces q1 engine) */
2820 +                                                               ,
2821 +                                                               #include "game_prophecy.h"      /* vortex: prophecy game ( darkplaces q1 engine) */
2822 +                                                               ,
2823                                                                 { NULL }        /* null game */
2824                                                         };
2825  #endif
2826 @@ -1929,6 +1969,7 @@\r
2827  Q_EXTERN char                          outbase[ 32 ];
2828  
2829  Q_EXTERN int                           sampleSize;                                             /* lightmap sample size in units */
2830 +Q_EXTERN int                           sampleScale;                                    /* vortex: lightmap sample scale (ie quality)*/
2831  
2832  Q_EXTERN int                           mapEntityNum Q_ASSIGN( 0 );
2833  
2834 @@ -2053,6 +2094,7 @@\r
2835  Q_EXTERN qboolean                      wolfLight Q_ASSIGN( qfalse );
2836  Q_EXTERN qboolean                      loMem Q_ASSIGN( qfalse );
2837  Q_EXTERN qboolean                      noStyles Q_ASSIGN( qfalse );
2838 +Q_EXTERN qboolean                      keepLights Q_ASSIGN( qfalse );
2839  
2840  Q_EXTERN int                           sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE );
2841  Q_EXTERN qboolean                      noVertexLighting Q_ASSIGN( qfalse );
2842 @@ -2065,6 +2107,7 @@\r
2843  
2844  Q_EXTERN qboolean                      deluxemap Q_ASSIGN( qfalse );
2845  Q_EXTERN qboolean                      debugDeluxemap Q_ASSIGN( qfalse );
2846 +Q_EXTERN int                           deluxemode Q_ASSIGN( 0 );       /* deluxemap format (0 - modelspace, 1 - tangentspace with renormalization, 2 - tangentspace without renormalization) */
2847  
2848  Q_EXTERN qboolean                      fast Q_ASSIGN( qfalse );
2849  Q_EXTERN qboolean                      faster Q_ASSIGN( qfalse );
2850 @@ -2098,6 +2141,14 @@\r
2851  Q_EXTERN float                         dirtScale Q_ASSIGN( 1.0f );
2852  Q_EXTERN float                         dirtGain Q_ASSIGN( 1.0f );
2853  
2854 +/* 27: floodlighting */
2855 +Q_EXTERN qboolean                                      debugnormals Q_ASSIGN( qfalse );
2856 +Q_EXTERN qboolean                                      floodlighty Q_ASSIGN( qfalse );
2857 +Q_EXTERN qboolean                                      floodlight_lowquality Q_ASSIGN( qfalse );
2858 +Q_EXTERN vec3_t                                                floodlightRGB;
2859 +Q_EXTERN float                                         floodlightIntensity Q_ASSIGN( 512.0f );
2860 +Q_EXTERN float                                         floodlightDistance Q_ASSIGN( 1024.0f );
2861 +
2862  Q_EXTERN qboolean                      dump Q_ASSIGN( qfalse );
2863  Q_EXTERN qboolean                      debug Q_ASSIGN( qfalse );
2864  Q_EXTERN qboolean                      debugUnused Q_ASSIGN( qfalse );
2865 @@ -2115,9 +2166,14 @@\r
2866  Q_EXTERN float                         skyScale Q_ASSIGN( 1.0f );
2867  Q_EXTERN float                         bounceScale Q_ASSIGN( 0.25f );
2868  
2869 +/* vortex: gridscale and gridambientscale */
2870 +Q_EXTERN float                         gridScale Q_ASSIGN( 1.0f );
2871 +Q_EXTERN float                         gridAmbientScale Q_ASSIGN( 1.0f );
2872 +
2873  /* ydnar: lightmap gamma/compensation */
2874  Q_EXTERN float                         lightmapGamma Q_ASSIGN( 1.0f );
2875  Q_EXTERN float                         lightmapCompensate Q_ASSIGN( 1.0f );
2876 +Q_EXTERN float                         lightmapExposure Q_ASSIGN( 1.0f );
2877  
2878  /* ydnar: for runtime tweaking of falloff tolerance */
2879  Q_EXTERN float                         falloffTolerance Q_ASSIGN( 1.0f );
2880 @@ -2221,6 +2277,9 @@\r
2881  Q_EXTERN int                           numExtLightmaps Q_ASSIGN( 0 );
2882  Q_EXTERN outLightmap_t         *outLightmaps Q_ASSIGN( NULL );
2883  
2884 +/* vortex: per surface floodlight statictics */
2885 +Q_EXTERN int                           numSurfacesFloodlighten Q_ASSIGN( 0 );
2886 +
2887  /* grid points */
2888  Q_EXTERN int                           numRawGridPoints Q_ASSIGN( 0 );
2889  Q_EXTERN rawGridPoint_t                *rawGridPoints Q_ASSIGN( NULL );
2890 Index: shaders.c\r
2891 ===================================================================\r
2892 --- shaders.c   (revision 158)\r
2893 +++ shaders.c   (working copy)\r
2894 @@ -793,8 +793,14 @@\r
2895         }
2896         
2897         if( VectorLength( si->color ) <= 0.0f )
2898 +       {
2899                 ColorNormalize( color, si->color );
2900 -       VectorScale( color, (1.0f / count), si->averageColor );
2901 +               VectorScale( color, (1.0f / count), si->averageColor );
2902 +       }
2903 +       else
2904 +       {
2905 +               VectorCopy( si->color, si->averageColor );
2906 +       }
2907  }
2908  
2909  
2910 @@ -804,13 +810,15 @@\r
2911  finds a shaderinfo for a named shader
2912  */
2913  
2914 +#define MAX_SHADER_DEPRECATION_DEPTH 16
2915 +
2916  shaderInfo_t *ShaderInfoForShader( const char *shaderName )
2917  {
2918         int                             i;
2919 +       int                             deprecationDepth;
2920         shaderInfo_t    *si;
2921         char                    shader[ MAX_QPATH ];
2922 -       
2923 -       
2924 +
2925         /* dummy check */
2926         if( shaderName == NULL || shaderName[ 0 ] == '\0' )
2927         {
2928 @@ -823,11 +831,27 @@\r
2929         StripExtension( shader );
2930         
2931         /* search for it */
2932 +       deprecationDepth = 0;
2933         for( i = 0; i < numShaderInfo; i++ )
2934         {
2935                 si = &shaderInfo[ i ];
2936                 if( !Q_stricmp( shader, si->shader ) )
2937                 {
2938 +                       /* check if shader is deprecated */
2939 +                       if (deprecationDepth < MAX_SHADER_DEPRECATION_DEPTH && si->deprecateShader && si->deprecateShader[ 0 ] )
2940 +                       {
2941 +                               /* override name */
2942 +                               strcpy( shader, si->deprecateShader );
2943 +                               StripExtension( shader );
2944 +                               /* increase deprecation depth */
2945 +                               deprecationDepth++;
2946 +                               if (deprecationDepth == MAX_SHADER_DEPRECATION_DEPTH)
2947 +                                       Sys_Printf("WARNING: Max deprecation depth of %i is reached on shader '%s'\n", MAX_SHADER_DEPRECATION_DEPTH, shader);
2948 +                               /* search again from beginning */
2949 +                               i = -1;
2950 +                               continue;
2951 +                       }
2952 +
2953                         /* load image if necessary */
2954                         if( si->finished == qfalse )
2955                         {
2956 @@ -1340,7 +1364,6 @@\r
2957                                 {
2958                                         surfaceModel_t  *model;
2959                                         
2960 -                                       
2961                                         /* allocate new model and attach it */
2962                                         model = safe_malloc( sizeof( *model ) );
2963                                         memset( model, 0, sizeof( *model ) );
2964 @@ -1465,6 +1488,24 @@\r
2965                                         GetTokenAppend( shaderText, qfalse );
2966                                         si->backsplashDistance = atof( token );
2967                                 }
2968 +
2969 +                               /* q3map_floodLight <r> <g> <b> <diste> <intensity> <light_direction_power> */
2970 +                               else if( !Q_stricmp( token, "q3map_floodLight" ) )
2971 +                               {
2972 +                                       /* get color */
2973 +                                       GetTokenAppend( shaderText, qfalse );
2974 +                                       si->floodlightRGB[ 0 ] = atof( token );
2975 +                                       GetTokenAppend( shaderText, qfalse );
2976 +                                       si->floodlightRGB[ 1 ] = atof( token );
2977 +                                       GetTokenAppend( shaderText, qfalse );
2978 +                                       si->floodlightRGB[ 2 ] = atof( token );
2979 +                                       GetTokenAppend( shaderText, qfalse );
2980 +                                       si->floodlightDistance = atof( token ); 
2981 +                                       GetTokenAppend( shaderText, qfalse );
2982 +                                       si->floodlightIntensity = atof( token ); 
2983 +                                       GetTokenAppend( shaderText, qfalse );
2984 +                                       si->floodlightDirectionScale = atof( token ); 
2985 +                               }
2986                                 
2987                                 /* q3map_lightmapSampleSize <value> */
2988                                 else if( !Q_stricmp( token, "q3map_lightmapSampleSize" ) )
2989 @@ -1590,6 +1631,18 @@\r
2990                                                 strcpy( si->remapShader, token );
2991                                         }
2992                                 }
2993 +
2994 +                               /* q3map_deprecateShader <shader> */
2995 +                               else if( !Q_stricmp( token, "q3map_deprecateShader" ) )
2996 +                               {
2997 +                                       GetTokenAppend( shaderText, qfalse );
2998 +                                       if( token[ 0 ] != '\0' )
2999 +                                       {
3000 +
3001 +                                               si->deprecateShader = safe_malloc( strlen( token ) + 1 );
3002 +                                               strcpy( si->deprecateShader, token );
3003 +                                       }
3004 +                               }
3005                                 
3006                                 /* ydnar: q3map_offset <value> */
3007                                 else if( !Q_stricmp( token, "q3map_offset" ) )
3008 @@ -1896,12 +1949,14 @@\r
3009                                         si->styleMarker = 2;
3010                                 
3011                                 /* ydnar: default to searching for q3map_<surfaceparm> */
3012 -                               else
3013 +#if 0
3014 +                               else
3015                                 {
3016 -                                       //%     Sys_FPrintf( SYS_VRB, "Attempting to match %s with a known surfaceparm\n", token );
3017 +                                       Sys_FPrintf( SYS_VRB, "Attempting to match %s with a known surfaceparm\n", token );
3018                                         if( ApplySurfaceParm( &token[ 6 ], &si->contentFlags, &si->surfaceFlags, &si->compileFlags ) == qfalse )
3019 -                                               ;//%    Sys_Printf( "WARNING: Unknown q3map_* directive \"%s\"\n", token );
3020 +                                               Sys_Printf( "WARNING: Unknown q3map_* directive \"%s\"\n", token );
3021                                 }
3022 +#endif
3023                         }
3024                         
3025                         
3026 Index: surface.c\r
3027 ===================================================================\r
3028 --- surface.c   (revision 158)\r
3029 +++ surface.c   (working copy)\r
3030 @@ -304,7 +304,7 @@\r
3031                 out = &mapDrawSurfs[ i ];
3032                 
3033                 /* walk the surface list again until a proper surface is found */
3034 -               for( j; j < numMapDrawSurfs; j++ )
3035 +               for( ; j < numMapDrawSurfs; j++ )
3036                 {
3037                         /* get in surface */
3038                         in = &mapDrawSurfs[ j ];
3039 @@ -484,7 +484,7 @@\r
3040         
3041         
3042         /* walk the list of surfaces */
3043 -       for( numSurfs; numSurfs > 0; numSurfs--, ds++ )
3044 +       for( ; numSurfs > 0; numSurfs--, ds++ )
3045         {
3046                 /* ignore bogus (or flare) surfaces */
3047                 if( ds->type == SURFACE_BAD || ds->numVerts <= 0 )
3048 @@ -2445,25 +2445,27 @@\r
3049         numSurfacesByType[ ds->type ]++;
3050  }
3051  
3052 -
3053 -
3054  /*
3055  EmitPatchSurface()
3056  emits a bsp patch drawsurface
3057  */
3058  
3059 -void EmitPatchSurface( mapDrawSurface_t *ds )
3060 +void EmitPatchSurface( entity_t *e, mapDrawSurface_t *ds )
3061  {
3062         int                                     i, j;
3063         bspDrawSurface_t        *out;
3064         int                                     surfaceFlags, contentFlags;
3065 +       int                                     forcePatchMeta;
3066 +
3067 +       /* vortex: _patchMeta support */
3068 +       forcePatchMeta = IntForKey(e, "_patchMeta" );
3069 +       if (!forcePatchMeta)
3070 +               forcePatchMeta = IntForKey(e, "patchMeta" );
3071         
3072 -       
3073         /* invert the surface if necessary */
3074         if( ds->backSide || ds->shaderInfo->invert )
3075         {
3076                 bspDrawVert_t   *dv1, *dv2, temp;
3077 -               
3078  
3079                 /* walk the verts, flip the normal */
3080                 for( i = 0; i < ds->numVerts; i++ )
3081 @@ -2485,7 +2487,7 @@\r
3082                 /* invert facing */
3083                 VectorScale( ds->lightmapVecs[ 2 ], -1.0f, ds->lightmapVecs[ 2 ] );
3084         }
3085 -       
3086 +
3087         /* allocate a new surface */
3088         if( numBSPDrawSurfaces == MAX_MAP_DRAW_SURFS )
3089                 Error( "MAX_MAP_DRAW_SURFS" );
3090 @@ -2493,12 +2495,12 @@\r
3091         ds->outputNum = numBSPDrawSurfaces;
3092         numBSPDrawSurfaces++;
3093         memset( out, 0, sizeof( *out ) );
3094 -       
3095 +
3096         /* set it up */
3097         out->surfaceType = MST_PATCH;
3098         if( debugSurfaces )
3099                 out->shaderNum = EmitShader( "debugsurfaces", NULL, NULL );
3100 -       else if( patchMeta )
3101 +       else if( patchMeta || forcePatchMeta )
3102         {
3103                 /* patch meta requires that we have nodraw patches for collision */
3104                 surfaceFlags = ds->shaderInfo->surfaceFlags;
3105 @@ -2548,8 +2550,6 @@\r
3106         numSurfacesByType[ ds->type ]++;
3107  }
3108  
3109 -
3110 -
3111  /*
3112  OptimizeTriangleSurface() - ydnar
3113  optimizes the vertex/index data in a triangle surface
3114 @@ -2677,8 +2677,7 @@\r
3115  {
3116         int                                             i, temp;
3117         bspDrawSurface_t                *out;
3118 -       
3119 -       
3120 +
3121         /* invert the surface if necessary */
3122         if( ds->backSide || ds->shaderInfo->invert )
3123         {
3124 @@ -2689,15 +2688,15 @@\r
3125                         ds->indexes[ i ] = ds->indexes[ i + 1 ];
3126                         ds->indexes[ i + 1 ] = temp;
3127                 }
3128 -               
3129 +                       
3130                 /* walk the verts, flip the normal */
3131                 for( i = 0; i < ds->numVerts; i++ )
3132                         VectorScale( ds->verts[ i ].normal, -1.0f, ds->verts[ i ].normal );
3133 -               
3134 +                       
3135                 /* invert facing */
3136                 VectorScale( ds->lightmapVecs[ 2 ], -1.0f, ds->lightmapVecs[ 2 ] );
3137         }
3138 -       
3139 +               
3140         /* allocate a new surface */
3141         if( numBSPDrawSurfaces == MAX_MAP_DRAW_SURFS )
3142                 Error( "MAX_MAP_DRAW_SURFS" );
3143 @@ -2804,15 +2803,14 @@\r
3144  emits a bsp planar winding (brush face) drawsurface
3145  */
3146  
3147 -static void EmitFaceSurface( mapDrawSurface_t *ds )
3148 +static void EmitFaceSurface(mapDrawSurface_t *ds )
3149  {
3150         /* strip/fan finding was moved elsewhere */
3151         StripFaceSurface( ds );
3152 -       EmitTriangleSurface( ds );
3153 +       EmitTriangleSurface(ds);
3154  }
3155  
3156  
3157 -
3158  /*
3159  MakeDebugPortalSurfs_r() - ydnar
3160  generates drawsurfaces for passable portals in the bsp
3161 @@ -3502,7 +3500,7 @@\r
3162                                 if( refs == 0 )
3163                                         refs = FilterPatchIntoTree( ds, tree );
3164                                 if( refs > 0 )
3165 -                                       EmitPatchSurface( ds );
3166 +                                       EmitPatchSurface( e, ds );
3167                                 break;
3168                         
3169                         /* handle triangle surfaces */
3170 Index: surface_meta.c\r
3171 ===================================================================\r
3172 --- surface_meta.c      (revision 158)\r
3173 +++ surface_meta.c      (working copy)\r
3174 @@ -312,23 +312,41 @@\r
3175  creates triangles from a patch
3176  */
3177  
3178 -void TriangulatePatchSurface( mapDrawSurface_t *ds )
3179 +void TriangulatePatchSurface( entity_t *e , mapDrawSurface_t *ds )
3180  {
3181         int                                     iterations, x, y, pw[ 5 ], r;
3182         mapDrawSurface_t        *dsNew;
3183         mesh_t                          src, *subdivided, *mesh;
3184 -       
3185 -       
3186 +       int                                     forcePatchMeta;
3187 +       int                                     patchQuality;
3188 +       int                                     patchSubdivision;
3189 +
3190 +       /* vortex: _patchMeta, _patchQuality, _patchSubdivide support */
3191 +       forcePatchMeta = IntForKey(e, "_patchMeta" );
3192 +       if (!forcePatchMeta)
3193 +               forcePatchMeta = IntForKey(e, "patchMeta" );
3194 +       patchQuality = IntForKey(e, "_patchQuality" );
3195 +       if (!patchQuality)
3196 +               patchQuality = IntForKey(e, "patchQuality" );
3197 +       if (!patchQuality)
3198 +               patchQuality = 1.0;
3199 +       patchSubdivision = IntForKey(e, "_patchSubdivide" );
3200 +       if (!patchSubdivision)
3201 +               patchSubdivision = IntForKey(e, "patchSubdivide" );
3202 +
3203         /* try to early out */
3204 -       if( ds->numVerts == 0 || ds->type != SURFACE_PATCH || patchMeta == qfalse )
3205 +       if(ds->numVerts == 0 || ds->type != SURFACE_PATCH || ( patchMeta == qfalse && !forcePatchMeta) )
3206                 return;
3207 -       
3208         /* make a mesh from the drawsurf */ 
3209         src.width = ds->patchWidth;
3210         src.height = ds->patchHeight;
3211         src.verts = ds->verts;
3212         //%     subdivided = SubdivideMesh( src, 8, 999 );
3213 -       iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions );
3214 +       if (patchSubdivision)
3215 +               iterations = IterationsForCurve( ds->longestCurve, patchSubdivision );
3216 +       else
3217 +               iterations = IterationsForCurve( ds->longestCurve, patchSubdivisions / patchQuality );
3218 +
3219         subdivided = SubdivideMesh2( src, iterations ); //%     ds->maxIterations
3220         
3221         /* fit it to the curve and remove colinear verts on rows/columns */
3222 @@ -652,12 +685,12 @@\r
3223                                 break;
3224                         
3225                         case SURFACE_PATCH:
3226 -                               TriangulatePatchSurface( ds );
3227 +                               TriangulatePatchSurface(e, ds );
3228                                 break;
3229                         
3230                         case SURFACE_TRIANGLES:
3231                                 break;
3232 -                       
3233 +               
3234                         case SURFACE_FORCED_META:
3235                         case SURFACE_META:
3236                                 SurfaceToMetaTriangles( ds );
3237 @@ -972,8 +1005,8 @@\r
3238         vec3_t                  average, diff;
3239         int                             indexes[ MAX_SAMPLES ];
3240         vec3_t                  votes[ MAX_SAMPLES ];
3241 +       const char              *classname;
3242         
3243 -       
3244         /* note it */
3245         Sys_FPrintf( SYS_VRB, "--- SmoothMetaTriangles ---\n" );
3246         
3247 @@ -994,11 +1027,31 @@\r
3248            and set per-vertex smoothing angle */
3249         for( i = 0, tri = &metaTriangles[ i ]; i < numMetaTriangles; i++, tri++ )
3250         {
3251 +               /* vortex: try get smoothing from entity key */
3252 +               shadeAngle = FloatForKey(&entities[tri->entityNum], "_smoothnormals");
3253 +               if (shadeAngle <= 0.0f)
3254 +                       shadeAngle = FloatForKey(&entities[tri->entityNum], "_sn");
3255 +               if (shadeAngle <= 0.0f)
3256 +                       shadeAngle = FloatForKey(&entities[tri->entityNum], "_smooth");
3257 +               if (shadeAngle > 0.0f)
3258 +               {
3259 +                       if (entities[tri->entityNum].forceNormalSmoothing == qfalse)
3260 +                       {
3261 +                               entities[tri->entityNum].forceNormalSmoothing = qtrue;
3262 +                               classname = ValueForKey( &entities[tri->entityNum], "classname" );
3263 +                               Sys_Printf( "Entity %d (%s) has vertex normal smoothing with breaking angle of %3.0f\n", tri->entityNum, classname, shadeAngle );
3264 +                       }
3265 +                       shadeAngle = DEG2RAD( shadeAngle );
3266 +               }
3267 +
3268                 /* get shader for shade angle */
3269 -               if( tri->si->shadeAngleDegrees > 0.0f )
3270 -                       shadeAngle = DEG2RAD( tri->si->shadeAngleDegrees );
3271 -               else
3272 -                       shadeAngle = defaultShadeAngle;
3273 +               if (shadeAngle <= 0.0f)
3274 +               {
3275 +                       if( tri->si->shadeAngleDegrees > 0.0f )
3276 +                               shadeAngle = DEG2RAD( tri->si->shadeAngleDegrees );
3277 +                       else
3278 +                               shadeAngle = defaultShadeAngle;
3279 +               }
3280                 if( shadeAngle > maxShadeAngle )
3281                         maxShadeAngle = shadeAngle;
3282                 
3283 Index: writebsp.c\r
3284 ===================================================================\r
3285 --- writebsp.c  (revision 158)\r
3286 +++ writebsp.c  (working copy)\r
3287 @@ -136,7 +136,6 @@\r
3288         bspLeaf_t               *leaf_p;
3289         brush_t                 *b;
3290         drawSurfRef_t   *dsr;
3291 -       int                             i = 0;
3292  
3293         
3294         /* check limits */
3295 @@ -278,18 +277,19 @@\r
3296  void SetLightStyles( void )
3297  {
3298         int                     i, j, style, numStyles;
3299 -       qboolean        keepLights;
3300         const char      *t;
3301         entity_t        *e;
3302         epair_t         *ep, *next;
3303         char            value[ 10 ];
3304         char            lightTargets[ MAX_SWITCHED_LIGHTS ][ 64 ];
3305         int                     lightStyles[ MAX_SWITCHED_LIGHTS ];
3306 -       
3307 -       
3308 +
3309         /* ydnar: determine if we keep lights in the bsp */
3310 -       t = ValueForKey( &entities[ 0 ], "_keepLights" );
3311 -       keepLights = (t[ 0 ] == '1') ? qtrue : qfalse;
3312 +       if (KeyExists(&entities[ 0 ], "_keepLights") == qtrue)
3313 +       {
3314 +               t = ValueForKey( &entities[ 0 ], "_keepLights" );
3315 +               keepLights = (t[ 0 ] == '1') ? qtrue : qfalse;
3316 +       }
3317         
3318         /* any light that is controlled (has a targetname) must have a unique style number generated for it */
3319         numStyles = 0;