19 #ifndef DETOURNAVMESH_H 20 #define DETOURNAVMESH_H 125 inline void setArea(
unsigned char a) { areaAndtype = (areaAndtype & 0xc0) | (a & 0x3f); }
128 inline void setType(
unsigned char t) { areaAndtype = (areaAndtype & 0x3f) | (t << 6); }
131 inline unsigned char getArea()
const {
return areaAndtype & 0x3f; }
134 inline unsigned char getType()
const {
return areaAndtype >> 6; }
164 unsigned short bmin[3];
165 unsigned short bmax[3];
292 dtStatus init(
unsigned char* data,
const int dataSize,
const int flags);
322 void calcTileLoc(
const float* pos,
int* tx,
int* ty)
const;
329 const dtMeshTile* getTileAt(
const int x,
const int y,
const int layer)
const;
337 int getTilesAt(
const int x,
const int y,
338 dtMeshTile const** tiles,
const int maxTiles)
const;
345 dtTileRef getTileRefAt(
int x,
int y,
int layer)
const;
360 int getMaxTiles()
const;
383 bool isValidPolyRef(
dtPolyRef ref)
const;
436 int getTileStateSize(
const dtMeshTile* tile)
const;
443 dtStatus storeTileState(
const dtMeshTile* tile,
unsigned char* data,
const int maxDataSize)
const;
450 dtStatus restoreTileState(
dtMeshTile* tile,
const unsigned char* data,
const int maxDataSize);
480 salt = (
unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
481 it = (
unsigned int)((ref >> m_polyBits) & tileMask);
482 ip = (
unsigned int)(ref & polyMask);
492 return (
unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
502 return (
unsigned int)((ref >> m_polyBits) & tileMask);
512 return (
unsigned int)(ref & polyMask);
523 int getTilesAt(
const int x,
const int y,
524 dtMeshTile** tiles,
const int maxTiles)
const;
527 int getNeighbourTilesAt(
const int x,
const int y,
const int side,
528 dtMeshTile** tiles,
const int maxTiles)
const;
531 int findConnectingPolys(
const float* va,
const float* vb,
533 dtPolyRef* con,
float* conarea,
int maxcon)
const;
552 int queryPolygonsInTile(
const dtMeshTile* tile,
const float* qmin,
const float* qmax,
553 dtPolyRef* polys,
const int maxPolys)
const;
556 const float* extents,
float* nearestPt)
const;
558 void closestPointOnPolyInTile(
const dtMeshTile* tile,
unsigned int ip,
559 const float* pos,
float* closest)
const;
563 float m_tileWidth, m_tileHeight;
572 unsigned int m_saltBits;
573 unsigned int m_tileBits;
574 unsigned int m_polyBits;
587 #endif // DETOURNAVMESH_H unsigned int decodePolyIdTile(dtPolyRef ref) const
Extracts the tile's index from the specified polygon reference.
The navigation mesh owns the tile memory and is responsible for freeing it.
unsigned int dtPolyRef
A handle to a polygon within a navigation mesh tile.
unsigned char areaAndtype
The bit packed area id and polygon type.
dtMeshHeader * header
The tile header.
unsigned short poly
The polygon reference of the connection within the tile.
dtStraightPathFlags
Vertex flags returned by dtNavMeshQuery::findStraightPath.
unsigned int dtTileRef
A handle to a tile within a navigation mesh.
unsigned int next
Index of the next link.
unsigned char side
End point side.
Defines the location of detail sub-mesh data within a dtMeshTile.
unsigned int decodePolyIdSalt(dtPolyRef ref) const
Extracts a tile's salt value from the specified polygon reference.
unsigned short flags
The user defined polygon flags.
static const int DT_NAVMESH_STATE_VERSION
A version number used to detect compatibility of navigation tile states.
unsigned char triCount
The number of triangles in the sub-mesh.
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
unsigned char getArea() const
Gets the user defined area id.
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Decodes a standard polygon reference.
unsigned char flags
Link flags.
void setArea(unsigned char a)
Sets the user defined area id. [Limit: < DT_MAX_AREAS].
unsigned char side
If a boundary link, defines on which side the link is.
dtBVNode * bvTree
The tile bounding volume nodes. Size: dtMeshHeader::bvNodeCount
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.)
unsigned short verts[DT_VERTS_PER_POLYGON]
The indices of the polygon's vertices. The actual vertices are located in dtMeshTile::verts.
void dtFreeNavMesh(dtNavMesh *navmesh)
Frees the specified navigation mesh object using the Detour allocator.
unsigned char vertCount
The number of vertices in the sub-mesh.
dtPolyTypes
Flags representing the type of a navigation mesh polygon.
The vertex is the start position in the path.
unsigned int userId
The id of the offmesh connection. (User assigned when the navigation mesh is built.)
A navigation mesh based on tiles of convex polygons.
int i
The node's index. (Negative for escape sequence.)
unsigned int vertBase
The offset of the vertices in the dtMeshTile::detailVerts array.
int flags
Tile flags. (See: dtTileFlags)
unsigned char getType() const
Gets the polygon type. (See: dtPolyTypes)
unsigned short neis[DT_VERTS_PER_POLYGON]
Packed data representing neighbor polygons references and flags for each edge.
static const int DT_MAX_AREAS
The maximum number of user defined area ids.
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
The vertex is the end position in the path.
Defines a polyogn within a dtMeshTile object.
float rad
The radius of the endpoints. [Limit: >= 0].
dtTileFlags
Tile flags used for various functions and fields. For an example, see dtNavMesh::addTile().
unsigned int linksFreeList
Index to the next free link.
unsigned int salt
Counter describing modifications to the tile.
unsigned char edge
Index of the polygon edge that owns this link.
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
int dataSize
Size of the tile data.
float * detailVerts
The detail mesh's unique vertices. [(x, y, z) * dtMeshHeader::detailVertCount].
unsigned char * detailTris
The detail mesh's triangles. [(vertA, vertB, vertC) * dtMeshHeader::detailTriCount].
static const unsigned short DT_EXT_LINK
A flag that indicates that an entity links to an external entity. (E.g. A polygon edge is a portal th...
unsigned int decodePolyIdPoly(dtPolyRef ref) const
Extracts the polygon's index (within its tile) from the specified polygon reference.
unsigned char bmin
If a boundary link, defines the minimum sub-edge area.
dtPolyDetail * detailMeshes
The tile's detail sub-meshes. [Size: dtMeshHeader::detailMeshCount].
int maxPolys
The maximum number of polygons each tile can contain.
unsigned char * data
The tile data. (Not directly accessed under normal situations.)
float tileWidth
The width of each tile. (Along the x-axis.)
dtPolyRef ref
Neighbour reference. (The neighbor that is linked to.)
The polygon is an off-mesh connection consisting of two vertices.
unsigned int firstLink
Index to first link in linked list. (Or DT_NULL_LINK if there is no link.)
static const int DT_NAVMESH_STATE_MAGIC
A magic number used to detect the compatibility of navigation tile states.
Configuration parameters used to define multi-tile navigation meshes. The values are used to allocate...
unsigned char vertCount
The number of vertices in the polygon.
dtNavMesh * dtAllocNavMesh()
Allocates a navigation mesh object using the Detour allocator.
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
float tileHeight
The height of each tile. (Along the z-axis.)
unsigned int triBase
The offset of the triangles in the dtMeshTile::detailTris array.
unsigned char bmax
If a boundary link, defines the maximum sub-edge area.
dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
Derives a standard polygon reference.
static const int DT_NAVMESH_MAGIC
A magic number used to detect compatibility of navigation tile data.
Defines a navigation mesh tile.
int maxTiles
The maximum number of tiles the navigation mesh can contain.
The vertex is the start of an off-mesh connection.
void setType(unsigned char t)
Sets the polygon type. (See: dtPolyTypes.)
static const int DT_NAVMESH_VERSION
A version number used to detect compatibility of navigation tile data.
The polygon is a standard convex polygon that is part of the surface of the mesh. ...
Defines a link between polygons.
Defines an navigation mesh off-mesh connection within a dtMeshTile object. An off-mesh connection is ...
static const int DT_VERTS_PER_POLYGON
The maximum number of vertices per navigation polygon.
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.