UFO: Alien Invasion
Loading...
Searching...
No Matches
cmodel.h File Reference

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

#include "tracing.h"
#include "qfiles.h"
Include dependency graph for cmodel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define CM_TransformedBoxTrace(tile, line, box, headnode, brushmask, brushreject, origin, angles)

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.
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.
cBspModel_tCM_SetInlineModelOrientation (mapTiles_t *mapTiles, const char *name, const vec3_t origin, const vec3_t angles)
 This function updates a model's orientation.
void CM_GetInlineModelAABB (mapTiles_t *mapTiles, const char *name, AABB &aabb)
 This function calculates a model's aabb in world coordinates.
float CM_GetVisibility (const mapTiles_t *mapTiles, const pos3_t position)
 Checks how well a position is visible.
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.
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.
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.
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.
bool CM_EntTestLine (mapTiles_t *mapTiles, const Line &traceLine, const int levelmask, const char **entlist)
 Checks traces against the world and all inline models.
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.

Detailed Description

Common model code header (for bsp and others).

Definition in file cmodel.h.

Macro Definition Documentation

◆ CM_TransformedBoxTrace

#define CM_TransformedBoxTrace ( tile,
line,
box,
headnode,
brushmask,
brushreject,
origin,
angles )
Value:
CM_HintedTransformedBoxTrace(tile, line, box, headnode, brushmask, brushreject, origin, angles, vec3_origin, 1.0f);
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.
Definition cmodel.cpp:84
voidpf uLong int origin
Definition ioapi.h:45
const vec3_t vec3_origin
Definition mathlib.cpp:35

Definition at line 48 of file cmodel.h.

Referenced by R_Trace().

Function Documentation

◆ CM_CompleteBoxTrace()

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_t::fraction, MapTile::getTileBox(), trace_t::mapTile, mapTiles, AABB::set(), Line::stop, tr, TR_TileBoxTrace(), and VectorCopy.

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

◆ CM_EntCompleteBoxTrace()

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_t::angles, CM_CalculateWidestBoundingBox(), CM_CompleteBoxTrace(), CM_HintedTransformedBoxTrace(), CM_InlineModel(), Com_Error(), AABB::doesIntersect(), ERR_DROP, trace_t::fraction, AABB::getMaxZ(), AABB::getMinZ(), cBspModel_t::headnode, i, mapTiles, name, cBspModel_t::origin, PATHFINDING_HEIGHT, AABB::set(), cBspModel_t::shift, cBspModel_t::tile, TL_FLAG_ACTORCLIP, tr, and UNIT_HEIGHT.

◆ CM_EntTestLine()

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_t::angles, CM_HintedTransformedBoxTrace(), CM_InlineModel(), CM_LineMissesModel(), Com_Error(), ERR_DROP, trace_t::fraction, cBspModel_t::headnode, mapTiles, MASK_VISIBILILITY, name, cBspModel_t::origin, cBspModel_t::shift, Line::start, trace_t::startsolid, Line::stop, cBspModel_t::tile, and TR_TestLine().

Referenced by SV_TestLineWithEnt().

◆ CM_EntTestLineDM()

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_t::angles, CM_HintedTransformedBoxTrace(), CM_InlineModel(), CM_LineMissesModel(), Com_Error(), trace_t::endpos, ERR_DROP, trace_t::fraction, cBspModel_t::headnode, mapTiles, MASK_ALL, name, cBspModel_t::origin, Line::start, trace_t::startsolid, Line::stop, cBspModel_t::tile, TR_TestLineDM(), vec3_origin, and VectorCopy.

Referenced by CL_ActorMouseTrace(), and CL_GetWorldCoordsUnderMouse().

◆ CM_GetInlineModelAABB()

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_t::angles, CalculateMinsMaxs(), cBspModel_t::cbmBox, CM_InlineModel(), mapTiles, name, and cBspModel_t::origin.

Referenced by SV_GetInlineModelAABB().

◆ CM_GetVisibility()

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, VectorInside, MapTile::wpMaxs, and MapTile::wpMins.

Referenced by SV_GetVisibility().

◆ CM_HeadnodeForBox()

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_t::dist, MAX_MAP_NODES, AABB::maxs, and AABB::mins.

Referenced by CL_HullForEntity(), and SV_HullForEntity().

◆ CM_HintedTransformedBoxTrace()

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_t::endpos, trace_t::fraction, MapTile::idx, boxtrace_t::init(), trace_t::mapTile, trace_t::plane, boxtrace_t::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().

◆ CM_InlineModel()

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, MAX_MODELS, name, and NUM_REGULAR_MODELS.

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

◆ CM_LoadBsp()

◆ CM_LoadMap()

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, mapData, mapTiles, MAX_QPATH, MAX_VAR, Mem_FreePool, name, OBJZERO, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, and Q_strncpyz().

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

◆ CM_SetInlineModelOrientation()

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_t::angles, CM_InlineModel(), mapTiles, name, cBspModel_t::origin, and VectorCopy.

Referenced by CL_AddBrushModel(), LET_RotateDoor(), SV_SetInlineModelOrientation(), and SV_SetModel().