#include "common/shared.h"
#include "common/bspfile.h"
#include "common/polylib.h"
Go to the source code of this file.
Data Structures | |
struct | patch_s |
Defines | |
#define | MAX_PATCHES 65000 |
Typedefs | |
typedef struct patch_s | patch_t |
Functions | |
void | BuildFacelights (unsigned int facenum) |
void | FinalLightFace (unsigned int facenum) |
Add the indirect lighting on top of the direct lighting and save into final map format. | |
void | ExportLightmaps (const char *bspFileName) |
Export the day and night lightmap and direction data for the given map. | |
void | BuildLights (void) |
Create lights out of patches and lights. | |
void | BuildPatches (void) |
Create surface fragments for light-emitting surfaces so that light sources may be computed along them. This function is responsible for one. | |
void | SubdividePatches (void) |
Iterate all of the head face patches, subdividing them as necessary. | |
void | CalcTextureReflectivity (void) |
void | LightWorld (void) |
void | BuildVertexNormals (void) |
Calculate per-vertex (instead of per-plane) normal vectors. This is done by finding all of the faces which share a given vertex, and calculating a weighted average of their normals. | |
void | FreePatches (void) |
After light sources have been created, patches may be freed. | |
Variables | |
patch_t * | face_patches [MAX_MAP_FACES] |
vec3_t | face_offset [MAX_MAP_FACES] |
Definition in file lighting.h.
#define MAX_PATCHES 65000 |
Definition at line 29 of file lighting.h.
void BuildFacelights | ( | unsigned int | facenum | ) |
Definition at line 744 of file lightmap.c.
References CalcLightinfoExtents(), CalcLightinfoVectors(), CalcPoints(), extents_s::center, Com_Printf(), config, curTile, facelight_s::directions, dBspPlane_t::dist, DotProduct, lightinfo_t::face, face_offset, lightinfo_t::facedist, lightinfo_t::facenormal, dMapTile_t::faces, GatherSampleLight(), i, MAX_MAP_FACES, MAX_SAMPLES, Mem_Alloc, Mem_Free, dBspPlane_t::normal, light_s::normal, NudgeSamplePosition(), numlights, facelight_s::numsamples, lightinfo_t::numsurfpt, facelight_s::origins, dBspSurface_t::planenum, dMapTile_t::planes, pos, SampleNormal(), sampleofs, facelight_s::samples, scale, dBspSurface_t::side, SURF_PHONG, SURF_WARP, texinfo_s::surfaceFlags, lightinfo_t::surfpt, TangentVectors(), dBspSurface_t::texinfo, dMapTile_t::texinfo, vec3_origin, texinfo_s::vecs, VectorCompare, VectorCopy, VectorNegate, VectorNormalize(), and VectorSet.
Referenced by LightWorld().
void BuildLights | ( | void | ) |
Create lights out of patches and lights.
Definition at line 290 of file lightmap.c.
References ambient, ANGLE_DOWN, ANGLE_UP, AngleVectors(), patch_s::area, light_s::color, light_t::color, ColorNormalize(), Com_Printf(), config, dest, emit_point, emit_spotlight, emit_surface, entities, f, face_patches, FindTargetEntity(), FloatForKey(), GetVectorForKey(), GetVectorFromString(), i, light_s::intensity, patch_s::light, MAX_MAP_FACES, Mem_Alloc, name, patch_s::next, num_entities, numlights, light_t::origin, patch_s::origin, sun_ambient_color, sun_angles, sun_color, sun_intensity, sun_normal, torad, ValueForKey(), vec3_origin, VectorClear, VectorCompare, VectorCopy, VectorNormalize(), VectorSubtract, VERB_EXTRA, VERB_NORMAL, and Verb_Printf().
Referenced by LightWorld().
void BuildPatches | ( | void | ) |
Create surface fragments for light-emitting surfaces so that light sources may be computed along them. This function is responsible for one.
Definition at line 194 of file patches.c.
References BuildPatch(), curTile, EntityForModel(), f, face_offset, dMapTile_t::faces, dBspModel_t::firstface, GetVectorForKey(), HasLight(), i, dMapTile_t::models, dBspModel_t::numfaces, dMapTile_t::nummodels, winding_s::numpoints, winding_s::p, VectorAdd, VectorCopy, and WindingFromFace().
Referenced by LightWorld().
void BuildVertexNormals | ( | void | ) |
Calculate per-vertex (instead of per-plane) normal vectors. This is done by finding all of the faces which share a given vertex, and calculating a weighted average of their normals.
Definition at line 665 of file lightmap.c.
References BuildFaceExtents(), curTile, dMapTile_t::faces, FacesWithVert(), i, MAX_VERT_FACES, dBspPlane_t::normal, dBspNormal_t::normal, dMapTile_t::normals, dMapTile_t::numvertexes, dBspSurface_t::planenum, dMapTile_t::planes, scale, dBspSurface_t::side, VectorAdd, VectorClear, VectorLength(), VectorNormalize(), VectorScale, and VectorSubtract.
Referenced by LightWorld(), and main().
void CalcTextureReflectivity | ( | void | ) |
Definition at line 38 of file patches.c.
References byte, light_s::color, Com_sprintf(), curTile, i, Img_LoadImage(), MAX_QPATH, dMapTile_t::numtexinfo, pos, dMapTile_t::texinfo, texinfo_s::texture, texture_reflectivity, VectorCopy, VectorSet, VERB_EXTRA, VERB_NORMAL, and Verb_Printf().
Referenced by main().
void ExportLightmaps | ( | const char * | bspFileName | ) |
Export the day and night lightmap and direction data for the given map.
bspFileName | The path of the loaded bsp file. |
Definition at line 965 of file lightmap.c.
References BuildFaceExtents(), Com_FilePath(), Com_Printf(), Com_SkipPath(), Com_StripExtension(), ExportLightmap(), MAX_QPATH, qfalse, and qtrue.
Referenced by main().
void FinalLightFace | ( | unsigned int | facenum | ) |
Add the indirect lighting on top of the direct lighting and save into final map format.
Definition at line 989 of file lightmap.c.
References byte, config, curTile, dest, facelight_s::directions, DotProduct, f, dMapTile_t::faces, light_s::intensity, dMapTile_t::lightdata, dMapTile_t::lightdatasize, dBspSurface_t::lightofs, luminosity, MAX_MAP_LIGHTING, facelight_s::numsamples, facelight_s::samples, sun_ambient_color, SURF_WARP, texinfo_s::surfaceFlags, Sys_Error(), dBspSurface_t::texinfo, dMapTile_t::texinfo, texinfo_s::texture, ThreadLock(), ThreadUnlock(), VectorAdd, VectorCopy, VectorMix(), VectorScale, and VectorSet.
Referenced by LightWorld().
void FreePatches | ( | void | ) |
After light sources have been created, patches may be freed.
Definition at line 326 of file patches.c.
References i, MAX_MAP_FACES, Mem_Free, and patch_s::next.
Referenced by LightWorld().
void LightWorld | ( | void | ) |
Definition at line 30 of file lighting.c.
References BuildFacelights(), BuildLights(), BuildPatches(), BuildVertexNormals(), CloseTracingNodes(), config, curTile, FinalLightFace(), FreePatches(), LEVEL_LASTLIGHTBLOCKING, dMapTile_t::lightdata, dMapTile_t::lightdatasize, MakeTracingNodes(), dMapTile_t::numfaces, dMapTile_t::numnodes, RunThreadsOn(), SubdividePatches(), Sys_Error(), and VERB_NORMAL.
Referenced by main().
void SubdividePatches | ( | void | ) |
Iterate all of the head face patches, subdividing them as necessary.
Definition at line 311 of file patches.c.
References i, MAX_MAP_FACES, and SubdividePatch().
Referenced by LightWorld().
vec3_t face_offset[MAX_MAP_FACES] |
for rotating bmodels
Definition at line 34 of file lightmap.c.
Referenced by BuildFacelights(), and BuildPatches().
patch_t* face_patches[MAX_MAP_FACES] |
Definition at line 30 of file patches.c.
Referenced by BuildLights().