UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
cmodel.h File Reference

Common model code header (for bsp and others) More...

#include "tracing.h"
#include "qfiles.h"

Go to the source code of this file.

Macros

#define CM_TransformedBoxTrace(tile, line, box, headnode, brushmask, brushreject, origin, angles)   CM_HintedTransformedBoxTrace(tile, line, box, headnode, brushmask, brushreject, origin, angles, vec3_origin, 1.0f);
 

Functions

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_tCM_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_tCM_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...
 
void CM_LoadBsp (MapTile &tile, const dBspHeader_t &header, const vec3_t shift, const byte *base)
 
int32_t CM_HeadnodeForBox (MapTile &tile, const AABB &box)
 To keep everything totally uniform, bounding boxes are turned into small BSP trees instead of being compared directly. More...
 
trace_t CM_HintedTransformedBoxTrace (MapTile &tile, const Line &traceLine, const AABB &traceBox, const int headnode, const int brushmask, const int brushrejects, const vec3_t origin, const vec3_t angles, const vec3_t rmaShift, const float fraction)
 Handles offseting and rotation of the end points for moving and rotating entities. More...
 
trace_t CM_EntCompleteBoxTrace (mapTiles_t *mapTiles, const Line &traceLine, const AABB *traceBox, int levelmask, int brushmask, int brushreject, const char **list)
 Performs box traces against the world and all inline models, gives the hit position back. More...
 
bool CM_EntTestLineDM (mapTiles_t *mapTiles, const Line &trLine, vec3_t hit, const int levelmask, const char **entlist)
 Checks traces against the world and all inline models, gives the hit position back. More...
 
bool CM_EntTestLine (mapTiles_t *mapTiles, const Line &traceLine, const int levelmask, const char **entlist)
 Checks traces against the world and all inline models. More...
 
trace_t CM_CompleteBoxTrace (mapTiles_t *mapTiles, const Line &trLine, const AABB &box, int levelmask, int brushmask, int brushreject)
 Traces all submodels in all tiles. Used by ufo and ufo_ded. More...
 

Detailed Description

Common model code header (for bsp and others)

Definition in file cmodel.h.

Macro Definition Documentation

#define CM_TransformedBoxTrace (   tile,
  line,
  box,
  headnode,
  brushmask,
  brushreject,
  origin,
  angles 
)    CM_HintedTransformedBoxTrace(tile, line, box, headnode, brushmask, brushreject, origin, angles, vec3_origin, 1.0f);

Definition at line 48 of file cmodel.h.

Referenced by R_Trace().

Function Documentation

trace_t CM_CompleteBoxTrace ( mapTiles_t mapTiles,
const Line trLine,
const AABB box,
int  levelmask,
int  brushmask,
int  brushreject 
)

Traces all submodels in all tiles. Used by ufo and ufo_ded.

Parameters
[in]mapTilesList of tiles the current (RMA-)map is composed of
[in]trLineThe line to trace
[in]boxThe box we move through the world
[in]levelmaskSelects which submodels get scanned.
[in]brushmaskbrushes the trace should stop at (see MASK_*)
[in]brushrejectbrushes the trace should ignore (see MASK_*)

Definition at line 283 of file cmodel.cpp.

References AABB::doesIntersect(), trace_s::endpos, trace_s::fraction, MapTile::getTileBox(), trace_s::mapTile, mapTiles_s::mapTiles, mapTiles_s::numTiles, AABB::set(), Line::stop, tr, TR_TileBoxTrace(), and VectorCopy.

Referenced by CL_Trace(), CM_EntCompleteBoxTrace(), R_Trace(), SV_PointContents(), and SV_Trace().

trace_t CM_EntCompleteBoxTrace ( mapTiles_t mapTiles,
const Line traceLine,
const AABB traceBox,
int  levelmask,
int  brushmask,
int  brushreject,
const char **  list 
)

Performs box traces against the world and all inline models, gives the hit position back.

Parameters
[in]mapTilesList of tiles the current (RMA-)map is composed of
[in]traceLineThe start/stop position of the trace.
[in]traceBoxThe minimum/maximum extents of the collision box that is projected.
[in]levelmaskA mask of the game levels to trace against. Mask 0x100 filters clips.
[in]brushmaskAny brush detected must at least have one of these contents.
[in]brushrejectAny brush detected with any of these contents will be ignored.
[in]listThe local models list (a local model has a name starting with * followed by the model number)
Returns
a trace_t with the information of the closest brush intersected.
See also
CM_CompleteBoxTrace
CM_HintedTransformedBoxTrace

Definition at line 327 of file cmodel.cpp.

References cBspModel_s::angles, CM_CalculateWidestBoundingBox(), CM_CompleteBoxTrace(), CM_HintedTransformedBoxTrace(), CM_InlineModel(), Com_Error(), AABB::doesIntersect(), ERR_DROP, trace_s::fraction, AABB::getMaxZ(), AABB::getMinZ(), cBspModel_s::headnode, i, mapTiles_s::mapTiles, name, cBspModel_s::origin, PATHFINDING_HEIGHT, AABB::set(), cBspModel_s::shift, cBspModel_s::tile, TL_FLAG_ACTORCLIP, tr, and UNIT_HEIGHT.

bool CM_EntTestLine ( mapTiles_t mapTiles,
const Line traceLine,
const int  levelmask,
const char **  entlist 
)

Checks traces against the world and all inline models.

Parameters
[in]mapTilesList of tiles the current (RMA-)map is composed of
[in]traceLineThe start/stop positions of the trace.
[in]levelmask
[in]entlistThe local models list
See also
TR_TestLine
CM_InlineModel
CM_TransformedBoxTrace
Returns
true - hit something
false - hit nothing

Definition at line 184 of file cmodel.cpp.

References cBspModel_s::angles, CM_HintedTransformedBoxTrace(), CM_InlineModel(), CM_LineMissesModel(), Com_Error(), ERR_DROP, trace_s::fraction, cBspModel_s::headnode, mapTiles_s::mapTiles, MASK_VISIBILILITY, name, cBspModel_s::origin, cBspModel_s::shift, Line::start, trace_s::startsolid, Line::stop, cBspModel_s::tile, and TR_TestLine().

Referenced by SV_TestLineWithEnt().

bool CM_EntTestLineDM ( mapTiles_t mapTiles,
const Line trLine,
vec3_t  hit,
const int  levelmask,
const char **  entlist 
)

Checks traces against the world and all inline models, gives the hit position back.

Parameters
[in]mapTilesList of tiles the current (RMA-)map is composed of
[in]trLineThe start/stop positions of the trace.
[out]hitThe position where the line hits a object or the stop position if nothing is in the line
[in]levelmask
[in]entlistThe local models list
See also
TR_TestLineDM
CM_TransformedBoxTrace

Definition at line 230 of file cmodel.cpp.

References cBspModel_s::angles, CM_HintedTransformedBoxTrace(), CM_InlineModel(), CM_LineMissesModel(), Com_Error(), trace_s::endpos, ERR_DROP, trace_s::fraction, cBspModel_s::headnode, mapTiles_s::mapTiles, MASK_ALL, name, cBspModel_s::origin, Line::start, trace_s::startsolid, Line::stop, cBspModel_s::tile, TR_TestLineDM(), vec3_origin, and VectorCopy.

Referenced by CL_ActorMouseTrace(), and CL_GetWorldCoordsUnderMouse().

void CM_GetInlineModelAABB ( mapTiles_t mapTiles,
const char *  name,
AABB aabb 
)

This function calculates a model's aabb in world coordinates.

Parameters
[in]mapTilesList of tiles the current (RMA-)map is composed of
[in]nameThe name of the model, must include the '*'
[out]aabbThe 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.

Returns
a visibility factor. 1.0 means fully visible, 0.0 means hardly visible because the given position is in the darkness
Todo:
implement me

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().

int32_t CM_HeadnodeForBox ( MapTile tile,
const AABB box 
)

To keep everything totally uniform, bounding boxes are turned into small BSP trees instead of being compared directly.

creates a clipping hull for an arbitrary box

Definition at line 151 of file cmodel.cpp.

References MapTile::box_headnode, MapTile::box_planes, cBspPlane_s::dist, MAX_MAP_NODES, AABB::maxs, and AABB::mins.

Referenced by CL_HullForEntity(), and SV_HullForEntity().

trace_t CM_HintedTransformedBoxTrace ( MapTile tile,
const Line traceLine,
const AABB traceBox,
const int  headnode,
const int  contentmask,
const int  brushrejects,
const vec3_t  origin,
const vec3_t  angles,
const vec3_t  rmaShift,
const float  fraction 
)

Handles offseting and rotation of the end points for moving and rotating entities.

Parameters
[in]tileTile to check (normally 0 - except in assembled maps)
[in]traceLineThe start and stop vectors of the trace
[in]traceBoxThe box we shove through the world
[in]headnodeif < 0 we are in a leaf node
[in]contentmaskcontent flags the trace should stop at (see MASK_*)
[in]brushrejectsbrushes the trace should ignore (see MASK_*)
[in]origincenter for rotating objects
[in]anglescurrent rotation status (in degrees) for rotating objects
[in]rmaShifthow much the object was shifted by the RMA process (needed for doors)
[in]fractionThe furthest distance needed to trace before we stop.
See also
CM_BoxTrace
Todo:
figure out how to do this with existing angles

Definition at line 84 of file cmodel.cpp.

References AngleVectors(), MapTile::box_headnode, DotProduct, trace_s::endpos, trace_s::fraction, MapTile::idx, boxtrace_s::init(), trace_s::mapTile, trace_s::plane, boxtrace_s::setLineAndBox(), Line::start, Line::stop, TR_BoxTrace(), VectorAdd, VectorCopy, VectorInterpolation, VectorNegate, VectorNotEmpty, and VectorSubtract.

Referenced by CL_ClipMoveToLEs(), CM_EntCompleteBoxTrace(), CM_EntTestLine(), CM_EntTestLineDM(), and SV_ClipMoveToEntities().

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.

Parameters
[in]mapTilesList of tiles the current (RMA-)map is composed of
[in]nameThe 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 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_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.

Note
This function loads the collision data from the bsp file. For rendering R_ModBeginLoading is used.
Parameters
[in]tilesMap name(s) relative to base/maps or random map assembly string
[in]dayUse the day (true) or the night (false) version of the map
[in]posIn 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]mapDataThe loaded data is stored here.
[in]mapTilesList of tiles the current (RMA-)map is composed of
[in]entityStringAn entity string that is used for all map tiles. Might be nullptr.
See also
CM_AddMapTile
R_ModBeginLoading

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().

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.

Parameters
[in]mapTilesList of tiles the current (RMA-)map is composed of
[in]nameThe name of the model, must include the '*'
[in]originThe new origin for the model
[in]anglesThe 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 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().