dtNavMesh

A navigation mesh based on tiles of convex polygons.

Windows
MacOS
Linux

References

Module

Navmesh

Header

/Engine/Source/Runtime/Navmesh/Public/Detour/DetourNavMesh.h

Include

#include "Detour/DetourNavMesh.h"

Syntax

class dtNavMesh

Remarks

A navigation mesh based on tiles of convex polygons.

The navigation mesh consists of one or more tiles defining three primary types of structural data:

A polygon mesh which defines most of the navigation graph. (See rcPolyMesh for its structure.) A detail mesh used for determining surface height on the polygon mesh. (See rcPolyMeshDetail for its structure.) Off-mesh connections, which define custom point-to-point edges within the navigation graph.

The general build process is as follows:

Create rcPolyMesh and rcPolyMeshDetail data using the Recast build pipeline.

Optionally, create off-mesh connection data.

Combine the source data into a dtNavMeshCreateParams structure.

Create a tile data array using dtCreateNavMeshData().

Allocate at dtNavMesh object and initialize it. (For single tile navigation meshes, the tile data is loaded during this step.)

For multi-tile navigation meshes, load the tile data using dtNavMesh::addTile().

Notes:

  • This class is usually used in conjunction with the dtNavMeshQuery class for pathfinding.

  • Technically, all navigation meshes are tiled. A 'solo' mesh is simply a navigation mesh initialized to have only a single tile.

  • This class does not implement any asynchronous methods. So the dtStatus result of all methods will always contain either a success or failure flag.

Constructors

Name Description

Public function

dtNavMesh()

Destructors

Name Description

Public function

~dtNavMesh()

Functions

Name Description

Public function

dtStatus

 

addTile

(
    unsigned char* data,
    int dataSize,
    int flags,
    dtTileRef lastRef,
    dtTileRef* result
)

Adds a tile to the navigation mesh.

Public function

void

 

applyAreaCostOrder

(
    unsigned char* costOrder
)

Public function

void

 

applyWorldOffset

(
    const float* offset
)

Shift navigation mesh by provided offset.

Public function Const

void

 

calcTileLoc

(
    const float* pos,
    int* tx,
    int* ty
)

Calculates the tile grid location for the specified world position.

Public function Const

unsigned int

 

decodeClusterIdTile

(
    dtClusterRef ref
)

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

Public function Const

void

 

decodePolyId

(
    dtPolyRef ref,
    unsigned int& salt,
    unsigned int& it,
    unsigned int& ip
)

Decodes a standard polygon reference. @note This function is generally meant for internal use only.

Public function Const

unsigned int

 

decodePolyIdPoly

(
    dtPolyRef ref
)

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

Public function Const

unsigned int

 

decodePolyIdSalt

(
    dtPolyRef ref
)

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

Public function Const

unsigned int

 

decodePolyIdTile

(
    dtPolyRef ref
)

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

Public function Const

dtPolyRef

 

encodePolyId

(
    unsigned int salt,
    unsigned int it,
    unsigned int ip
)

Derives a standard polygon reference. @note This function is generally meant for internal use only.

Public function Const

dtClusterRef

 

getClusterRefBase

(
    const dtMeshTile* tile
)

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

Public function Const

const dtLink...

 

getLink

(
    const dtMeshTile* tile,
    unsigned int linkIdx
)

Public function

dtLink &

 

getLink

(
    dtMeshTile* tile,
    unsigned int linkIdx
)

Helper for accessing links.

Public function Const

int

 

getMaxTiles()

The maximum number of tiles supported by the navigation mesh.

Public function Const

bool

 

getNeighbourCoords

(
    const int x,
    const int y,
    const int side,
    int& outX,
    int& outY
)

Public function Const

int

 

getNeighbourTilesCountAt

(
    const int x,
    const int y,
    const int side
)

Returns neighbour tile count based on side of given tile.

Public function Const

const dtOffM...

 

getOffMeshConnectionByRef

(
    dtPolyRef ref
)

Gets the specified off-mesh connection: point type.

Public function Const

dtStatus

 

getOffMeshConnectionPolyEndPoints

(
    dtPolyRef prevRef,
    dtPolyRef polyRef,
    const float* currentPos,
    float* startPos,
    float* endPos
)

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

Public function Const

const dtNavM...

 

getParams()

The navigation mesh initialization params.

Public function Const

dtStatus

 

getPolyArea

(
    dtPolyRef ref,
    unsigned char* resultArea
)

Gets the user defined area for the specified polygon.

Public function Const

dtStatus

 

getPolyFlags

(
    dtPolyRef ref,
    unsigned short* resultFlags
)

Gets the user defined flags for the specified polygon.

Public function Const

dtPolyRef

 

getPolyRefBase

(
    const dtMeshTile* tile
)

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

Public function Const

unsigned int

 

getSaltBits()

Public function Const

const dtMesh...

 

getTile

(
    int i
)

Gets the tile at the specified index.

Public function Const

dtStatus

 

getTileAndPolyByRef

(
    const dtPolyRef ref,
    const dtMeshTile** tile,
    const dtPoly** poly
)

Gets the tile and polygon for the specified polygon reference.

Public function Const

void

 

getTileAndPolyByRefUnsafe

(
    const dtPolyRef ref,
    const dtMeshTile** tile,
    const dtPoly** poly
)

Returns the tile and polygon for the specified polygon reference.

Public function Const

const dtMesh...

 

getTileAt

(
    const int x,
    const int y,
    const int layer
)

Gets the tile at the specified grid location.

Public function Const

const dtMesh...

 

getTileByRef

(
    dtTileRef ref
)

Gets the tile for the specified tile reference.

Public function Const

int

 

getTileCountAt

(
    const int x,
    const int y
)

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

Public function Const

unsigned int

 

getTileIndex

(
    const dtMeshTile* tile
)

Public function Const

dtTileRef

 

getTileRef

(
    const dtMeshTile* tile
)

Gets the tile reference for the specified tile.

Public function Const

dtTileRef

 

getTileRefAt

(
    int x,
    int y,
    int layer
)

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

Public function Const

int

 

getTilesAt

(
    const int x,
    const int y,
    dtMeshTile const** tiles,
    const int maxTiles
)

Gets all tiles at the specified grid location.

Public function Const

int

 

getTileStateSize

(
    const dtMeshTile* tile
)

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

Public function

dtStatus

 

init

(
    const dtNavMeshParams* params
)

Initializes the navigation mesh for tiled use.

Public function

dtStatus

 

init

(
    unsigned char* data,
    const int dataSize,
    const int flags
)

Initializes the navigation mesh for single tile use.

Public function Const

bool

 

isEmpty()

Public function Const

bool

 

isValidPolyRef

(
    dtPolyRef ref
)

Checks the validity of a polygon reference.

Public function

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.

Public function

dtStatus

 

removeTile

(
    dtTileRef ref,
    unsigned char** data,
    int* dataSize
)

Removes the specified tile from the navigation mesh.

Public function

dtStatus

 

restoreTileState

(
    dtMeshTile* tile,
    const unsigned char* data,
    const int maxDataSize
)

Restores the state of the tile.

Public function

dtStatus

 

setPolyArea

(
    dtPolyRef ref,
    unsigned char area
)

Sets the user defined area for the specified polygon.

Public function

dtStatus

 

setPolyFlags

(
    dtPolyRef ref,
    unsigned short flags
)

Sets the user defined flags for the specified polygon.

Public function Const

dtStatus

 

storeTileState

(
    const dtMeshTile* tile,
    unsigned char* data,
    const int maxDataSize
)

Stores the non-structural state of the tile in the specified buffer.

Public function

void

 

updateOffMeshConnectionByUserId

(
    unsigned int userId,
    unsigned char newArea,
    unsigned short newFlags
)

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

See Also

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss