UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
patches.cpp File Reference
#include "lighting.h"
#include "bsp.h"
#include "../../shared/images.h"

Go to the source code of this file.

Macros

#define PATCH_SUBDIVIDE   64
 

Functions

void CalcTextureReflectivity (void)
 Calculates the texture color that is used for light emitting surfaces. More...
 
static winding_tWindingFromFace (const dBspSurface_t *f)
 
static bool HasLight (const dBspSurface_t *f)
 
static void EmissiveLight (patch_t *patch)
 Check for light emitted by texture. More...
 
static void BuildPatch (int fn, winding_t *w)
 Build a patch for a surface that emits light. More...
 
static entity_tEntityForModel (int modnum)
 
void BuildPatches (void)
 Create surface fragments for light-emitting surfaces so that light sources may be computed along them. More...
 
static void FinishSubdividePatch (patch_t *patch, patch_t *newp)
 
static void SubdividePatch (patch_t *patch)
 Chops the patch by a global grid. More...
 
void SubdividePatches (void)
 Iterate all of the head face patches, subdividing them as necessary. More...
 
void FreePatches (void)
 After light sources have been created, patches may be freed. More...
 

Variables

static vec3_t texture_reflectivity [MAX_MAP_TEXINFO]
 
patch_tface_patches [MAX_MAP_FACES]
 

Macro Definition Documentation

#define PATCH_SUBDIVIDE   64

Definition at line 236 of file patches.cpp.

Referenced by SubdividePatch().

Function Documentation

static void BuildPatch ( int  fn,
winding_t w 
)
static

Build a patch for a surface that emits light.

Note
This is called in the lighting stage
Parameters
fnThe face number of the surface that emits the light
wThe winding
See also
BuildLights

Definition at line 145 of file patches.cpp.

References patch_s::area, curTile, EmissiveLight(), patch_s::face, dMapTile_t::faces, Mem_AllocType, patch_s::normal, dBspPlane_t::normal, patch_s::origin, dBspSurface_t::planenum, dMapTile_t::planes, dBspSurface_t::side, VectorCopy, VectorMA(), VectorNegate, patch_s::winding, WindingArea(), and WindingCenter().

Referenced by BuildPatches().

void BuildPatches ( void  )

Create surface fragments for light-emitting surfaces so that light sources may be computed along them.

Definition at line 198 of file patches.cpp.

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, OBJZERO, winding_s::p, VectorAdd, VectorCopy, and WindingFromFace().

Referenced by LightWorld().

void CalcTextureReflectivity ( void  )

Calculates the texture color that is used for light emitting surfaces.

Definition at line 41 of file patches.cpp.

References Com_sprintf(), curTile, i, Img_LoadImage(), MAX_QPATH, dMapTile_t::numtexinfo, Q_streq, dMapTile_t::texinfo, texinfo_s::texture, texture_reflectivity, VectorCopy, VectorSet, VERB_EXTRA, VERB_NORMAL, and Verb_Printf().

Referenced by main().

static void EmissiveLight ( patch_t patch)
inlinestatic

Check for light emitted by texture.

Note
Surface lights
See also
TexinfoForBrushTexture

Definition at line 130 of file patches.cpp.

References curTile, patch_s::face, patch_s::light, dBspSurface_t::texinfo, dMapTile_t::texinfo, texture_reflectivity, texinfo_s::value, and VectorScale.

Referenced by BuildPatch().

static entity_t* EntityForModel ( int  modnum)
static

Definition at line 178 of file patches.cpp.

References Com_sprintf(), entities, i, name, num_entities, Q_streq, and ValueForKey().

Referenced by BuildPatches().

static void FinishSubdividePatch ( patch_t patch,
patch_t newp 
)
static
void FreePatches ( void  )

After light sources have been created, patches may be freed.

Definition at line 325 of file patches.cpp.

References i, MAX_MAP_FACES, Mem_Free, and patch_s::next.

Referenced by LightWorld().

static bool HasLight ( const dBspSurface_t f)
inlinestatic
static void SubdividePatch ( patch_t patch)
static

Chops the patch by a global grid.

Definition at line 266 of file patches.cpp.

References ClipWindingEpsilon(), FinishSubdividePatch(), i, Mem_AllocType, patch_s::next, ON_EPSILON, PATCH_SUBDIVIDE, VectorClear, patch_s::winding, and WindingBounds().

Referenced by SubdividePatches().

void SubdividePatches ( void  )

Iterate all of the head face patches, subdividing them as necessary.

Definition at line 312 of file patches.cpp.

References i, MAX_MAP_FACES, and SubdividePatch().

Referenced by LightWorld().

Variable Documentation

patch_t* face_patches[MAX_MAP_FACES]

Definition at line 30 of file patches.cpp.

Referenced by BuildLights().

vec3_t texture_reflectivity[MAX_MAP_TEXINFO]
static

Definition at line 29 of file patches.cpp.

Referenced by CalcTextureReflectivity(), and EmissiveLight().