|
UFO: Alien Invasion
|
Battlescape grid functions. More...

Go to the source code of this file.
Data Structures | |
| struct | forbiddenList_t |
| A list of locations that cannot be moved to. More... | |
| struct | pathing_t |
Macros | |
| #define | MAX_FORBIDDENLIST (MAX_EDICTS * 4) |
Functions | |
| void | Grid_RecalcRouting (mapTiles_t *mapTiles, Routing &routing, const char *name, const GridBox &box, const char **list) |
| This function recalculates the routing surrounding the entity name. | |
| void | Grid_RecalcBoxRouting (mapTiles_t *mapTiles, Routing &routing, const GridBox &box, const char **list) |
| This function recalculates the routing in and around the box bounded by min and max. | |
| void | Grid_CalcPathing (const Routing &routing, const actorSizeEnum_t actorSize, pathing_t *path, const pos3_t from, int distance, forbiddenList_t *forbiddenList) |
| Recalculate the pathing table for the given actor(-position). | |
| bool | Grid_FindPath (const Routing &routing, const actorSizeEnum_t actorSize, pathing_t *path, const pos3_t from, const pos3_t targetPos, byte crouchingState, int maxTUs, forbiddenList_t *forbiddenList) |
| Tries to find a path from the given actor(-position) to a given target 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, bool 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 &routing, const actorSizeEnum_t actorSize, const pos3_t pos) |
| Returns the height of the floor in a cell. | |
| int | Grid_Floor (const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos) |
| Returns the height of the floor in a cell. | |
| int | Grid_GetTUsForDirection (const int dir, bool crouched) |
| Returns the amounts of TUs that are needed to perform one step into the given direction. | |
| pos_t | Grid_Fall (const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos) |
| Calculated the new height level when something falls down from a certain position. | |
| bool | Grid_ShouldUseAutostand (const pathing_t *path, const pos3_t toPos) |
| Checks if a crouched actor could save TUs by standing up, walking and crouching again. | |
| void | Grid_PosToVec (const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos, vec3_t vec) |
| Converts a grid position to world coordinates. | |
Battlescape grid functions.
Definition in file grid.h.
| #define MAX_FORBIDDENLIST (MAX_EDICTS * 4) |
Definition at line 28 of file grid.h.
Referenced by forbiddenList_t::add().
| void Grid_CalcPathing | ( | const Routing & | routing, |
| const actorSizeEnum_t | actorSize, | ||
| pathing_t * | path, | ||
| const pos3_t | from, | ||
| int | maxTUs, | ||
| forbiddenList_t * | fb_list ) |
Recalculate the pathing table for the given actor(-position).
We calculate the table for ALL possible movement states (atm stand and crouch) to be able to propose smart things like autostand.
| [in] | routing | Reference 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] | maxTUs | The maximum TUs away from 'from' to calculate move-information for |
| [in] | fb_list | Forbidden list (entities are standing at those points) |
< Extended position; includes crouching state
Definition at line 497 of file grid.cpp.
References ACTOR_MAX_STATES, Step::actorSize, pathing_t::area, pathing_t::areaFrom, Step::crouchingState, Step::dir, DIRECTION_CROUCH, DIRECTION_STAND_UP, pathing_t::fbList, Step::fromPos, Grid_CheckForbidden(), Grid_SetMoveData(), Step::init(), Step::isPossible(), MAX_ROUTE_TUS, OBJSET, PATHFINDING_DIRECTIONS, PATHFINDING_HEIGHT, PQueueFree(), PQueueInitialise(), PQueueIsEmpty, PQueuePop(), PQueuePush(), ROUTING_NOT_REACHABLE, RT_AREA_POS, RT_AREA_TEST_POS, Step::toPos, Step::TUsAfter, Vector4Set, and VectorCopy.
Referenced by CL_ActorConditionalMoveCalc(), SV_GridCalcPathing(), TEST_F(), and TEST_F().
| unsigned int Grid_Ceiling | ( | const Routing & | routing, |
| const actorSizeEnum_t | actorSize, | ||
| const pos3_t | pos ) |
Returns the height of the floor in a cell.
| [in] | routing | Reference 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 741 of file grid.cpp.
References Routing::getCeiling(), PATHFINDING_HEIGHT, and QuantToModel.
Referenced by HUD_MapDebugCursor().
| pos_t Grid_Fall | ( | const Routing & | routing, |
| const actorSizeEnum_t | actorSize, | ||
| const pos3_t | pos ) |
Calculated the new height level when something falls down from a certain position.
| [in] | routing | Reference 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 783 of file grid.cpp.
References CELL_HEIGHT, Routing::getFloor(), and PATHFINDING_HEIGHT.
Referenced by CL_ActorMouseTrace(), SV_GridFall(), and TEST_F().
| bool Grid_FindPath | ( | const Routing & | routing, |
| const actorSizeEnum_t | actorSize, | ||
| pathing_t * | path, | ||
| const pos3_t | from, | ||
| const pos3_t | targetPos, | ||
| byte | crouchingState, | ||
| int | maxTUs, | ||
| forbiddenList_t * | forbiddenList ) |
Tries to find a path from the given actor(-position) to a given target position.
Unlike Grid_CalcPathing, this function does not neccessarily calculate the TU values for all positions reachable from 'from'. Instead it tries to find the shortest/fastest path to the target position. There is no limit to maxTUs.
| [in] | routing | Reference 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] | targetPos | The position where we want to end up. |
| [in] | maxTUs | 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] | forbiddenList | Forbidden list (entities are standing at those points) |
< Extended position; includes crouching state
Definition at line 590 of file grid.cpp.
References Step::actorSize, pathing_t::area, pathing_t::areaFrom, Step::crouchingState, Step::dir, DIRECTION_CROUCH, DIRECTION_STAND_UP, pathing_t::fbList, forbiddenList, Step::fromPos, Grid_CheckForbidden(), Grid_SetMoveData(), Step::init(), int(), Step::isPossible(), OBJSET, PATHFINDING_DIRECTIONS, PATHFINDING_HEIGHT, PQueueFree(), PQueueInitialise(), PQueueIsEmpty, PQueuePop(), PQueuePush(), ROUTING_NOT_REACHABLE, RT_AREA_POS, RT_AREA_TEST_POS, Step::toPos, Step::TUsAfter, Vector4Set, VectorCompare, VectorCopy, VectorDist, and VectorEqual.
Referenced by SV_GridFindPath().
| int Grid_Floor | ( | const Routing & | routing, |
| const actorSizeEnum_t | actorSize, | ||
| const pos3_t | pos ) |
Returns the height of the floor in a cell.
| [in] | routing | Reference 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 754 of file grid.cpp.
References Routing::getFloor(), PATHFINDING_HEIGHT, and QuantToModel.
Referenced by CL_AddPathingBox(), Grid_PosToVec(), and HUD_MapDebugCursor().
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 |
| [in] | crouched | The crouching state of the actor |
Definition at line 766 of file grid.cpp.
References CORE_DIRECTIONS, PATHFINDING_DIRECTIONS, TU_CROUCH_MOVING_FACTOR, and TUsUsed.
Referenced by Step::calcNewTUs(), Step::checkWalkingDirections(), SV_InitGameProgs(), and TEST_F().
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 698 of file grid.cpp.
References PATHFINDING_HEIGHT, RT_AREA_POS, and RT_SAREA.
Referenced by CL_ActorMoveLength(), SV_InitGameProgs(), TEST_F(), and TEST_F().
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 719 of file grid.cpp.
References ROUTING_NOT_REACHABLE, ROUTING_UNREACHABLE, RT_AREA_FROM_POS, and RT_AREA_POS.
Referenced by CL_ActorMaximumMove(), CL_ActorMoveLength(), CL_ActorTraceMove(), HUD_MapDebugCursor(), and SV_InitGameProgs().
Caches the calculated move.
| [in] | path | Pointer to client or server side pathing table (clPathMap, svPathMap) |
Definition at line 683 of file grid.cpp.
References pathing_t::area, and pathing_t::areaStored.
Referenced by SV_InitGameProgs(), TEST_F(), and TEST_F().
| void Grid_PosToVec | ( | const Routing & | routing, |
| const actorSizeEnum_t | actorSize, | ||
| const pos3_t | pos, | ||
| vec3_t | vec ) |
Converts a grid position to world coordinates.
| [in] | routing | The routing map |
| [in] | actorSize | width of the actor in cells |
| [in] | pos | The grid position |
| [out] | vec | The world vector |
Definition at line 832 of file grid.cpp.
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_GridPosToVec().
| void Grid_RecalcBoxRouting | ( | mapTiles_t * | mapTiles, |
| Routing & | routing, | ||
| const GridBox & | box, | ||
| const char ** | list ) |
This function recalculates the routing in and around the box bounded by min and max.
| [in] | mapTiles | List of tiles the current (RMA-)map is composed of |
| [in] | routing | The routing map (either server or client map) |
| [in] | box | The box to recalc routing for |
| [in] | list | The local models list (a local model has a name starting with * followed by the model number) |
Definition at line 854 of file grid.cpp.
References ACTOR_MAX_SIZE, ACTOR_SIZE_NORMAL, GridBox::addOneZ(), CORE_DIRECTIONS, GridBox::expandXY(), GridBox::getMaxX(), GridBox::getMaxY(), GridBox::getMaxZ(), GridBox::getMinX(), GridBox::getMinY(), GridBox::getMinZ(), mapTiles, RT_CheckCell(), and RT_UpdateConnectionColumn().
Referenced by Grid_RecalcRouting().
| void Grid_RecalcRouting | ( | mapTiles_t * | mapTiles, |
| Routing & | routing, | ||
| const char * | name, | ||
| const GridBox & | box, | ||
| const char ** | list ) |
This function recalculates the routing surrounding the entity name.
| [in] | mapTiles | List of tiles the current (RMA-)map is composed of |
| [in] | routing | The routing map (either server or client map) |
| [in] | name | Name of the inline model to compute the mins/maxs for |
| [in] | box | The box around the inline model (alternative to name) |
| [in] | list | The local models list (a local model has a name starting with * followed by the model number) |
Definition at line 922 of file grid.cpp.
References cBspModel_t::angles, CalculateMinsMaxs(), cBspModel_t::cbmBox, GridBox::clipToMaxBoundaries(), CM_InlineModel(), Com_Printf(), AABB::getCenter(), Grid_RecalcBoxRouting(), GridBox::isZero(), m, mapTiles, AABB::maxs, name, cBspModel_t::origin, AABB::set(), GridBox::set(), AABB::shift(), VectorAdd, VectorCreateRotationMatrix(), VectorNotEmpty, VectorRotate(), and VectorSubtract.
Referenced by CL_GridRecalcRouting(), and SV_RecalcRouting().
Checks if a crouched actor could save TUs by standing up, walking and crouching again.
| [in] | path | Pointer to client or server side pathing table |
| [in] | toPos | Desired position |
Definition at line 818 of file grid.cpp.
References RT_AREA_POS, and TU_CROUCH.
Referenced by CL_ActorMoveLength(), CL_ActorMoveMode(), and SV_InitGameProgs().