r_bsp.c 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.c:

Go to the source code of this file.

Defines

#define BACKFACE_EPSILON   0.01

Functions

static qboolean R_CullBox (const vec3_t mins, const vec3_t maxs)
 Returns true if the specified bounding box is completely culled by the view frustum, false otherwise.
qboolean R_CullSphere (const vec3_t centre, const float radius, const unsigned int clipflags)
 Performs a spherical frustum check.
qboolean R_CullBspModel (const entity_t *e)
 Returns true if the specified entity is completely culled by the view frustum, false otherwise.
static void R_DrawBspModelSurfaces (const entity_t *e, const vec3_t modelorg)
 Renders all the surfaces that belongs to an inline bsp model entity.
void R_DrawBrushModel (const entity_t *e)
 Draws a brush model.
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_RecursiveWorldNode (const mBspNode_t *node, int tile)
 Recurse down the bsp tree and mark surfaces that are visible (not culled and in front) 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.

Detailed Description

BSP model code.

Definition in file r_bsp.c.


Define Documentation

#define BACKFACE_EPSILON   0.01

Definition at line 38 of file r_bsp.c.

Referenced by R_DrawBspModelSurfaces().


Function Documentation

static qboolean R_CullBox ( const vec3_t  mins,
const vec3_t  maxs 
) [static]

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

Parameters:
[in] mins The mins of the bounding box
[in] maxs The maxs of the bounding box

Definition at line 47 of file r_bsp.c.

References rlocals_s::frustum, i, cvar_s::integer, lengthof, PSIDE_BACK, qfalse, qtrue, r_locals, r_nocull, and TR_BoxOnPlaneSide().

Referenced by R_CullBspModel(), and R_RecursiveWorldNode().

qboolean R_CullBspModel ( const entity_t e  ) 

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

Parameters:
[in] e The entity to check
See also:
R_CullBox

Definition at line 93 of file r_bsp.c.

References i, qtrue, R_CullBox(), R_EntityGetOrigin(), VectorAdd, and VectorCopy.

Referenced by R_CullEntity().

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

Performs a spherical frustum check.

Parameters:
[in] centre The world coordinate that is the center of the sphere
[in] radius The radius of the sphere to check the frustum for
[in] clipflags Can be used to skip sides of the frustum planes
Returns:
true if the sphere is completely outside the frustum, false otherwise

Definition at line 68 of file r_bsp.c.

References cBspPlane_s::dist, DotProduct, rlocals_s::frustum, i, cvar_s::integer, lengthof, cBspPlane_s::normal, qfalse, qtrue, r_locals, and r_nocull.

void R_DrawBrushModel ( const entity_t e  ) 

Draws a brush model.

Parameters:
[in] e The inline bsp model entity
Note:
E.g. a func_breakable or func_door

Definition at line 181 of file r_bsp.c.

References cvar_s::integer, PITCH, R_DrawBoundingBox(), R_DrawBspModelSurfaces(), R_EntityGetOrigin(), R_ShiftLights(), r_showbox, refdef, ROLL, vec3_origin, VectorCopy, VectorCreateRotationMatrix(), VectorNotEmpty, VectorRotatePoint(), VectorSubtract, rendererData_t::viewOrigin, and YAW.

Referenced by R_DrawBspEntities().

static void R_DrawBspModelSurfaces ( const entity_t e,
const vec3_t  modelorg 
) [static]

Renders all the surfaces that belongs to an inline bsp model entity.

Parameters:
[in] e The inline bsp model entity
[in] modelorg relative to viewpoint

Todo:
This leads to unrendered backfaces for e.g. doors

Definition at line 121 of file r_bsp.c.

References AXIAL, BACKFACE_EPSILON, cBspPlane_s::dist, DotProduct, f, mBspSurface_s::flags, mBspSurface_s::frame, rlocals_s::frame, i, MSURF_PLANEBACK, cBspPlane_s::normal, mBspSurface_s::plane, qfalse, qtrue, R_DrawAlphaTestSurfaces(), R_DrawBlendSurfaces(), R_DrawBlendWarpSurfaces(), R_DrawFlareSurfaces(), R_DrawMaterialSurfaces(), R_DrawOpaqueSurfaces(), R_DrawOpaqueWarpSurfaces(), R_EnableBlend(), R_EnableFog(), r_locals, and cBspPlane_s::type.

Referenced by R_DrawBrushModel().

void R_DrawBspNormals ( int  tile  ) 
void R_GetLevelSurfaceLists ( void   ) 

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

See also:
cvar cl_worldlevel

Definition at line 366 of file r_bsp.c.

References model_s::bsp, rlocals_s::frame, mBspHeader_s::headnode, i, cvar_s::integer, LEVEL_LASTVISIBLE, r_drawworld, r_locals, r_mapTiles, r_numMapTiles, R_RecurseWorld(), refdef, mBspModel_s::submodels, and rendererData_t::worldlevel.

Referenced by R_RenderFrame(), and R_RunThread().

static 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] node The bsp node to check
[in] tile The maptile (map assembly)
See also:
R_ModLoadNodes about pathfinding nodes

Definition at line 350 of file r_bsp.c.

References mBspNode_s::children, mBspNode_s::contents, CONTENTS_PATHFINDING_NODE, and R_RecursiveWorldNode().

Referenced by R_GetLevelSurfaceLists().

static void R_RecursiveWorldNode ( const mBspNode_t node,
int  tile 
) [static]

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

See also:
R_DrawWorld
R_RecurseWorld
Parameters:
[in] node The bsp node to check
[in] tile The maptile (map assembly)

Definition at line 292 of file r_bsp.c.

References AXIAL, model_s::bsp, mBspNode_s::children, mBspNode_s::contents, CONTENTS_NODE, CONTENTS_SOLID, cBspPlane_s::dist, DotProduct, mBspNode_s::firstsurface, mBspSurface_s::flags, rlocals_s::forward, rlocals_s::frame, mBspSurface_s::frame, i, cvar_s::integer, mBspNode_s::minmaxs, MSURF_PLANEBACK, cBspPlane_s::normal, mBspNode_s::numsurfaces, mBspNode_s::plane, R_CullBox(), r_isometric, r_locals, r_mapTiles, refdef, mBspModel_s::surfaces, cBspPlane_s::type, and rendererData_t::viewOrigin.

Referenced by R_RecurseWorld().


Generated by  doxygen 1.6.2