UFO: Alien Invasion
|
bsp model loading More...
#include "common.h"
#include "qfiles.h"
#include "tracing.h"
#include "routing.h"
#include "../shared/parse.h"
Go to the source code of this file.
Functions | |
static int | CMod_ValidateLump (const lump_t *lump, const char *functionName, size_t elementSize, const char *elementName, int elementMaxCount) |
static void | CMod_LoadSubmodels (MapTile &tile, const byte *base, const lump_t *lump, const vec3_t shift) |
Loads brush entities like func_door and func_breakable. More... | |
static void | CMod_LoadSurfaces (MapTile &tile, const byte *base, const lump_t *lump) |
static void | CMod_LoadNodes (MapTile &tile, const byte *base, const lump_t *lump, const vec3_t shift) |
static void | CMod_LoadBrushes (MapTile &tile, const byte *base, const lump_t *lump) |
static void | CMod_LoadLeafs (MapTile &tile, const byte *base, const lump_t *lump) |
static void | CMod_LoadPlanes (MapTile &tile, const byte *base, const lump_t *lump, const vec3_t shift) |
static void | CMod_LoadLeafBrushes (MapTile &tile, const byte *base, const lump_t *lump) |
static void | CMod_LoadBrushSides (MapTile &tile, const byte *base, const lump_t *lump) |
static int | CMod_DeCompressRouting (const byte **source, byte *dataStart) |
static void | CM_MakeTracingNodes (MapTile &tile) |
Use the bsp node structure to reconstruct efficient tracing structures that are used for fast visibility and pathfinding checks. More... | |
static void | CMod_LoadRouting (MapTile &tile, mapData_t *mapData, const byte *base, const char *name, const lump_t *lump, const int sX, const int sY, const int sZ) |
static void | CMod_LoadEntityString (MapTile &tile, const char *entityString, mapData_t *mapData, const byte *base, const lump_t *l, const vec3_t shift) |
static void | CMod_LoadLighting (MapTile &tile, const byte *base, const lump_t *lump) |
Loads the lightmap for server side visibility lookup. More... | |
static void | CM_InitBoxHull (MapTile &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. More... | |
void | CM_LoadBsp (MapTile &tile, const dBspHeader_t &header, const vec3_t shift, const byte *base) |
static void | CM_AddMapTile (const char *name, const char *entityString, const bool day, const int sX, const int sY, const byte sZ, mapData_t *mapData, mapTiles_t *mapTiles) |
Adds in a single map tile. More... | |
static void | CMod_RerouteMap (mapTiles_t *mapTiles, mapData_t *mapData) |
Recalculate the seams of the tiles after an RMA. More... | |
void | CM_LoadMap (const char *tiles, bool day, const char *pos, const char *entityString, mapData_t *mapData, mapTiles_t *mapTiles) |
Loads in the map and all submodels. More... | |
cBspModel_t * | CM_InlineModel (const mapTiles_t *mapTiles, const char *name) |
Searches all inline models and return the cBspModel_t pointer for the given modelnumber or -name. More... | |
cBspModel_t * | CM_SetInlineModelOrientation (mapTiles_t *mapTiles, const char *name, const vec3_t origin, const vec3_t angles) |
This function updates a model's orientation. More... | |
void | CM_GetInlineModelAABB (mapTiles_t *mapTiles, const char *name, AABB &aabb) |
This function calculates a model's aabb in world coordinates. More... | |
float | CM_GetVisibility (const mapTiles_t *mapTiles, const pos3_t position) |
Checks how well a position is visible. More... | |
Variables | |
static cBspSurface_t | nullSurface |
bsp model loading
Definition in file bsp.cpp.
|
static |
Adds in a single map tile.
[in] | name | The (file-)name of the tile to add. |
[in] | entityString | If not empty, this is added to mapEntityString by CMod_LoadEntityString |
[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 |
[in] | mapData | The loaded data is stored here. |
[in] | mapTiles | List of tiles the current (RMA-)map is composed of |
Definition at line 674 of file bsp.cpp.
References BSP_SwapHeader, BSPVERSION, CM_InitBoxHull(), CM_LoadBsp(), CM_MakeTracingNodes(), CMod_LoadEntityString(), CMod_LoadLighting(), CMod_LoadRouting(), Com_BlockChecksum(), Com_DPrintf(), Com_Error(), Com_sprintf(), DEBUG_ENGINE, ERR_DROP, ERR_FATAL, FS_FreeFile(), FS_LoadFile(), MapTile::idx, length, LittleLong, LUMP_ENTITIES, LUMP_LIGHTING_DAY, LUMP_LIGHTING_NIGHT, LUMP_ROUTING, dBspHeader_t::lumps, mapData_s::mapBox, mapData_s::mapChecksum, mapTiles_s::mapTiles, MAX_QPATH, MapTile::name, NUM_REGULAR_MODELS, mapData_s::numInline, MapTile::nummodels, mapTiles_s::numTiles, OBJZERO, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, Q_strncpyz(), RT_GetMapSize(), shift, UNIT_HEIGHT, UNIT_SIZE, VectorSet, and dBspHeader_t::version.
Referenced by CM_LoadMap().
void CM_GetInlineModelAABB | ( | mapTiles_t * | mapTiles, |
const char * | name, | ||
AABB & | aabb | ||
) |
This function calculates a model's aabb in world coordinates.
[in] | mapTiles | List of tiles the current (RMA-)map is composed of |
[in] | name | The name of the model, must include the '*' |
[out] | aabb | The aabb to be filled |
Definition at line 979 of file bsp.cpp.
References cBspModel_s::angles, CalculateMinsMaxs(), cBspModel_s::cbmBox, CM_InlineModel(), and cBspModel_s::origin.
Referenced by SV_GetInlineModelAABB().
float CM_GetVisibility | ( | const mapTiles_t * | mapTiles, |
const pos3_t | position | ||
) |
Checks how well a position is visible.
1.0
means fully visible, 0.0
means hardly visible because the given position is in the darkness Definition at line 991 of file bsp.cpp.
References Com_Printf(), i, MapTile::lightdata, mapTiles_s::mapTiles, mapTiles_s::numTiles, VectorInside, MapTile::wpMaxs, and MapTile::wpMins.
Referenced by SV_GetVisibility().
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.
Definition at line 589 of file bsp.cpp.
References MapTile::box_brush, MapTile::box_headnode, MapTile::box_leaf, MapTile::box_planes, cBspBrush_s::brushContentFlags, MapTile::brushes, MapTile::brushsides, cBspNode_s::children, Com_Error(), cBspLeaf_s::contentFlags, CONTENTS_WEAPONCLIP, MapTile::emptyleaf, ERR_DROP, cBspBrush_s::firstbrushside, cBspLeaf_s::firstleafbrush, i, MapTile::idx, MapTile::leafbrushes, LEAFNODE, MapTile::leafs, MAX_MAP_BRUSHES, MAX_MAP_BRUSHSIDES, MAX_MAP_LEAFBRUSHES, MAX_MAP_NODES, MAX_MAP_PLANES, MapTile::nodes, cBspPlane_s::normal, nullSurface, MapTile::numbrushes, MapTile::numbrushsides, cBspLeaf_s::numleafbrushes, MapTile::numleafbrushes, MapTile::numleafs, MapTile::numnodes, MapTile::numplanes, cBspBrush_s::numsides, cBspNode_s::plane, cBspBrushSide_s::plane, PLANE_ANYX, MapTile::planes, cBspBrushSide_s::surface, cBspPlane_s::type, and VectorClear.
Referenced by CM_AddMapTile().
cBspModel_t* CM_InlineModel | ( | const mapTiles_t * | mapTiles, |
const char * | name | ||
) |
Searches all inline models and return the cBspModel_t pointer for the given modelnumber or -name.
[in] | mapTiles | List of tiles the current (RMA-)map is composed of |
[in] | name | The modelnumber (e.g. "*2") for inline brush models [bmodels] |
Definition at line 929 of file bsp.cpp.
References Com_Error(), ERR_DROP, i, mapTiles_s::mapTiles, MAX_MODELS, NUM_REGULAR_MODELS, and mapTiles_s::numTiles.
Referenced by CL_GridRecalcRouting(), CL_ParseConfigString(), CL_ViewLoadMedia(), CM_EntCompleteBoxTrace(), CM_EntTestLine(), CM_EntTestLineDM(), CM_GetInlineModelAABB(), CM_SetInlineModelOrientation(), Grid_RecalcRouting(), LET_SlideDoor(), SV_Map(), and SV_SetModel().
void CM_LoadBsp | ( | MapTile & | tile, |
const dBspHeader_t & | header, | ||
const vec3_t | shift, | ||
const byte * | base | ||
) |
Definition at line 644 of file bsp.cpp.
References CMod_LoadBrushes(), CMod_LoadBrushSides(), CMod_LoadLeafBrushes(), CMod_LoadLeafs(), CMod_LoadNodes(), CMod_LoadPlanes(), CMod_LoadSubmodels(), CMod_LoadSurfaces(), LUMP_BRUSHES, LUMP_BRUSHSIDES, LUMP_LEAFBRUSHES, LUMP_LEAFS, LUMP_MODELS, LUMP_NODES, LUMP_PLANES, LUMP_TEXINFO, and dBspHeader_t::lumps.
Referenced by CM_AddMapTile().
void CM_LoadMap | ( | const char * | tiles, |
bool | day, | ||
const char * | pos, | ||
const char * | entityString, | ||
mapData_t * | mapData, | ||
mapTiles_t * | mapTiles | ||
) |
Loads in the map and all submodels.
R_ModBeginLoading
is used. [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. |
[in] | mapTiles | List of tiles the current (RMA-)map is composed of |
[in] | entityString | An entity string that is used for all map tiles. Might be nullptr . |
Definition at line 860 of file bsp.cpp.
References CM_AddMapTile(), CMod_RerouteMap(), com_cmodelSysPool, Com_DPrintf(), Com_Error(), Com_Parse(), Com_sprintf(), DEBUG_ENGINE, ERR_DROP, i, MAX_QPATH, MAX_VAR, Mem_FreePool, name, OBJZERO, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, and Q_strncpyz().
Referenced by CL_CanMultiplayerStart(), SV_Map(), and TEST_F().
Use the bsp node structure to reconstruct efficient tracing structures that are used for fast visibility and pathfinding checks.
Definition at line 345 of file bsp.cpp.
References com_cmodelSysPool, cBspModel_s::headnode, i, LEAFNODE, LEVEL_MAX, Mem_PoolAllocTypeN, MapTile::models, NUM_REGULAR_MODELS, MapTile::numcheads, MapTile::nummodels, MapTile::numnodes, MapTile::numtheads, MapTile::thead, MapTile::theadlevel, MapTile::tnodes, and TR_BuildTracingNode_r().
Referenced by CM_AddMapTile().
cBspModel_t* CM_SetInlineModelOrientation | ( | mapTiles_t * | mapTiles, |
const char * | name, | ||
const vec3_t | origin, | ||
const vec3_t | angles | ||
) |
This function updates a model's orientation.
[in] | mapTiles | List of tiles the current (RMA-)map is composed of |
[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 |
Definition at line 963 of file bsp.cpp.
References cBspModel_s::angles, CM_InlineModel(), cBspModel_s::origin, and VectorCopy.
Referenced by CL_AddBrushModel(), LET_RotateDoor(), SV_SetInlineModelOrientation(), and SV_SetModel().
[in] | source | Source will be set to the end of the compressed data block! |
[in] | dataStart | where to place the uncompressed data |
Definition at line 304 of file bsp.cpp.
References i.
Referenced by CMod_LoadRouting().
[in] | tile | Stores the data of the map tile |
[in] | base | The start of the data loaded from the file. |
[in] | lump | descriptor of the data block we are working on |
Definition at line 160 of file bsp.cpp.
References dBspBrush_t::brushContentFlags, MapTile::brushes, CMod_ValidateLump(), com_cmodelSysPool, count, lump_t::fileofs, cBspBrush_s::firstbrushside, dBspBrush_t::firstbrushside, i, LittleLong, MAX_MAP_BRUSHES, Mem_PoolAllocTypeN, MapTile::numbrushes, and dBspBrush_t::numsides.
Referenced by CM_LoadBsp().
[in] | tile | Stores the data of the map tile |
[in] | base | The start of the data loaded from the file. |
[in] | lump | descriptor of the data block we are working on |
Definition at line 276 of file bsp.cpp.
References MapTile::brushsides, CMod_ValidateLump(), com_cmodelSysPool, Com_Error(), count, ERR_DROP, lump_t::fileofs, i, LittleShort, MAX_MAP_BRUSHSIDES, Mem_PoolAllocTypeN, MapTile::numbrushsides, MapTile::numtexinfo, cBspBrushSide_s::plane, MapTile::planes, cBspBrushSide_s::surface, and MapTile::surfaces.
Referenced by CM_LoadBsp().
|
static |
[in] | mapData | The loaded data is stored here. |
[in] | tile | Stores the data of the map tile |
[in] | entityString | If not empty, this is added to mapEntityString |
[in] | base | The start of the data loaded from the file. |
[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. |
Definition at line 488 of file bsp.cpp.
References cBspModel_s::cbmBox, Com_Error(), Com_Parse(), ERR_DROP, lump_t::filelen, lump_t::fileofs, MapTile::idx, mapData_s::mapEntityString, MAX_MAP_ENTSTRING, AABB::maxs, AABB::mins, MapTile::models, NUM_REGULAR_MODELS, mapData_s::numInline, Q_strcat(), Q_streq, Q_strncpyz(), Q_strvalid, v, VectorAdd, and VectorSubtract.
Referenced by CM_AddMapTile().
[in] | tile | Stores the data of the map tile |
[in] | base | The start of the data loaded from the file. |
[in] | lump | descriptor of the data block we are working on |
Definition at line 254 of file bsp.cpp.
References CMod_ValidateLump(), com_cmodelSysPool, count, lump_t::fileofs, i, MapTile::leafbrushes, LittleShort, MAX_MAP_LEAFBRUSHES, Mem_PoolAllocTypeN, and MapTile::numleafbrushes.
Referenced by CM_LoadBsp().
[in] | tile | Stores the data of the map tile |
[in] | base | The start of the data loaded from the file. |
[in] | lump | descriptor of the data block we are working on |
Definition at line 185 of file bsp.cpp.
References CMod_ValidateLump(), com_cmodelSysPool, Com_Error(), cBspLeaf_s::contentFlags, CONTENTS_SOLID, count, MapTile::emptyleaf, ERR_DROP, lump_t::fileofs, cBspLeaf_s::firstleafbrush, i, MapTile::leafs, LittleLong, LittleShort, MAX_MAP_LEAFS, Mem_PoolAllocTypeN, cBspLeaf_s::numleafbrushes, and MapTile::numleafs.
Referenced by CM_LoadBsp().
Loads the lightmap for server side visibility lookup.
Definition at line 576 of file bsp.cpp.
References com_cmodelSysPool, lump_t::filelen, lump_t::fileofs, MapTile::lightdata, and Mem_PoolAllocTypeN.
Referenced by CM_AddMapTile().
|
static |
[in] | tile | Stores the data of the map tile |
[in] | base | The start of the data loaded from the file. |
[in] | lump | descriptor of the data block we are working on |
[in] | shift | The shifting vector in case this is a map assemble |
Definition at line 123 of file bsp.cpp.
References dBspNode_t::children, CMod_ValidateLump(), com_cmodelSysPool, count, lump_t::fileofs, i, LittleLong, LittleShort, MAX_MAP_NODES, dBspNode_t::maxs, Mem_PoolAllocTypeN, dBspNode_t::mins, MapTile::nodes, MapTile::numnodes, cBspNode_s::plane, dBspNode_t::planenum, PLANENUM_LEAF, and MapTile::planes.
Referenced by CM_LoadBsp().
|
static |
[in] | tile | Stores the data of the map tile |
[in] | base | The start of the data loaded from the file. |
[in] | lump | descriptor of the data block we are working on |
[in] | shift | The shifting vector in case this is a map assemble |
Definition at line 224 of file bsp.cpp.
References CMod_ValidateLump(), com_cmodelSysPool, count, cBspPlane_s::dist, lump_t::fileofs, i, LittleFloat, LittleLong, MAX_MAP_PLANES, Mem_PoolAllocTypeN, cBspPlane_s::normal, MapTile::numplanes, MapTile::planes, and cBspPlane_s::type.
Referenced by CM_LoadBsp().
|
static |
[in] | tile | Stores the data of the map tile |
[in] | base | The start of the data loaded from the file. |
[in] | mapData | The loaded data is stored here. |
[in] | name | The name of the maptile |
[in] | lump | 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 |
Definition at line 380 of file bsp.cpp.
References ACTOR_MAX_SIZE, CMod_DeCompressRouting(), Com_DPrintf(), Com_Error(), Routing::copyPosData(), DEBUG_ROUTING, ERR_DROP, lump_t::filelen, lump_t::fileofs, i, MapTile::idx, length, LittleLong, Mem_Alloc, Mem_Free, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, mapData_s::reroute, mapData_s::routing, ROUTING_NOT_REACHABLE, MapTile::wpMaxs, and MapTile::wpMins.
Referenced by CM_AddMapTile().
|
static |
Loads brush entities like func_door and func_breakable.
[in] | tile | Stores the data of the map tile |
[in] | base | The start of the data loaded from the file. |
[in] | lump | The lump to load the data from |
[in] | shift | The shifting vector in case this is a map assemble |
Definition at line 68 of file bsp.cpp.
References cBspModel_s::cbmBox, CMod_ValidateLump(), com_cmodelSysPool, count, AABB::expand(), lump_t::fileofs, cBspModel_s::headnode, i, MapTile::idx, LittleLong, MAX_MAP_MODELS, Mem_PoolAllocTypeN, MapTile::models, MapTile::nummodels, AABB::setFromLittleFloat(), cBspModel_s::shift, AABB::shift(), cBspModel_s::tile, and VectorCopy.
Referenced by CM_LoadBsp().
[in] | tile | Stores the data of the map tile |
[in] | base | The start of the data loaded from the file. |
[in] | lump | descriptor of the data block we are working on |
Definition at line 97 of file bsp.cpp.
References CMod_ValidateLump(), com_cmodelSysPool, count, lump_t::fileofs, i, LittleLong, MAX_MAP_TEXINFO, Mem_PoolAllocTypeN, cBspSurface_s::name, MapTile::numtexinfo, Q_strncpyz(), cBspSurface_s::surfaceFlags, and MapTile::surfaces.
Referenced by CM_LoadBsp().
|
static |
Recalculate the seams of the tiles after an RMA.
Definition at line 745 of file bsp.cpp.
References ACTOR_MAX_SIZE, ACTOR_SIZE_INVALID, GridBox::clipToMaxBoundaries(), Com_Printf(), CORE_DIRECTIONS, dvecs, GridBox::getMaxX(), GridBox::getMaxY(), GridBox::getMaxZ(), GridBox::getMinX(), GridBox::getMinY(), GridBox::getMinZ(), mapTiles_s::getTileOverlap(), mapTiles_s::getTilesAt(), mapData_s::mapBox, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, mapData_s::reroute, mapData_s::routing, ROUTING_NOT_REACHABLE, RT_CheckCell(), RT_UpdateConnectionColumn(), and Routing::setConn().
Referenced by CM_LoadMap().
|
static |
Definition at line 41 of file bsp.cpp.
References Com_DPrintf(), Com_Error(), count, DEBUG_ENGINE, ERR_DROP, lump_t::filelen, S_COLOR_GREEN, and UFO_SIZE_T.
Referenced by CMod_LoadBrushes(), CMod_LoadBrushSides(), CMod_LoadLeafBrushes(), CMod_LoadLeafs(), CMod_LoadNodes(), CMod_LoadPlanes(), CMod_LoadSubmodels(), and CMod_LoadSurfaces().
|
static |
Definition at line 33 of file bsp.cpp.
Referenced by CM_InitBoxHull().