World query functions. More...
#include "server.h"
Go to the source code of this file.
Data Structures | |
struct | areaParms_t |
struct | moveclip_t |
Client side moveclip. More... | |
Defines | |
#define | AREA_DEPTH 4 |
Functions | |
static worldSector_t * | SV_CreateWorldSector (int depth, const vec3_t mins, const vec3_t maxs) |
Builds a uniformly subdivided tree for the given world size. | |
void | SV_ClearWorld (void) |
Clear physics interaction links. | |
static sv_edict_t * | SV_GetServerDataForEdict (const edict_t *ent) |
void | SV_UnlinkEdict (edict_t *ent) |
call before removing an entity, and before trying to move one, so it doesn't clip against itself | |
void | SV_LinkEdict (edict_t *ent) |
Needs to be called any time an entity changes origin, mins, maxs, or solid. Automatically unlinks if needed. Sets ent->absmin and ent->absmax. | |
static qboolean | SV_BoundingBoxesIntersect (const vec3_t mins, const vec3_t maxs, const edict_t *ent) |
Checks whether the bounding box of the given edict will intersect with the given bbox. | |
static void | SV_AreaEdicts_r (worldSector_t *node, areaParms_t *ap) |
fills in a table of edict pointers with edicts that have bounding boxes that intersect the given area. It is possible for a non-axial bmodel to be returned that doesn't actually intersect the area on an exact test. | |
int | SV_AreaEdicts (const vec3_t mins, const vec3_t maxs, edict_t **list, int maxCount) |
int | SV_TouchEdicts (const vec3_t mins, const vec3_t maxs, edict_t **list, int maxCount, edict_t *skip) |
Fills a list with edicts that are in use and are touching the given bounding box. | |
static int | SV_HullForEntity (const edict_t *ent, int *tile, vec3_t rmaShift) |
Returns a headnode that can be used for testing or clipping an object of mins/maxs size. Offset is filled in to contain the adjustment that must be added to the testing object's origin to get a point to use with the returned hull. | |
static void | SV_ClipMoveToEntities (moveclip_t *clip) |
int | SV_PointContents (vec3_t p) |
Returns the content flags for a given point. | |
static void | SV_TraceBounds (const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, vec3_t boxmins, vec3_t boxmaxs) |
calculates the bounding box for the whole trace | |
trace_t | SV_Trace (const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, const edict_t *passedict, int contentmask) |
Moves the given mins/maxs volume through the world from start to end. | |
const char * | SV_GetFootstepSound (const char *texture) |
float | SV_GetBounceFraction (const char *texture) |
Different terrain types might have different bounce fraction. | |
static void | SV_ModLoadAliasMD2Model (sv_model_t *mod, const byte *buffer) |
Loads the mins/maxs for a md2 mesh model. | |
static void | SV_ModLoadAliasMD3Model (sv_model_t *mod, const byte *buffer) |
Loads the mins/maxs for a md3 mesh model. | |
static void | SV_ModLoadAliasDPMModel (sv_model_t *mod, const byte *buffer) |
Loads the mins/maxs for a dpm mesh model. | |
static void | SV_ModLoadObjModel (sv_model_t *mod, const byte *buffer, int bufferLength) |
Loads the mins/maxs for a obj mesh model. | |
qboolean | SV_LoadModelMinsMaxs (const char *model, int frame, vec3_t mins, vec3_t maxs) |
Load the mins, maxs for the model on the serverside for pathfinding and clipping. |
World query functions.
Definition in file sv_world.c.
#define AREA_DEPTH 4 |
Definition at line 31 of file sv_world.c.
Referenced by SV_CreateWorldSector().
[in] | mins | The mins of the bounding box |
[in] | maxs | The maxs of the bounding box |
[out] | list | The edict list that this trace is hitting |
[in] | maxCount | The size of the given list |
Definition at line 313 of file sv_world.c.
References areaParms_t::areaEdictList, areaParms_t::areaEdictListCount, areaParms_t::areaEdictListMaxCount, areaParms_t::areaMaxs, areaParms_t::areaMins, sv, SV_AreaEdicts_r(), and serverInstanceGame_t::worldSectors.
Referenced by SV_ClipMoveToEntities(), and SV_InitGameProgs().
static void SV_AreaEdicts_r | ( | worldSector_t * | node, | |
areaParms_t * | ap | |||
) | [static] |
fills in a table of edict pointers with edicts that have bounding boxes that intersect the given area. It is possible for a non-axial bmodel to be returned that doesn't actually intersect the area on an exact test.
[out] | node | |
[out] | ap |
Definition at line 269 of file sv_world.c.
References areaParms_t::areaEdictList, areaParms_t::areaEdictListCount, areaParms_t::areaEdictListMaxCount, areaParms_t::areaMaxs, areaParms_t::areaMins, worldSector_s::axis, check, worldSector_s::children, Com_Printf(), worldSector_s::dist, sv_edict_s::ent, worldSector_s::entities, edict_s::inuse, LEAFNODE, next, sv_edict_s::nextEntityInWorldSector, edict_s::solid, SOLID_NOT, and SV_BoundingBoxesIntersect().
Referenced by SV_AreaEdicts().
static qboolean SV_BoundingBoxesIntersect | ( | const vec3_t | mins, | |
const vec3_t | maxs, | |||
const edict_t * | ent | |||
) | [static] |
Checks whether the bounding box of the given edict will intersect with the given bbox.
mins | The mins of the bounding box | |
maxs | The maxs of the bounding box | |
ent | The edict to check the intersection for |
true
if intersect, false
otherwise Definition at line 246 of file sv_world.c.
References edict_s::absmax, edict_s::absmin, qfalse, and qtrue.
Referenced by SV_AreaEdicts_r(), and SV_TouchEdicts().
void SV_ClearWorld | ( | void | ) |
Clear physics interaction links.
Definition at line 87 of file sv_world.c.
References serverInstanceGame_t::mapData, mapData_s::mapMax, mapData_s::mapMin, sv, and SV_CreateWorldSector().
Referenced by SV_Map().
static void SV_ClipMoveToEntities | ( | moveclip_t * | clip | ) | [static] |
Definition at line 414 of file sv_world.c.
References trace_s::allsolid, edict_s::angles, moveclip_t::boxmaxs, moveclip_t::boxmins, CM_HintedTransformedBoxTrace(), Com_DPrintf(), moveclip_t::contentmask, DEBUG_SERVER, moveclip_t::end, trace_s::ent, trace_s::fraction, i, mapTiles_t::mapTiles, serverInstanceGame_t::mapTiles, MAX_EDICTS, MAX_MAP_NODES, edict_s::maxs, moveclip_t::maxs, edict_s::mins, moveclip_t::mins, edict_s::modelindex, edict_s::number, edict_s::origin, edict_s::owner, moveclip_t::passedict, qtrue, edict_s::solid, SOLID_BSP, SOLID_NOT, SOLID_TRIGGER, moveclip_t::start, trace_s::startsolid, sv, SV_AreaEdicts(), SV_HullForEntity(), moveclip_t::trace, and vec3_origin.
Referenced by SV_Trace().
static worldSector_t* SV_CreateWorldSector | ( | int | depth, | |
const vec3_t | mins, | |||
const vec3_t | maxs | |||
) | [static] |
Builds a uniformly subdivided tree for the given world size.
[in] | mins | |
[in] | maxs | |
[in] | depth |
Definition at line 41 of file sv_world.c.
References AREA_DEPTH, worldSector_s::axis, worldSector_s::children, Com_Error(), worldSector_s::dist, worldSector_s::entities, ERR_DROP, LEAFNODE, lengthof, serverInstanceGame_t::numWorldSectors, PLANE_X, PLANE_Y, sv, VectorCopy, VectorSubtract, and serverInstanceGame_t::worldSectors.
Referenced by SV_ClearWorld().
float SV_GetBounceFraction | ( | const char * | texture | ) |
Different terrain types might have different bounce fraction.
Definition at line 604 of file sv_world.c.
References terrainType_s::bounceFraction, and Com_GetTerrainType().
Referenced by SV_InitGameProgs().
const char* SV_GetFootstepSound | ( | const char * | texture | ) |
Definition at line 593 of file sv_world.c.
References Com_GetTerrainType(), and terrainType_s::footStepSound.
Referenced by SV_InitGameProgs().
static sv_edict_t* SV_GetServerDataForEdict | ( | const edict_t * | ent | ) | [inline, static] |
Definition at line 92 of file sv_world.c.
References Com_Error(), serverInstanceGame_t::edicts, ERR_DROP, lengthof, edict_s::number, and sv.
Referenced by SV_LinkEdict(), and SV_UnlinkEdict().
Returns a headnode that can be used for testing or clipping an object of mins/maxs size. Offset is filled in to contain the adjustment that must be added to the testing object's origin to get a point to use with the returned hull.
[in] | ent | The edict to get the bmodel from (at least in case of SOLID_BSP) |
[out] | tile | The maptile the bmodel belongs, too (at least in case of SOLID_BSP) |
[out] | rmaShift | the shift vector in case of an RMA (needed for doors) |
Definition at line 381 of file sv_world.c.
References CM_HeadnodeForBox(), Com_Error(), ERR_FATAL, cBspModel_s::headnode, mapTiles_t::mapTiles, serverInstanceGame_t::mapTiles, MAX_MAP_NODES, MAX_MODELS, edict_s::maxs, edict_s::mins, edict_s::modelindex, serverInstanceGame_t::models, cBspModel_s::shift, edict_s::solid, SOLID_BSP, SOLID_NOT, SOLID_TRIGGER, sv, cBspModel_s::tile, vec3_origin, and VectorCopy.
Referenced by SV_ClipMoveToEntities().
void SV_LinkEdict | ( | edict_t * | ent | ) |
Needs to be called any time an entity changes origin, mins, maxs, or solid. Automatically unlinks if needed. Sets ent->absmin and ent->absmax.
Definition at line 140 of file sv_world.c.
References edict_s::absmax, edict_s::absmin, edict_s::angles, worldSector_s::axis, edict_s::child, worldSector_s::children, worldSector_s::dist, game_export_t::edicts, sv_edict_s::ent, worldSector_s::entities, serverInstanceStatic_t::ge, edict_s::inuse, LEAFNODE, edict_s::linkcount, sv_edict_s::linked, m, edict_s::maxs, edict_s::mins, sv_edict_s::nextEntityInWorldSector, edict_s::origin, qtrue, edict_s::size, edict_s::solid, SOLID_BSP, SOLID_NOT, sv, SV_GetServerDataForEdict(), SV_LinkEdict(), SV_UnlinkEdict(), svs, UNIT_SIZE, VectorAdd, VectorCenterFromMinsMaxs(), VectorCopy, VectorCreateRotationMatrix(), VectorNotEmpty, VectorRotate(), VectorSubtract, sv_edict_s::worldSector, and serverInstanceGame_t::worldSectors.
Referenced by SV_InitGameProgs(), and SV_LinkEdict().
Load the mins, maxs for the model on the serverside for pathfinding and clipping.
[in] | model | The relative model path to load the mins, maxs for |
[in] | frame | The frame to load the mins and maxs vectors for |
[out] | mins | The mins vector of the model - this is absolute to the worldorigin (0,0,0) |
[out] | maxs | The maxs vector of the model - this is absolute to the worldorigin (0,0,0) |
Definition at line 708 of file sv_world.c.
References byte, ClearBounds(), Com_Error(), com_genericPool, DPMHEADER, ERR_DROP, sv_model_s::frame, FS_FreeFile(), FS_LoadFile(), i, IDALIASHEADER, IDMD3HEADER, LittleLong(), MAX_MOD_KNOWN, sv_model_s::maxs, Mem_PoolStrDup, sv_model_s::mins, sv_model_s::name, serverInstanceGame_t::numSVModels, Q_strcasecmp, qfalse, qtrue, sv, SV_ModLoadAliasDPMModel(), SV_ModLoadAliasMD2Model(), SV_ModLoadAliasMD3Model(), SV_ModLoadObjModel(), serverInstanceGame_t::svModels, vec3_origin, and VectorCopy.
Referenced by SV_InitGameProgs().
static void SV_ModLoadAliasDPMModel | ( | sv_model_t * | mod, | |
const byte * | buffer | |||
) | [static] |
Loads the mins/maxs for a dpm mesh model.
[in,out] | mod | The server side model struct to store the results in |
[in] | buffer | The mesh model buffer |
[in] | bufferLength | The mesh model buffer length |
Definition at line 670 of file sv_world.c.
References BigFloat(), BigLong(), byte, sv_model_s::frame, dpmframe_s::maxs, sv_model_s::maxs, dpmframe_s::mins, sv_model_s::mins, dpmheader_s::num_frames, and dpmheader_s::ofs_frames.
Referenced by SV_LoadModelMinsMaxs().
static void SV_ModLoadAliasMD2Model | ( | sv_model_t * | mod, | |
const byte * | buffer | |||
) | [static] |
Loads the mins/maxs for a md2 mesh model.
[in,out] | mod | The server side model struct to store the results in |
[in] | buffer | The mesh model buffer |
[in] | bufferLength | The mesh model buffer length |
Definition at line 616 of file sv_world.c.
References AddPointToBounds(), byte, sv_model_s::frame, dMD2Model_t::framesize, LittleFloat(), LittleLong(), sv_model_s::maxs, sv_model_s::mins, dMD2Model_t::num_frames, dMD2Model_t::ofs_frames, dAliasFrame_s::scale, scale, dAliasFrame_s::translate, and VectorMA().
Referenced by SV_LoadModelMinsMaxs().
static void SV_ModLoadAliasMD3Model | ( | sv_model_t * | mod, | |
const byte * | buffer | |||
) | [static] |
Loads the mins/maxs for a md3 mesh model.
[in,out] | mod | The server side model struct to store the results in |
[in] | buffer | The mesh model buffer |
[in] | bufferLength | The mesh model buffer length |
Definition at line 644 of file sv_world.c.
References AddPointToBounds(), byte, sv_model_s::frame, LittleFloat(), LittleLong(), sv_model_s::maxs, dmd3frame_t::maxs, sv_model_s::mins, dmd3frame_t::mins, dmd3_t::num_frames, and dmd3_t::ofs_frames.
Referenced by SV_LoadModelMinsMaxs().
static void SV_ModLoadObjModel | ( | sv_model_t * | mod, | |
const byte * | buffer, | |||
int | bufferLength | |||
) | [static] |
Loads the mins/maxs for a obj mesh model.
[in,out] | mod | The server side model struct to store the results in |
[in] | buffer | The mesh model buffer |
[in] | bufferLength | The mesh model buffer length |
Definition at line 696 of file sv_world.c.
Referenced by SV_LoadModelMinsMaxs().
int SV_PointContents | ( | vec3_t | p | ) |
Returns the content flags for a given point.
Definition at line 491 of file sv_world.c.
References CM_CompleteBoxTrace(), trace_s::contentFlags, trace_s::fraction, serverInstanceGame_t::mapTiles, MASK_ALL, sv, TRACING_ALL_VISIBLE_LEVELS, and vec3_origin.
Referenced by SV_InitGameProgs().
int SV_TouchEdicts | ( | const vec3_t | mins, | |
const vec3_t | maxs, | |||
edict_t ** | list, | |||
int | maxCount, | |||
edict_t * | skip | |||
) |
Fills a list with edicts that are in use and are touching the given bounding box.
[in] | mins | The mins of the bounding box |
[in] | maxs | The maxs of the bounding box |
[out] | list | The edict list that this trace is hitting |
[in] | maxCount | The size of the given list |
[in] | skip | An edict to skip (e.g. pointer to the calling edict) |
Definition at line 338 of file sv_world.c.
References EDICT_NUM, serverInstanceStatic_t::ge, i, game_export_t::num_edicts, edict_s::solid, SOLID_NOT, SV_BoundingBoxesIntersect(), and svs.
Referenced by SV_InitGameProgs().
trace_t SV_Trace | ( | const vec3_t | start, | |
const vec3_t | mins, | |||
const vec3_t | maxs, | |||
const vec3_t | end, | |||
const edict_t * | passedict, | |||
int | contentmask | |||
) |
Moves the given mins/maxs volume through the world from start to end.
[in] | start | The starting position in the world for this trace |
[in] | end | The position in the world where this trace should stop |
[in] | passedict | is explicitly excluded from clipping checks (normally NULL) if the entire move stays in a solid volume, trace.allsolid will be set, trace.startsolid will be set, and trace.fraction will be 0 if the starting point is in a solid, it will be allowed to move out to an open area |
[in] | contentmask | brushes the trace should stop at (see MASK_*) |
[in] | mins | The mins of the bounding box that is moved through the world |
[in] | maxs | The maxs of the bounding box that is moved through the world |
clip.trace.mapTile
to get the correct one Definition at line 546 of file sv_world.c.
References moveclip_t::boxmaxs, moveclip_t::boxmins, CM_CompleteBoxTrace(), Com_Printf(), moveclip_t::contentmask, game_export_t::edicts, moveclip_t::end, trace_s::ent, trace_s::fraction, serverInstanceStatic_t::ge, serverInstanceGame_t::mapTiles, moveclip_t::maxs, moveclip_t::mins, moveclip_t::passedict, moveclip_t::start, sv, SV_ClipMoveToEntities(), SV_TraceBounds(), svs, moveclip_t::trace, TRACING_ALL_VISIBLE_LEVELS, and vec3_origin.
Referenced by SV_InitGameProgs().
static void SV_TraceBounds | ( | const vec3_t | start, | |
const vec3_t | mins, | |||
const vec3_t | maxs, | |||
const vec3_t | end, | |||
vec3_t | boxmins, | |||
vec3_t | boxmaxs | |||
) | [static] |
calculates the bounding box for the whole trace
[in] | start | The starting point of the trace |
[in] | mins | extents of the box we are moving through the world |
[in] | maxs | guess what |
[in] | end | The point where the trace should end |
[out] | boxmins | The lower bounds of the trace |
[out] | boxmaxs | The upper bounds |
Definition at line 510 of file sv_world.c.
References i.
Referenced by SV_Trace().
void SV_UnlinkEdict | ( | edict_t * | ent | ) |
call before removing an entity, and before trying to move one, so it doesn't clip against itself
Definition at line 103 of file sv_world.c.
References edict_s::child, Com_Printf(), worldSector_s::entities, sv_edict_s::linked, sv_edict_s::nextEntityInWorldSector, qfalse, SV_GetServerDataForEdict(), SV_UnlinkEdict(), and sv_edict_s::worldSector.
Referenced by SV_InitGameProgs(), SV_LinkEdict(), and SV_UnlinkEdict().