UFO: Alien Invasion
|
#include "map.h"
#include "bsp.h"
#include "textures.h"
#include "check/check.h"
#include "check/checkentities.h"
#include "common/aselib.h"
#include "../../shared/parse.h"
Go to the source code of this file.
Macros | |
#define | PLANE_HASHES 1024 |
Functions | |
static int | GetPlaneHashValueForDistance (const vec_t distance) |
Planes are stored by their distance (resp. the calculated hash) in the plane hash table. More... | |
static int | PlaneTypeForNormal (const vec3_t normal) |
Set the type of the plane according to it's normal vector. More... | |
static bool | PlaneEqual (const plane_t *p, const vec3_t normal, const vec_t dist) |
Checks whether the given normal and distance vectors match the given plane by some epsilon value. More... | |
static void | AddPlaneToHash (plane_t *p) |
static uint16_t | CreateNewFloatPlane (vec3_t normal, vec_t dist) |
static bool | SnapVector (vec3_t normal) |
Round the vector to int values. More... | |
static void | SnapPlane (vec3_t normal, vec_t *dist) |
Snaps normal to axis-aligned if it is within an epsilon of axial. More... | |
uint16_t | FindOrCreateFloatPlane (vec3_t normal, vec_t dist) |
static int16_t | PlaneFromPoints (const mapbrush_t *b, const vec3_t p0, const vec3_t p1, const vec3_t p2) |
Builds a plane normal and distance from three points on the plane. If the normal is nearly axial, it will be snapped to be axial. Looks up the plane in the unique planes. More... | |
static int | BrushContents (mapbrush_t *b) |
Get the content flags for a given brush. More... | |
byte | GetLevelFlagsFromBrush (const mapbrush_t *brush) |
Extract the level flags (1-8) from the content flags of the given brush. More... | |
static void | AddBrushBevels (mapbrush_t *b) |
Adds any additional planes necessary to allow the brush to be expanded against axial bounding boxes. More... | |
static bool | MakeBrushWindings (mapbrush_t *brush) |
makes basewindings for sides and mins / maxs for the brush More... | |
static void | CheckFlags (side_t *side, const mapbrush_t *b) |
Checks whether the surface and content flags are correct. More... | |
static void | GenerateMaterialFile (const char *filename, int mipTexIndex, side_t *s) |
Generates material files in case the settings can be guessed from map file. More... | |
static void | GenerateFootstepList (const char *filename, int mipTexIndex) |
Generate a list of textures that should have footsteps when walking on them. More... | |
static void | ParseBrush (entity_t *mapent, const char *filename) |
Parses a brush from the map file. More... | |
static void | MoveBrushesToWorld (entity_t *mapent) |
Takes all of the brushes from the current entity and adds them to the world's brush list. More... | |
static void | AdjustBrushesForOrigin (const entity_t *ent) |
If there was an origin brush, offset all of the planes and texinfo. More... | |
static bool | IsInlineModelEntity (const char *entName) |
Checks whether this entity is an inline model that should have brushes. More... | |
entity_t * | FindTargetEntity (const char *target) |
Searches the entities array for an entity with the parameter targetname that matches the searched target parameter. More... | |
static bool | ParseMapEntity (const char *filename, const char *entityString) |
Parsed map entites and brushes. More... | |
static void | WriteMapEntities (qFILE *f, const epair_t *e) |
Recurse down the epair list. More... | |
static void | WriteMapBrush (const mapbrush_t *brush, const int j, qFILE *f) |
write a brush to the .map file More... | |
void | WriteMapFile (const char *filename) |
static void | ParseUMP (const char *name, char *entityString, bool inherit) |
Parses an ump file that contains the random map definition. More... | |
static const char * | GetUMPName (const char *mapFilename) |
The contract is that the directory name is equal to the base of the ump filename. More... | |
void | LoadMapFile (const char *filename) |
Variables | |
mapbrush_t | mapbrushes [MAX_MAP_BRUSHES] |
int | nummapbrushes |
side_t | brushsides [MAX_MAP_SIDES] |
int | nummapbrushsides |
brush_texture_t | side_brushtextures [MAX_MAP_SIDES] |
plane_t | mapplanes [MAX_MAP_PLANES] |
int | nummapplanes |
static plane_t * | planehash [PLANE_HASHES] |
static int | c_boxbevels = 0 |
static int | c_edgebevels = 0 |
static int | materialsCnt = 0 |
How many materials were created for this map. More... | |
static int | footstepsCnt = 0 |
Amount of footstep surfaces found in this map. More... | |
#define PLANE_HASHES 1024 |
Definition at line 46 of file map.cpp.
Referenced by FindOrCreateFloatPlane(), and GetPlaneHashValueForDistance().
|
static |
Adds any additional planes necessary to allow the brush to be expanded against axial bounding boxes.
Definition at line 289 of file map.cpp.
References side_s::bevel, brushsides, c_boxbevels, c_edgebevels, side_s::contentFlags, CrossProduct(), DotProduct, f, FindOrCreateFloatPlane(), i, index, MAX_MAP_BRUSHSIDES, AABB::maxs, mapbrush_s::mbBox, AABB::mins, plane_s::normal, light_s::normal, nummapbrushsides, winding_s::numpoints, mapbrush_s::numsides, mapbrush_s::original_sides, winding_s::p, PlaneEqual(), side_s::planenum, SnapVector(), Sys_Error(), side_s::texinfo, VectorClear, VectorNormalize(), VectorSubtract, and side_s::winding.
Referenced by ParseBrush().
Definition at line 112 of file map.cpp.
References plane_s::dist, GetPlaneHashValueForDistance(), hash, and plane_s::hash_chain.
Referenced by CreateNewFloatPlane().
If there was an origin brush, offset all of the planes and texinfo.
Definition at line 869 of file map.cpp.
References side_s::brush, brushsides, side_s::contentFlags, CONTENTS_TERRAIN, plane_s::dist, DotProduct, FindOrCreateFloatPlane(), entity_t::firstbrush, i, index, MakeBrushWindings(), plane_s::normal, entity_t::numbrushes, mapbrush_s::numsides, entity_t::origin, mapbrush_s::original_sides, side_s::planenum, SURF_ORIGIN, brush_texture_s::surfaceFlags, side_s::surfaceFlags, side_s::texinfo, and TexinfoForBrushTexture().
Referenced by ParseMapEntity().
|
static |
Get the content flags for a given brush.
b | The mapbrush to get the content flags for |
Definition at line 254 of file map.cpp.
References mapbrush_s::brushnum, side_s::contentFlags, mapbrush_s::entitynum, i, mapbrush_s::numsides, mapbrush_s::original_sides, VERB_EXTRA, and Verb_Printf().
Referenced by ParseBrush().
|
inlinestatic |
Checks whether the surface and content flags are correct.
Definition at line 484 of file map.cpp.
References mapbrush_s::brushnum, side_s::contentFlags, CONTENTS_ACTORCLIP, CONTENTS_LIGHTCLIP, CONTENTS_PASSABLE, CONTENTS_SOLID, CONTENTS_WEAPONCLIP, mapbrush_s::entitynum, and Sys_Error().
Referenced by ParseBrush().
Definition at line 119 of file map.cpp.
References AddPlaneToHash(), AXIAL, plane_s::dist, MAX_MAP_PLANES, plane_s::normal, nummapplanes, PlaneTypeForNormal(), Sys_Error(), type, plane_s::type, vec3_origin, VectorCopy, VectorLength(), and VectorSubtract.
Referenced by FindOrCreateFloatPlane().
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().
entity_t* FindTargetEntity | ( | const char * | target | ) |
Searches the entities array for an entity with the parameter targetname that matches the searched target parameter.
[in] | target | The targetname value that the entity should have that we are looking for |
Definition at line 911 of file map.cpp.
References entities, i, num_entities, Q_streq, and ValueForKey().
Referenced by BuildLights().
Generate a list of textures that should have footsteps when walking on them.
[in] | filename | Add this texture to the list of textures where we should have footstep sounds for |
[in] | mipTexIndex | The index in the textures array |
Definition at line 568 of file map.cpp.
References Com_Printf(), Com_StripExtension(), config, f, FILE_APPEND, textureref_t::footstepMarked, footstepsCnt, FS_OpenFile(), FS_Printf(), MAX_OSPATH, name, textureref, and va().
Referenced by ParseBrush().
Generates material files in case the settings can be guessed from map file.
Definition at line 498 of file map.cpp.
References Com_Printf(), Com_SkipPath(), Com_sprintf(), Com_StripExtension(), config, side_s::contentFlags, CONTENTS_TERRAIN, CONTENTS_WATER, f, FILE_APPEND, FS_OpenFile(), FS_Printf(), textureref_t::materialMarked, materialsCnt, MAX_OSPATH, name, and textureref.
Referenced by ParseBrush().
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.
Planes are stored by their distance (resp. the calculated hash) in the plane hash table.
Definition at line 62 of file map.cpp.
References hash, int(), and PLANE_HASHES.
Referenced by AddPlaneToHash(), and FindOrCreateFloatPlane().
|
static |
The contract is that the directory name is equal to the base of the ump filename.
Definition at line 1174 of file map.cpp.
References Com_Printf(), Com_SkipPath(), MAX_QPATH, name, and Q_strncpyz().
Referenced by LoadMapFile().
|
inlinestatic |
Checks whether this entity is an inline model that should have brushes.
[in] | entName |
Definition at line 895 of file map.cpp.
References Q_streq, and Q_strstart().
Referenced by ParseMapEntity().
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().
|
static |
makes basewindings for sides and mins / maxs for the brush
Definition at line 436 of file map.cpp.
References AABB::add(), BaseWindingForPlane(), side_s::bevel, mapbrush_s::brushnum, ChopWindingInPlace(), Com_Printf(), plane_s::dist, mapbrush_s::entitynum, i, MAX_WORLD_WIDTH, AABB::maxs, mapbrush_s::mbBox, AABB::mins, plane_s::normal, winding_s::numpoints, mapbrush_s::numsides, mapbrush_s::original_sides, winding_s::p, side_s::planenum, AABB::reset(), AABB::setNegativeVolume(), side_s::visible, and side_s::winding.
Referenced by AdjustBrushesForOrigin(), and ParseBrush().
Takes all of the brushes from the current entity and adds them to the world's brush list.
Definition at line 831 of file map.cpp.
References entities, entity_t::firstbrush, i, Mem_AllocTypeN, Mem_Free, num_entities, entity_t::numbrushes, nummapbrushes, and Sys_Error().
Referenced by ParseMapEntity().
Parses a brush from the map file.
[in] | mapent | The entity the brush to parse belongs to |
[in] | filename | The map filename, used to derive the name for the footsteps file |
Definition at line 603 of file map.cpp.
References AddBrushBevels(), side_s::brush, BrushContents(), mapbrush_s::brushnum, CheckFlags(), CheckPropagateParserContentFlags(), Com_Printf(), Com_sprintf(), config, side_s::contentFlags, mapbrush_s::contentFlags, CONTENTS_ACTORCLIP, CONTENTS_DETAIL, CONTENTS_LIGHTCLIP, CONTENTS_ORIGIN, CONTENTS_SOLID, CONTENTS_TERRAIN, CONTENTS_TRANSLUCENT, CONTENTS_WATER, CONTENTS_WEAPONCLIP, CONTENTS_WINDOW, entities, mapbrush_s::entitynum, FindMiptex(), entity_t::firstbrush, GenerateFootstepList(), GenerateMaterialFile(), AABB::getCenter(), GetToken(), i, LAST_VISIBLE_CONTENTS, m, MakeBrushWindings(), MAX_MAP_BRUSHES, MAX_MAP_BRUSHSIDES, MAX_TEXPATH, AABB::maxs, mapbrush_s::mbBox, AABB::mins, brush_texture_s::name, num_entities, entity_t::numbrushes, nummapbrushes, nummapbrushsides, mapbrush_s::numsides, OBJZERO, entity_t::origin, mapbrush_s::original_sides, parsedToken, PlaneFromPoints(), side_s::planenum, PLANENUM_LEAF, Q_strncpyz(), Q_strnull(), brush_texture_s::rotate, brush_texture_s::scale, SetImpliedFlags(), SetKeyValue(), brush_texture_s::shift, SURF_ALPHATEST, SURF_BLEND33, SURF_BLEND66, SURF_FOOTSTEP, SURF_HINT, SURF_SKIP, brush_texture_s::surfaceFlags, side_s::surfaceFlags, Sys_Error(), side_s::texinfo, TexinfoForBrushTexture(), TokenAvailable(), brush_texture_s::value, vec3_origin, VectorCopy, VERB_DUMP, VERB_EXTRA, and Verb_Printf().
Referenced by ParseMapEntity().
|
static |
Parsed map entites and brushes.
[in] | filename | The map filename |
[in] | entityString | The body of the entity we are parsing |
Definition at line 928 of file map.cpp.
References AddEpair(), AdjustBrushesForOrigin(), Com_Parse(), Com_Printf(), config, entities, EpairCheckForDuplicate(), entity_t::epairs, entity_t::firstbrush, GetToken(), GetVectorForKey(), IsInlineModelEntity(), key, MAX_MAP_ENTITIES, Mem_StrDup, MoveBrushesToWorld(), epair_s::next, num_entities, entity_t::numbrushes, nummapbrushes, OBJZERO, entity_t::origin, ParseBrush(), parsedToken, ParseEpair(), Q_streq, Q_strnull(), Sys_Error(), epair_s::ump, ValueForKey(), and VectorNotEmpty.
Referenced by LoadMapFile().
|
static |
Parses an ump file that contains the random map definition.
[in] | name | The basename of the ump file (without extension) |
[in] | inherit | When true , this is called to inherit tile definitions |
[out] | entityString | An entity string that is used for all map tiles. Parsed from the ump. from another ump file (no assemblies) |
Definition at line 1117 of file map.cpp.
References Com_GetBlock(), Com_Parse(), Com_Printf(), Com_sprintf(), FS_FreeFile(), FS_LoadFile(), length, MAX_QPATH, MAX_TOKEN_CHARS, Q_streq, and Q_strncpyz().
Referenced by LoadMapFile().
Checks whether the given normal and distance vectors match the given plane by some epsilon value.
p | The plane to compare the normal and distance with |
normal | |
dist |
Definition at line 102 of file map.cpp.
References plane_s::dist, MAP_DIST_EPSILON, plane_s::normal, and NORMAL_EPSILON.
Referenced by AddBrushBevels(), and FindOrCreateFloatPlane().
|
static |
Builds a plane normal and distance from three points on the plane. If the normal is nearly axial, it will be snapped to be axial. Looks up the plane in the unique planes.
[in] | b | The brush that the points belong to. |
[in] | p0 | Three points on the plane. (A vector with plane coordinates) |
[in] | p1 | Three points on the plane. (A vector with plane coordinates) |
[in] | p2 | Three points on the plane. (A vector with plane coordinates) |
Definition at line 227 of file map.cpp.
References mapbrush_s::brushnum, CrossProduct(), DotProduct, FindOrCreateFloatPlane(), light_s::normal, Sys_Error(), VectorNormalize(), VectorNotEmpty, and VectorSubtract.
Referenced by ParseBrush().
Set the type of the plane according to it's normal vector.
Definition at line 72 of file map.cpp.
References PLANE_ANYX, PLANE_ANYY, PLANE_ANYZ, PLANE_X, PLANE_Y, and PLANE_Z.
Referenced by CreateNewFloatPlane().
Snaps normal to axis-aligned if it is within an epsilon of axial.
[in,out] | normal | - Plane normal vector (assumed to be unit length) |
[in,out] | dist | - Plane constant - return as rounded to integer if it is within an epsilon of MAP_DIST_EPSILON |
Definition at line 186 of file map.cpp.
References MAP_DIST_EPSILON, Q_rint(), and SnapVector().
Referenced by FindOrCreateFloatPlane().
|
inlinestatic |
Round the vector to int values.
[in,out] | normal | the normal vector to snap |
Definition at line 163 of file map.cpp.
References i, NORMAL_EPSILON, and VectorClear.
Referenced by AddBrushBevels(), and SnapPlane().
|
static |
write a brush to the .map file
[in] | brush | The brush to write |
[in] | j | the index of the brush in the entity, to label the brush in the comment in the map file |
[in] | f | file to write to |
Definition at line 1032 of file map.cpp.
References brushsides, side_s::contentFlags, FS_Printf(), i, index, brush_texture_s::name, mapbrush_s::numsides, mapbrush_s::original_sides, side_s::planenum, plane_s::planeVector, brush_texture_s::rotate, brush_texture_s::scale, brush_texture_s::shift, brush_texture_s::surfaceFlags, and brush_texture_s::value.
Referenced by WriteMapFile().
Recurse down the epair list.
Definition at line 1013 of file map.cpp.
References FS_Printf(), epair_s::key, epair_s::next, epair_s::ump, and epair_s::value.
Referenced by WriteMapFile().
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().
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().
|
static |
Definition at line 49 of file map.cpp.
Referenced by AddBrushBevels(), and LoadMapFile().
|
static |
Definition at line 50 of file map.cpp.
Referenced by AddBrushBevels(), and LoadMapFile().
|
static |
Amount of footstep surfaces found in this map.
Definition at line 558 of file map.cpp.
Referenced by GenerateFootstepList(), and LoadMapFile().
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().
|
static |
How many materials were created for this map.
Definition at line 493 of file map.cpp.
Referenced by GenerateMaterialFile(), and LoadMapFile().
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().
|
static |
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().