Planeshift
|
A navigation mesh based on tiles of convex polygons. More...
#include <DetourNavMesh.h>
Public Member Functions | |
dtNavMesh () | |
dtMeshTile * | getTile (int i) |
Returns pointer to tile in the tile array. | |
~dtNavMesh () | |
Initialization and Tile Management | |
dtStatus | init (const dtNavMeshParams *params) |
Initializes the navigation mesh for tiled use. | |
dtStatus | init (unsigned char *data, const int dataSize, const int flags) |
Initializes the navigation mesh for single tile use. | |
const dtNavMeshParams * | getParams () const |
The navigation mesh initialization params. | |
dtStatus | addTile (unsigned char *data, int dataSize, int flags, dtTileRef lastRef, dtTileRef *result) |
Adds a tile to the navigation mesh. | |
dtStatus | removeTile (dtTileRef ref, unsigned char **data, int *dataSize) |
Removes the specified tile from the navigation mesh. | |
Query Functions | |
void | calcTileLoc (const float *pos, int *tx, int *ty) const |
Calculates the tile grid location for the specified world position. | |
const dtMeshTile * | getTileAt (const int x, const int y, const int layer) const |
Gets the tile at the specified grid location. | |
int | getTilesAt (const int x, const int y, dtMeshTile const **tiles, const int maxTiles) const |
Gets all tiles at the specified grid location. (All layers.) | |
dtTileRef | getTileRefAt (int x, int y, int layer) const |
Gets the tile reference for the tile at specified grid location. | |
dtTileRef | getTileRef (const dtMeshTile *tile) const |
Gets the tile reference for the specified tile. | |
const dtMeshTile * | getTileByRef (dtTileRef ref) const |
Gets the tile for the specified tile reference. | |
int | getMaxTiles () const |
The maximum number of tiles supported by the navigation mesh. | |
const dtMeshTile * | getTile (int i) const |
Gets the tile at the specified index. | |
dtStatus | getTileAndPolyByRef (const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const |
Gets the tile and polygon for the specified polygon reference. | |
void | getTileAndPolyByRefUnsafe (const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const |
Returns the tile and polygon for the specified polygon reference. | |
bool | isValidPolyRef (dtPolyRef ref) const |
Checks the validity of a polygon reference. | |
dtPolyRef | getPolyRefBase (const dtMeshTile *tile) const |
Gets the polygon reference for the tile's base polygon. | |
dtStatus | getOffMeshConnectionPolyEndPoints (dtPolyRef prevRef, dtPolyRef polyRef, float *startPos, float *endPos) const |
Gets the endpoints for an off-mesh connection, ordered by "direction of travel". | |
const dtOffMeshConnection * | getOffMeshConnectionByRef (dtPolyRef ref) const |
Gets the specified off-mesh connection. | |
State Management | |
dtStatus | setPolyFlags (dtPolyRef ref, unsigned short flags) |
Sets the user defined flags for the specified polygon. | |
dtStatus | getPolyFlags (dtPolyRef ref, unsigned short *resultFlags) const |
Gets the user defined flags for the specified polygon. | |
dtStatus | setPolyArea (dtPolyRef ref, unsigned char area) |
Sets the user defined area for the specified polygon. | |
dtStatus | getPolyArea (dtPolyRef ref, unsigned char *resultArea) const |
Gets the user defined area for the specified polygon. | |
int | getTileStateSize (const dtMeshTile *tile) const |
Gets the size of the buffer required by storeTileState to store the specified tile's state. | |
dtStatus | storeTileState (const dtMeshTile *tile, unsigned char *data, const int maxDataSize) const |
Stores the non-structural state of the tile in the specified buffer. (Flags, area ids, etc.) | |
dtStatus | restoreTileState (dtMeshTile *tile, const unsigned char *data, const int maxDataSize) |
Restores the state of the tile. | |
Encoding and Decoding | |
These functions are generally meant for internal use only. | |
dtPolyRef | encodePolyId (unsigned int salt, unsigned int it, unsigned int ip) const |
Derives a standard polygon reference. | |
void | decodePolyId (dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const |
Decodes a standard polygon reference. | |
unsigned int | decodePolyIdSalt (dtPolyRef ref) const |
Extracts a tile's salt value from the specified polygon reference. | |
unsigned int | decodePolyIdTile (dtPolyRef ref) const |
Extracts the tile's index from the specified polygon reference. | |
unsigned int | decodePolyIdPoly (dtPolyRef ref) const |
Extracts the polygon's index (within its tile) from the specified polygon reference. |
A navigation mesh based on tiles of convex polygons.
Definition at line 272 of file DetourNavMesh.h.
dtNavMesh::dtNavMesh | ( | ) |
dtNavMesh::~dtNavMesh | ( | ) |
dtStatus dtNavMesh::addTile | ( | unsigned char * | data, |
int | dataSize, | ||
int | flags, | ||
dtTileRef | lastRef, | ||
dtTileRef * | result | ||
) |
Adds a tile to the navigation mesh.
[in] | data | Data for the new tile mesh. (See: dtCreateNavMeshData) |
[in] | dataSize | Data size of the new tile mesh. |
[in] | flags | Tile flags. (See: dtTileFlags) |
[in] | lastRef | The desired reference for the tile. (When reloading a tile.) [opt] [Default: 0] |
[out] | result | The tile reference. (If the tile was successfully added.) [opt] |
Calculates the tile grid location for the specified world position.
[in] | pos | The world position for the query. [(x, y, z)] |
[out] | tx | The tile's x-location. (x, y) |
[out] | ty | The tile's y-location. (x, y) |
void dtNavMesh::decodePolyId | ( | dtPolyRef | ref, |
unsigned int & | salt, | ||
unsigned int & | it, | ||
unsigned int & | ip | ||
) | const [inline] |
Decodes a standard polygon reference.
[in] | ref | The polygon reference to decode. |
[out] | salt | The tile's salt value. |
[out] | it | The index of the tile. |
[out] | ip | The index of the polygon within the tile. |
Definition at line 475 of file DetourNavMesh.h.
Extracts the polygon's index (within its tile) from the specified polygon reference.
[in] | ref | The polygon reference. |
Definition at line 509 of file DetourNavMesh.h.
Extracts a tile's salt value from the specified polygon reference.
[in] | ref | The polygon reference. |
Definition at line 489 of file DetourNavMesh.h.
Extracts the tile's index from the specified polygon reference.
[in] | ref | The polygon reference. |
Definition at line 499 of file DetourNavMesh.h.
dtPolyRef dtNavMesh::encodePolyId | ( | unsigned int | salt, |
unsigned int | it, | ||
unsigned int | ip | ||
) | const [inline] |
Derives a standard polygon reference.
[in] | salt | The tile's salt value. |
[in] | it | The index of the tile. |
[in] | ip | The index of the polygon within the tile. |
Definition at line 463 of file DetourNavMesh.h.
int dtNavMesh::getMaxTiles | ( | ) | const |
The maximum number of tiles supported by the navigation mesh.
const dtOffMeshConnection* dtNavMesh::getOffMeshConnectionByRef | ( | dtPolyRef | ref | ) | const |
Gets the specified off-mesh connection.
[in] | ref | The polygon reference of the off-mesh connection. |
dtStatus dtNavMesh::getOffMeshConnectionPolyEndPoints | ( | dtPolyRef | prevRef, |
dtPolyRef | polyRef, | ||
float * | startPos, | ||
float * | endPos | ||
) | const |
Gets the endpoints for an off-mesh connection, ordered by "direction of travel".
[in] | prevRef | The reference of the polygon before the connection. |
[in] | polyRef | The reference of the off-mesh connection polygon. |
[out] | startPos | The start position of the off-mesh connection. [(x, y, z)] |
[out] | endPos | The end position of the off-mesh connection. [(x, y, z)] |
const dtNavMeshParams* dtNavMesh::getParams | ( | ) | const |
The navigation mesh initialization params.
Gets the user defined area for the specified polygon.
[in] | ref | The polygon reference. |
[out] | resultArea | The area id for the polygon. |
Gets the user defined flags for the specified polygon.
[in] | ref | The polygon reference. |
[out] | resultFlags | The polygon flags. |
dtPolyRef dtNavMesh::getPolyRefBase | ( | const dtMeshTile * | tile | ) | const |
Gets the polygon reference for the tile's base polygon.
[in] | tile | The tile. |
dtMeshTile* dtNavMesh::getTile | ( | int | i | ) |
Returns pointer to tile in the tile array.
const dtMeshTile* dtNavMesh::getTile | ( | int | i | ) | const |
Gets the tile at the specified index.
[in] | i | The tile index. [Limit: 0 >= index < getMaxTiles()] |
dtStatus dtNavMesh::getTileAndPolyByRef | ( | const dtPolyRef | ref, |
const dtMeshTile ** | tile, | ||
const dtPoly ** | poly | ||
) | const |
Gets the tile and polygon for the specified polygon reference.
[in] | ref | The reference for the a polygon. |
[out] | tile | The tile containing the polygon. |
[out] | poly | The polygon. |
void dtNavMesh::getTileAndPolyByRefUnsafe | ( | const dtPolyRef | ref, |
const dtMeshTile ** | tile, | ||
const dtPoly ** | poly | ||
) | const |
Returns the tile and polygon for the specified polygon reference.
[in] | ref | A known valid reference for a polygon. |
[out] | tile | The tile containing the polygon. |
[out] | poly | The polygon. |
const dtMeshTile* dtNavMesh::getTileAt | ( | const int | x, |
const int | y, | ||
const int | layer | ||
) | const |
Gets the tile at the specified grid location.
[in] | x | The tile's x-location. (x, y, layer) |
[in] | y | The tile's y-location. (x, y, layer) |
[in] | layer | The tile's layer. (x, y, layer) |
const dtMeshTile* dtNavMesh::getTileByRef | ( | dtTileRef | ref | ) | const |
Gets the tile for the specified tile reference.
[in] | ref | The tile reference of the tile to retrieve. |
dtTileRef dtNavMesh::getTileRef | ( | const dtMeshTile * | tile | ) | const |
Gets the tile reference for the specified tile.
[in] | tile | The tile. |
Gets the tile reference for the tile at specified grid location.
[in] | x | The tile's x-location. (x, y, layer) |
[in] | y | The tile's y-location. (x, y, layer) |
[in] | layer | The tile's layer. (x, y, layer) |
int dtNavMesh::getTilesAt | ( | const int | x, |
const int | y, | ||
dtMeshTile const ** | tiles, | ||
const int | maxTiles | ||
) | const |
Gets all tiles at the specified grid location. (All layers.)
[in] | x | The tile's x-location. (x, y) |
[in] | y | The tile's y-location. (x, y) |
[out] | tiles | A pointer to an array of tiles that will hold the result. |
[in] | maxTiles | The maximum tiles the tiles parameter can hold. |
int dtNavMesh::getTileStateSize | ( | const dtMeshTile * | tile | ) | const |
Gets the size of the buffer required by storeTileState to store the specified tile's state.
[in] | tile | The tile. |
Initializes the navigation mesh for single tile use.
[in] | data | Data of the new tile. (See: dtCreateNavMeshData) |
[in] | dataSize | The data size of the new tile. |
[in] | flags | The tile flags. (See: dtTileFlags) |
dtStatus dtNavMesh::init | ( | const dtNavMeshParams * | params | ) |
Initializes the navigation mesh for tiled use.
[in] | params | Initialization parameters. |
bool dtNavMesh::isValidPolyRef | ( | dtPolyRef | ref | ) | const |
Checks the validity of a polygon reference.
[in] | ref | The polygon reference to check. |
Removes the specified tile from the navigation mesh.
[in] | ref | The reference of the tile to remove. |
[out] | data | Data associated with deleted tile. |
[out] | dataSize | Size of the data associated with deleted tile. |
dtStatus dtNavMesh::restoreTileState | ( | dtMeshTile * | tile, |
const unsigned char * | data, | ||
const int | maxDataSize | ||
) |
Restores the state of the tile.
[in] | tile | The tile. |
[in] | data | The new state. (Obtained from storeTileState.) |
[in] | maxDataSize | The size of the state within the data buffer. |
Sets the user defined area for the specified polygon.
[in] | ref | The polygon reference. |
[in] | area | The new area id for the polygon. [Limit: < DT_MAX_AREAS] |
Sets the user defined flags for the specified polygon.
[in] | ref | The polygon reference. |
[in] | flags | The new flags for the polygon. |
dtStatus dtNavMesh::storeTileState | ( | const dtMeshTile * | tile, |
unsigned char * | data, | ||
const int | maxDataSize | ||
) | const |
Stores the non-structural state of the tile in the specified buffer. (Flags, area ids, etc.)
[in] | tile | The tile. |
[out] | data | The buffer to store the tile's state in. |
[in] | maxDataSize | The size of the data buffer. [Limit: >= getTileStateSize] |