UFO: Alien Invasion
|
#include <assert.h>
#include "map.h"
#include "bspbrush.h"
#include "common/shared.h"
#include "common/scriplib.h"
#include "common/polylib.h"
#include "common/bspfile.h"
#include "../../common/tracing.h"
Go to the source code of this file.
Data Structures | |
struct | node_s |
struct | tree_s |
Typedefs | |
typedef struct node_s | node_t |
typedef struct tree_s | tree_t |
Functions | |
byte | GetLevelFlagsFromBrush (const mapbrush_t *brush) |
Extract the level flags (1-8) from the content flags of the given brush. More... | |
void | LoadMapFile (const char *filename) |
void | WriteMapFile (const char *filename) |
uint16_t | FindOrCreateFloatPlane (vec3_t normal, vec_t dist) |
int | MapBrushesBounds (const int startbrush, const int endbrush, const int level, const AABB &clipBox, AABB &bBox) |
sets mins and maxs to the smallest sizes that can contain all brushes from startbrush to endbrush that are in a given level. More... | |
bspbrush_t * | MakeBspBrushList (int startbrush, int endbrush, int level, const AABB &clip) |
bspbrush_t * | ChopBrushes (bspbrush_t *head) |
Carves any intersecting solid brushes into the minimum number of non-intersecting brushes. More... | |
uint32_t | VisibleContents (uint32_t contents) |
Returns the single content bit of the strongest visible content present. More... | |
void | MarkVisibleSides (tree_t *tree, int start, int end) |
void | FreePortal (portal_t *p) |
void | MakeTreePortals (tree_t *tree) |
void | RemovePortalFromNode (portal_t *portal, node_t *l) |
Removes references to the given portal from the given node. More... | |
void | SetModelNumbers (void) |
Set the model numbers for SOLID_BSP or SOLID_TRIGGER entities like func_door or func_breakable. More... | |
void | BeginBSPFile (void) |
Starts a new bsp file. More... | |
int | WriteBSP (node_t *headnode) |
copies working data for a bsp tree into the structures used to create the bsp file. More... | |
void | EndBSPFile (const char *filename) |
Finishes a new bsp and writes to disk. More... | |
void | BeginModel (int entityNum) |
Sets up a new brush model. More... | |
void | EndModel (void) |
Finish a model's processing. More... | |
void | EmitBrushes (void) |
Writes the brush list to the bsp. More... | |
void | EmitPlanes (void) |
Emits planes to the bsp file. More... | |
void | MakeFaces (node_t *headnode) |
void | FixTjuncs (node_t *headnode) |
int | GetEdge (int v1, int v2, const face_t *f) |
void | FreeFace (face_t *f) |
node_t * | AllocNode (void) |
tree_t * | AllocTree (void) |
Allocates a tree and initializes it. More... | |
tree_t * | BuildTree (bspbrush_t *brushlist, const vec3_t mins, const vec3_t maxs) |
The incoming list will be freed before exiting. More... | |
void | FreeTree (tree_t *tree) |
void | PruneNodes (node_t *node) |
void | MakeTracingNodes (int levels) |
Use the bsp node structure to reconstruct efficient tracing structures that are used for fast visibility and pathfinding checks. More... | |
void | CloseTracingNodes (void) |
void | DoRouting (void) |
Calculates the routing of a map. More... | |
void | ProcessModels (const char *filename) |
Definition at line 34 of file tree.cpp.
References Mem_AllocType.
Referenced by BuildTree(), and BuildTree_r().
Allocates a tree and initializes it.
Definition at line 92 of file tree.cpp.
References tree_s::aabb, Mem_AllocType, and AABB::setNegativeVolume().
Referenced by BuildTree().
Starts a new bsp file.
Definition at line 303 of file writebsp.cpp.
References dBspLeaf_t::contentFlags, CONTENTS_SOLID, curTile, dMapTile_t::leafs, mapTiles, mapTiles_s::mapTiles, dMapTile_t::numbrushsides, dMapTile_t::numedges, dMapTile_t::numfaces, dMapTile_t::numleafbrushes, dMapTile_t::numleafs, dMapTile_t::nummodels, dMapTile_t::numnodes, dMapTile_t::numnormals, dMapTile_t::numsurfedges, mapTiles_s::numTiles, and dMapTile_t::numvertexes.
Referenced by ProcessModels().
Sets up a new brush model.
Definition at line 353 of file writebsp.cpp.
References AABB::add(), curTile, dBspModel_t::dbmBox, entities, entityNum, entity_t::firstbrush, dBspModel_t::firstface, firstmodeledge, mapbrushes, MAX_MAP_MODELS, mapbrush_s::mbBox, dMapTile_t::models, entity_t::numbrushes, dMapTile_t::numedges, dMapTile_t::numfaces, dMapTile_t::nummodels, mapbrush_s::numsides, AABB::set(), AABB::setNegativeVolume(), and Sys_Error().
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
tree_t* BuildTree | ( | bspbrush_t * | brushlist, |
const vec3_t | mins, | ||
const vec3_t | maxs | ||
) |
The incoming list will be freed before exiting.
Definition at line 182 of file tree.cpp.
References tree_s::aabb, AABB::add(), AllocNode(), AllocTree(), BrushFromBounds(), BrushlistCalcStats(), BuildTree_r(), c_nodes, c_nonvis, tree_s::headnode, AABB::setNegativeVolume(), VERB_EXTRA, Verb_Printf(), and node_s::volume.
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
bspbrush_t* ChopBrushes | ( | bspbrush_t * | head | ) |
Carves any intersecting solid brushes into the minimum number of non-intersecting brushes.
Definition at line 376 of file csg.cpp.
References AddBrushListToTail(), BrushesDisjoint(), BrushGE(), CountBrushList(), CullList(), FreeBrushList(), bspbrush_s::next, SubtractBrush(), VERB_EXTRA, and Verb_Printf().
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
Definition at line 65 of file trace.cpp.
References curTile, Mem_Free, and dMapTile_t::tnodes.
Referenced by LightWorld(), and MakeTracingNodes().
Calculates the routing of a map.
This is needed for tracing to work!!!
Definition at line 115 of file routing.cpp.
References ACTOR_MAX_SIZE, baseFilename, CELL_HEIGHT, CheckConnectionsThread(), CheckUnitThread(), CompressRouting(), config, CORE_DIRECTIONS, curTile, debugTrace, EmitBrushes(), EmitPlanes(), Routing::getFloor(), i, Routing::init(), LEVEL_ACTORCLIP, LittleLong, MakeTracingNodes(), mapTiles, MAX_MAP_ROUTING, AABB::maxs, AABB::mins, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, PopInfo(), PushInfo(), dMapTile_t::routedata, dMapTile_t::routedatasize, RT_GetMapSize(), RT_IS_BIDIRECTIONAL, RT_WriteCSVFiles(), RunSingleThreadOn(), UNIT_HEIGHT, VecToPos, VectorCopy, VectorSet, VERB_NORMAL, wpMaxs, and wpMins.
Referenced by ProcessWorldModel().
Writes the brush list to the bsp.
Definition at line 236 of file writebsp.cpp.
References cBspBrush_s::brushContentFlags, dBspBrush_t::brushContentFlags, dMapTile_t::brushes, dMapTile_t::brushsides, cBspBrush_s::checkcount, mapbrush_s::contentFlags, curTile, dMapTile_t::dbrushes, FindOrCreateFloatPlane(), cBspBrush_s::firstbrushside, dBspBrush_t::firstbrushside, i, mapbrushes, MAX_MAP_BRUSHSIDES, AABB::maxs, mapbrush_s::mbBox, AABB::mins, dMapTile_t::numbrushes, dMapTile_t::numbrushsides, nummapbrushes, cBspBrush_s::numsides, mapbrush_s::numsides, dBspBrush_t::numsides, OBJZERO, mapbrush_s::original_sides, side_s::planenum, dBspBrushSide_t::planenum, Sys_Error(), side_s::texinfo, dBspBrushSide_t::texinfo, vec3_origin, and VectorCopy.
Referenced by DoRouting(), and EndBSPFile().
Emits planes to the bsp file.
Definition at line 41 of file writebsp.cpp.
References curTile, plane_s::dist, dBspPlane_t::dist, i, mapplanes, plane_s::normal, dBspPlane_t::normal, nummapplanes, dMapTile_t::numplanes, dMapTile_t::planes, plane_s::type, dBspPlane_t::type, and VectorCopy.
Referenced by DoRouting(), and EndBSPFile().
void EndBSPFile | ( | const char * | filename | ) |
Finishes a new bsp and writes to disk.
Definition at line 336 of file writebsp.cpp.
References EmitBrushes(), EmitPlanes(), UnparseEntities(), VERB_LESS, Verb_Printf(), and WriteBSPFile().
Referenced by ProcessModels().
Finish a model's processing.
Definition at line 387 of file writebsp.cpp.
References curTile, dBspModel_t::firstface, dMapTile_t::models, dBspModel_t::numfaces, dMapTile_t::numfaces, and dMapTile_t::nummodels.
Referenced by ProcessSubModel().
Definition at line 194 of file map.cpp.
References CreateNewFloatPlane(), GetPlaneHashValueForDistance(), hash, plane_s::hash_chain, i, index, mapplanes, PLANE_HASHES, PlaneEqual(), and SnapPlane().
Referenced by AddBrushBevels(), AdjustBrushesForOrigin(), BrushFromBounds(), EmitBrushes(), MakeBspBrushList(), and PlaneFromPoints().
Definition at line 370 of file faces.cpp.
References c_badstartverts, c_degenerate, c_facecollapse, c_faceoverflows, c_tjunctions, c_totalverts, c_uniqueverts, config, EmitVertexes_r(), FixEdges_r(), hashverts, OBJZERO, VERB_EXTRA, and Verb_Printf().
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
Definition at line 133 of file faces.cpp.
References c_faces, FreeWinding(), Mem_Free, and face_s::w.
Referenced by FreeTree_r().
Definition at line 52 of file portals.cpp.
References c_active_portals, FreeWinding(), Mem_Free, threadstate, and portal_s::winding.
Referenced by FreeTreePortals_r().
Definition at line 102 of file tree.cpp.
References FreeTree_r(), FreeTreePortals_r(), tree_s::headnode, and Mem_Free.
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
Definition at line 399 of file faces.cpp.
References config, face_s::contentFlags, curTile, dMapTile_t::edges, f, firstmodeledge, i, MAX_MAP_EDGES, dMapTile_t::numedges, Sys_Error(), and dBspEdge_t::v.
Referenced by EmitFace().
byte GetLevelFlagsFromBrush | ( | const mapbrush_t * | brush | ) |
Extract the level flags (1-8) from the content flags of the given brush.
brush | The brush to extract the level flags from |
Definition at line 277 of file map.cpp.
References mapbrush_s::contentFlags.
void LoadMapFile | ( | const char * | filename | ) |
Definition at line 1197 of file map.cpp.
References AABB_STRING, AABB::add(), AABB::asIntString(), c_boxbevels, c_edgebevels, Com_Printf(), config, curTile, entities, footstepsCnt, GetUMPName(), i, LoadScriptFile(), mapTiles, mapTiles_s::mapTiles, materialsCnt, MAX_TOKEN_CHARS, MAX_WORLD_WIDTH, num_entities, entity_t::numbrushes, nummapbrushes, nummapbrushsides, nummapplanes, mapTiles_s::numTiles, OBJZERO, ParseMapEntity(), ParseUMP(), AABB::setNegativeVolume(), ValueForKey(), VERB_EXTRA, and Verb_Printf().
Referenced by main().
bspbrush_t* MakeBspBrushList | ( | int | startbrush, |
int | endbrush, | ||
int | level, | ||
const AABB & | clip | ||
) |
Definition at line 292 of file csg.cpp.
References AllocBrush(), bspbrush_s::brBox, ClipBrushToBox(), AABB::contains(), mapbrush_s::contentFlags, CopyWinding(), FindOrCreateFloatPlane(), mapbrush_s::finished, i, IsInLevel(), mapbrushes, maxplanenums, AABB::maxs, mapbrush_s::mbBox, minplanenums, AABB::mins, bspbrush_s::next, bspbrush_s::numsides, mapbrush_s::numsides, bspbrush_s::original, mapbrush_s::original_sides, AABB::set(), bspbrush_s::sides, SURF_HINT, side_s::surfaceFlags, VERB_DUMP, Verb_Printf(), side_s::visible, and side_s::winding.
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
Definition at line 764 of file faces.cpp.
References c_merge, c_nodefaces, c_subdivide, MakeFaces_r(), VERB_EXTRA, and Verb_Printf().
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
Use the bsp node structure to reconstruct efficient tracing structures that are used for fast visibility and pathfinding checks.
Definition at line 38 of file trace.cpp.
References CloseTracingNodes(), curTile, dBspModel_t::headnode, i, LEVEL_ACTORCLIP, LEVEL_LIGHTCLIP, LEVEL_MAX, Mem_AllocTypeN, dMapTile_t::models, dBspModel_t::numfaces, dMapTile_t::numnodes, dMapTile_t::numtheads, dMapTile_t::thead, dMapTile_t::theadlevel, dMapTile_t::tnodes, and TR_BuildTracingNode_r().
Referenced by DoRouting(), and LightWorld().
Definition at line 391 of file portals.cpp.
References tree_s::headnode, MakeHeadnodePortals(), and MakeTreePortals_r().
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
int MapBrushesBounds | ( | const int | startbrush, |
const int | endbrush, | ||
const int | level, | ||
const AABB & | clipBox, | ||
AABB & | bBox | ||
) |
sets mins and maxs to the smallest sizes that can contain all brushes from startbrush to endbrush that are in a given level.
[in] | startbrush | the index of the first brush to check. |
[in] | endbrush | the index after the last brush to check. |
[in] | level | the level that we are searching for brushes in. -1 for skipping the levelflag check. |
[in] | clipBox | the absolute lowest and highest boundaries to allow for brushes. |
[out] | bBox | the max boundaries for all accepted brushes within the clipped bounds. |
Definition at line 264 of file csg.cpp.
References AABB::add(), AABB::contains(), mapbrush_s::contentFlags, mapbrush_s::finished, i, IsInLevel(), mapbrushes, mapbrush_s::mbBox, and AABB::setNegativeVolume().
Referenced by ConstructLevelNodes_r().
Definition at line 482 of file portals.cpp.
References tree_s::headnode, i, mapbrushes, MarkVisibleSides_r(), mapbrush_s::numsides, mapbrush_s::original_sides, VERB_EXTRA, Verb_Printf(), and side_s::visible.
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
void ProcessModels | ( | const char * | filename | ) |
Definition at line 106 of file bsp.cpp.
References BeginBSPFile(), config, EndBSPFile(), entities, num_entities, dMapTile_t::nummodels, ProcessSubModel(), ProcessWorldModel(), VERB_EXTRA, Verb_Printf(), and config_s::verbose.
Referenced by main().
Definition at line 261 of file tree.cpp.
References c_pruned, PruneNodes_r(), VERB_EXTRA, and Verb_Printf().
Referenced by ConstructLevelNodes_r().
Removes references to the given portal from the given node.
[in,out] | portal | The portal to remove from the node |
[in,out] | l | The node to remove the portal from |
Definition at line 102 of file portals.cpp.
References portal_s::next, portal_s::nodes, node_s::portals, and Sys_Error().
Referenced by FreeTreePortals_r(), and SplitNodePortals().
Set the model numbers for SOLID_BSP or SOLID_TRIGGER entities like func_door or func_breakable.
Definition at line 217 of file writebsp.cpp.
References Com_sprintf(), entities, i, num_entities, and SetKeyValue().
Referenced by main().
uint32_t VisibleContents | ( | uint32_t | contents | ) |
Returns the single content bit of the strongest visible content present.
Definition at line 64 of file portals.cpp.
References i, and LAST_VISIBLE_CONTENTS.
Referenced by FaceFromPortal(), and FindPortalSide().
copies working data for a bsp tree into the structures used to create the bsp file.
[in] | headnode | the top-most node in this bsp tree |
Definition at line 195 of file writebsp.cpp.
References c_facenodes, c_nofaces, curTile, EmitDrawNode_r(), dMapTile_t::numfaces, oldfaces, VERB_EXTRA, and Verb_Printf().
Referenced by ConstructLevelNodes_r(), and ProcessSubModel().
void WriteMapFile | ( | const char * | filename | ) |
Definition at line 1055 of file map.cpp.
References Check_ExtraBrushesForWorldspawn(), entities, entity_t::epairs, f, FILE_WRITE, entity_t::firstbrush, FS_OpenFile(), FS_Printf(), i, Mem_Free, num_entities, entity_t::numbrushes, entity_t::skip, mapbrush_s::skipWriteBack, Sys_Error(), VERB_NORMAL, Verb_Printf(), WriteMapBrush(), and WriteMapEntities().
Referenced by main().
int brush_end |
Definition at line 29 of file levels.cpp.
Referenced by ConstructLevelNodes_r(), and ProcessWorldModel().
int brush_start |
Definition at line 29 of file levels.cpp.
Referenced by ConstructLevelNodes_r(), and ProcessWorldModel().
side_t brushsides[MAX_MAP_SIDES] |
Definition at line 37 of file map.cpp.
Referenced by AddBrushBevels(), AdjustBrushesForOrigin(), Check_SetNodraw(), Check_SurfProp(), Check_SurfProps(), CheckFlagsBasedOnTextures(), CheckMixedFaceContents(), CheckTexturesBasedOnFlags(), and WriteMapBrush().
dMapTile_t* curTile |
Definition at line 32 of file bsp.cpp.
Referenced by BeginBSPFile(), BeginModel(), BuildFaceExtents(), BuildFacelights(), BuildNodeChildren(), BuildPatch(), BuildPatches(), BuildVertexNormals(), CalcLightinfoExtents(), CalcLightinfoVectors(), CalcTextureReflectivity(), CalcTextureSize(), CloseTracingNodes(), DoRouting(), EmissiveLight(), EmitBrushes(), EmitDrawNode_r(), EmitFace(), EmitFaceVertexes(), EmitLeaf(), EmitPlanes(), EndModel(), ExportLightmap(), FaceFromPortal(), FacesWithVert(), FinalLightFace(), FixFaceEdges(), GetEdge(), GetVertexnum(), HasLight(), LightWorld(), LoadBSPFile(), LoadMapFile(), MakeTracingNodes(), ParseEntities(), PopInfo(), PrintBSPFileSizes(), ProcessLevel(), PushInfo(), SampleNormal(), SubdivideFace(), SwapBSPFile(), TestEdge(), TexinfoForBrushTexture(), TR_TestLineSingleTile(), UnparseEntities(), WindingFromFace(), WriteBSP(), and WriteBSPFile().
mapbrush_t mapbrushes[MAX_MAP_BRUSHES] |
Definition at line 34 of file map.cpp.
Referenced by BeginModel(), Check_BrushIntersection(), Check_ContainedBrushes(), Check_ExtraBrushesForWorldspawn(), Check_FindCompositeSides(), Check_Free(), Check_MapSize(), Check_NearList(), CheckBrushes(), CheckFillLevelFlags(), CheckFlagsBasedOnTextures(), CheckLevelFlags(), CheckMapMicro(), CheckMixedFaceContents(), CheckNodraws(), CheckTexturesBasedOnFlags(), CheckZFighting(), EmitBrushes(), EmitLeaf(), MakeBspBrushList(), MapBrushesBounds(), MarkVisibleSides(), and ProcessLevel().
plane_t mapplanes[MAX_MAP_PLANES] |
an index of the planes containing the faces of the brushes
Definition at line 43 of file map.cpp.
Referenced by BaseWindingForNode(), BrushVolume(), Check_IsPointInsideBrush(), Check_MapBrushVolume(), Check_SidePointsDown(), Check_WindingIntersects(), CreateBrushWindings(), DoesPlaneSplitBrush(), EmitPlanes(), FaceFromPortal(), FacingAndCoincidentTo(), FindOrCreateFloatPlane(), FindPortalSide(), MakeNodePortal(), MergeNodeFaces(), ParallelAndCoincidentTo(), SelectSplitSide(), SplitBrush(), SplitNodePortals(), and TestBrushToPlanenum().
mapTiles_t mapTiles |
int nummapbrushes |
Definition at line 35 of file map.cpp.
Referenced by Check_BrushIntersection(), Check_ContainedBrushes(), Check_FindCompositeSides(), Check_Free(), Check_MapSize(), Check_NearList(), Check_Stats(), CheckBrushes(), CheckFillLevelFlags(), CheckFlagsBasedOnTextures(), CheckLevelFlags(), CheckMapMicro(), CheckMixedFaceContents(), CheckNodraws(), CheckTexturesBasedOnFlags(), CheckZFighting(), EmitBrushes(), LoadMapFile(), MoveBrushesToWorld(), ParseBrush(), ParseMapEntity(), and ProcessLevel().
int nummapbrushsides |
Definition at line 38 of file map.cpp.
Referenced by AddBrushBevels(), Check_Stats(), LoadMapFile(), and ParseBrush().
int nummapplanes |
Definition at line 44 of file map.cpp.
Referenced by Check_Stats(), CreateNewFloatPlane(), EmitPlanes(), and LoadMapFile().
brush_texture_t side_brushtextures[MAX_MAP_SIDES] |
Definition at line 40 of file map.cpp.
Referenced by Check_SetNodraw(), Check_SurfProp(), Check_SurfProps(), CheckFlagsBasedOnTextures(), CheckMixedFaceContents(), and CheckTexturesBasedOnFlags().