32#define RT_AREA_POS(path, p, state) ((path)->area[(state)][(p)[2]][(p)[1]][(p)[0]])
33#define RT_AREA_FROM_POS(path, p, state) ((path)->areaFrom[(state)][(p)[2]][(p)[1]][(p)[0]])
34#define RT_SAREA(path, x, y, z, state) ((path)->areaStored[(state)][(z)][(y)][(x)])
35#define RT_AREA_TEST_POS(path, p, state) assert((p)[2] < PATHFINDING_HEIGHT);\
36 assert((state) == 0 || (state) == 1);
110 const int fx = (*p)[0];
111 const int fy = (*p)[1];
112 const int fz = (*p)[2];
114 if (fx + entSize <= chkPos[0] || chkPos[0] + actorSize <= fx)
116 if (fy + entSize <= chkPos[1] || chkPos[1] + actorSize <= fy)
312 if (actorStepupHeight < stepupHeight) {
316 const int nx =
toPos[0];
317 const int ny =
toPos[1];
318 const int nz =
toPos[2];
398 if (passageHeight < neededHeight) {
510 pos3_t excludeFromForbiddenList;
523 Vector4Set(epos, from[0], from[1], from[2], amst);
533 if (usedTUs >= maxTUs)
538 if (dir == 12 || dir == 14 || dir == 15)
544 Step step(routing, pos, actorSize, amst, dir);
594 assert(crouchingState == 0 || crouchingState == 1);
604 pos3_t excludeFromForbiddenList;
616 Vector4Set(epos, from[0], from[1], from[2], crouchingState);
625 const byte usedTUs =
RT_AREA_POS(path, pos, crouchingState);
626 if (usedTUs >= maxTUs)
631 if (dir == 12 || dir == 14 || dir == 15)
637 Step step(routing, pos, actorSize, crouchingState, dir);
702 assert(crouchingState == 0 || crouchingState == 1);
707 return RT_SAREA(path, to[0], to[1], to[2], crouchingState);
801 const int base = routing.
getFloor(actorSize, pos[0], pos[1], z);
820 const int tusCrouched =
RT_AREA_POS(path, toPos, 1);
821 const int tusUpright =
RT_AREA_POS(path, toPos, 0);
822 return tusUpright + 2 *
TU_CROUCH < tusCrouched;
837 Com_Printf(
"Grid_PosToVec: Warning - z level bigger than 7 (%i - source: %.02f)\n", pos[2], vec[2]);
840 const int gridFloor =
Grid_Floor(routing, actorSize, pos);
841 vec[2] += std::max(0, std::min(
UNIT_HEIGHT, gridFloor));
857 for (
int actorSize = 1; actorSize <=
ACTOR_MAX_SIZE; ++actorSize) {
866 for (
int z = rBox.
getMaxZ(); z >= 0; --z) {
876 for (
int actorSize = 1; actorSize <=
ACTOR_MAX_SIZE; actorSize++) {
884 if (x > box.
getMaxX() && dir != 1 && dir != 5 && dir != 6)
886 if (y > box.
getMaxY() && dir != 3 && dir != 5 && dir != 7)
889 if (x < box.
getMinX() && dir != 0 && dir != 4 && dir != 7)
891 if (y < box.
getMinY() && dir != 2 && dir != 4 && dir != 6)
895 if (x < box.
getMinX() - 1 && dir != 0 && dir != 4 && dir != 7)
897 if (y < box.
getMinY() - 1 && dir != 2 && dir != 4 && dir != 6)
927 Com_Printf(
"Called Grid_RecalcRouting with no inline model\n");
932 Com_Printf(
"Called Grid_RecalcRouting with invalid inline model name '%s'\n",
name);
946 vec3_t centerVec, halfVec, newCenterVec;
961 VectorAdd(newCenterVec, halfVec, maxVec);
964 absbox.
set(minVec, maxVec);
973 rerouteBox.
set(absbox);
static forbiddenList_t forbiddenList
A list of locations that cannot be moved to.
void getCenter(vec3_t center) const
Calculates the center of the bounding box.
void set(const AABB &other)
Copies the values from the given aabb.
void shift(const vec3_t shiftVec)
shove the whole box by the given vector
void set(const pos3_t mini, const pos3_t maxi)
void clipToMaxBoundaries()
void expandXY(const int byVal)
expand the box in four directions, but clip them to the maximum boundaries
signed char getFloor(const actorSizeEnum_t actorSize, const pos3_t pos) const
byte getCeiling(const int actorSize, const pos3_t pos) const
a struct holding the relevant data to check if we can move between two adjacent cells
Step(const Routing &r, const pos3_t fromPos, const actorSizeEnum_t actorSize, const byte crouchingState, const int dir)
Constructor.
bool init()
Initialize the other Step data.
bool checkFlyingDirections() const
Checks if we can move in the given flying direction.
bool isPossible(const pathing_t *path)
bool checkVerticalDirections() const
Checks if we can move in the given vertical direction.
const byte crouchingState
bool checkWalkingDirections(const pathing_t *path)
Checks if we can walk in the given direction First test for opening height availability....
actorSizeEnum_t actorSize
bool calcNewPos()
Calculate the cell the we end up in if moving in the give dir.
void calcNewTUs(const pathing_t *path)
Calculate the TUs after we in the given dir.
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.
int RT_CheckCell(mapTiles_t *mapTiles, Routing &routing, const int actorSize, const int x, const int y, const int z, const char **list)
This function looks to see if an actor of a given size can occupy a cell(s) and if so identifies the ...
void RT_UpdateConnectionColumn(mapTiles_t *mapTiles, Routing &routing, const int actorSize, const int x, const int y, const int dir, const char **list, const int minZ, const int maxZ)
Routing Function to update the connection between two fields.
void Com_Printf(const char *const fmt,...)
definitions common between client and server, but not game lib
#define TU_FLYING_MOVING_FACTOR
#define PATHFINDING_MAX_FALL
#define ROUTING_NOT_REACHABLE
#define CELL_HEIGHT
A cell's height in QUANT sized units.
#define TU_CROUCH_MOVING_FACTOR
#define DIRECTION_CLIMB_DOWN
#define DIRECTION_STAND_UP
#define ROUTING_UNREACHABLE
#define PATHFINDING_MAX_STEPUP
#define ACTOR_SIZE_NORMAL
#define PATHFINDING_HEIGHT
15 max, adjusting above 8 will require a rewrite to the DV code
#define DIRECTION_CLIMB_UP
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).
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.
static bool Grid_CheckForbidden(const pos3_t exclude, const actorSizeEnum_t actorSize, pathing_t *path, pos3_t chkPos)
Checks one cell on the grid against the 'forbiddenList' (i.e. cells blocked by other entities).
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.
void Grid_PosToVec(const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos, vec3_t vec)
Converts a grid position to world coordinates.
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.
#define RT_SAREA(path, x, y, z, state)
void Grid_MoveStore(pathing_t *path)
Caches the calculated move.
#define RT_AREA_POS(path, p, state)
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).
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_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.
unsigned int Grid_Ceiling(const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos)
Returns the height of the floor in a cell.
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.
#define RT_AREA_TEST_POS(path, p, state)
static void Grid_SetMoveData(pathing_t *path, const pos3_t toPos, const int crouch, const byte length, const int dir, const int oldZ)
static const int TUsUsed[]
#define RT_AREA_FROM_POS(path, p, state)
int Grid_Floor(const Routing &routing, const actorSizeEnum_t actorSize, const pos3_t pos)
Returns the height of the floor in a cell.
Battlescape grid functions.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
const vec4_t dvecs[PATHFINDING_DIRECTIONS]
void CalculateMinsMaxs(const vec3_t angles, const AABB &relBox, const vec3_t origin, AABB &absBox)
Calculates the bounding box in absolute coordinates, also for rotating objects. WARNING: do not use t...
void VectorCreateRotationMatrix(const vec3_t angles, vec3_t matrix[3])
void VectorRotate(vec3_t m[3], const vec3_t va, vec3_t vb)
Rotate a vector with a rotation matrix.
#define FLYING_DIRECTIONS
#define DV_FLAG_AUTOCROUCH
#define PATHFINDING_DIRECTIONS
#define DV_FLAG_AUTOCROUCHED
void PQueueFree(priorityQueue_t *pq)
free up memory for pqueue
void PQueueInitialise(priorityQueue_t *pq, uint32_t maxElements)
initialise the priority queue with a maximum size of maxelements.
void PQueuePush(priorityQueue_t *pq, const pos4_t item, priorityQueueRating_t r)
void PQueuePop(priorityQueue_t *pq, pos4_t item)
remove the first node from the pqueue and provide a pointer to it
Header file for the priority queue implementation.
#define PQueueIsEmpty(pq)
#define PLAYER_STANDING_HEIGHT
#define PLAYER_CROUCHING_HEIGHT
QGL_EXTERN GLuint GLsizei GLsizei * length
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
grid pathfinding and routing
#define ModelCeilingToQuant(x)
#define SizedPosToVec(p, actorSize, v)
SizedPosToVect locates the center of an actor based on size and position.
A list of locations that cannot be moved to.
actorSizeEnum_t getEntSize(pos_t **current)
pos_t ** getNext(pos_t **prev)
byte areaStored[ACTOR_MAX_STATES][PATHFINDING_HEIGHT][PATHFINDING_WIDTH][PATHFINDING_WIDTH]
dvec_t areaFrom[ACTOR_MAX_STATES][PATHFINDING_HEIGHT][PATHFINDING_WIDTH][PATHFINDING_WIDTH]
byte area[ACTOR_MAX_STATES][PATHFINDING_HEIGHT][PATHFINDING_WIDTH][PATHFINDING_WIDTH]
the priority queue struct the actual data is stored in priorityQueueElement_t
static mapTiles_t mapTiles
#define Vector4Set(v, r, g, b, a)
#define VectorEqual(a, b)
#define VectorNotEmpty(a)
#define VectorSubtract(a, b, dest)
#define VectorCopy(src, dest)
#define VectorCompare(a, b)
#define VectorAdd(a, b, dest)