UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
lighting.cpp
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 1997-2001 Id Software, Inc.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24 */
25 
26 #include "lighting.h"
27 #include "map.h"
28 #include "bsp.h"
29 
34 void LightWorld (void)
35 {
36  if (curTile->numnodes == 0 || curTile->numfaces == 0)
37  Sys_Error("Empty map");
38 
39  /* initialize light data */
40  curTile->lightdata[config.compile_for_day][0] = config.lightquant;
41  curTile->lightdatasize[config.compile_for_day] = 1;
42 
44 
45  /* turn each face into a single patch */
46  BuildPatches();
47 
48  /* subdivide patches to a maximum dimension */
50 
51  /* create lights out of patches and lights */
52  BuildLights();
53 
54  /* patches are no longer needed */
55  FreePatches();
56 
57  /* build per-vertex normals for phong shading */
59 
60  /* build initial facelights */
61  RunThreadsOn(BuildFacelights, curTile->numfaces, config.verbosity >= VERB_NORMAL, "FACELIGHTS");
62 
63  /* finalize it and write it out */
64  RunThreadsOn(FinalLightFace, curTile->numfaces, config.verbosity >= VERB_NORMAL, "FINALLIGHT");
66 }
void BuildVertexNormals(void)
Calculate per-vertex (instead of per-plane) normal vectors. This is done by finding all of the faces ...
Definition: lightmap.cpp:673
void BuildLights(void)
Create lights out of patches and entity lights.
Definition: lightmap.cpp:293
#define LEVEL_LASTLIGHTBLOCKING
Definition: defines.h:350
void Sys_Error(const char *error,...)
Definition: g_main.cpp:421
void CloseTracingNodes(void)
Definition: trace.cpp:65
void SubdividePatches(void)
Iterate all of the head face patches, subdividing them as necessary.
Definition: patches.cpp:312
void MakeTracingNodes(int levels)
Use the bsp node structure to reconstruct efficient tracing structures that are used for fast visibil...
Definition: trace.cpp:38
byte lightdata[LIGHTMAP_MAX][MAX_MAP_LIGHTING]
Definition: typedefs.h:465
void LightWorld(void)
Build the lightmap out of light entities and surface lights (patches)
Definition: lighting.cpp:34
void BuildPatches(void)
Create surface fragments for light-emitting surfaces so that light sources may be computed along them...
Definition: patches.cpp:198
int lightdatasize[LIGHTMAP_MAX]
Definition: typedefs.h:464
static config_t config
Definition: test_all.cpp:43
dMapTile_t * curTile
Definition: bsp.cpp:32
void RunThreadsOn(void(*func)(unsigned int), unsigned int workcount, bool progress, const char *id)
void FinalLightFace(unsigned int facenum)
Add the indirect lighting on top of the direct lighting and save into final map format.
Definition: lightmap.cpp:987
int numnodes
Definition: typedefs.h:483
void FreePatches(void)
After light sources have been created, patches may be freed.
Definition: patches.cpp:325
int numfaces
Definition: typedefs.h:489
void BuildFacelights(unsigned int facenum)
Definition: lightmap.cpp:753