Grid oriented movement and scanning. More...
#include "common.h"
#include "grid.h"
#include "tracing.h"
#include "routing.h"
#include "../shared/parse.h"
Go to the source code of this file.
Functions | |
CASSERT (lengthof(TUsUsed)==PATHFINDING_DIRECTIONS) | |
static qboolean | Grid_CheckForbidden (const pos3_t exclude, const actorSizeEnum_t actorSize, pathing_t *path, int x, int y, int z) |
Checks one field (square) on the grid of the given routing data (i.e. the map). | |
static void | Grid_SetMoveData (pathing_t *path, const int x, const int y, const int z, const int c, const byte length, const int dir, const int ox, const int oy, const int oz, const int oc, priorityQueue_t *pqueue) |
static void | Grid_MoveMark (const routing_t *map, const pos3_t exclude, const actorSizeEnum_t actorSize, pathing_t *path, const pos3_t pos, byte crouchingState, const int dir, priorityQueue_t *pqueue) |
void | Grid_MoveCalc (const routing_t *map, const actorSizeEnum_t actorSize, pathing_t *path, const pos3_t from, byte crouchingState, int distance, byte **fb_list, int fb_length) |
Recalculate the pathing table for the given actor(-position). | |
void | Grid_MoveStore (pathing_t *path) |
Caches the calculated move. | |
pos_t | Grid_MoveLength (const pathing_t *path, const pos3_t to, byte crouchingState, qboolean stored) |
Return the needed TUs to walk to a given position. | |
int | Grid_MoveNext (const pathing_t *path, const pos3_t toPos, byte crouchingState) |
Get the direction to use to move to a position (used to reconstruct the path). | |
unsigned int | Grid_Ceiling (const routing_t *map, const actorSizeEnum_t actorSize, const pos3_t pos) |
Returns the height of the floor in a cell. | |
int | Grid_Height (const routing_t *map, const actorSizeEnum_t actorSize, const pos3_t pos) |
Returns the height of the floor in a cell. | |
int | Grid_Floor (const routing_t *map, const actorSizeEnum_t actorSize, const pos3_t pos) |
Returns the height of the floor in a cell. | |
pos_t | Grid_StepUp (const routing_t *map, const actorSizeEnum_t actorSize, const pos3_t pos, const int dir) |
Returns the maximum height of an obstruction that an actor can travel over. | |
int | Grid_GetTUsForDirection (int dir) |
Returns the amounts of TUs that are needed to perform one step into the given direction. | |
int | Grid_Filled (const routing_t *map, const actorSizeEnum_t actorSize, const pos3_t pos) |
Returns non-zero if the cell is filled (solid) and cannot be entered. | |
pos_t | Grid_Fall (const routing_t *map, const actorSizeEnum_t actorSize, const pos3_t pos) |
Calculated the new height level when something falls down from a certain position. | |
void | Grid_PosToVec (const routing_t *map, const actorSizeEnum_t actorSize, const pos3_t pos, vec3_t vec) |
Converts a grid position to world coordinates. | |
void | Grid_RecalcBoxRouting (mapTiles_t *mapTiles, routing_t *map, const pos3_t min, const pos3_t max, const char **list) |
This function recalculates the routing in the box bounded by min and max. | |
void | Grid_RecalcRouting (mapTiles_t *mapTiles, routing_t *map, const char *name, const char **list) |
This function recalculates the routing surrounding the entity name. | |
Variables | |
static const int | TUsUsed [] |
Grid oriented movement and scanning.
Definition in file grid.c.
CASSERT | ( | lengthof(TUsUsed) | = =PATHFINDING_DIRECTIONS |
) |
unsigned int Grid_Ceiling | ( | const routing_t * | map, | |
const actorSizeEnum_t | actorSize, | |||
const pos3_t | pos | |||
) |
Returns the height of the floor in a cell.
[in] | map | Pointer to client or server side routing table (clMap, svMap) |
[in] | actorSize | width of the actor in cells |
[in] | pos | Position in the map to check the height |
Definition at line 641 of file grid.c.
References Com_Printf(), PATHFINDING_HEIGHT, QuantToModel, and RT_CEILING.
Referenced by HUD_MapDebugCursor().
static qboolean Grid_CheckForbidden | ( | const pos3_t | exclude, | |
const actorSizeEnum_t | actorSize, | |||
pathing_t * | path, | |||
int | x, | |||
int | y, | |||
int | z | |||
) | [static] |
Checks one field (square) on the grid of the given routing data (i.e. the map).
[in] | map | Routing data/map. |
[in] | actorSize | width of the actor in cells |
[in] | path | Pointer to client or server side pathing table (clPathMap, svPathMap) |
[in] | x | Field in x direction |
[in] | y | Field in y direction |
[in] | z | Field in z direction |
[in] | exclude | Exclude this position from the forbidden list check |
< Holding variables for the forbidden x and y
Definition at line 92 of file grid.c.
References byte, Com_DPrintf(), DEBUG_PATHING, pathing_s::fblist, i, qfalse, qtrue, and VectorCompare.
Referenced by Grid_MoveMark().
pos_t Grid_Fall | ( | const routing_t * | map, | |
const actorSizeEnum_t | actorSize, | |||
const pos3_t | pos | |||
) |
Calculated the new height level when something falls down from a certain position.
[in] | map | Pointer to client or server side routing table (clMap, svMap) |
[in] | pos | Position in the map to start the fall (starting height is the z-value in this position) |
[in] | actorSize | Give the field size of the actor (e.g. for 2x2 units) to check linked fields as well. |
Definition at line 742 of file grid.c.
References CELL_HEIGHT, Com_DPrintf(), DEBUG_PATHING, PATHFINDING_HEIGHT, qfalse, and RT_FLOOR.
Referenced by CL_ActorMouseTrace(), and SV_InitGameProgs().
int Grid_Filled | ( | const routing_t * | map, | |
const actorSizeEnum_t | actorSize, | |||
const pos3_t | pos | |||
) |
Returns non-zero if the cell is filled (solid) and cannot be entered.
[in] | map | Pointer to client or server side routing table (clMap, svMap) |
[in] | actorSize | width of the actor in cells |
[in] | pos | Position in the map to check for filling |
Definition at line 726 of file grid.c.
References PATHFINDING_HEIGHT, and RT_FILLED.
int Grid_Floor | ( | const routing_t * | map, | |
const actorSizeEnum_t | actorSize, | |||
const pos3_t | pos | |||
) |
Returns the height of the floor in a cell.
[in] | map | Pointer to client or server side routing table (clMap, svMap) |
[in] | actorSize | width of the actor in cells |
[in] | pos | Position in the map to check the height |
Definition at line 678 of file grid.c.
References Com_Printf(), PATHFINDING_HEIGHT, QuantToModel, and RT_FLOOR.
Referenced by CL_AddPathingBox(), Grid_PosToVec(), HUD_MapDebugCursor(), and SV_InitGameProgs().
int Grid_GetTUsForDirection | ( | int | dir | ) |
Returns the amounts of TUs that are needed to perform one step into the given direction.
[in] | dir | the direction in which we are moving |
Definition at line 712 of file grid.c.
References PATHFINDING_DIRECTIONS, and TUsUsed.
Referenced by Grid_MoveMark(), and SV_InitGameProgs().
int Grid_Height | ( | const routing_t * | map, | |
const actorSizeEnum_t | actorSize, | |||
const pos3_t | pos | |||
) |
Returns the height of the floor in a cell.
[in] | map | Pointer to client or server side routing table (clMap, svMap) |
[in] | actorSize | width of the actor in cells |
[in] | pos | Position in the map to check the height |
Definition at line 659 of file grid.c.
References Com_Printf(), PATHFINDING_HEIGHT, QuantToModel, RT_CEILING, and RT_FLOOR.
Referenced by Grid_MoveMark().
void Grid_MoveCalc | ( | const routing_t * | map, | |
const actorSizeEnum_t | actorSize, | |||
pathing_t * | path, | |||
const pos3_t | from, | |||
byte | crouchingState, | |||
int | distance, | |||
byte ** | fb_list, | |||
int | fb_length | |||
) |
Recalculate the pathing table for the given actor(-position).
[in] | map | Pointer to client or server side routing table (clMap, svMap) |
[in] | actorSize | The size of thing to calc the move for (e.g. size=2 means 2x2). The plan is to have the 'origin' in 2x2 units in the bottom-left (towards the lower coordinates) corner of the 2x2 square. |
[in,out] | path | Pointer to client or server side pathing table (clMap, svMap) |
[in] | from | The position to start the calculation from. |
[in] | distance | The maximum TUs away from 'from' to calculate move-information for |
[in] | crouchingState | Whether the actor is currently crouching, 1 is yes, 0 is no. |
[in] | fb_list | Forbidden list (entities are standing at those points) |
[in] | fb_length | Length of forbidden list |
< Extended position; includes crouching state
< if reaching that square already took too many TUs, don't bother to reach new squares *from* there.
Definition at line 513 of file grid.c.
References ACTOR_MAX_STATES, pathing_s::area, pathing_s::areaFrom, Com_DPrintf(), count, DEBUG_PATHING, pathing_s::fblength, pathing_s::fblist, Grid_MoveMark(), MAX_ROUTE, PATHFINDING_DIRECTIONS, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, pos, PQueueFree(), PQueueInitialise(), PQueueIsEmpty, PQueuePop(), PQueuePush(), ROUTING_NOT_REACHABLE, RT_AREA, Vector4Set, and VectorCopy.
Referenced by CL_ActorConditionalMoveCalc(), and SV_InitGameProgs().
pos_t Grid_MoveLength | ( | const pathing_t * | path, | |
const pos3_t | to, | |||
byte | crouchingState, | |||
qboolean | stored | |||
) |
Return the needed TUs to walk to a given position.
[in] | path | Pointer to client or server side pathing table (clPathMap, svPathMap) |
[in] | to | Position to walk to |
[in] | crouchingState | Whether the actor is currently crouching, 1 is yes, 0 is no. |
[in] | stored | Use the stored mask (the cached move) of the routing data |
Definition at line 592 of file grid.c.
References Com_DPrintf(), DEBUG_PATHING, PATHFINDING_HEIGHT, ROUTING_NOT_REACHABLE, RT_AREA, and RT_SAREA.
Referenced by CL_ActorMoveLength(), CL_AddPathingBox(), and SV_InitGameProgs().
static void Grid_MoveMark | ( | const routing_t * | map, | |
const pos3_t | exclude, | |||
const actorSizeEnum_t | actorSize, | |||
pathing_t * | path, | |||
const pos3_t | pos, | |||
byte | crouchingState, | |||
const int | dir, | |||
priorityQueue_t * | pqueue | |||
) | [static] |
[in] | map | Pointer to client or server side routing table (clMap, svMap) |
[in] | exclude | Exclude this position from the forbidden list check |
[in] | actorSize | Give the field size of the actor (e.g. for 2x2 units) to check linked fields as well. |
[in,out] | path | Pointer to client or server side pathing table (clMap, svMap) |
[in] | pos | Current location in the map. |
[in] | crouchingState | Whether the actor is currently crouching, 1 is yes, 0 is no. |
[in] | dir | Direction vector index (see DIRECTIONS and dvecs) |
[in,out] | pqueue | Priority queue (heap) to insert the now reached tiles for reconsidering |
< This can be keyed into whether an actor can fly or not to allow flying
< Indicates if there is a ladder present providing support.
< Indicates if there is a ladder present providing ability to climb.
<This is the maximum height that an actor can fall.
< The compass direction of this move if less than CORE_DIRECTIONS or at least FLYING_DIRECTIONS
< The actor's height
< Get the difference value for x for this direction. (can be pos or neg)
< Get the difference value for y for this direction. (can be pos or neg)
< Get the difference value for z for this direction. (can be pos or neg)
< "new" x value = starting x value + difference from chosen direction
< "new" y value = starting y value + difference from chosen direction
< "new" z value = starting z value + difference from chosen direction
< The stepup needed to get to/through the passage
< The actual stepup height without the level flags
OK, now some crazy tests: Because of the grid based nature of this game, each cell can have at most only ONE floor that can be stood upon. If an actor can walk down a slope that is in the same level, and actor should be able to walk on (and not fall into) the slope that decends a game level. BUT it is possible for an actor to be able to crawl under a floor that can be stood on, with this opening being in the same cell as the floor. SO to prevent any conflicts, we will move down a floor under the following conditions:
This will prevent actors from walking under a floor in the same cell in order to fall to the floor beneath. They will need to be able to step down into the cell or will not be able to use the opening.
Definition at line 163 of file grid.c.
References byte, CELL_HEIGHT, Com_DPrintf(), CORE_DIRECTIONS, DEBUG_PATHING, DIRECTION_CLIMB_DOWN, DIRECTION_CLIMB_UP, DIRECTION_CROUCH, DIRECTION_FALL, DIRECTION_STAND_UP, dvecs, FLYING_DIRECTIONS, Grid_CheckForbidden(), Grid_GetTUsForDirection(), Grid_Height(), Grid_SetMoveData(), MAX_MOVELENGTH, ModelCeilingToQuant, PATHFINDING_BIG_STEPDOWN, PATHFINDING_BIG_STEPUP, PATHFINDING_DIRECTIONS, PATHFINDING_HEIGHT, PATHFINDING_MAX_FALL, PATHFINDING_MAX_STEPUP, PATHFINDING_WIDTH, PLAYER_CROUCHING_HEIGHT, PLAYER_HEIGHT, PLAYER_STANDING_HEIGHT, qfalse, QuantToModel, ROUTING_NOT_REACHABLE, RT_AREA, RT_AREA_TEST, RT_CEILING, RT_CONN, RT_CONN_TEST, RT_FLOOR, RT_STEPUP, TU_CROUCH_MOVING_FACTOR, and UNIT_HEIGHT.
Referenced by Grid_MoveCalc().
Get the direction to use to move to a position (used to reconstruct the path).
[in] | path | Pointer to client or server side pathing table (le->PathMap, svPathMap) |
[in] | toPos | The desired location |
[in] | crouchingState | Whether the actor is currently crouching, 1 is yes, 0 is no. |
< Get TUs for this square
Definition at line 619 of file grid.c.
References ROUTING_NOT_REACHABLE, ROUTING_UNREACHABLE, RT_AREA, and RT_AREA_FROM.
Referenced by CL_ActorMaximumMove(), CL_ActorTraceMove(), HUD_MapDebugCursor(), and SV_InitGameProgs().
void Grid_MoveStore | ( | pathing_t * | path | ) |
Caches the calculated move.
[in] | path | Pointer to client or server side pathing table (clPathMap, svPathMap) |
Definition at line 577 of file grid.c.
References pathing_s::area, and pathing_s::areaStored.
Referenced by SV_InitGameProgs().
void Grid_PosToVec | ( | const routing_t * | map, | |
const actorSizeEnum_t | actorSize, | |||
const pos3_t | pos, | |||
vec3_t | vec | |||
) |
Converts a grid position to world coordinates.
[in] | map | The routing map |
[in] | actorSize | width of the actor in cells |
[in] | pos | The grid position |
[out] | vec | The world vector |
Definition at line 781 of file grid.c.
References Com_Printf(), Grid_Floor(), PATHFINDING_HEIGHT, SizedPosToVec, and UNIT_HEIGHT.
Referenced by CL_ActorAdd(), CL_ActorAppear(), CL_ActorTraceMove(), CL_AddPathingBox(), CL_AddTargetingBox(), CL_DisplayFloorArrows(), CL_DisplayObstructionArrows(), CL_EntAppear(), CL_TargetingGrenade(), CL_TargetingStraight(), LE_ActorGetStepTime(), LE_PlaceItem(), LET_PathMove(), and SV_InitGameProgs().
void Grid_RecalcBoxRouting | ( | mapTiles_t * | mapTiles, | |
routing_t * | map, | |||
const pos3_t | min, | |||
const pos3_t | max, | |||
const char ** | list | |||
) |
This function recalculates the routing in the box bounded by min and max.
[in] | map | The routing map (either server or client map) |
[in] | min | The lower extents of the box to recalc routing for |
[in] | max | The upper extents of the box to recalc routing for |
Definition at line 801 of file grid.c.
References ACTOR_MAX_SIZE, Com_DPrintf(), CORE_DIRECTIONS, DEBUG_PATHING, PATHFINDING_WIDTH, RT_CheckCell(), and RT_UpdateConnectionColumn().
Referenced by Grid_RecalcRouting().
void Grid_RecalcRouting | ( | mapTiles_t * | mapTiles, | |
routing_t * | map, | |||
const char * | name, | |||
const char ** | list | |||
) |
This function recalculates the routing surrounding the entity name.
[in] | map | The routing map (either server or client map) |
[in] | name | Name of the inline model to compute the mins/maxs for |
Definition at line 861 of file grid.c.
References cBspModel_s::angles, CM_InlineModel(), Com_DPrintf(), Com_Printf(), DEBUG_PATHING, DEBUG_ROUTING, Grid_RecalcBoxRouting(), i, m, cBspModel_s::maxs, cBspModel_s::mins, cBspModel_s::origin, PATHFINDING_HEIGHT, PATHFINDING_WIDTH, VecToPos, VectorAdd, VectorCenterFromMinsMaxs(), VectorCreateRotationMatrix(), VectorNotEmpty, VectorRotate(), and VectorSubtract.
Referenced by CL_CompleteRecalcRouting(), CL_RecalcRouting(), and SV_RecalcRouting().
static void Grid_SetMoveData | ( | pathing_t * | path, | |
const int | x, | |||
const int | y, | |||
const int | z, | |||
const int | c, | |||
const byte | length, | |||
const int | dir, | |||
const int | ox, | |||
const int | oy, | |||
const int | oz, | |||
const int | oc, | |||
priorityQueue_t * | pqueue | |||
) | [static] |
< Store TUs for this square.
< Store origination information for this square.
Definition at line 127 of file grid.c.
References Com_Error(), Com_Printf(), ERR_DROP, makeDV, pos, PosSubDV, PQueuePush(), RT_AREA, RT_AREA_FROM, RT_AREA_TEST, Vector4Set, VectorCompare, and VectorSet.
Referenced by Grid_MoveMark().
pos_t Grid_StepUp | ( | const routing_t * | map, | |
const actorSizeEnum_t | actorSize, | |||
const pos3_t | pos, | |||
const int | dir | |||
) |
Returns the maximum height of an obstruction that an actor can travel over.
[in] | map | Pointer to client or server side routing table (clMap, svMap) |
[in] | actorSize | width of the actor in cells |
[in] | pos | Position in the map to check the height |
[in] | dir | the direction in which we are moving |
Definition at line 697 of file grid.c.
References Com_Printf(), PATHFINDING_HEIGHT, QuantToModel, and RT_STEPUP.
const int TUsUsed[] [static] |
Definition at line 33 of file grid.c.
Referenced by Grid_GetTUsForDirection().