bsp.c File Reference

#include "common.h"
#include "tracing.h"
#include "routing.h"
#include "../shared/parse.h"
Include dependency graph for bsp.c:

Go to the source code of this file.

Functions

static void CMod_LoadSubmodels (mapTile_t *tile, const byte *base, const lump_t *l, const vec3_t shift)
 Loads brush entities like func_door and func_breakable.
static void CMod_LoadSurfaces (mapTile_t *tile, const byte *base, const lump_t *l)
static void CMod_LoadNodes (mapTile_t *tile, const byte *base, const lump_t *l, const vec3_t shift)
static void CMod_LoadBrushes (mapTile_t *tile, const byte *base, const lump_t *l)
static void CMod_LoadLeafs (mapTile_t *tile, const byte *base, const lump_t *l)
static void CMod_LoadPlanes (mapTile_t *tile, const byte *base, const lump_t *l, const vec3_t shift)
static void CMod_LoadLeafBrushes (mapTile_t *tile, const byte *base, const lump_t *l)
static void CMod_LoadBrushSides (mapTile_t *tile, const byte *base, const lump_t *l)
static int CMod_DeCompressRouting (const byte **source, byte *dataStart)
static void CM_MakeTracingNodes (mapTile_t *tile)
 Use the bsp node structure to reconstruct efficient tracing structures that are used for fast visibility and pathfinding checks.
static void CMod_LoadRouting (mapTile_t *tile, mapData_t *mapData, const byte *base, const char *name, const lump_t *l, int sX, int sY, int sZ)
static void CMod_LoadEntityString (mapTile_t *tile, mapData_t *mapData, const byte *base, const lump_t *l, const vec3_t shift)
static void CMod_LoadLighting (mapTile_t *tile, const byte *base, const lump_t *l)
 Loads the lightmap for server side visibility lookup.
static void CM_InitBoxHull (mapTile_t *tile)
 Set up the planes and nodes so that the six floats of a bounding box can just be stored out and get a proper clipping hull structure.
static void CM_AddMapTile (const char *name, qboolean day, int sX, int sY, byte sZ, mapData_t *mapData, mapTiles_t *mapTiles)
 Adds in a single map tile.
static void CMod_RerouteMap (mapTiles_t *mapTiles, mapData_t *mapData)
void CM_LoadMap (const char *tiles, qboolean day, const char *pos, mapData_t *mapData, mapTiles_t *mapTiles)
 Loads in the map and all submodels.
cBspModel_tCM_InlineModel (mapTiles_t *mapTiles, const char *name)
 Searches all inline models and return the cBspModel_t pointer for the given modelnumber or -name.
void CM_SetInlineModelOrientation (mapTiles_t *mapTiles, const char *name, const vec3_t origin, const vec3_t angles)
 This function updates a model's orientation.

Variables

static cBspSurface_t nullSurface

Function Documentation

static void CM_AddMapTile ( const char *  name,
qboolean  day,
int  sX,
int  sY,
byte  sZ,
mapData_t mapData,
mapTiles_t mapTiles 
) [static]

Adds in a single map tile.

Parameters:
[in] name The (file-)name of the tile to add.
[in] day whether the lighting for day or night should be loaded.
[in] sX The x position on the world plane (grid position) - values from -(PATHFINDING_WIDTH / 2) up to PATHFINDING_WIDTH / 2 are allowed
[in] sY The y position on the world plane (grid position) - values from -(PATHFINDING_WIDTH / 2) up to PATHFINDING_WIDTH / 2 are allowed
[in] sZ The height level on the world plane (grid position) - values from 0 up to PATHFINDING_HEIGHT are allowed
Note:
The sX and sY values are grid positions - max. grid size is PATHFINDING_WIDTH - unit size is UNIT_SIZE => ends up at 2*MAX_WORLD_WIDTH (the worldplace size - or [-MAX_WORLD_WIDTH, MAX_WORLD_WIDTH])
Returns:
The checksum of the maptile
0 on error
See also:
CM_LoadMap
R_ModAddMapTile

Definition at line 758 of file bsp.c.

References BSPVERSION, byte, CM_InitBoxHull(), CM_MakeTracingNodes(), CMod_LoadBrushes(), CMod_LoadBrushSides(), CMod_LoadEntityString(), CMod_LoadLeafBrushes(), CMod_LoadLeafs(), CMod_LoadLighting(), CMod_LoadNodes(), CMod_LoadPlanes(), CMod_LoadRouting(), CMod_LoadSubmodels(), CMod_LoadSurfaces(), Com_BlockChecksum(), Com_DPrintf(), Com_Error(), Com_sprintf(), DEBUG_ENGINE, ERR_DROP, ERR_FATAL, FS_FreeFile(), FS_LoadFile(), header, i, mapTile_t::idx, LittleLong(), LUMP_BRUSHES, LUMP_BRUSHSIDES, LUMP_ENTITIES, LUMP_LEAFBRUSHES, LUMP_LEAFS, LUMP_LIGHTING_DAY, LUMP_LIGHTING_NIGHT, LUMP_MODELS, LUMP_NODES, LUMP_PLANES, LUMP_ROUTING, LUMP_TEXINFO, dBspHeader_t::lumps, mapData_s::mapChecksum, mapData_s::mapMax, mapData_s::mapMin, mapTiles_t::mapTiles, MAX_QPATH, mapTile_t::name, NUM_REGULAR_MODELS, mapData_s::numInline, mapTile_t::nummodels, mapTiles_t::numTiles, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, Q_strncpyz(), RT_GetMapSize(), shift, UNIT_HEIGHT, UNIT_SIZE, VectorSet, and dBspHeader_t::version.

Referenced by CM_LoadMap().

static void CM_InitBoxHull ( mapTile_t tile  )  [static]
cBspModel_t* CM_InlineModel ( mapTiles_t mapTiles,
const char *  name 
)

Searches all inline models and return the cBspModel_t pointer for the given modelnumber or -name.

Parameters:
[in] name The modelnumber (e.g. "*2") for inline brush models [bmodels]
Note:
Inline bmodels are e.g. the brushes that are assoziated with a func_breakable or func_door

Definition at line 1001 of file bsp.c.

References Com_Error(), ERR_DROP, i, mapTiles_t::mapTiles, MAX_MODELS, uiNode_s::num, NUM_REGULAR_MODELS, and mapTiles_t::numTiles.

Referenced by CL_ParseConfigString(), CL_ViewLoadMedia(), CM_EntCompleteBoxTrace(), CM_EntTestLine(), CM_EntTestLineDM(), CM_SetInlineModelOrientation(), Grid_RecalcRouting(), SV_Map(), and SV_SetModel().

void CM_LoadMap ( const char *  tiles,
qboolean  day,
const char *  pos,
mapData_t mapData,
mapTiles_t mapTiles 
)

Loads in the map and all submodels.

Note:
This function loads the collision data from the bsp file. For rendering R_ModBeginLoading is used.
Parameters:
[in] tiles Map name(s) relative to base/maps or random map assembly string
[in] day Use the day (true) or the night (false) version of the map
[in] pos In case you gave more than one tile (Random map assembly [rma]) you also have to provide the positions where those tiles should be placed at.
[out] mapData The loaded data is stored here.
See also:
CM_AddMapTile
R_ModBeginLoading

Definition at line 928 of file bsp.c.

References CM_AddMapTile(), CMod_RerouteMap(), com_cmodelSysPool, Com_DPrintf(), Com_Error(), Com_Parse(), Com_Printf(), Com_sprintf(), DEBUG_ENGINE, ERR_DROP, i, MAX_QPATH, MAX_VAR, Mem_FreePool, name, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, and Q_strncpyz().

Referenced by CL_CanMultiplayerStart(), SV_Map(), and testConnection().

static void CM_MakeTracingNodes ( mapTile_t tile  )  [static]

Use the bsp node structure to reconstruct efficient tracing structures that are used for fast visibility and pathfinding checks.

Note:
tile->tnodes is expected to have enough memory malloc'ed for the function to work.
See also:
BuildTracingNode_r

Definition at line 434 of file bsp.c.

References com_cmodelSysPool, cBspModel_s::headnode, i, LEAFNODE, LEVEL_MAX, Mem_PoolAlloc, mapTile_t::models, NUM_REGULAR_MODELS, mapTile_t::numcheads, mapTile_t::nummodels, mapTile_t::numnodes, mapTile_t::numtheads, mapTile_t::thead, mapTile_t::theadlevel, mapTile_t::tnodes, and TR_BuildTracingNode_r().

Referenced by CM_AddMapTile().

void CM_SetInlineModelOrientation ( mapTiles_t mapTiles,
const char *  name,
const vec3_t  origin,
const vec3_t  angles 
)

This function updates a model's orientation.

Parameters:
[in] name The name of the model, must include the '*'
[in] origin The new origin for the model
[in] angles The new facing angles for the model
Note:
This is used whenever a model's orientation changes, e.g. for func_doors and func_rotating models
See also:
LE_DoorAction
G_ClientUseEdict

Definition at line 1036 of file bsp.c.

References cBspModel_s::angles, CM_InlineModel(), cBspModel_s::origin, and VectorCopy.

Referenced by CL_AddBrushModel(), CL_DoorClose(), CL_DoorOpen(), SV_SetInlineModelOrientation(), and SV_SetModel().

static int CMod_DeCompressRouting ( const byte **  source,
byte dataStart 
) [static]
Parameters:
[in] source Source will be set to the end of the compressed data block!
[in] dataStart where to place the uncompressed data
See also:
CompressRouting (ufo2map)
CMod_LoadRouting

Definition at line 391 of file bsp.c.

References byte, and i.

Referenced by CMod_LoadRouting().

static void CMod_LoadBrushes ( mapTile_t tile,
const byte base,
const lump_t l 
) [static]
static void CMod_LoadBrushSides ( mapTile_t tile,
const byte base,
const lump_t l 
) [static]
static void CMod_LoadEntityString ( mapTile_t tile,
mapData_t mapData,
const byte base,
const lump_t l,
const vec3_t  shift 
) [static]
Note:
Transforms coordinates and stuff for assembled maps
Parameters:
[in] l descriptor of the data block we are working on
[in] shift The shifting vector in case this is a map assemble loaded map tiles.
See also:
CM_AddMapTile

Definition at line 586 of file bsp.c.

References Com_Error(), Com_Parse(), ERR_DROP, lump_t::filelen, lump_t::fileofs, mapTile_t::idx, mapData_s::mapEntityString, MAX_MAP_ENTSTRING, cBspModel_s::maxs, cBspModel_s::mins, mapTile_t::models, uiNode_s::num, NUM_REGULAR_MODELS, mapData_s::numInline, Q_strcat(), Q_strncpyz(), va(), VectorAdd, and VectorSubtract.

Referenced by CM_AddMapTile().

static void CMod_LoadLeafBrushes ( mapTile_t tile,
const byte base,
const lump_t l 
) [static]
Parameters:
[in] l descriptor of the data block we are working on
See also:
CM_AddMapTile

Definition at line 313 of file bsp.c.

References COLORED_GREEN, com_cmodelSysPool, Com_DPrintf(), Com_Error(), count, DEBUG_ENGINE, ERR_DROP, lump_t::filelen, lump_t::fileofs, i, mapTile_t::leafbrushes, LittleShort(), MAX_MAP_LEAFBRUSHES, Mem_PoolAlloc, and mapTile_t::numleafbrushes.

Referenced by CM_AddMapTile().

static void CMod_LoadLeafs ( mapTile_t tile,
const byte base,
const lump_t l 
) [static]
static void CMod_LoadLighting ( mapTile_t tile,
const byte base,
const lump_t l 
) [static]

Loads the lightmap for server side visibility lookup.

Todo:
Implement this

Definition at line 672 of file bsp.c.

References com_cmodelSysPool, lump_t::filelen, lump_t::fileofs, and Mem_PoolAlloc.

Referenced by CM_AddMapTile().

static void CMod_LoadNodes ( mapTile_t tile,
const byte base,
const lump_t l,
const vec3_t  shift 
) [static]
Parameters:
[in] l descriptor of the data block we are working on
[in] shift The shifting vector in case this is a map assemble
See also:
CM_AddMapTile
TR_BuildTracingNode_r

Definition at line 131 of file bsp.c.

References dBspNode_t::children, COLORED_GREEN, com_cmodelSysPool, Com_DPrintf(), Com_Error(), count, DEBUG_ENGINE, ERR_DROP, lump_t::filelen, lump_t::fileofs, i, LittleLong(), LittleShort(), MAX_MAP_NODES, dBspNode_t::maxs, Mem_PoolAlloc, dBspNode_t::mins, mapTile_t::nodes, mapTile_t::numnodes, cBspNode_s::plane, dBspNode_t::planenum, PLANENUM_LEAF, and mapTile_t::planes.

Referenced by CM_AddMapTile().

static void CMod_LoadPlanes ( mapTile_t tile,
const byte base,
const lump_t l,
const vec3_t  shift 
) [static]
Parameters:
[in] l descriptor of the data block we are working on
[in] shift The shifting vector in case this is a map assemble
See also:
CM_AddMapTile
R_ModLoadPlanes

Definition at line 269 of file bsp.c.

References COLORED_GREEN, com_cmodelSysPool, Com_DPrintf(), Com_Error(), count, DEBUG_ENGINE, cBspPlane_s::dist, ERR_DROP, lump_t::filelen, lump_t::fileofs, i, LittleFloat(), LittleLong(), MAX_MAP_PLANES, Mem_PoolAlloc, cBspPlane_s::normal, mapTile_t::numplanes, mapTile_t::planes, and cBspPlane_s::type.

Referenced by CM_AddMapTile().

static void CMod_LoadRouting ( mapTile_t tile,
mapData_t mapData,
const byte base,
const char *  name,
const lump_t l,
int  sX,
int  sY,
int  sZ 
) [static]
Parameters:
[in] name The name of the maptile
[in] l Routing lump ... (routing data lump from bsp file)
[in] sX The x position on the world plane (grid position) - values from -(PATHFINDING_WIDTH/2) up to PATHFINDING_WIDTH/2 are allowed
[in] sY The y position on the world plane (grid position) - values from -(PATHFINDING_WIDTH/2) up to PATHFINDING_WIDTH/2 are allowed
[in] sZ The height level on the world plane (grid position) - values from 0 - PATHFINDING_HEIGHT are allowed
See also:
CM_AddMapTile
Todo:
TEST z-level routing

Todo:
this eats a lot of memory - load directory into mapData->map

Definition at line 469 of file bsp.c.

References ACTOR_MAX_SIZE, byte, routing_s::ceil, CMod_DeCompressRouting(), Com_DPrintf(), Com_Error(), CORE_DIRECTIONS, DEBUG_ROUTING, ERR_DROP, lump_t::filelen, lump_t::fileofs, routing_s::floor, i, mapTile_t::idx, LittleLong(), mapData_s::map, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, mapData_s::reroute, routing_s::route, ROUTING_NOT_REACHABLE, routing_s::stepup, mapTile_t::wpMaxs, and mapTile_t::wpMins.

Referenced by CM_AddMapTile().

static void CMod_LoadSubmodels ( mapTile_t tile,
const byte base,
const lump_t l,
const vec3_t  shift 
) [static]

Loads brush entities like func_door and func_breakable.

Parameters:
[in] l The lump to load the data from
[in] shift The shifting vector in case this is a map assemble
See also:
CM_AddMapTile
R_ModLoadSubmodels
CM_InlineModel

Definition at line 48 of file bsp.c.

References COLORED_GREEN, com_cmodelSysPool, Com_DPrintf(), Com_Error(), count, DEBUG_ENGINE, ERR_DROP, lump_t::filelen, lump_t::fileofs, cBspModel_s::headnode, i, mapTile_t::idx, LittleFloat(), LittleLong(), MAX_MAP_MODELS, cBspModel_s::maxs, Mem_PoolAlloc, cBspModel_s::mins, mapTile_t::models, mapTile_t::nummodels, cBspModel_s::shift, cBspModel_s::tile, UFO_SIZE_T, and VectorCopy.

Referenced by CM_AddMapTile().

static void CMod_LoadSurfaces ( mapTile_t tile,
const byte base,
const lump_t l 
) [static]
static void CMod_RerouteMap ( mapTiles_t mapTiles,
mapData_t mapData 
) [static]

Note:
The new R_UpdateConnection updates both directions at the same time, so we only need to check every other direction.

< Can't const: need to check bounds first.

Note:
This update MUST go from the bottom (0) to the top (7) of the model. RT_UpdateConnection expects it and breaks otherwise.

Definition at line 842 of file bsp.c.

References ACTOR_MAX_SIZE, ACTOR_SIZE_INVALID, byte, Com_DPrintf(), Com_Printf(), CORE_DIRECTIONS, DEBUG_PATHING, dvecs, i, mapData_s::map, mapData_s::mapMax, mapData_s::mapMin, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, mapData_s::reroute, ROUTING_NOT_REACHABLE, RT_CheckCell(), RT_UpdateConnectionColumn(), and VecToPos.

Referenced by CM_LoadMap().


Variable Documentation

Note:
this is a zeroed surface structure

Definition at line 32 of file bsp.c.


Generated by  doxygen 1.6.2