00001 00006 /* 00007 Copyright (C) 1997-2001 Id Software, Inc. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00017 00018 See the GNU General Public License for more details. 00019 00020 You should have received a copy of the GNU General Public License 00021 along with this program; if not, write to the Free Software 00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00023 00024 */ 00025 00026 #include "lighting.h" 00027 #include "map.h" 00028 #include "bsp.h" 00029 00030 void LightWorld (void) 00031 { 00032 if (curTile->numnodes == 0 || curTile->numfaces == 0) 00033 Sys_Error("Empty map"); 00034 00035 /* initialize light data */ 00036 curTile->lightdata[config.compile_for_day][0] = config.lightquant; 00037 curTile->lightdatasize[config.compile_for_day] = 1; 00038 00039 MakeTracingNodes(LEVEL_LASTLIGHTBLOCKING + 1); 00040 00041 /* turn each face into a single patch */ 00042 BuildPatches(); 00043 00044 /* subdivide patches to a maximum dimension */ 00045 SubdividePatches(); 00046 00047 /* create lights out of patches and lights */ 00048 BuildLights(); 00049 00050 /* patches are no longer needed */ 00051 FreePatches(); 00052 00053 /* build per-vertex normals for phong shading */ 00054 BuildVertexNormals(); 00055 00056 /* build initial facelights */ 00057 RunThreadsOn(BuildFacelights, curTile->numfaces, config.verbosity >= VERB_NORMAL, "FACELIGHTS"); 00058 00059 /* finalize it and write it out */ 00060 RunThreadsOn(FinalLightFace, curTile->numfaces, config.verbosity >= VERB_NORMAL, "FINALLIGHT"); 00061 CloseTracingNodes(); 00062 }