19 #ifndef DETOURNAVMESH_H
20 #define DETOURNAVMESH_H
22 #include "SharedConfig.h"
39 static const unsigned int DT_SALT_BITS = 16;
40 static const unsigned int DT_TILE_BITS = 28;
41 static const unsigned int DT_POLY_BITS = 20;
348 dtStatus init(
unsigned char* data,
const int dataSize,
const int flags);
378 void calcTileLoc(
const float* pos,
int* tx,
int* ty)
const;
394 dtMeshTile const** tiles,
const int maxTiles)
const;
535 salt = (
unsigned int)((ref >> (DT_POLY_BITS+DT_TILE_BITS)) & saltMask);
536 it = (
unsigned int)((ref >> DT_POLY_BITS) & tileMask);
537 ip = (
unsigned int)(ref & polyMask);
542 salt = (
unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
543 it = (
unsigned int)((ref >> m_polyBits) & tileMask);
544 ip = (
unsigned int)(ref & polyMask);
556 return (
unsigned int)((ref >> (DT_POLY_BITS+DT_TILE_BITS)) & saltMask);
559 return (
unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
571 return (
unsigned int)((ref >> DT_POLY_BITS) & tileMask);
574 return (
unsigned int)((ref >> m_polyBits) & tileMask);
586 return (
unsigned int)(ref & polyMask);
589 return (
unsigned int)(ref & polyMask);
603 dtMeshTile** tiles,
const int maxTiles)
const;
606 int getNeighbourTilesAt(
const int x,
const int y,
const int side,
607 dtMeshTile** tiles,
const int maxTiles)
const;
610 int findConnectingPolys(
const float* va,
const float* vb,
612 dtPolyRef* con,
float* conarea,
int maxcon)
const;
631 int queryPolygonsInTile(
const dtMeshTile* tile,
const float* qmin,
const float* qmax,
632 dtPolyRef* polys,
const int maxPolys)
const;
635 const float* extents,
float* nearestPt)
const;
637 void closestPointOnPoly(
dtPolyRef ref,
const float* pos,
float* closest,
bool* posOverPoly)
const;
641 float m_tileWidth, m_tileHeight;
651 unsigned int m_saltBits;
652 unsigned int m_tileBits;
653 unsigned int m_polyBits;
667 #endif // DETOURNAVMESH_H
unsigned int decodePolyIdTile(dtPolyRef ref) const
Extracts the tile's index from the specified polygon reference.
Definition: DetourNavMesh.h:567
The navigation mesh owns the tile memory and is responsible for freeing it.
Definition: DetourNavMesh.h:103
dtTileRef getTileRef(const dtMeshTile *tile) const
Gets the tile reference for the specified tile.
Definition: DetourNavMesh.cpp:1298
unsigned int dtPolyRef
A handle to a polygon within a navigation mesh tile.
Definition: DetourNavMesh.h:44
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:287
unsigned short poly
The polygon reference of the connection within the tile.
Definition: DetourNavMesh.h:234
dtStraightPathOptions
Options for dtNavMeshQuery::findStraightPath.
Definition: DetourNavMesh.h:115
dtStraightPathFlags
Vertex flags returned by dtNavMeshQuery::findStraightPath.
Definition: DetourNavMesh.h:107
unsigned int dtTileRef
A handle to a tile within a navigation mesh.
Definition: DetourNavMesh.h:52
unsigned short bmax[3]
Maximum bounds of the node's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:219
unsigned int next
Index of the next link.
Definition: DetourNavMesh.h:206
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:139
[provisional] trade quality for performance far from the origin. The idea is that by then a new query...
Definition: DetourNavMesh.h:126
unsigned char side
End point side.
Definition: DetourNavMesh.h:242
Defines the location of detail sub-mesh data within a dtMeshTile.
Definition: DetourNavMesh.h:192
unsigned int decodePolyIdSalt(dtPolyRef ref) const
Extracts a tile's salt value from the specified polygon reference.
Definition: DetourNavMesh.h:552
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:1419
dtStatus init(const dtNavMeshParams *params)
Initializes the navigation mesh for tiled use.
Definition: DetourNavMesh.cpp:224
static const int DT_NAVMESH_STATE_VERSION
A version number used to detect compatibility of navigation tile states.
Definition: DetourNavMesh.h:84
float orig[3]
The world space origin of the navigation mesh's tile space. [(x, y, z)].
Definition: DetourNavMesh.h:317
unsigned char triCount
The number of triangles in the sub-mesh.
Definition: DetourNavMesh.h:197
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
Definition: DetourNavMesh.h:303
bool isValidPolyRef(dtPolyRef ref) const
Checks the validity of a polygon reference.
Definition: DetourNavMesh.cpp:1185
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:1177
const dtNavMeshParams * getParams() const
The navigation mesh initialization params.
Definition: DetourNavMesh.cpp:294
float teamCost[DT_MAX_TEAMS]
Definition: DetourNavMesh.h:176
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Decodes a standard polygon reference.
Definition: DetourNavMesh.h:529
unsigned char flags
Link flags.
Definition: DetourNavMesh.h:239
dtStatus addTile(unsigned char *data, int dataSize, int flags, dtTileRef lastRef, dtTileRef *result)
Adds a tile to the navigation mesh.
Definition: DetourNavMesh.cpp:841
dtStatus getPolyFlags(dtPolyRef ref, navAreaMask *resultFlags) const
Gets the user defined flags for the specified polygon.
Definition: DetourNavMesh.cpp:1504
Raycast should calculate movement cost along the ray and fill RaycastHit::cost.
Definition: DetourNavMesh.h:133
unsigned char side
If a boundary link, defines on which side the link is.
Definition: DetourNavMesh.h:208
const dtMeshTile * getTileByRef(dtTileRef ref) const
Gets the tile for the specified tile reference.
Definition: DetourNavMesh.cpp:1110
dtBVNode * bvTree
The tile bounding volume nodes.
Definition: DetourNavMesh.h:301
static const unsigned int DT_OFFMESH_CON_BIDIR
A flag that indicates that an off-mesh connection can be traversed in both directions. (Is bidirectional.)
Definition: DetourNavMesh.h:96
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:1352
unsigned short verts[DT_VERTS_PER_POLYGON]
The indices of the polygon's vertices.
Definition: DetourNavMesh.h:160
navAreaMask areaMask
The user defined polygon flags.
Definition: DetourNavMesh.h:166
const dtOffMeshConnection * getOffMeshConnectionByRef(dtPolyRef ref) const
Gets the specified off-mesh connection.
Definition: DetourNavMesh.cpp:1462
unsigned int dtStatus
Definition: DetourStatus.h:22
unsigned char polyType
The bit packed area id and polygon type.
Definition: DetourNavMesh.h:173
void setTeamCost(dtTeam team, float cost)
Sets the polygon type. (See: dtPolyTypes.)
Definition: DetourNavMesh.h:185
void dtFreeNavMesh(dtNavMesh *navmesh)
Frees the specified navigation mesh object using the Detour allocator.
Definition: DetourNavMesh.cpp:149
unsigned char vertCount
The number of vertices in the sub-mesh.
Definition: DetourNavMesh.h:196
dtPolyTypes
Flags representing the type of a navigation mesh polygon.
Definition: DetourNavMesh.h:142
dtNavMesh()
Definition: DetourNavMesh.cpp:188
The vertex is the start position in the path.
Definition: DetourNavMesh.h:109
unsigned int userId
The id of the offmesh connection. (User assigned when the navigation mesh is built.)
Definition: DetourNavMesh.h:245
A navigation mesh based on tiles of convex polygons.
Definition: DetourNavMesh.h:328
int i
The node's index. (Negative for escape sequence.)
Definition: DetourNavMesh.h:220
Bounding volume node.
Definition: DetourNavMesh.h:216
unsigned int vertBase
The offset of the vertices in the dtMeshTile::detailVerts array.
Definition: DetourNavMesh.h:194
int flags
Tile flags. (See: dtTileFlags)
Definition: DetourNavMesh.h:307
unsigned short bmin[3]
Minimum bounds of the node's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:218
unsigned short neis[DT_VERTS_PER_POLYGON]
Packed data representing neighbor polygons references and flags for each edge.
Definition: DetourNavMesh.h:163
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition: DetourNavMesh.h:308
dtStatus setPolyTeamCost(dtPolyRef ref, dtTeam team, float cost)
Definition: DetourNavMesh.cpp:1538
The vertex is the end position in the path.
Definition: DetourNavMesh.h:110
dtStatus restoreTileState(dtMeshTile *tile, const unsigned char *data, const int maxDataSize)
Restores the state of the tile.
Definition: DetourNavMesh.cpp:1383
Definition: DetourNavMesh.h:63
Defines a polyogn within a dtMeshTile object.
Definition: DetourNavMesh.h:153
float rad
The radius of the endpoints. [Limit: >= 0].
Definition: DetourNavMesh.h:231
dtTileFlags
Tile flags used for various functions and fields.
Definition: DetourNavMesh.h:100
Add a vertex at every polygon edge crossing.
Definition: DetourNavMesh.h:119
unsigned int linksFreeList
Index to the next free link.
Definition: DetourNavMesh.h:286
dtStatus getPolyTeamCost(dtPolyRef ref, dtTeam team, float *costResult) const
Definition: DetourNavMesh.cpp:1555
unsigned int salt
Counter describing modifications to the tile.
Definition: DetourNavMesh.h:284
dtFindPathOptions
Options for dtNavMeshQuery::findPath.
Definition: DetourNavMesh.h:124
unsigned char edge
Index of the polygon edge that owns this link.
Definition: DetourNavMesh.h:207
~dtNavMesh()
Definition: DetourNavMesh.cpp:209
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:1159
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:289
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:290
int dataSize
Size of the tile data.
Definition: DetourNavMesh.h:306
float * detailVerts
The detail mesh's unique vertices. [(x, y, z) * dtMeshHeader::detailVertCount].
Definition: DetourNavMesh.h:294
unsigned char * detailTris
The detail mesh's triangles. [(vertA, vertB, vertC) * dtMeshHeader::detailTriCount].
Definition: DetourNavMesh.h:297
void queryTiles(const float mins[3], const float maxs[3], dtTileCallback callback, void *userdata) const
Definition: DetourNavMesh.cpp:1065
static const unsigned short DT_EXT_LINK
A flag that indicates that an entity links to an external entity.
Definition: DetourNavMesh.h:90
Definition: DetourNavMesh.h:117
void setPolyType(unsigned char t)
Sets the polygon type. (See: dtPolyTypes.)
Definition: DetourNavMesh.h:179
unsigned int decodePolyIdPoly(dtPolyRef ref) const
Extracts the polygon's index (within its tile) from the specified polygon reference.
Definition: DetourNavMesh.h:582
unsigned char bmin
If a boundary link, defines the minimum sub-edge area.
Definition: DetourNavMesh.h:209
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:1339
dtStatus setPolyFlags(dtPolyRef ref, navAreaMask areaMask)
Sets the user defined flags for the specified polygon.
Definition: DetourNavMesh.cpp:1487
dtPolyDetail * detailMeshes
The tile's detail sub-meshes. [Size: dtMeshHeader::detailMeshCount].
Definition: DetourNavMesh.h:291
int maxPolys
The maximum number of polygons each tile can contain.
Definition: DetourNavMesh.h:321
Add a vertex at every polygon edge crossing where area changes.
Definition: DetourNavMesh.h:118
const dtMeshTile * getTile(int i) const
Gets the tile at the specified index.
Definition: DetourNavMesh.cpp:1148
use raycasts during pathfind to "shortcut" (raycast still consider costs)
Definition: DetourNavMesh.h:127
void calcTileLoc(const float *pos, int *tx, int *ty) const
Calculates the tile grid location for the specified world position.
Definition: DetourNavMesh.cpp:1153
unsigned char * data
The tile data. (Not directly accessed under normal situations.)
Definition: DetourNavMesh.h:305
float tileWidth
The width of each tile. (Along the x-axis.)
Definition: DetourNavMesh.h:318
dtPolyRef ref
Neighbour reference. (The neighbor that is linked to.)
Definition: DetourNavMesh.h:205
Definition: DetourNavMesh.h:64
The polygon is an off-mesh connection consisting of two vertices.
Definition: DetourNavMesh.h:147
unsigned int firstLink
Index to first link in linked list. (Or DT_NULL_LINK if there is no link.)
Definition: DetourNavMesh.h:156
dtPolyRef getPolyRefBase(const dtMeshTile *tile) const
Gets the polygon reference for the tile's base polygon.
Definition: DetourNavMesh.cpp:1319
static const int DT_NAVMESH_STATE_MAGIC
A magic number used to detect the compatibility of navigation tile states.
Definition: DetourNavMesh.h:81
Configuration parameters used to define multi-tile navigation meshes.
Definition: DetourNavMesh.h:315
unsigned char vertCount
The number of vertices in the polygon.
Definition: DetourNavMesh.h:169
dtNavMesh * dtAllocNavMesh()
Allocates a navigation mesh object using the Detour allocator.
Definition: DetourNavMesh.cpp:138
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:288
float tileHeight
The height of each tile. (Along the z-axis.)
Definition: DetourNavMesh.h:319
unsigned int triBase
The offset of the triangles in the dtMeshTile::detailTris array.
Definition: DetourNavMesh.h:195
unsigned char bmax
If a boundary link, defines the maximum sub-edge area.
Definition: DetourNavMesh.h:210
dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
Derives a standard polygon reference.
Definition: DetourNavMesh.h:513
static const int DT_NAVMESH_MAGIC
A magic number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:75
dtRaycastOptions
Options for dtNavMeshQuery::raycast.
Definition: DetourNavMesh.h:131
Defines a navigation mesh tile.
Definition: DetourNavMesh.h:282
Definition: DetourNavMesh.h:61
int maxTiles
The maximum number of tiles the navigation mesh can contain.
Definition: DetourNavMesh.h:320
float pos[6]
The endpoints of the connection. [(ax, ay, az, bx, by, bz)].
Definition: DetourNavMesh.h:228
dtStatus removeTile(dtTileRef ref, unsigned char **data, int *dataSize)
Removes the specified tile from the navigation mesh.
Definition: DetourNavMesh.cpp:1202
Definition: DetourNavMesh.h:65
The vertex is the start of an off-mesh connection.
Definition: DetourNavMesh.h:111
dtTileRef getTileRefAt(int x, int y, int layer) const
Gets the tile reference for the tile at specified grid location.
Definition: DetourNavMesh.cpp:1091
dtStatus addPolyTeamCost(dtPolyRef ref, dtTeam team, float cost)
Definition: DetourNavMesh.cpp:1521
void(* dtTileCallback)(const dtMeshTile *tile, void *userdata)
Definition: DetourNavMesh.h:324
static const int DT_NAVMESH_VERSION
A version number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:78
const dtMeshTile * getTileAt(const int x, const int y, const int layer) const
Gets the tile at the specified grid location.
Definition: DetourNavMesh.cpp:980
The polygon is a standard convex polygon that is part of the surface of the mesh. ...
Definition: DetourNavMesh.h:145
Definition: DetourNavMesh.h:62
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:1043
Defines a link between polygons.
Definition: DetourNavMesh.h:203
Defines an navigation mesh off-mesh connection within a dtMeshTile object.
Definition: DetourNavMesh.h:225
unsigned char getPolyType() const
Gets the polygon type. (See: dtPolyTypes)
Definition: DetourNavMesh.h:182
int getMaxTiles() const
The maximum number of tiles supported by the navigation mesh.
Definition: DetourNavMesh.cpp:1138
dtTeam
Definition: DetourNavMesh.h:59
static const int DT_VERTS_PER_POLYGON
The maximum number of vertices per navigation polygon.
Definition: DetourNavMesh.h:57
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:93
float getTeamCost(dtTeam team) const
Gets the polygon type. (See: dtPolyTypes)
Definition: DetourNavMesh.h:188