Atoms Crowd  4.1.0
AtomsUtils::dtNavMesh Class Reference

#include <DetourNavMesh.h>

Classes

struct  FConnectingPolyData
 

Public Member Functions

void applyWorldOffset (const float *offset)
 Shift navigation mesh by provided offset.
 
dtLinkgetLink (dtMeshTile *tile, unsigned int linkIdx)
 Helper for accessing links.
 
const dtLinkgetLink (const dtMeshTile *tile, unsigned int linkIdx) const
 
dtClusterLinkgetClusterLink (dtMeshTile *tile, unsigned int linkIdx)
 Helper for accessing cluster links.
 
const dtClusterLinkgetClusterLink (const dtMeshTile *tile, unsigned int linkIdx) const
 
void linkOffMeshHelper (dtMeshTile *tile0, unsigned int polyIdx0, dtMeshTile *tile1, unsigned int polyIdx1, unsigned char side, unsigned char edge)
 Helper for creating links in off-mesh connections.
 
bool isEmpty () const
 
unsigned int getSaltBits () const
 
void applyAreaCostOrder (unsigned char *costOrder)
 
int getNeighbourTilesCountAt (const int x, const int y, const int side) const
 Returns neighbour tile count based on side of given tile.
 
bool getNeighbourCoords (const int x, const int y, const int side, int &outX, int &outY) const
 
unsigned int getTileIndex (const dtMeshTile *tile) const
 
dtMeshTilegetTile (int i)
 Returns pointer to tile in the tile array.
 
int getTilesAt (const int x, const int y, dtMeshTile **tiles, const int maxTiles) const
 Returns neighbour tile based on side.
 
int getNeighbourTilesAt (const int x, const int y, const int side, dtMeshTile **tiles, const int maxTiles) const
 Returns neighbour tile based on side.
 
int findConnectingPolys (const float *va, const float *vb, const dtMeshTile *fromTile, int fromPolyIdx, const dtMeshTile *tile, int side, dtChunkArray< FConnectingPolyData > &cons) const
 Returns all polygons in neighbour tile based on portal defined by the segment.
 
void connectIntLinks (dtMeshTile *tile)
 Builds internal polygons links for a tile.
 
void baseOffMeshLinks (dtMeshTile *tile)
 Builds internal polygons links for a tile.
 
void connectExtLinks (dtMeshTile *tile, dtMeshTile *target, int side, bool updateCLinks)
 Builds external polygon links for a tile.
 
void connectExtOffMeshLinks (dtMeshTile *tile, dtMeshTile *target, int side, bool updateCLinks)
 Builds external polygon links for a tile.
 
void unconnectExtLinks (dtMeshTile *tile, dtMeshTile *target)
 Removes external links at specified side.
 
void connectClusterLink (dtMeshTile *tile0, unsigned int cluster0, dtMeshTile *tile1, unsigned int cluster1, unsigned char flags, bool bCheckExisting=true)
 Try to connect clusters.
 
void unconnectClusterLinks (dtMeshTile *tile, dtMeshTile *target)
 Removes cluster links at specified side.
 
int queryPolygonsInTile (const dtMeshTile *tile, const float *qmin, const float *qmax, dtPolyRef *polys, const int maxPolys, bool bExcludeUnwalkable=false) const
 Queries polygons within a tile.
 
dtPolyRef findNearestPolyInTile (const dtMeshTile *tile, const float *center, const float *extents, float *nearestPt, bool bExcludeUnwalkable=false) const
 Find nearest polygon within a tile.
 
dtPolyRef findCheapestNearPolyInTile (const dtMeshTile *tile, const float *center, const float *extents, float *nearestPt) const
 
void closestPointOnPolyInTile (const dtMeshTile *tile, unsigned int ip, const float *pos, float *closest) const
 Returns closest point on polygon.
 
Initialization and Tile Management
dtStatus init (const dtNavMeshParams *params)
 
dtStatus init (unsigned char *data, const int dataSize, const int flags)
 
const dtNavMeshParamsgetParams () const
 The navigation mesh initialization params.
 
dtStatus addTile (unsigned char *data, int dataSize, int flags, dtTileRef lastRef, dtTileRef *result)
 
dtStatus removeTile (dtTileRef ref, unsigned char **data, int *dataSize)
 
Query Functions
void calcTileLoc (const float *pos, int *tx, int *ty) const
 
const dtMeshTilegetTileAt (const int x, const int y, const int layer) const
 
int getTileCountAt (const int x, const int y) const
 
int getTilesAt (const int x, const int y, dtMeshTile const **tiles, const int maxTiles) const
 
dtTileRef getTileRefAt (int x, int y, int layer) const
 
dtTileRef getTileRef (const dtMeshTile *tile) const
 
const dtMeshTilegetTileByRef (dtTileRef ref) const
 
int getMaxTiles () const
 
const dtMeshTilegetTile (int i) const
 
dtStatus getTileAndPolyByRef (const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const
 
void getTileAndPolyByRefUnsafe (const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const
 
bool isValidPolyRef (dtPolyRef ref) const
 
dtPolyRef getPolyRefBase (const dtMeshTile *tile) const
 
dtClusterRef getClusterRefBase (const dtMeshTile *tile) const
 
dtStatus getOffMeshConnectionPolyEndPoints (dtPolyRef prevRef, dtPolyRef polyRef, const float *currentPos, float *startPos, float *endPos) const
 
const dtOffMeshConnectiongetOffMeshConnectionByRef (dtPolyRef ref) const
 
const dtOffMeshSegmentConnectiongetOffMeshSegmentConnectionByRef (dtPolyRef ref) const
 
void updateOffMeshConnectionByUserId (unsigned int userId, unsigned char newArea, unsigned short newFlags)
 
void updateOffMeshSegmentConnectionByUserId (unsigned int userId, unsigned char newArea, unsigned short newFlags)
 
State Management

These functions do not effect dtTileRef or dtPolyRef's.

dtStatus setPolyFlags (dtPolyRef ref, unsigned short flags)
 
dtStatus getPolyFlags (dtPolyRef ref, unsigned short *resultFlags) const
 
dtStatus setPolyArea (dtPolyRef ref, unsigned char area)
 
dtStatus getPolyArea (dtPolyRef ref, unsigned char *resultArea) const
 
int getTileStateSize (const dtMeshTile *tile) const
 
dtStatus storeTileState (const dtMeshTile *tile, unsigned char *data, const int maxDataSize) const
 
dtStatus restoreTileState (dtMeshTile *tile, const unsigned char *data, const int maxDataSize)
 
Encoding and Decoding

These functions are generally meant for internal use only.

dtPolyRef encodePolyId (unsigned int salt, unsigned int it, unsigned int ip) const
 
void decodePolyId (dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
 
unsigned int decodePolyIdSalt (dtPolyRef ref) const
 
unsigned int decodePolyIdTile (dtPolyRef ref) const
 
unsigned int decodePolyIdPoly (dtPolyRef ref) const
 
unsigned int decodeClusterIdTile (dtClusterRef ref) const
 
unsigned int decodeClusterIdCluster (dtClusterRef ref) const
 

Public Attributes

dtNavMeshParams m_params
 Current initialization params. TODO: do not store this info twice.
 
float m_orig [3]
 Origin of the tile (0,0)
 
float m_tileWidth
 
float m_tileHeight
 Dimensions of each tile.
 
int m_maxTiles
 Max number of tiles.
 
int m_tileLutSize
 Tile hash lookup size (must be pot).
 
int m_tileLutMask
 Tile hash lookup mask.
 
unsigned char m_areaCostOrder [DT_MAX_AREAS]
 
dtMeshTile ** m_posLookup
 Tile hash lookup.
 
dtMeshTilem_nextFree
 Freelist of tiles.
 
dtMeshTilem_tiles
 List of tiles.
 
unsigned int m_saltBits
 Number of salt bits in the tile ID.
 
unsigned int m_tileBits
 Number of tile bits in the tile ID.
 
unsigned int m_polyBits
 Number of poly bits in the tile ID.
 

Detailed Description

A navigation mesh based on tiles of convex polygons.

Member Function Documentation

◆ addTile()

dtStatus AtomsUtils::dtNavMesh::addTile ( unsigned char *  data,
int  dataSize,
int  flags,
dtTileRef  lastRef,
dtTileRef result 
)

Adds a tile to the navigation mesh.

Parameters
[in]dataData for the new tile mesh. (See: dtCreateNavMeshData)
[in]dataSizeData size of the new tile mesh.
[in]flagsTile flags. (See: dtTileFlags)
[in]lastRefThe desired reference for the tile. (When reloading a tile.) [opt] [Default: 0]
[out]resultThe tile reference. (If the tile was succesfully added.) [opt]
Returns
The status flags for the operation.

◆ calcTileLoc()

void AtomsUtils::dtNavMesh::calcTileLoc ( const float *  pos,
int *  tx,
int *  ty 
) const

Calculates the tile grid location for the specified world position.

Parameters
[in]posThe world position for the query. [(x, y, z)]
[out]txThe tile's x-location. (x, y)
[out]tyThe tile's y-location. (x, y)

◆ decodeClusterIdCluster()

unsigned int AtomsUtils::dtNavMesh::decodeClusterIdCluster ( dtClusterRef  ref) const
inline

Extracts the cluster's index (within its tile) from the specified cluster reference.

Note
This function is generally meant for internal use only.
Parameters
[in]refThe cluster reference.

◆ decodeClusterIdTile()

unsigned int AtomsUtils::dtNavMesh::decodeClusterIdTile ( dtClusterRef  ref) const
inline

Extracts the tile's index from the specified cluster reference.

Note
This function is generally meant for internal use only.
Parameters
[in]refThe cluster reference.

◆ decodePolyId()

void AtomsUtils::dtNavMesh::decodePolyId ( dtPolyRef  ref,
unsigned int &  salt,
unsigned int &  it,
unsigned int &  ip 
) const
inline

Decodes a standard polygon reference.

Note
This function is generally meant for internal use only.
Parameters
[in]refThe polygon reference to decode.
[out]saltThe tile's salt value.
[out]itThe index of the tile.
[out]ipThe index of the polygon within the tile.
See also
encodePolyId

◆ decodePolyIdPoly()

unsigned int AtomsUtils::dtNavMesh::decodePolyIdPoly ( dtPolyRef  ref) const
inline

Extracts the polygon's index (within its tile) from the specified polygon reference.

Note
This function is generally meant for internal use only.
Parameters
[in]refThe polygon reference.
See also
encodePolyId

◆ decodePolyIdSalt()

unsigned int AtomsUtils::dtNavMesh::decodePolyIdSalt ( dtPolyRef  ref) const
inline

Extracts a tile's salt value from the specified polygon reference.

Note
This function is generally meant for internal use only.
Parameters
[in]refThe polygon reference.
See also
encodePolyId

◆ decodePolyIdTile()

unsigned int AtomsUtils::dtNavMesh::decodePolyIdTile ( dtPolyRef  ref) const
inline

Extracts the tile's index from the specified polygon reference.

Note
This function is generally meant for internal use only.
Parameters
[in]refThe polygon reference.
See also
encodePolyId

◆ encodePolyId()

dtPolyRef AtomsUtils::dtNavMesh::encodePolyId ( unsigned int  salt,
unsigned int  it,
unsigned int  ip 
) const
inline

Derives a standard polygon reference.

Note
This function is generally meant for internal use only.
Parameters
[in]saltThe tile's salt value.
[in]itThe index of the tile.
[in]ipThe index of the polygon within the tile.

◆ getClusterRefBase()

dtClusterRef AtomsUtils::dtNavMesh::getClusterRefBase ( const dtMeshTile tile) const

Gets the cluster reference for the tile's base cluster.

Parameters
[in]tileThe tile.
Returns
The cluster reference for the base cluster in the specified tile.

◆ getMaxTiles()

int AtomsUtils::dtNavMesh::getMaxTiles ( ) const

The maximum number of tiles supported by the navigation mesh.

Returns
The maximum number of tiles supported by the navigation mesh.

◆ getOffMeshConnectionByRef()

const dtOffMeshConnection* AtomsUtils::dtNavMesh::getOffMeshConnectionByRef ( dtPolyRef  ref) const

Gets the specified off-mesh connection: point type.

Parameters
[in]refThe polygon reference of the off-mesh connection.
Returns
The specified off-mesh connection, or null if the polygon reference is not valid.

◆ getOffMeshConnectionPolyEndPoints()

dtStatus AtomsUtils::dtNavMesh::getOffMeshConnectionPolyEndPoints ( dtPolyRef  prevRef,
dtPolyRef  polyRef,
const float *  currentPos,
float *  startPos,
float *  endPos 
) const

Gets the endpoints for an off-mesh connection, ordered by "direction of travel".

Parameters
[in]prevRefThe reference of the polygon before the connection.
[in]polyRefThe reference of the off-mesh connection polygon.
[in]currentPosPosition before entering off-mesh connection [(x, y, z)]
[out]startPosThe start position of the off-mesh connection. [(x, y, z)]
[out]endPosThe end position of the off-mesh connection. [(x, y, z)]
Returns
The status flags for the operation.

◆ getOffMeshSegmentConnectionByRef()

const dtOffMeshSegmentConnection* AtomsUtils::dtNavMesh::getOffMeshSegmentConnectionByRef ( dtPolyRef  ref) const

Gets the specified off-mesh connection: segment type

Parameters
[in]refThe polygon reference of the off-mesh connection.
Returns
The specified off-mesh connection, or null if the polygon reference is not valid.

◆ getPolyArea()

dtStatus AtomsUtils::dtNavMesh::getPolyArea ( dtPolyRef  ref,
unsigned char *  resultArea 
) const

Gets the user defined area for the specified polygon.

Parameters
[in]refThe polygon reference.
[out]resultAreaThe area id for the polygon.
Returns
The status flags for the operation.

◆ getPolyFlags()

dtStatus AtomsUtils::dtNavMesh::getPolyFlags ( dtPolyRef  ref,
unsigned short *  resultFlags 
) const

Gets the user defined flags for the specified polygon.

Parameters
[in]refThe polygon reference.
[out]resultFlagsThe polygon flags.
Returns
The status flags for the operation.

◆ getPolyRefBase()

dtPolyRef AtomsUtils::dtNavMesh::getPolyRefBase ( const dtMeshTile tile) const

Gets the polygon reference for the tile's base polygon.

Parameters
[in]tileThe tile.
Returns
The polygon reference for the base polygon in the specified tile.

◆ getTile()

const dtMeshTile* AtomsUtils::dtNavMesh::getTile ( int  i) const

Gets the tile at the specified index.

Parameters
[in]iThe tile index. [Limit: 0 >= index < getMaxTiles()]
Returns
The tile at the specified index.

◆ getTileAndPolyByRef()

dtStatus AtomsUtils::dtNavMesh::getTileAndPolyByRef ( const dtPolyRef  ref,
const dtMeshTile **  tile,
const dtPoly **  poly 
) const

Gets the tile and polygon for the specified polygon reference.

Parameters
[in]refThe reference for the a polygon.
[out]tileThe tile containing the polygon.
[out]polyThe polygon.
Returns
The status flags for the operation.

◆ getTileAndPolyByRefUnsafe()

void AtomsUtils::dtNavMesh::getTileAndPolyByRefUnsafe ( const dtPolyRef  ref,
const dtMeshTile **  tile,
const dtPoly **  poly 
) const

Returns the tile and polygon for the specified polygon reference.

Parameters
[in]refA known valid reference for a polygon.
[out]tileThe tile containing the polygon.
[out]polyThe polygon.

◆ getTileAt()

const dtMeshTile* AtomsUtils::dtNavMesh::getTileAt ( const int  x,
const int  y,
const int  layer 
) const

Gets the tile at the specified grid location.

Parameters
[in]xThe tile's x-location. (x, y, layer)
[in]yThe tile's y-location. (x, y, layer)
[in]layerThe tile's layer. (x, y, layer)
Returns
The tile, or null if the tile does not exist.

◆ getTileByRef()

const dtMeshTile* AtomsUtils::dtNavMesh::getTileByRef ( dtTileRef  ref) const

Gets the tile for the specified tile reference.

Parameters
[in]refThe tile reference of the tile to retrieve.
Returns
The tile for the specified reference, or null if the reference is invalid.

◆ getTileCountAt()

int AtomsUtils::dtNavMesh::getTileCountAt ( const int  x,
const int  y 
) const

Gets number of tiles at the specified grid location. (All layers.)

Parameters
[in]xThe tile's x-location. (x, y)
[in]yThe tile's y-location. (x, y)
Returns
The number of tiles in grid.

◆ getTileRef()

dtTileRef AtomsUtils::dtNavMesh::getTileRef ( const dtMeshTile tile) const

Gets the tile reference for the specified tile.

Parameters
[in]tileThe tile.
Returns
The tile reference of the tile.

◆ getTileRefAt()

dtTileRef AtomsUtils::dtNavMesh::getTileRefAt ( int  x,
int  y,
int  layer 
) const

Gets the tile reference for the tile at specified grid location.

Parameters
[in]xThe tile's x-location. (x, y, layer)
[in]yThe tile's y-location. (x, y, layer)
[in]layerThe tile's layer. (x, y, layer)
Returns
The tile reference of the tile, or 0 if there is none.

◆ getTilesAt()

int AtomsUtils::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.)

Parameters
[in]xThe tile's x-location. (x, y)
[in]yThe tile's y-location. (x, y)
[out]tilesA pointer to an array of tiles that will hold the result.
[in]maxTilesThe maximum tiles the tiles parameter can hold.
Returns
The number of tiles returned in the tiles array.

◆ getTileStateSize()

int AtomsUtils::dtNavMesh::getTileStateSize ( const dtMeshTile tile) const

Gets the size of the buffer required by storeTileState to store the specified tile's state.

Parameters
[in]tileThe tile.
Returns
The size of the buffer required to store the state.

◆ init() [1/2]

dtStatus AtomsUtils::dtNavMesh::init ( const dtNavMeshParams params)

Initializes the navigation mesh for tiled use.

Parameters
[in]paramsInitialization parameters.
Returns
The status flags for the operation.

◆ init() [2/2]

dtStatus AtomsUtils::dtNavMesh::init ( unsigned char *  data,
const int  dataSize,
const int  flags 
)

Initializes the navigation mesh for single tile use.

Parameters
[in]dataData of the new tile. (See: dtCreateNavMeshData)
[in]dataSizeThe data size of the new tile.
[in]flagsThe tile flags. (See: dtTileFlags)
Returns
The status flags for the operation.
See also
dtCreateNavMeshData

◆ isValidPolyRef()

bool AtomsUtils::dtNavMesh::isValidPolyRef ( dtPolyRef  ref) const

Checks the validity of a polygon reference.

Parameters
[in]refThe polygon reference to check.
Returns
True if polygon reference is valid for the navigation mesh.

◆ removeTile()

dtStatus AtomsUtils::dtNavMesh::removeTile ( dtTileRef  ref,
unsigned char **  data,
int *  dataSize 
)

Removes the specified tile from the navigation mesh.

Parameters
[in]refThe reference of the tile to remove.
[out]dataData associated with deleted tile.
[out]dataSizeSize of the data associated with deleted tile.
Returns
The status flags for the operation.

◆ restoreTileState()

dtStatus AtomsUtils::dtNavMesh::restoreTileState ( dtMeshTile tile,
const unsigned char *  data,
const int  maxDataSize 
)

Restores the state of the tile.

Parameters
[in]tileThe tile.
[in]dataThe new state. (Obtained from storeTileState.)
[in]maxDataSizeThe size of the state within the data buffer.
Returns
The status flags for the operation.

◆ setPolyArea()

dtStatus AtomsUtils::dtNavMesh::setPolyArea ( dtPolyRef  ref,
unsigned char  area 
)

Sets the user defined area for the specified polygon.

Parameters
[in]refThe polygon reference.
[in]areaThe new area id for the polygon. [Limit: < #DT_MAX_AREAS]
Returns
The status flags for the operation.

◆ setPolyFlags()

dtStatus AtomsUtils::dtNavMesh::setPolyFlags ( dtPolyRef  ref,
unsigned short  flags 
)

Sets the user defined flags for the specified polygon.

Parameters
[in]refThe polygon reference.
[in]flagsThe new flags for the polygon.
Returns
The status flags for the operation.

◆ storeTileState()

dtStatus AtomsUtils::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.)

Parameters
[in]tileThe tile.
[out]dataThe buffer to store the tile's state in.
[in]maxDataSizeThe size of the data buffer. [Limit: >= getTileStateSize]
Returns
The status flags for the operation.

◆ updateOffMeshConnectionByUserId()

void AtomsUtils::dtNavMesh::updateOffMeshConnectionByUserId ( unsigned int  userId,
unsigned char  newArea,
unsigned short  newFlags 
)

Updates area and flags for specified off-mesh connection: point type

Parameters
[in]userIdUser Id of connection
[in]newAreaArea code to apply

◆ updateOffMeshSegmentConnectionByUserId()

void AtomsUtils::dtNavMesh::updateOffMeshSegmentConnectionByUserId ( unsigned int  userId,
unsigned char  newArea,
unsigned short  newFlags 
)

Updates area and flags for specified off-mesh connection: segment type

Parameters
[in]userIdUser Id of connection
[in]newAreaArea code to apply

The documentation for this class was generated from the following file: