UFO: Alien Invasion
Loading...
Searching...
No Matches
r_bsp.cpp File Reference

BSP model code. More...

#include "r_local.h"
#include "r_lightmap.h"
#include "r_material.h"
#include "r_light.h"
#include "r_draw.h"
Include dependency graph for r_bsp.cpp:

Go to the source code of this file.

Data Structures

struct  bspRenderRef_t

Macros

#define BACKFACE_EPSILON   0.01
#define MAX_BSPS_TO_RENDER   1024

Typedefs

typedef void(* drawSurfaceFunc) (const mBspSurfaces_t *surfs, glElementIndex_t *indexPtr)

Functions

static int R_CullBox (const vec3_t mins, const vec3_t maxs)
 Returns whether if the specified bounding box is completely culled by the view frustum (PSIDE_BACK), completely not culled (PSIDE_FRONT) or split by it (PSIDE_BOTH).
bool R_CullSphere (const vec3_t centre, const float radius, const unsigned int clipflags)
 Performs a spherical frustum check.
bool R_CullBspModel (const entity_t *e)
 Returns true if the specified entity is completely culled by the view frustum, false otherwise.
void R_DrawBspNormals (int tile)
 Developer tool for viewing BSP vertex normals. Only Phong interpolated surfaces show their normals when r_shownormals > 1.
static void R_RecursiveVisibleWorldNode (const mBspNode_t *node, int tile)
 Recurse down the bsp tree and mark all surfaces as visible for being rendered.
static void R_RecursiveWorldNode (const mBspNode_t *node, int tile)
 Recurse down the bsp tree and mark surfaces that are visible (not culled) for being rendered.
static void R_RecurseWorld (const mBspNode_t *node, int tile)
 Wrapper that recurses the bsp nodes but skip the pathfinding nodes.
void R_GetLevelSurfaceLists (void)
 Fills the surface chains for the current worldlevel and hide other levels.
void R_ClearBspRRefs (void)
void R_AddBspRRef (const mBspModel_t *model, const vec3_t origin, const vec3_t angles, const bool forceVisibility)
 Adds bsp render references.
static void R_RenderBspRRefs (drawSurfaceFunc drawFunc, surfaceArrayType_t surfType)
void R_RenderOpaqueBspRRefs (void)
 Draw all simple opaque bsp surfaces with multitexture enabled and light enabled.
void R_RenderOpaqueWarpBspRRefs (void)
 Draw all warped opaque bsp surfaces via warp shader.
void R_RenderAlphaTestBspRRefs (void)
void R_RenderMaterialBspRRefs (void)
void R_RenderFlareBspRRefs (void)
void R_RenderBlendBspRRefs (void)
 Draw all translucent bsp surfaces with multitexture enabled and blend enabled.
void R_RenderBlendWarpBspRRefs (void)
 Draw all warped translucent bsp surfaces via warp shader and with blend enabled.

Variables

static bspRenderRef_t bspRRefs [MAX_BSPS_TO_RENDER]
static int numBspRRefs

Detailed Description

BSP model code.

Definition in file r_bsp.cpp.

Macro Definition Documentation

◆ BACKFACE_EPSILON

#define BACKFACE_EPSILON   0.01

Definition at line 38 of file r_bsp.cpp.

◆ MAX_BSPS_TO_RENDER

#define MAX_BSPS_TO_RENDER   1024

Definition at line 40 of file r_bsp.cpp.

Referenced by R_AddBspRRef().

Typedef Documentation

◆ drawSurfaceFunc

typedef void(* drawSurfaceFunc) (const mBspSurfaces_t *surfs, glElementIndex_t *indexPtr)

Definition at line 351 of file r_bsp.cpp.

Function Documentation

◆ R_AddBspRRef()

void R_AddBspRRef ( const mBspModel_t * model,
const vec3_t origin,
const vec3_t angles,
const bool forceVisibility )

Adds bsp render references.

Note
If forceVisibility is set, will mark the surfaces of the given bsp model as visible for this frame.
Parameters
[in]modelThe bsp model to add to the render chain
[in]origin
[in]angles
[in]forceVisibilityforce model to be fully visible

Definition at line 324 of file r_bsp.cpp.

References bspRenderRef_t::angles, bspRenderRef_t::bsp, bspRRefs, Com_Printf(), mBspModel_t::firstmodelsurface, mBspSurface_t::frame, i, MAX_BSPS_TO_RENDER, numBspRRefs, mBspModel_t::nummodelsurfaces, bspRenderRef_t::origin, r_locals, mBspModel_t::surfaces, and VectorCopy.

Referenced by R_GetEntityLists(), and R_RenderFrame().

◆ R_ClearBspRRefs()

void R_ClearBspRRefs ( void )

Definition at line 311 of file r_bsp.cpp.

References numBspRRefs.

Referenced by R_ClearScene().

◆ R_CullBox()

int R_CullBox ( const vec3_t mins,
const vec3_t maxs )
static

Returns whether if the specified bounding box is completely culled by the view frustum (PSIDE_BACK), completely not culled (PSIDE_FRONT) or split by it (PSIDE_BOTH).

Parameters
[in]minsThe mins of the bounding box
[in]maxsThe maxs of the bounding box

Definition at line 57 of file r_bsp.cpp.

References i, lengthof, PSIDE_BACK, PSIDE_FRONT, r_locals, r_nocull, and TR_BoxOnPlaneSide().

Referenced by R_CullBspModel(), and R_RecursiveWorldNode().

◆ R_CullBspModel()

bool R_CullBspModel ( const entity_t * e)

Returns true if the specified entity is completely culled by the view frustum, false otherwise.

Parameters
[in]eThe entity to check
See also
R_CullBox

Definition at line 108 of file r_bsp.cpp.

References AABB::expand(), AABB::getMaxs(), AABB::getMins(), entity_t::isOriginBrushModel, entity_t::model, entity_t::origin, PSIDE_BACK, R_CullBox(), and AABB::shift().

Referenced by R_CullEntity().

◆ R_CullSphere()

bool R_CullSphere ( const vec3_t centre,
const float radius,
const unsigned int clipflags )

Performs a spherical frustum check.

Parameters
[in]centreThe world coordinate that is the center of the sphere
[in]radiusThe radius of the sphere to check the frustum for
[in]clipflagsCan be used to skip sides of the frustum planes
Returns
true if the sphere is completely outside the frustum, false otherwise

Definition at line 83 of file r_bsp.cpp.

References cBspPlane_t::dist, DotProduct, i, lengthof, cBspPlane_t::normal, r_locals, and r_nocull.

◆ R_DrawBspNormals()

void R_DrawBspNormals ( int tile)

◆ R_GetLevelSurfaceLists()

void R_GetLevelSurfaceLists ( void )

Fills the surface chains for the current worldlevel and hide other levels.

See also
cvar cl_worldlevel

Definition at line 281 of file r_bsp.cpp.

References mBspHeader_t::headnode, i, LEVEL_LASTVISIBLE, mBspModel_t::nodes, mBspHeader_t::numfaces, r_drawworld, r_mapTiles, r_numMapTiles, R_RecurseWorld(), refdef, and mBspModel_t::submodels.

Referenced by R_RenderFrame(), and R_RunThread().

◆ R_RecurseWorld()

void R_RecurseWorld ( const mBspNode_t * node,
int tile )
static

Wrapper that recurses the bsp nodes but skip the pathfinding nodes.

See also
R_GetLevelSurfaceLists
Parameters
[in]nodeThe bsp node to check
[in]tileThe maptile (map assembly)
See also
R_ModLoadNodes about pathfinding nodes

Definition at line 265 of file r_bsp.cpp.

References mBspNode_t::children, mBspNode_t::contents, CONTENTS_PATHFINDING_NODE, R_RecurseWorld(), and R_RecursiveWorldNode().

Referenced by R_GetLevelSurfaceLists(), and R_RecurseWorld().

◆ R_RecursiveVisibleWorldNode()

void R_RecursiveVisibleWorldNode ( const mBspNode_t * node,
int tile )
static

Recurse down the bsp tree and mark all surfaces as visible for being rendered.

See also
R_DrawWorld
R_RecurseWorld
R_RecursiveWorldNode
Parameters
[in]nodeThe bsp node to mark
[in]tileThe maptile (map assembly)

Definition at line 200 of file r_bsp.cpp.

References mBspNode_t::children, mBspNode_t::contents, CONTENTS_NODE, mBspNode_t::firstsurface, mBspSurface_t::frame, i, mBspNode_t::numsurfaces, mBspNode_t::plane, r_locals, r_mapTiles, and R_RecursiveVisibleWorldNode().

Referenced by R_RecursiveVisibleWorldNode(), and R_RecursiveWorldNode().

◆ R_RecursiveWorldNode()

void R_RecursiveWorldNode ( const mBspNode_t * node,
int tile )
static

Recurse down the bsp tree and mark surfaces that are visible (not culled) for being rendered.

See also
R_DrawWorld
R_RecurseWorld
R_RecursiveVisibleWorldNode
Parameters
[in]nodeThe bsp node to check
[in]tileThe maptile (map assembly)
Todo
avoid being too precise, it's a waste of CPU time; possibly, granularity of 256x256x256 should be enough

Definition at line 227 of file r_bsp.cpp.

References mBspNode_t::children, mBspNode_t::contents, CONTENTS_NODE, mBspNode_t::firstsurface, mBspSurface_t::frame, i, AABB::maxs, mBspNode_t::minmaxs, AABB::mins, mBspNode_t::numsurfaces, mBspNode_t::plane, PSIDE_BACK, PSIDE_FRONT, R_CullBox(), r_locals, r_mapTiles, R_RecursiveVisibleWorldNode(), and R_RecursiveWorldNode().

Referenced by R_RecurseWorld(), and R_RecursiveWorldNode().

◆ R_RenderAlphaTestBspRRefs()

void R_RenderAlphaTestBspRRefs ( void )

◆ R_RenderBlendBspRRefs()

void R_RenderBlendBspRRefs ( void )

Draw all translucent bsp surfaces with multitexture enabled and blend enabled.

Definition at line 462 of file r_bsp.cpp.

References R_DrawSurfaces(), R_EnableTexture(), R_RenderBspRRefs(), r_state, S_BLEND, and texunit_lightmap.

Referenced by R_RenderFrame().

◆ R_RenderBlendWarpBspRRefs()

void R_RenderBlendWarpBspRRefs ( void )

Draw all warped translucent bsp surfaces via warp shader and with blend enabled.

Definition at line 475 of file r_bsp.cpp.

References R_DrawSurfaces(), R_EnableGlowMap(), R_EnableWarp(), R_RenderBspRRefs(), r_state, and S_BLEND_WARP.

Referenced by R_RenderFrame().

◆ R_RenderBspRRefs()

void R_RenderBspRRefs ( drawSurfaceFunc drawFunc,
surfaceArrayType_t surfType )
static

◆ R_RenderFlareBspRRefs()

void R_RenderFlareBspRRefs ( void )

Definition at line 454 of file r_bsp.cpp.

References R_DrawFlareSurfaces(), R_RenderBspRRefs(), and S_FLARE.

Referenced by R_RenderFrame().

◆ R_RenderMaterialBspRRefs()

void R_RenderMaterialBspRRefs ( void )

Definition at line 449 of file r_bsp.cpp.

References R_DrawMaterialSurfaces(), R_RenderBspRRefs(), and S_MATERIAL.

Referenced by R_RenderFrame().

◆ R_RenderOpaqueBspRRefs()

void R_RenderOpaqueBspRRefs ( void )

Draw all simple opaque bsp surfaces with multitexture enabled and light enabled.

Definition at line 410 of file r_bsp.cpp.

References R_DrawSurfaces(), R_EnableGlowMap(), R_EnableLighting(), R_EnableTexture(), R_EnableWorldLights(), R_RenderBspRRefs(), r_state, S_OPAQUE, and texunit_lightmap.

Referenced by R_RenderFrame().

◆ R_RenderOpaqueWarpBspRRefs()

void R_RenderOpaqueWarpBspRRefs ( void )

Draw all warped opaque bsp surfaces via warp shader.

Definition at line 426 of file r_bsp.cpp.

References R_DrawSurfaces(), R_EnableGlowMap(), R_EnableWarp(), R_RenderBspRRefs(), r_state, and S_OPAQUE_WARP.

Referenced by R_RenderFrame().

Variable Documentation

◆ bspRRefs

Definition at line 48 of file r_bsp.cpp.

Referenced by R_AddBspRRef(), and R_RenderBspRRefs().

◆ numBspRRefs

int numBspRRefs
static

Definition at line 49 of file r_bsp.cpp.

Referenced by R_AddBspRRef(), R_ClearBspRRefs(), and R_RenderBspRRefs().