19 #ifndef DETOURNAVMESH_H
20 #define DETOURNAVMESH_H
43 static const unsigned int DT_SALT_BITS = 16;
44 static const unsigned int DT_TILE_BITS = 28;
45 static const unsigned int DT_POLY_BITS = 20;
320 return (triFlags >> (edgeIndex * 2)) & 0x3;
358 dtStatus init(
unsigned char* data,
const int dataSize,
const int flags);
388 void calcTileLoc(
const float* pos,
int* tx,
int* ty)
const;
404 dtMeshTile const** tiles,
const int maxTiles)
const;
551 salt = (
unsigned int)((ref >> (DT_POLY_BITS+DT_TILE_BITS)) & saltMask);
552 it = (
unsigned int)((ref >> DT_POLY_BITS) & tileMask);
553 ip = (
unsigned int)(ref & polyMask);
558 salt = (
unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
559 it = (
unsigned int)((ref >> m_polyBits) & tileMask);
560 ip = (
unsigned int)(ref & polyMask);
572 return (
unsigned int)((ref >> (DT_POLY_BITS+DT_TILE_BITS)) & saltMask);
575 return (
unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
587 return (
unsigned int)((ref >> DT_POLY_BITS) & tileMask);
590 return (
unsigned int)((ref >> m_polyBits) & tileMask);
602 return (
unsigned int)(ref & polyMask);
605 return (
unsigned int)(ref & polyMask);
621 dtMeshTile** tiles,
const int maxTiles)
const;
624 int getNeighbourTilesAt(
const int x,
const int y,
const int side,
625 dtMeshTile** tiles,
const int maxTiles)
const;
628 int findConnectingPolys(
const float* va,
const float* vb,
630 dtPolyRef* con,
float* conarea,
int maxcon)
const;
649 int queryPolygonsInTile(
const dtMeshTile* tile,
const float* qmin,
const float* qmax,
650 dtPolyRef* polys,
const int maxPolys)
const;
653 const float* halfExtents,
float* nearestPt)
const;
655 bool getPolyHeight(
const dtMeshTile* tile,
const dtPoly* poly,
const float* pos,
float* height)
const;
657 void closestPointOnPoly(
dtPolyRef ref,
const float* pos,
float* closest,
bool* posOverPoly)
const;
661 float m_tileWidth, m_tileHeight;
671 unsigned int m_saltBits;
672 unsigned int m_tileBits;
673 unsigned int m_polyBits;
dtPolyTypes
Flags representing the type of a navigation mesh polygon.
Definition: DetourNavMesh.h:145
@ DT_POLYTYPE_GROUND
The polygon is a standard convex polygon that is part of the surface of the mesh.
Definition: DetourNavMesh.h:147
@ DT_POLYTYPE_OFFMESH_CONNECTION
The polygon is an off-mesh connection consisting of two vertices.
Definition: DetourNavMesh.h:149
dtStraightPathOptions
Options for dtNavMeshQuery::findStraightPath.
Definition: DetourNavMesh.h:115
@ DT_STRAIGHTPATH_AREA_CROSSINGS
Add a vertex at every polygon edge crossing where area changes.
Definition: DetourNavMesh.h:116
@ DT_STRAIGHTPATH_ALL_CROSSINGS
Add a vertex at every polygon edge crossing.
Definition: DetourNavMesh.h:117
dtDetailTriEdgeFlags
Definition: DetourNavMesh.h:134
@ DT_DETAIL_EDGE_BOUNDARY
Detail triangle edge is part of the poly boundary.
Definition: DetourNavMesh.h:135
static const float DT_RAY_CAST_LIMIT_PROPORTIONS
Limit raycasting during any angle pahfinding The limit is given as a multiple of the character radius...
Definition: DetourNavMesh.h:141
int dtGetDetailTriEdgeFlags(unsigned char triFlags, int edgeIndex)
Get flags for edge in detail triangle.
Definition: DetourNavMesh.h:318
static const int DT_NAVMESH_VERSION
A version number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:73
dtRaycastOptions
Options for dtNavMeshQuery::raycast.
Definition: DetourNavMesh.h:129
@ DT_RAYCAST_USE_COSTS
Raycast should calculate movement cost along the ray and fill RaycastHit::cost.
Definition: DetourNavMesh.h:130
static const unsigned short DT_EXT_LINK
A flag that indicates that an entity links to an external entity.
Definition: DetourNavMesh.h:85
dtFindPathOptions
Options for dtNavMeshQuery::initSlicedFindPath and updateSlicedFindPath.
Definition: DetourNavMesh.h:123
@ DT_FINDPATH_ANY_ANGLE
use raycasts during pathfind to "shortcut" (raycast still consider costs)
Definition: DetourNavMesh.h:124
static const int DT_NAVMESH_MAGIC
A magic number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:70
dtStraightPathFlags
Vertex flags returned by dtNavMeshQuery::findStraightPath.
Definition: DetourNavMesh.h:107
@ DT_STRAIGHTPATH_END
The vertex is the end position in the path.
Definition: DetourNavMesh.h:109
@ DT_STRAIGHTPATH_START
The vertex is the start position in the path.
Definition: DetourNavMesh.h:108
@ DT_STRAIGHTPATH_OFFMESH_CONNECTION
The vertex is the start of an off-mesh connection.
Definition: DetourNavMesh.h:110
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:88
dtTileFlags
Tile flags used for various functions and fields.
Definition: DetourNavMesh.h:100
@ DT_TILE_FREE_DATA
The navigation mesh owns the tile memory and is responsible for freeing it.
Definition: DetourNavMesh.h:102
static const int DT_NAVMESH_STATE_VERSION
A version number used to detect compatibility of navigation tile states.
Definition: DetourNavMesh.h:79
static const unsigned int DT_OFFMESH_CON_BIDIR
A flag that indicates that an off-mesh connection can be traversed in both directions....
Definition: DetourNavMesh.h:91
static const int DT_NAVMESH_STATE_MAGIC
A magic number used to detect the compatibility of navigation tile states.
Definition: DetourNavMesh.h:76
unsigned int dtStatus
Definition: DetourStatus.h:22
Provides the ability to perform pathfinding related queries against a navigation mesh.
Definition: DetourNavMeshQuery.h:166
A navigation mesh based on tiles of convex polygons.
Definition: DetourNavMesh.h:339
dtStatus init(const dtNavMeshParams *params)
Initializes the navigation mesh for tiled use.
Definition: DetourNavMesh.cpp:224
dtPolyRef getPolyRefBase(const dtMeshTile *tile) const
Gets the polygon reference for the tile's base polygon.
Definition: DetourNavMesh.cpp:1356
~dtNavMesh()
Definition: DetourNavMesh.cpp:209
dtStatus storeTileState(const dtMeshTile *tile, unsigned char *data, const int maxDataSize) const
Stores the non-structural state of the tile in the specified buffer.
Definition: DetourNavMesh.cpp:1390
dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
Derives a standard polygon reference.
Definition: DetourNavMesh.h:529
int getMaxTiles() const
The maximum number of tiles supported by the navigation mesh.
Definition: DetourNavMesh.cpp:1176
int getTilesAt(const int x, const int y, dtMeshTile const **tiles, const int maxTiles) const
Gets all tiles at the specified grid location.
Definition: DetourNavMesh.cpp:1120
const dtOffMeshConnection * getOffMeshConnectionByRef(dtPolyRef ref) const
Gets the specified off-mesh connection.
Definition: DetourNavMesh.cpp:1502
dtNavMesh()
Definition: DetourNavMesh.cpp:188
dtStatus getTileAndPolyByRef(const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const
Gets the tile and polygon for the specified polygon reference.
Definition: DetourNavMesh.cpp:1197
const dtMeshTile * getTile(int i) const
Gets the tile at the specified index.
Definition: DetourNavMesh.cpp:1186
unsigned int decodePolyIdSalt(dtPolyRef ref) const
Extracts a tile's salt value from the specified polygon reference.
Definition: DetourNavMesh.h:568
dtStatus addTile(unsigned char *data, int dataSize, int flags, dtTileRef lastRef, dtTileRef *result)
Adds a tile to the navigation mesh.
Definition: DetourNavMesh.cpp:908
dtStatus removeTile(dtTileRef ref, unsigned char **data, int *dataSize)
Removes the specified tile from the navigation mesh.
Definition: DetourNavMesh.cpp:1240
dtStatus getOffMeshConnectionPolyEndPoints(dtPolyRef prevRef, dtPolyRef polyRef, float *startPos, float *endPos) const
Gets the endpoints for an off-mesh connection, ordered by "direction of travel".
Definition: DetourNavMesh.cpp:1459
dtTileRef getTileRef(const dtMeshTile *tile) const
Gets the tile reference for the specified tile.
Definition: DetourNavMesh.cpp:1335
void calcTileLoc(const float *pos, int *tx, int *ty) const
Calculates the tile grid location for the specified world position.
Definition: DetourNavMesh.cpp:1191
dtStatus setPolyArea(dtPolyRef ref, unsigned char area)
Sets the user defined area for the specified polygon.
Definition: DetourNavMesh.cpp:1560
bool isValidPolyRef(dtPolyRef ref) const
Checks the validity of a polygon reference.
Definition: DetourNavMesh.cpp:1223
dtTileRef getTileRefAt(int x, int y, int layer) const
Gets the tile reference for the tile at specified grid location.
Definition: DetourNavMesh.cpp:1143
dtStatus getPolyFlags(dtPolyRef ref, unsigned short *resultFlags) const
Gets the user defined flags for the specified polygon.
Definition: DetourNavMesh.cpp:1544
const dtNavMeshParams * getParams() const
The navigation mesh initialization params.
Definition: DetourNavMesh.cpp:294
unsigned int decodePolyIdPoly(dtPolyRef ref) const
Extracts the polygon's index (within its tile) from the specified polygon reference.
Definition: DetourNavMesh.h:598
unsigned int decodePolyIdTile(dtPolyRef ref) const
Extracts the tile's index from the specified polygon reference.
Definition: DetourNavMesh.h:583
dtStatus getPolyArea(dtPolyRef ref, unsigned char *resultArea) const
Gets the user defined area for the specified polygon.
Definition: DetourNavMesh.cpp:1576
int getTileStateSize(const dtMeshTile *tile) const
Gets the size of the buffer required by storeTileState to store the specified tile's state.
Definition: DetourNavMesh.cpp:1377
void getTileAndPolyByRefUnsafe(const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const
Returns the tile and polygon for the specified polygon reference.
Definition: DetourNavMesh.cpp:1215
const dtMeshTile * getTileByRef(dtTileRef ref) const
Gets the tile for the specified tile reference.
Definition: DetourNavMesh.cpp:1162
const dtMeshTile * getTileAt(const int x, const int y, const int layer) const
Gets the tile at the specified grid location.
Definition: DetourNavMesh.cpp:1057
dtStatus restoreTileState(dtMeshTile *tile, const unsigned char *data, const int maxDataSize)
Restores the state of the tile.
Definition: DetourNavMesh.cpp:1422
dtStatus setPolyFlags(dtPolyRef ref, unsigned short flags)
Sets the user defined flags for the specified polygon.
Definition: DetourNavMesh.cpp:1527
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Decodes a standard polygon reference.
Definition: DetourNavMesh.h:545
dtNavMesh * dtAllocNavMesh()
Allocates a navigation mesh object using the Detour allocator.
Definition: DetourNavMesh.cpp:138
unsigned int dtTileRef
A handle to a tile within a navigation mesh.
Definition: DetourNavMesh.h:56
static const int DT_VERTS_PER_POLYGON
The maximum number of vertices per navigation polygon.
Definition: DetourNavMesh.h:61
static const int DT_MAX_AREAS
The maximum number of user defined area ids.
Definition: DetourNavMesh.h:95
unsigned int dtPolyRef
A handle to a polygon within a navigation mesh tile.
Definition: DetourNavMesh.h:48
void dtFreeNavMesh(dtNavMesh *navmesh)
Frees the specified navigation mesh object using the Detour allocator.
Definition: DetourNavMesh.cpp:149
Bounding volume node.
Definition: DetourNavMesh.h:216
unsigned short bmin[3]
Minimum bounds of the node's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:217
int i
The node's index. (Negative for escape sequence.)
Definition: DetourNavMesh.h:219
unsigned short bmax[3]
Maximum bounds of the node's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:218
Defines a link between polygons.
Definition: DetourNavMesh.h:203
unsigned char bmin
If a boundary link, defines the minimum sub-edge area.
Definition: DetourNavMesh.h:208
unsigned char edge
Index of the polygon edge that owns this link.
Definition: DetourNavMesh.h:206
dtPolyRef ref
Neighbour reference. (The neighbor that is linked to.)
Definition: DetourNavMesh.h:204
unsigned int next
Index of the next link.
Definition: DetourNavMesh.h:205
unsigned char side
If a boundary link, defines on which side the link is.
Definition: DetourNavMesh.h:207
unsigned char bmax
If a boundary link, defines the maximum sub-edge area.
Definition: DetourNavMesh.h:209
Defines a navigation mesh tile.
Definition: DetourNavMesh.h:282
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:289
int dataSize
Size of the tile data.
Definition: DetourNavMesh.h:306
dtBVNode * bvTree
The tile bounding volume nodes.
Definition: DetourNavMesh.h:301
unsigned int salt
Counter describing modifications to the tile.
Definition: DetourNavMesh.h:283
unsigned char * detailTris
The detail mesh's triangles.
Definition: DetourNavMesh.h:297
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition: DetourNavMesh.h:308
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:286
float * detailVerts
The detail mesh's unique vertices. [(x, y, z) * dtMeshHeader::detailVertCount].
Definition: DetourNavMesh.h:293
int flags
Tile flags. (See: dtTileFlags)
Definition: DetourNavMesh.h:307
dtPolyDetail * detailMeshes
The tile's detail sub-meshes. [Size: dtMeshHeader::detailMeshCount].
Definition: DetourNavMesh.h:290
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
Definition: DetourNavMesh.h:303
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:287
float * verts
The tile vertices. [(x, y, z) * dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:288
unsigned int linksFreeList
Index to the next free link.
Definition: DetourNavMesh.h:285
unsigned char * data
The tile data. (Not directly accessed under normal situations.)
Definition: DetourNavMesh.h:305
Configuration parameters used to define multi-tile navigation meshes.
Definition: DetourNavMesh.h:328
float orig[3]
The world space origin of the navigation mesh's tile space. [(x, y, z)].
Definition: DetourNavMesh.h:329
int maxPolys
The maximum number of polygons each tile can contain. This and maxTiles are used to calculate how man...
Definition: DetourNavMesh.h:333
float tileWidth
The width of each tile. (Along the x-axis.)
Definition: DetourNavMesh.h:330
float tileHeight
The height of each tile. (Along the z-axis.)
Definition: DetourNavMesh.h:331
int maxTiles
The maximum number of tiles the navigation mesh can contain. This and maxPolys are used to calculate ...
Definition: DetourNavMesh.h:332
Defines an navigation mesh off-mesh connection within a dtMeshTile object.
Definition: DetourNavMesh.h:225
unsigned int userId
The id of the offmesh connection. (User assigned when the navigation mesh is built....
Definition: DetourNavMesh.h:244
float pos[6]
The endpoints of the connection. [(ax, ay, az, bx, by, bz)].
Definition: DetourNavMesh.h:227
unsigned short poly
The polygon reference of the connection within the tile.
Definition: DetourNavMesh.h:233
unsigned char side
End point side.
Definition: DetourNavMesh.h:241
unsigned char flags
Link flags.
Definition: DetourNavMesh.h:238
float rad
The radius of the endpoints. [Limit: >= 0].
Definition: DetourNavMesh.h:230
Defines the location of detail sub-mesh data within a dtMeshTile.
Definition: DetourNavMesh.h:192
unsigned char vertCount
The number of vertices in the sub-mesh.
Definition: DetourNavMesh.h:195
unsigned int triBase
The offset of the triangles in the dtMeshTile::detailTris array.
Definition: DetourNavMesh.h:194
unsigned int vertBase
The offset of the vertices in the dtMeshTile::detailVerts array.
Definition: DetourNavMesh.h:193
unsigned char triCount
The number of triangles in the sub-mesh.
Definition: DetourNavMesh.h:196
Defines a polygon within a dtMeshTile object.
Definition: DetourNavMesh.h:156
unsigned char getType() const
Gets the polygon type. (See: dtPolyTypes)
Definition: DetourNavMesh.h:187
unsigned short flags
The user defined polygon flags.
Definition: DetourNavMesh.h:168
unsigned int firstLink
Index to first link in linked list. (Or DT_NULL_LINK if there is no link.)
Definition: DetourNavMesh.h:158
void setArea(unsigned char a)
Sets the user defined area id. [Limit: < DT_MAX_AREAS].
Definition: DetourNavMesh.h:178
unsigned char getArea() const
Gets the user defined area id.
Definition: DetourNavMesh.h:184
unsigned short neis[DT_VERTS_PER_POLYGON]
Packed data representing neighbor polygons references and flags for each edge.
Definition: DetourNavMesh.h:165
void setType(unsigned char t)
Sets the polygon type. (See: dtPolyTypes.)
Definition: DetourNavMesh.h:181
unsigned short verts[DT_VERTS_PER_POLYGON]
The indices of the polygon's vertices.
Definition: DetourNavMesh.h:162
unsigned char areaAndtype
The bit packed area id and polygon type.
Definition: DetourNavMesh.h:175
unsigned char vertCount
The number of vertices in the polygon.
Definition: DetourNavMesh.h:171