TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
dtNavMesh Class Reference

#include <DetourNavMesh.h>

Public Member Functions

 dtNavMesh ()
 
 ~dtNavMesh ()
 
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. More...
 
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 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
 
dtStatus getOffMeshConnectionPolyEndPoints (dtPolyRef prevRef, dtPolyRef polyRef, float *startPos, float *endPos) const
 
const dtOffMeshConnectiongetOffMeshConnectionByRef (dtPolyRef ref) const
 
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
 

Private Member Functions

dtMeshTilegetTile (int i)
 Returns pointer to tile in the tile array. More...
 
int getTilesAt (const int x, const int y, dtMeshTile **tiles, const int maxTiles) const
 Returns neighbour tile based on side. More...
 
int getNeighbourTilesAt (const int x, const int y, const int side, dtMeshTile **tiles, const int maxTiles) const
 Returns neighbour tile based on side. More...
 
int findConnectingPolys (const float *va, const float *vb, const dtMeshTile *tile, int side, dtPolyRef *con, float *conarea, int maxcon) const
 Returns all polygons in neighbour tile based on portal defined by the segment. More...
 
void connectIntLinks (dtMeshTile *tile)
 Builds internal polygons links for a tile. More...
 
void baseOffMeshLinks (dtMeshTile *tile)
 Builds internal polygons links for a tile. More...
 
void connectExtLinks (dtMeshTile *tile, dtMeshTile *target, int side)
 Builds external polygon links for a tile. More...
 
void connectExtOffMeshLinks (dtMeshTile *tile, dtMeshTile *target, int side)
 Builds external polygon links for a tile. More...
 
void unconnectExtLinks (dtMeshTile *tile, dtMeshTile *target)
 Removes external links at specified side. More...
 
int queryPolygonsInTile (const dtMeshTile *tile, const float *qmin, const float *qmax, dtPolyRef *polys, const int maxPolys) const
 Queries polygons within a tile. More...
 
dtPolyRef findNearestPolyInTile (const dtMeshTile *tile, const float *center, const float *extents, float *nearestPt) const
 Find nearest polygon within a tile. More...
 
void closestPointOnPoly (dtPolyRef ref, const float *pos, float *closest, bool *posOverPoly) const
 Returns closest point on polygon. More...
 

Private Attributes

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

Detailed Description

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:

  1. Create rcPolyMesh and rcPolyMeshDetail data using the Recast build pipeline.
  2. Optionally, create off-mesh connection data.
  3. Combine the source data into a dtNavMeshCreateParams structure.
  4. Create a tile data array using dtCreateNavMeshData().
  5. Allocate at dtNavMesh object and initialize it. (For single tile navigation meshes, the tile data is loaded during this step.)
  6. 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.
See also
dtNavMeshQuery, dtCreateNavMeshData, dtNavMeshCreateParams, dtAllocNavMesh, dtFreeNavMesh

Constructor & Destructor Documentation

dtNavMesh::dtNavMesh ( )
188  :
189  m_tileWidth(0),
190  m_tileHeight(0),
191  m_maxTiles(0),
192  m_tileLutSize(0),
193  m_tileLutMask(0),
194  m_posLookup(0),
195  m_nextFree(0),
196  m_tiles(0),
197  m_saltBits(0),
198  m_tileBits(0),
199  m_polyBits(0)
200 {
201  memset(&m_params, 0, sizeof(dtNavMeshParams));
202  m_orig[0] = 0;
203  m_orig[1] = 0;
204  m_orig[2] = 0;
205 }
dtMeshTile ** m_posLookup
Tile hash lookup.
Definition: DetourNavMesh.h:618
dtNavMeshParams m_params
Current initialization params. TODO: do not store this info twice.
Definition: DetourNavMesh.h:611
float m_tileHeight
Dimensions of each tile.
Definition: DetourNavMesh.h:613
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
float m_orig[3]
Origin of the tile (0,0)
Definition: DetourNavMesh.h:612
float m_tileWidth
Definition: DetourNavMesh.h:613
unsigned int m_tileBits
Number of tile bits in the tile ID.
Definition: DetourNavMesh.h:623
int m_tileLutMask
Tile hash lookup mask.
Definition: DetourNavMesh.h:616
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
unsigned int m_polyBits
Number of poly bits in the tile ID.
Definition: DetourNavMesh.h:624
unsigned int m_saltBits
Number of salt bits in the tile ID.
Definition: DetourNavMesh.h:622
int m_tileLutSize
Tile hash lookup size (must be pot).
Definition: DetourNavMesh.h:615
dtMeshTile * m_nextFree
Freelist of tiles.
Definition: DetourNavMesh.h:619
Definition: DetourNavMesh.h:312
dtNavMesh::~dtNavMesh ( )
208 {
209  for (int i = 0; i < m_maxTiles; ++i)
210  {
212  {
213  dtFree(m_tiles[i].data);
214  m_tiles[i].data = 0;
215  m_tiles[i].dataSize = 0;
216  }
217  }
219  dtFree(m_tiles);
220 }
The navigation mesh owns the tile memory and is responsible for freeing it.
Definition: DetourNavMesh.h:104
dtMeshTile ** m_posLookup
Tile hash lookup.
Definition: DetourNavMesh.h:618
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
int dataSize
Size of the tile data.
Definition: DetourNavMesh.h:303
unsigned char * data
The tile data. (Not directly accessed under normal situations.)
Definition: DetourNavMesh.h:302
uint8 flags
Definition: DisableMgr.cpp:44
void dtFree(void *ptr)
Definition: DetourAlloc.cpp:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Function Documentation

dtStatus 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.

The add operation will fail if the data is in the wrong format, the allocated tile space is full, or there is a tile already at the specified reference.

The lastRef parameter is used to restore a tile with the same tile reference it had previously used. In this case the dtPolyRef's for the tile will be restored to the same values they were before the tile was removed.

See also
dtCreateNavMeshData, removeTile
836 {
837  // Make sure the data is in right format.
838  dtMeshHeader* header = (dtMeshHeader*)data;
839  if (header->magic != DT_NAVMESH_MAGIC)
840  return DT_FAILURE | DT_WRONG_MAGIC;
841  if (header->version != DT_NAVMESH_VERSION)
842  return DT_FAILURE | DT_WRONG_VERSION;
843 
844  // Make sure the location is free.
845  if (getTileAt(header->x, header->y, header->layer))
846  return DT_FAILURE;
847 
848  // Allocate a tile.
849  dtMeshTile* tile = 0;
850  if (!lastRef)
851  {
852  if (m_nextFree)
853  {
854  tile = m_nextFree;
855  m_nextFree = tile->next;
856  tile->next = 0;
857  }
858  }
859  else
860  {
861  // Try to relocate the tile to specific index with same salt.
862  int tileIndex = (int)decodePolyIdTile((dtPolyRef)lastRef);
863  if (tileIndex >= m_maxTiles)
864  return DT_FAILURE | DT_OUT_OF_MEMORY;
865  // Try to find the specific tile id from the free list.
866  dtMeshTile* target = &m_tiles[tileIndex];
867  dtMeshTile* prev = 0;
868  tile = m_nextFree;
869  while (tile && tile != target)
870  {
871  prev = tile;
872  tile = tile->next;
873  }
874  // Could not find the correct location.
875  if (tile != target)
876  return DT_FAILURE | DT_OUT_OF_MEMORY;
877  // Remove from freelist
878  if (!prev)
879  m_nextFree = tile->next;
880  else
881  prev->next = tile->next;
882 
883  // Restore salt.
884  tile->salt = decodePolyIdSalt((dtPolyRef)lastRef);
885  }
886 
887  // Make sure we could allocate a tile.
888  if (!tile)
889  return DT_FAILURE | DT_OUT_OF_MEMORY;
890 
891  // Insert tile into the position lut.
892  int h = computeTileHash(header->x, header->y, m_tileLutMask);
893  tile->next = m_posLookup[h];
894  m_posLookup[h] = tile;
895 
896  // Patch header pointers.
897  const int headerSize = dtAlign4(sizeof(dtMeshHeader));
898  const int vertsSize = dtAlign4(sizeof(float)*3*header->vertCount);
899  const int polysSize = dtAlign4(sizeof(dtPoly)*header->polyCount);
900  const int linksSize = dtAlign4(sizeof(dtLink)*(header->maxLinkCount));
901  const int detailMeshesSize = dtAlign4(sizeof(dtPolyDetail)*header->detailMeshCount);
902  const int detailVertsSize = dtAlign4(sizeof(float)*3*header->detailVertCount);
903  const int detailTrisSize = dtAlign4(sizeof(unsigned char)*4*header->detailTriCount);
904  const int bvtreeSize = dtAlign4(sizeof(dtBVNode)*header->bvNodeCount);
905  const int offMeshLinksSize = dtAlign4(sizeof(dtOffMeshConnection)*header->offMeshConCount);
906 
907  unsigned char* d = data + headerSize;
908  tile->verts = (float*)d; d += vertsSize;
909  tile->polys = (dtPoly*)d; d += polysSize;
910  tile->links = (dtLink*)d; d += linksSize;
911  tile->detailMeshes = (dtPolyDetail*)d; d += detailMeshesSize;
912  tile->detailVerts = (float*)d; d += detailVertsSize;
913  tile->detailTris = (unsigned char*)d; d += detailTrisSize;
914  tile->bvTree = (dtBVNode*)d; d += bvtreeSize;
915  tile->offMeshCons = (dtOffMeshConnection*)d; d += offMeshLinksSize;
916 
917  // If there are no items in the bvtree, reset the tree pointer.
918  if (!bvtreeSize)
919  tile->bvTree = 0;
920 
921  // Build links freelist
922  tile->linksFreeList = 0;
923  tile->links[header->maxLinkCount-1].next = DT_NULL_LINK;
924  for (int i = 0; i < header->maxLinkCount-1; ++i)
925  tile->links[i].next = i+1;
926 
927  // Init tile.
928  tile->header = header;
929  tile->data = data;
930  tile->dataSize = dataSize;
931  tile->flags = flags;
932 
933  connectIntLinks(tile);
934  baseOffMeshLinks(tile);
935 
936  // Create connections with neighbour tiles.
937  static const int MAX_NEIS = 32;
938  dtMeshTile* neis[MAX_NEIS];
939  int nneis;
940 
941  // Connect with layers in current tile.
942  nneis = getTilesAt(header->x, header->y, neis, MAX_NEIS);
943  for (int j = 0; j < nneis; ++j)
944  {
945  if (neis[j] != tile)
946  {
947  connectExtLinks(tile, neis[j], -1);
948  connectExtLinks(neis[j], tile, -1);
949  }
950  connectExtOffMeshLinks(tile, neis[j], -1);
951  connectExtOffMeshLinks(neis[j], tile, -1);
952  }
953 
954  // Connect with neighbour tiles.
955  for (int i = 0; i < 8; ++i)
956  {
957  nneis = getNeighbourTilesAt(header->x, header->y, i, neis, MAX_NEIS);
958  for (int j = 0; j < nneis; ++j)
959  {
960  connectExtLinks(tile, neis[j], i);
961  connectExtLinks(neis[j], tile, dtOppositeTile(i));
962  connectExtOffMeshLinks(tile, neis[j], i);
963  connectExtOffMeshLinks(neis[j], tile, dtOppositeTile(i));
964  }
965  }
966 
967  if (result)
968  *result = getTileRef(tile);
969 
970  return DT_SUCCESS;
971 }
unsigned int decodePolyIdTile(dtPolyRef ref) const
Definition: DetourNavMesh.h:550
dtTileRef getTileRef(const dtMeshTile *tile) const
Definition: DetourNavMesh.cpp:1248
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
static const unsigned int DT_WRONG_VERSION
Definition: DetourStatus.h:32
dtMeshTile ** m_posLookup
Tile hash lookup.
Definition: DetourNavMesh.h:618
void connectIntLinks(dtMeshTile *tile)
Builds internal polygons links for a tile.
Definition: DetourNavMesh.cpp:517
Defines the location of detail sub-mesh data within a dtMeshTile.
Definition: DetourNavMesh.h:189
unsigned int decodePolyIdSalt(dtPolyRef ref) const
Definition: DetourNavMesh.h:540
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
Definition: DetourNavMesh.h:300
void baseOffMeshLinks(dtMeshTile *tile)
Builds internal polygons links for a tile.
Definition: DetourNavMesh.cpp:554
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
int offMeshConCount
The number of off-mesh connections.
Definition: DetourNavMesh.h:265
dtBVNode * bvTree
Definition: DetourNavMesh.h:298
int detailMeshCount
The number of sub-meshes in the detail mesh.
Definition: DetourNavMesh.h:258
static const unsigned int DT_WRONG_MAGIC
Definition: DetourStatus.h:31
int m_tileLutMask
Tile hash lookup mask.
Definition: DetourNavMesh.h:616
Definition: DetourNavMesh.h:213
int layer
The layer of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:253
int flags
Tile flags. (See: dtTileFlags)
Definition: DetourNavMesh.h:304
Definition: DetourNavMesh.h:247
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition: DetourNavMesh.h:305
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
int bvNodeCount
The number of bounding volume nodes. (Zero if bounding volumes are disabled.)
Definition: DetourNavMesh.h:264
int x
The x-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:251
unsigned int linksFreeList
Index to the next free link.
Definition: DetourNavMesh.h:283
unsigned int salt
Counter describing modifications to the tile.
Definition: DetourNavMesh.h:281
int version
Tile data format version number.
Definition: DetourNavMesh.h:250
int detailVertCount
The number of unique vertices in the detail mesh. (In addition to the polygon vertices.)
Definition: DetourNavMesh.h:261
int maxLinkCount
The number of allocated links.
Definition: DetourNavMesh.h:257
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:286
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:287
int dataSize
Size of the tile data.
Definition: DetourNavMesh.h:303
float * detailVerts
The detail mesh's unique vertices. [(x, y, z) * dtMeshHeader::detailVertCount].
Definition: DetourNavMesh.h:291
void connectExtOffMeshLinks(dtMeshTile *tile, dtMeshTile *target, int side)
Builds external polygon links for a tile.
Definition: DetourNavMesh.cpp:447
unsigned char * detailTris
The detail mesh's triangles. [(vertA, vertB, vertC) * dtMeshHeader::detailTriCount].
Definition: DetourNavMesh.h:294
dtMeshTile * m_nextFree
Freelist of tiles.
Definition: DetourNavMesh.h:619
dtPolyDetail * detailMeshes
The tile's detail sub-meshes. [Size: dtMeshHeader::detailMeshCount].
Definition: DetourNavMesh.h:288
void connectExtLinks(dtMeshTile *tile, dtMeshTile *target, int side)
Builds external polygon links for a tile.
Definition: DetourNavMesh.cpp:380
int magic
Tile magic number. (Used to identify the data format.)
Definition: DetourNavMesh.h:249
int dtAlign4(int x)
Definition: DetourCommon.h:441
int detailTriCount
The number of triangles in the detail mesh.
Definition: DetourNavMesh.h:263
unsigned char * data
The tile data. (Not directly accessed under normal situations.)
Definition: DetourNavMesh.h:302
int prev(int i, int n)
Definition: RecastContour.cpp:468
int computeTileHash(int x, int y, const int mask)
Definition: DetourNavMesh.cpp:114
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
int getNeighbourTilesAt(const int x, const int y, const int side, dtMeshTile **tiles, const int maxTiles) const
Returns neighbour tile based on side.
Definition: DetourNavMesh.cpp:992
int dtOppositeTile(int side)
Definition: DetourCommon.h:443
static const int DT_NAVMESH_MAGIC
A magic number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:66
uint8 flags
Definition: DisableMgr.cpp:44
Definition: DetourNavMesh.h:279
int y
The y-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:252
static const int DT_NAVMESH_VERSION
A version number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:69
const dtMeshTile * getTileAt(const int x, const int y, const int layer) const
Definition: DetourNavMesh.cpp:973
int vertCount
The number of vertices in the tile.
Definition: DetourNavMesh.h:256
int getTilesAt(const int x, const int y, dtMeshTile const **tiles, const int maxTiles) const
Definition: DetourNavMesh.cpp:1036
Definition: DetourNavMesh.h:222
static const unsigned int DT_OUT_OF_MEMORY
Definition: DetourStatus.h:33
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:84
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void dtNavMesh::baseOffMeshLinks ( dtMeshTile tile)
private

Builds internal polygons links for a tile.

555 {
556  if (!tile) return;
557 
558  dtPolyRef base = getPolyRefBase(tile);
559 
560  // Base off-mesh connection start points.
561  for (int i = 0; i < tile->header->offMeshConCount; ++i)
562  {
563  dtOffMeshConnection* con = &tile->offMeshCons[i];
564  dtPoly* poly = &tile->polys[con->poly];
565 
566  const float ext[3] = { con->rad, tile->header->walkableClimb, con->rad };
567 
568  // Find polygon to connect to.
569  const float* p = &con->pos[0]; // First vertex
570  float nearestPt[3];
571  dtPolyRef ref = findNearestPolyInTile(tile, p, ext, nearestPt);
572  if (!ref) continue;
573  // findNearestPoly may return too optimistic results, further check to make sure.
574  if (dtSqr(nearestPt[0]-p[0])+dtSqr(nearestPt[2]-p[2]) > dtSqr(con->rad))
575  continue;
576  // Make sure the location is on current mesh.
577  float* v = &tile->verts[poly->verts[0]*3];
578  dtVcopy(v, nearestPt);
579 
580  // Link off-mesh connection to target poly.
581  unsigned int idx = allocLink(tile);
582  if (idx != DT_NULL_LINK)
583  {
584  dtLink* link = &tile->links[idx];
585  link->ref = ref;
586  link->edge = (unsigned char)0;
587  link->side = 0xff;
588  link->bmin = link->bmax = 0;
589  // Add to linked list.
590  link->next = poly->firstLink;
591  poly->firstLink = idx;
592  }
593 
594  // Start end-point is always connect back to off-mesh connection.
595  unsigned int tidx = allocLink(tile);
596  if (tidx != DT_NULL_LINK)
597  {
598  const unsigned short landPolyIdx = (unsigned short)decodePolyIdPoly(ref);
599  dtPoly* landPoly = &tile->polys[landPolyIdx];
600  dtLink* link = &tile->links[tidx];
601  link->ref = base | (dtPolyRef)(con->poly);
602  link->edge = 0xff;
603  link->side = 0xff;
604  link->bmin = link->bmax = 0;
605  // Add to linked list.
606  link->next = landPoly->firstLink;
607  landPoly->firstLink = tidx;
608  }
609  }
610 }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
unsigned short poly
The polygon reference of the connection within the tile.
Definition: DetourNavMesh.h:231
float walkableClimb
The maximum climb height of the agents using the tile.
Definition: DetourNavMesh.h:269
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
Definition: DetourNavMesh.h:300
int offMeshConCount
The number of off-mesh connections.
Definition: DetourNavMesh.h:265
unsigned short verts[DT_VERTS_PER_POLYGON]
Definition: DetourNavMesh.h:160
Definition: DetourNavMesh.h:153
float rad
The radius of the endpoints. [Limit: >= 0].
Definition: DetourNavMesh.h:228
unsigned int allocLink(dtMeshTile *tile)
Definition: DetourNavMesh.cpp:122
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:286
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:287
dtPolyRef findNearestPolyInTile(const dtMeshTile *tile, const float *center, const float *extents, float *nearestPt) const
Find nearest polygon within a tile.
Definition: DetourNavMesh.cpp:691
unsigned int decodePolyIdPoly(dtPolyRef ref) const
Definition: DetourNavMesh.h:560
void dtVcopy(float *dest, const float *a)
Definition: DetourCommon.h:190
T dtSqr(T a)
Definition: DetourCommon.h:67
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
Definition: DetourNavMesh.cpp:1269
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
float pos[6]
The endpoints of the connection. [(ax, ay, az, bx, by, bz)].
Definition: DetourNavMesh.h:225
Definition: DetourNavMesh.h:222
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:84

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void 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)
1108 {
1109  *tx = (int)floorf((pos[0]-m_orig[0]) / m_tileWidth);
1110  *ty = (int)floorf((pos[2]-m_orig[2]) / m_tileHeight);
1111 }
float m_tileHeight
Dimensions of each tile.
Definition: DetourNavMesh.h:613
float m_orig[3]
Origin of the tile (0,0)
Definition: DetourNavMesh.h:612
float m_tileWidth
Definition: DetourNavMesh.h:613

+ Here is the caller graph for this function:

void dtNavMesh::closestPointOnPoly ( dtPolyRef  ref,
const float *  pos,
float *  closest,
bool posOverPoly 
) const
private

Returns closest point on polygon.

613 {
614  const dtMeshTile* tile = 0;
615  const dtPoly* poly = 0;
616  getTileAndPolyByRefUnsafe(ref, &tile, &poly);
617 
618  // Off-mesh connections don't have detail polygons.
620  {
621  const float* v0 = &tile->verts[poly->verts[0]*3];
622  const float* v1 = &tile->verts[poly->verts[1]*3];
623  const float d0 = dtVdist(pos, v0);
624  const float d1 = dtVdist(pos, v1);
625  const float u = d0 / (d0+d1);
626  dtVlerp(closest, v0, v1, u);
627  if (posOverPoly)
628  *posOverPoly = false;
629  return;
630  }
631 
632  const unsigned int ip = (unsigned int)(poly - tile->polys);
633  const dtPolyDetail* pd = &tile->detailMeshes[ip];
634 
635  // Clamp point to be inside the polygon.
636  float verts[DT_VERTS_PER_POLYGON*3];
637  float edged[DT_VERTS_PER_POLYGON];
638  float edget[DT_VERTS_PER_POLYGON];
639  const int nv = poly->vertCount;
640  for (int i = 0; i < nv; ++i)
641  dtVcopy(&verts[i*3], &tile->verts[poly->verts[i]*3]);
642 
643  dtVcopy(closest, pos);
644  if (!dtDistancePtPolyEdgesSqr(pos, verts, nv, edged, edget))
645  {
646  // Point is outside the polygon, dtClamp to nearest edge.
647  float dmin = FLT_MAX;
648  int imin = -1;
649  for (int i = 0; i < nv; ++i)
650  {
651  if (edged[i] < dmin)
652  {
653  dmin = edged[i];
654  imin = i;
655  }
656  }
657  const float* va = &verts[imin*3];
658  const float* vb = &verts[((imin+1)%nv)*3];
659  dtVlerp(closest, va, vb, edget[imin]);
660 
661  if (posOverPoly)
662  *posOverPoly = false;
663  }
664  else
665  {
666  if (posOverPoly)
667  *posOverPoly = true;
668  }
669 
670  // Find height at the location.
671  for (int j = 0; j < pd->triCount; ++j)
672  {
673  const unsigned char* t = &tile->detailTris[(pd->triBase+j)*4];
674  const float* v[3];
675  for (int k = 0; k < 3; ++k)
676  {
677  if (t[k] < poly->vertCount)
678  v[k] = &tile->verts[poly->verts[t[k]]*3];
679  else
680  v[k] = &tile->detailVerts[(pd->vertBase+(t[k]-poly->vertCount))*3];
681  }
682  float h;
683  if (dtClosestHeightPointTriangle(pos, v[0], v[1], v[2], h))
684  {
685  closest[1] = h;
686  break;
687  }
688  }
689 }
Defines the location of detail sub-mesh data within a dtMeshTile.
Definition: DetourNavMesh.h:189
void dtVlerp(float *dest, const float *v1, const float *v2, const float t)
Definition: DetourCommon.h:117
float dtVdist(const float *v1, const float *v2)
Definition: DetourCommon.h:217
unsigned char triCount
The number of triangles in the sub-mesh.
Definition: DetourNavMesh.h:194
void getTileAndPolyByRefUnsafe(const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const
Definition: DetourNavMesh.cpp:1131
unsigned short verts[DT_VERTS_PER_POLYGON]
Definition: DetourNavMesh.h:160
unsigned int vertBase
The offset of the vertices in the dtMeshTile::detailVerts array.
Definition: DetourNavMesh.h:191
unsigned char getType() const
Gets the polygon type. (See: dtPolyTypes)
Definition: DetourNavMesh.h:185
Definition: DetourNavMesh.h:153
bool dtClosestHeightPointTriangle(const float *p, const float *a, const float *b, const float *c, float &h)
Definition: DetourCommon.cpp:204
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:286
float * detailVerts
The detail mesh's unique vertices. [(x, y, z) * dtMeshHeader::detailVertCount].
Definition: DetourNavMesh.h:291
unsigned char * detailTris
The detail mesh's triangles. [(vertA, vertB, vertC) * dtMeshHeader::detailTriCount].
Definition: DetourNavMesh.h:294
dtPolyDetail * detailMeshes
The tile's detail sub-meshes. [Size: dtMeshHeader::detailMeshCount].
Definition: DetourNavMesh.h:288
void dtVcopy(float *dest, const float *a)
Definition: DetourCommon.h:190
The polygon is an off-mesh connection consisting of two vertices.
Definition: DetourNavMesh.h:147
unsigned char vertCount
The number of vertices in the polygon.
Definition: DetourNavMesh.h:169
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
unsigned int triBase
The offset of the triangles in the dtMeshTile::detailTris array.
Definition: DetourNavMesh.h:192
Definition: DetourNavMesh.h:279
bool dtDistancePtPolyEdgesSqr(const float *pt, const float *verts, const int nverts, float *ed, float *et)
Definition: DetourCommon.cpp:255
static const int DT_VERTS_PER_POLYGON
Definition: DetourNavMesh.h:57

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void dtNavMesh::connectExtLinks ( dtMeshTile tile,
dtMeshTile target,
int  side 
)
private

Builds external polygon links for a tile.

381 {
382  if (!tile) return;
383 
384  // Connect border links.
385  for (int i = 0; i < tile->header->polyCount; ++i)
386  {
387  dtPoly* poly = &tile->polys[i];
388 
389  // Create new links.
390 // unsigned short m = DT_EXT_LINK | (unsigned short)side;
391 
392  const int nv = poly->vertCount;
393  for (int j = 0; j < nv; ++j)
394  {
395  // Skip non-portal edges.
396  if ((poly->neis[j] & DT_EXT_LINK) == 0)
397  continue;
398 
399  const int dir = (int)(poly->neis[j] & 0xff);
400  if (side != -1 && dir != side)
401  continue;
402 
403  // Create new links
404  const float* va = &tile->verts[poly->verts[j]*3];
405  const float* vb = &tile->verts[poly->verts[(j+1) % nv]*3];
406  dtPolyRef nei[4];
407  float neia[4*2];
408  int nnei = findConnectingPolys(va,vb, target, dtOppositeTile(dir), nei,neia,4);
409  for (int k = 0; k < nnei; ++k)
410  {
411  unsigned int idx = allocLink(tile);
412  if (idx != DT_NULL_LINK)
413  {
414  dtLink* link = &tile->links[idx];
415  link->ref = nei[k];
416  link->edge = (unsigned char)j;
417  link->side = (unsigned char)dir;
418 
419  link->next = poly->firstLink;
420  poly->firstLink = idx;
421 
422  // Compress portal limits to a byte value.
423  if (dir == 0 || dir == 4)
424  {
425  float tmin = (neia[k*2+0]-va[2]) / (vb[2]-va[2]);
426  float tmax = (neia[k*2+1]-va[2]) / (vb[2]-va[2]);
427  if (tmin > tmax)
428  dtSwap(tmin,tmax);
429  link->bmin = (unsigned char)(dtClamp(tmin, 0.0f, 1.0f)*255.0f);
430  link->bmax = (unsigned char)(dtClamp(tmax, 0.0f, 1.0f)*255.0f);
431  }
432  else if (dir == 2 || dir == 6)
433  {
434  float tmin = (neia[k*2+0]-va[0]) / (vb[0]-va[0]);
435  float tmax = (neia[k*2+1]-va[0]) / (vb[0]-va[0]);
436  if (tmin > tmax)
437  dtSwap(tmin,tmax);
438  link->bmin = (unsigned char)(dtClamp(tmin, 0.0f, 1.0f)*255.0f);
439  link->bmax = (unsigned char)(dtClamp(tmax, 0.0f, 1.0f)*255.0f);
440  }
441  }
442  }
443  }
444  }
445 }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
unsigned short verts[DT_VERTS_PER_POLYGON]
Definition: DetourNavMesh.h:160
unsigned short neis[DT_VERTS_PER_POLYGON]
Packed data representing neighbor polygons references and flags for each edge.
Definition: DetourNavMesh.h:163
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
unsigned int allocLink(dtMeshTile *tile)
Definition: DetourNavMesh.cpp:122
T dtClamp(T v, T mn, T mx)
Definition: DetourCommon.h:74
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:286
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:287
int findConnectingPolys(const float *va, const float *vb, const dtMeshTile *tile, int side, dtPolyRef *con, float *conarea, int maxcon) const
Returns all polygons in neighbour tile based on portal defined by the segment.
Definition: DetourNavMesh.cpp:292
static const unsigned short DT_EXT_LINK
Definition: DetourNavMesh.h:81
void dtSwap(T &a, T &b)
Definition: DetourCommon.h:45
unsigned int firstLink
Index to first link in linked list. (Or DT_NULL_LINK if there is no link.)
Definition: DetourNavMesh.h:156
unsigned char vertCount
The number of vertices in the polygon.
Definition: DetourNavMesh.h:169
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
int dtOppositeTile(int side)
Definition: DetourCommon.h:443
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:84

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void dtNavMesh::connectExtOffMeshLinks ( dtMeshTile tile,
dtMeshTile target,
int  side 
)
private

Builds external polygon links for a tile.

448 {
449  if (!tile) return;
450 
451  // Connect off-mesh links.
452  // We are interested on links which land from target tile to this tile.
453  const unsigned char oppositeSide = (side == -1) ? 0xff : (unsigned char)dtOppositeTile(side);
454 
455  for (int i = 0; i < target->header->offMeshConCount; ++i)
456  {
457  dtOffMeshConnection* targetCon = &target->offMeshCons[i];
458  if (targetCon->side != oppositeSide)
459  continue;
460 
461  dtPoly* targetPoly = &target->polys[targetCon->poly];
462  // Skip off-mesh connections which start location could not be connected at all.
463  if (targetPoly->firstLink == DT_NULL_LINK)
464  continue;
465 
466  const float ext[3] = { targetCon->rad, target->header->walkableClimb, targetCon->rad };
467 
468  // Find polygon to connect to.
469  const float* p = &targetCon->pos[3];
470  float nearestPt[3];
471  dtPolyRef ref = findNearestPolyInTile(tile, p, ext, nearestPt);
472  if (!ref)
473  continue;
474  // findNearestPoly may return too optimistic results, further check to make sure.
475  if (dtSqr(nearestPt[0]-p[0])+dtSqr(nearestPt[2]-p[2]) > dtSqr(targetCon->rad))
476  continue;
477  // Make sure the location is on current mesh.
478  float* v = &target->verts[targetPoly->verts[1]*3];
479  dtVcopy(v, nearestPt);
480 
481  // Link off-mesh connection to target poly.
482  unsigned int idx = allocLink(target);
483  if (idx != DT_NULL_LINK)
484  {
485  dtLink* link = &target->links[idx];
486  link->ref = ref;
487  link->edge = (unsigned char)1;
488  link->side = oppositeSide;
489  link->bmin = link->bmax = 0;
490  // Add to linked list.
491  link->next = targetPoly->firstLink;
492  targetPoly->firstLink = idx;
493  }
494 
495  // Link target poly to off-mesh connection.
496  if (targetCon->flags & DT_OFFMESH_CON_BIDIR)
497  {
498  unsigned int tidx = allocLink(tile);
499  if (tidx != DT_NULL_LINK)
500  {
501  const unsigned short landPolyIdx = (unsigned short)decodePolyIdPoly(ref);
502  dtPoly* landPoly = &tile->polys[landPolyIdx];
503  dtLink* link = &tile->links[tidx];
504  link->ref = getPolyRefBase(target) | (dtPolyRef)(targetCon->poly);
505  link->edge = 0xff;
506  link->side = (unsigned char)(side == -1 ? 0xff : side);
507  link->bmin = link->bmax = 0;
508  // Add to linked list.
509  link->next = landPoly->firstLink;
510  landPoly->firstLink = tidx;
511  }
512  }
513  }
514 
515 }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
unsigned short poly
The polygon reference of the connection within the tile.
Definition: DetourNavMesh.h:231
unsigned char side
End point side.
Definition: DetourNavMesh.h:239
float walkableClimb
The maximum climb height of the agents using the tile.
Definition: DetourNavMesh.h:269
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
Definition: DetourNavMesh.h:300
unsigned char flags
Definition: DetourNavMesh.h:236
int offMeshConCount
The number of off-mesh connections.
Definition: DetourNavMesh.h:265
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:87
unsigned short verts[DT_VERTS_PER_POLYGON]
Definition: DetourNavMesh.h:160
Definition: DetourNavMesh.h:153
float rad
The radius of the endpoints. [Limit: >= 0].
Definition: DetourNavMesh.h:228
unsigned int allocLink(dtMeshTile *tile)
Definition: DetourNavMesh.cpp:122
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:286
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:287
dtPolyRef findNearestPolyInTile(const dtMeshTile *tile, const float *center, const float *extents, float *nearestPt) const
Find nearest polygon within a tile.
Definition: DetourNavMesh.cpp:691
unsigned int decodePolyIdPoly(dtPolyRef ref) const
Definition: DetourNavMesh.h:560
void dtVcopy(float *dest, const float *a)
Definition: DetourCommon.h:190
T dtSqr(T a)
Definition: DetourCommon.h:67
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
Definition: DetourNavMesh.cpp:1269
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
int dtOppositeTile(int side)
Definition: DetourCommon.h:443
float pos[6]
The endpoints of the connection. [(ax, ay, az, bx, by, bz)].
Definition: DetourNavMesh.h:225
Definition: DetourNavMesh.h:222
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:84

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void dtNavMesh::connectIntLinks ( dtMeshTile tile)
private

Builds internal polygons links for a tile.

518 {
519  if (!tile) return;
520 
521  dtPolyRef base = getPolyRefBase(tile);
522 
523  for (int i = 0; i < tile->header->polyCount; ++i)
524  {
525  dtPoly* poly = &tile->polys[i];
526  poly->firstLink = DT_NULL_LINK;
527 
529  continue;
530 
531  // Build edge links backwards so that the links will be
532  // in the linked list from lowest index to highest.
533  for (int j = poly->vertCount-1; j >= 0; --j)
534  {
535  // Skip hard and non-internal edges.
536  if (poly->neis[j] == 0 || (poly->neis[j] & DT_EXT_LINK)) continue;
537 
538  unsigned int idx = allocLink(tile);
539  if (idx != DT_NULL_LINK)
540  {
541  dtLink* link = &tile->links[idx];
542  link->ref = base | (dtPolyRef)(poly->neis[j]-1);
543  link->edge = (unsigned char)j;
544  link->side = 0xff;
545  link->bmin = link->bmax = 0;
546  // Add to linked list.
547  link->next = poly->firstLink;
548  poly->firstLink = idx;
549  }
550  }
551  }
552 }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
unsigned char getType() const
Gets the polygon type. (See: dtPolyTypes)
Definition: DetourNavMesh.h:185
unsigned short neis[DT_VERTS_PER_POLYGON]
Packed data representing neighbor polygons references and flags for each edge.
Definition: DetourNavMesh.h:163
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
unsigned int allocLink(dtMeshTile *tile)
Definition: DetourNavMesh.cpp:122
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:287
static const unsigned short DT_EXT_LINK
Definition: DetourNavMesh.h:81
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
Definition: DetourNavMesh.cpp:1269
unsigned char vertCount
The number of vertices in the polygon.
Definition: DetourNavMesh.h:169
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:84

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void 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
527  {
528  const dtPolyRef saltMask = ((dtPolyRef)1<<m_saltBits)-1;
529  const dtPolyRef tileMask = ((dtPolyRef)1<<m_tileBits)-1;
530  const dtPolyRef polyMask = ((dtPolyRef)1<<m_polyBits)-1;
531  salt = (unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
532  it = (unsigned int)((ref >> m_polyBits) & tileMask);
533  ip = (unsigned int)(ref & polyMask);
534  }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
unsigned int m_tileBits
Number of tile bits in the tile ID.
Definition: DetourNavMesh.h:623
unsigned int m_polyBits
Number of poly bits in the tile ID.
Definition: DetourNavMesh.h:624
unsigned int m_saltBits
Number of salt bits in the tile ID.
Definition: DetourNavMesh.h:622

+ Here is the caller graph for this function:

unsigned int 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
561  {
562  const dtPolyRef polyMask = ((dtPolyRef)1<<m_polyBits)-1;
563  return (unsigned int)(ref & polyMask);
564  }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
unsigned int m_polyBits
Number of poly bits in the tile ID.
Definition: DetourNavMesh.h:624

+ Here is the caller graph for this function:

unsigned int 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
541  {
542  const dtPolyRef saltMask = ((dtPolyRef)1<<m_saltBits)-1;
543  return (unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
544  }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
unsigned int m_tileBits
Number of tile bits in the tile ID.
Definition: DetourNavMesh.h:623
unsigned int m_polyBits
Number of poly bits in the tile ID.
Definition: DetourNavMesh.h:624
unsigned int m_saltBits
Number of salt bits in the tile ID.
Definition: DetourNavMesh.h:622

+ Here is the caller graph for this function:

unsigned int 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
551  {
552  const dtPolyRef tileMask = ((dtPolyRef)1<<m_tileBits)-1;
553  return (unsigned int)((ref >> m_polyBits) & tileMask);
554  }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
unsigned int m_tileBits
Number of tile bits in the tile ID.
Definition: DetourNavMesh.h:623
unsigned int m_polyBits
Number of poly bits in the tile ID.
Definition: DetourNavMesh.h:624

+ Here is the caller graph for this function:

dtPolyRef 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.
515  {
516  return ((dtPolyRef)salt << (m_polyBits+m_tileBits)) | ((dtPolyRef)it << m_polyBits) | (dtPolyRef)ip;
517  }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
unsigned int m_tileBits
Number of tile bits in the tile ID.
Definition: DetourNavMesh.h:623
unsigned int m_polyBits
Number of poly bits in the tile ID.
Definition: DetourNavMesh.h:624

+ Here is the caller graph for this function:

int dtNavMesh::findConnectingPolys ( const float *  va,
const float *  vb,
const dtMeshTile tile,
int  side,
dtPolyRef con,
float *  conarea,
int  maxcon 
) const
private

Returns all polygons in neighbour tile based on portal defined by the segment.

295 {
296  if (!tile) return 0;
297 
298  float amin[2], amax[2];
299  calcSlabEndPoints(va,vb, amin,amax, side);
300  const float apos = getSlabCoord(va, side);
301 
302  // Remove links pointing to 'side' and compact the links array.
303  float bmin[2], bmax[2];
304  unsigned short m = DT_EXT_LINK | (unsigned short)side;
305  int n = 0;
306 
307  dtPolyRef base = getPolyRefBase(tile);
308 
309  for (int i = 0; i < tile->header->polyCount; ++i)
310  {
311  dtPoly* poly = &tile->polys[i];
312  const int nv = poly->vertCount;
313  for (int j = 0; j < nv; ++j)
314  {
315  // Skip edges which do not point to the right side.
316  if (poly->neis[j] != m) continue;
317 
318  const float* vc = &tile->verts[poly->verts[j]*3];
319  const float* vd = &tile->verts[poly->verts[(j+1) % nv]*3];
320  const float bpos = getSlabCoord(vc, side);
321 
322  // Segments are not close enough.
323  if (dtAbs(apos-bpos) > 0.01f)
324  continue;
325 
326  // Check if the segments touch.
327  calcSlabEndPoints(vc,vd, bmin,bmax, side);
328 
329  if (!overlapSlabs(amin,amax, bmin,bmax, 0.01f, tile->header->walkableClimb)) continue;
330 
331  // Add return value.
332  if (n < maxcon)
333  {
334  conarea[n*2+0] = dtMax(amin[0], bmin[0]);
335  conarea[n*2+1] = dtMin(amax[0], bmax[0]);
336  con[n] = base | (dtPolyRef)i;
337  n++;
338  }
339  break;
340  }
341  }
342  return n;
343 }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
float walkableClimb
The maximum climb height of the agents using the tile.
Definition: DetourNavMesh.h:269
static float getSlabCoord(const float *va, const int side)
Definition: DetourNavMesh.cpp:67
unsigned short verts[DT_VERTS_PER_POLYGON]
Definition: DetourNavMesh.h:160
static void calcSlabEndPoints(const float *va, const float *vb, float *bmin, float *bmax, const int side)
Definition: DetourNavMesh.cpp:76
unsigned short neis[DT_VERTS_PER_POLYGON]
Packed data representing neighbor polygons references and flags for each edge.
Definition: DetourNavMesh.h:163
T dtAbs(T a)
Definition: DetourCommon.h:62
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
T dtMax(T a, T b)
Definition: DetourCommon.h:57
bool overlapSlabs(const float *amin, const float *amax, const float *bmin, const float *bmax, const float px, const float py)
Definition: DetourNavMesh.cpp:31
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:286
static const unsigned short DT_EXT_LINK
Definition: DetourNavMesh.h:81
T dtMin(T a, T b)
Definition: DetourCommon.h:51
dtPolyRef getPolyRefBase(const dtMeshTile *tile) const
Definition: DetourNavMesh.cpp:1269
unsigned char vertCount
The number of vertices in the polygon.
Definition: DetourNavMesh.h:169
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

dtPolyRef dtNavMesh::findNearestPolyInTile ( const dtMeshTile tile,
const float *  center,
const float *  extents,
float *  nearestPt 
) const
private

Find nearest polygon within a tile.

694 {
695  float bmin[3], bmax[3];
696  dtVsub(bmin, center, extents);
697  dtVadd(bmax, center, extents);
698 
699  // Get nearby polygons from proximity grid.
700  dtPolyRef polys[128];
701  int polyCount = queryPolygonsInTile(tile, bmin, bmax, polys, 128);
702 
703  // Find nearest polygon amongst the nearby polygons.
704  dtPolyRef nearest = 0;
705  float nearestDistanceSqr = FLT_MAX;
706  for (int i = 0; i < polyCount; ++i)
707  {
708  dtPolyRef ref = polys[i];
709  float closestPtPoly[3];
710  float diff[3];
711  bool posOverPoly = false;
712  float d;
713  closestPointOnPoly(ref, center, closestPtPoly, &posOverPoly);
714 
715  // If a point is directly over a polygon and closer than
716  // climb height, favor that instead of straight line nearest point.
717  dtVsub(diff, center, closestPtPoly);
718  if (posOverPoly)
719  {
720  d = dtAbs(diff[1]) - tile->header->walkableClimb;
721  d = d > 0 ? d*d : 0;
722  }
723  else
724  {
725  d = dtVlenSqr(diff);
726  }
727 
728  if (d < nearestDistanceSqr)
729  {
730  dtVcopy(nearestPt, closestPtPoly);
731  nearestDistanceSqr = d;
732  nearest = ref;
733  }
734  }
735 
736  return nearest;
737 }
float dtVlenSqr(const float *v)
Definition: DetourCommon.h:208
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
void closestPointOnPoly(dtPolyRef ref, const float *pos, float *closest, bool *posOverPoly) const
Returns closest point on polygon.
Definition: DetourNavMesh.cpp:612
float walkableClimb
The maximum climb height of the agents using the tile.
Definition: DetourNavMesh.h:269
void dtVadd(float *dest, const float *v1, const float *v2)
Definition: DetourCommon.h:128
T dtAbs(T a)
Definition: DetourCommon.h:62
void dtVcopy(float *dest, const float *a)
Definition: DetourCommon.h:190
int queryPolygonsInTile(const dtMeshTile *tile, const float *qmin, const float *qmax, dtPolyRef *polys, const int maxPolys) const
Queries polygons within a tile.
Definition: DetourNavMesh.cpp:739
void dtVsub(float *dest, const float *v1, const float *v2)
Definition: DetourCommon.h:139

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int dtNavMesh::getMaxTiles ( ) const

The maximum number of tiles supported by the navigation mesh.

Returns
The maximum number of tiles supported by the navigation mesh.
1093 {
1094  return m_maxTiles;
1095 }
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614

+ Here is the caller graph for this function:

int dtNavMesh::getNeighbourTilesAt ( const int  x,
const int  y,
const int  side,
dtMeshTile **  tiles,
const int  maxTiles 
) const
private

Returns neighbour tile based on side.

993 {
994  int nx = x, ny = y;
995  switch (side)
996  {
997  case 0: nx++; break;
998  case 1: nx++; ny++; break;
999  case 2: ny++; break;
1000  case 3: nx--; ny++; break;
1001  case 4: nx--; break;
1002  case 5: nx--; ny--; break;
1003  case 6: ny--; break;
1004  case 7: nx++; ny--; break;
1005  };
1006 
1007  return getTilesAt(nx, ny, tiles, maxTiles);
1008 }
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
int getTilesAt(const int x, const int y, dtMeshTile const **tiles, const int maxTiles) const
Definition: DetourNavMesh.cpp:1036

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Gets the specified off-mesh connection.

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.
1416 {
1417  unsigned int salt, it, ip;
1418 
1419  if (!ref)
1420  return 0;
1421 
1422  // Get current polygon
1423  decodePolyId(ref, salt, it, ip);
1424  if (it >= (unsigned int)m_maxTiles) return 0;
1425  if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return 0;
1426  const dtMeshTile* tile = &m_tiles[it];
1427  if (ip >= (unsigned int)tile->header->polyCount) return 0;
1428  const dtPoly* poly = &tile->polys[ip];
1429 
1430  // Make sure that the current poly is indeed off-mesh link.
1431  if (poly->getType() != DT_POLYTYPE_OFFMESH_CONNECTION)
1432  return 0;
1433 
1434  const unsigned int idx = ip - tile->header->offMeshBase;
1435  dtAssert(idx < (unsigned int)tile->header->offMeshConCount);
1436  return &tile->offMeshCons[idx];
1437 }
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
Definition: DetourNavMesh.h:300
#define dtAssert
Definition: DetourAssert.h:30
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Definition: DetourNavMesh.h:526
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
int offMeshConCount
The number of off-mesh connections.
Definition: DetourNavMesh.h:265
int offMeshBase
The index of the first polygon which is an off-mesh connection.
Definition: DetourNavMesh.h:266
unsigned char getType() const
Gets the polygon type. (See: dtPolyTypes)
Definition: DetourNavMesh.h:185
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
The polygon is an off-mesh connection consisting of two vertices.
Definition: DetourNavMesh.h:147
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
Definition: DetourNavMesh.h:279

+ Here is the call graph for this function:

dtStatus dtNavMesh::getOffMeshConnectionPolyEndPoints ( dtPolyRef  prevRef,
dtPolyRef  polyRef,
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.
[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.

Off-mesh connections are stored in the navigation mesh as special 2-vertex polygons with a single edge. At least one of the vertices is expected to be inside a normal polygon. So an off-mesh connection is "entered" from a normal polygon at one of its endpoints. This is the polygon identified by the prevRef parameter.

1373 {
1374  unsigned int salt, it, ip;
1375 
1376  if (!polyRef)
1377  return DT_FAILURE;
1378 
1379  // Get current polygon
1380  decodePolyId(polyRef, salt, it, ip);
1381  if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
1382  if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
1383  const dtMeshTile* tile = &m_tiles[it];
1384  if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
1385  const dtPoly* poly = &tile->polys[ip];
1386 
1387  // Make sure that the current poly is indeed off-mesh link.
1388  if (poly->getType() != DT_POLYTYPE_OFFMESH_CONNECTION)
1389  return DT_FAILURE;
1390 
1391  // Figure out which way to hand out the vertices.
1392  int idx0 = 0, idx1 = 1;
1393 
1394  // Find link that points to first vertex.
1395  for (unsigned int i = poly->firstLink; i != DT_NULL_LINK; i = tile->links[i].next)
1396  {
1397  if (tile->links[i].edge == 0)
1398  {
1399  if (tile->links[i].ref != prevRef)
1400  {
1401  idx0 = 1;
1402  idx1 = 0;
1403  }
1404  break;
1405  }
1406  }
1407 
1408  dtVcopy(startPos, &tile->verts[poly->verts[idx0]*3]);
1409  dtVcopy(endPos, &tile->verts[poly->verts[idx1]*3]);
1410 
1411  return DT_SUCCESS;
1412 }
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Definition: DetourNavMesh.h:526
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
unsigned short verts[DT_VERTS_PER_POLYGON]
Definition: DetourNavMesh.h:160
unsigned char getType() const
Gets the polygon type. (See: dtPolyTypes)
Definition: DetourNavMesh.h:185
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:286
static const unsigned int DT_INVALID_PARAM
Definition: DetourStatus.h:34
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:287
void dtVcopy(float *dest, const float *a)
Definition: DetourCommon.h:190
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
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
Definition: DetourNavMesh.h:279
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:84
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const dtNavMeshParams * dtNavMesh::getParams ( ) const

The navigation mesh initialization params.

Note
The parameters are created automatically when the single tile initialization is performed.
287 {
288  return &m_params;
289 }
dtNavMeshParams m_params
Current initialization params. TODO: do not store this info twice.
Definition: DetourNavMesh.h:611

+ Here is the caller graph for this function:

dtStatus 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.
1490 {
1491  if (!ref) return DT_FAILURE;
1492  unsigned int salt, it, ip;
1493  decodePolyId(ref, salt, it, ip);
1494  if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
1495  if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
1496  const dtMeshTile* tile = &m_tiles[it];
1497  if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
1498  const dtPoly* poly = &tile->polys[ip];
1499 
1500  *resultArea = poly->getArea();
1501 
1502  return DT_SUCCESS;
1503 }
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
unsigned char getArea() const
Gets the user defined area id.
Definition: DetourNavMesh.h:182
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Definition: DetourNavMesh.h:526
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
static const unsigned int DT_INVALID_PARAM
Definition: DetourStatus.h:34
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
Definition: DetourNavMesh.h:279
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

dtStatus 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.
1458 {
1459  if (!ref) return DT_FAILURE;
1460  unsigned int salt, it, ip;
1461  decodePolyId(ref, salt, it, ip);
1462  if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
1463  if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
1464  const dtMeshTile* tile = &m_tiles[it];
1465  if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
1466  const dtPoly* poly = &tile->polys[ip];
1467 
1468  *resultFlags = poly->flags;
1469 
1470  return DT_SUCCESS;
1471 }
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
unsigned short flags
The user defined polygon flags.
Definition: DetourNavMesh.h:166
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Definition: DetourNavMesh.h:526
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
static const unsigned int DT_INVALID_PARAM
Definition: DetourStatus.h:34
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
Definition: DetourNavMesh.h:279
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

dtPolyRef 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.

Example use case:

const dtPolyRef base = navmesh->getPolyRefBase(tile);
for (int i = 0; i < tile->header->polyCount; ++i)
{
const dtPoly* p = &tile->polys[i];
const dtPolyRef ref = base | (dtPolyRef)i;
// Use the reference to access the polygon data.
}
1270 {
1271  if (!tile) return 0;
1272  const unsigned int it = (unsigned int)(tile - m_tiles);
1273  return encodePolyId(tile->salt, it, 0);
1274 }
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
unsigned int salt
Counter describing modifications to the tile.
Definition: DetourNavMesh.h:281
dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
Definition: DetourNavMesh.h:514

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const dtMeshTile * 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.
1103 {
1104  return &m_tiles[i];
1105 }
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620

+ Here is the caller graph for this function:

dtMeshTile * dtNavMesh::getTile ( int  i)
private

Returns pointer to tile in the tile array.

1098 {
1099  return &m_tiles[i];
1100 }
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
dtStatus 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.
1114 {
1115  if (!ref) return DT_FAILURE;
1116  unsigned int salt, it, ip;
1117  decodePolyId(ref, salt, it, ip);
1118  if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
1119  if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
1120  if (ip >= (unsigned int)m_tiles[it].header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
1121  *tile = &m_tiles[it];
1122  *poly = &m_tiles[it].polys[ip];
1123  return DT_SUCCESS;
1124 }
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Definition: DetourNavMesh.h:526
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
static const unsigned int DT_INVALID_PARAM
Definition: DetourStatus.h:34
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void 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.
Warning
Only use this function if it is known that the provided polygon reference is valid. This function is faster than getTileAndPolyByRef, but it does not validate the reference.
1132 {
1133  unsigned int salt, it, ip;
1134  decodePolyId(ref, salt, it, ip);
1135  *tile = &m_tiles[it];
1136  *poly = &m_tiles[it].polys[ip];
1137 }
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Definition: DetourNavMesh.h:526
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const dtMeshTile * 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.
974 {
975  // Find tile based on hash.
976  int h = computeTileHash(x,y,m_tileLutMask);
977  dtMeshTile* tile = m_posLookup[h];
978  while (tile)
979  {
980  if (tile->header &&
981  tile->header->x == x &&
982  tile->header->y == y &&
983  tile->header->layer == layer)
984  {
985  return tile;
986  }
987  tile = tile->next;
988  }
989  return 0;
990 }
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
dtMeshTile ** m_posLookup
Tile hash lookup.
Definition: DetourNavMesh.h:618
int m_tileLutMask
Tile hash lookup mask.
Definition: DetourNavMesh.h:616
int layer
The layer of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:253
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition: DetourNavMesh.h:305
int x
The x-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:251
G3D::int16 y
Definition: Vector2int16.h:38
int computeTileHash(int x, int y, const int mask)
Definition: DetourNavMesh.cpp:114
G3D::int16 x
Definition: Vector2int16.h:37
Definition: DetourNavMesh.h:279
int y
The y-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:252

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const dtMeshTile * 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.
1079 {
1080  if (!ref)
1081  return 0;
1082  unsigned int tileIndex = decodePolyIdTile((dtPolyRef)ref);
1083  unsigned int tileSalt = decodePolyIdSalt((dtPolyRef)ref);
1084  if ((int)tileIndex >= m_maxTiles)
1085  return 0;
1086  const dtMeshTile* tile = &m_tiles[tileIndex];
1087  if (tile->salt != tileSalt)
1088  return 0;
1089  return tile;
1090 }
unsigned int decodePolyIdTile(dtPolyRef ref) const
Definition: DetourNavMesh.h:550
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
unsigned int decodePolyIdSalt(dtPolyRef ref) const
Definition: DetourNavMesh.h:540
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
unsigned int salt
Counter describing modifications to the tile.
Definition: DetourNavMesh.h:281
Definition: DetourNavMesh.h:279

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

dtTileRef 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.
1249 {
1250  if (!tile) return 0;
1251  const unsigned int it = (unsigned int)(tile - m_tiles);
1252  return (dtTileRef)encodePolyId(tile->salt, it, 0);
1253 }
uint64_d dtTileRef
Definition: DetourNavMesh.h:53
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
unsigned int salt
Counter describing modifications to the tile.
Definition: DetourNavMesh.h:281
dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
Definition: DetourNavMesh.h:514

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

dtTileRef 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.
1060 {
1061  // Find tile based on hash.
1062  int h = computeTileHash(x,y,m_tileLutMask);
1063  dtMeshTile* tile = m_posLookup[h];
1064  while (tile)
1065  {
1066  if (tile->header &&
1067  tile->header->x == x &&
1068  tile->header->y == y &&
1069  tile->header->layer == layer)
1070  {
1071  return getTileRef(tile);
1072  }
1073  tile = tile->next;
1074  }
1075  return 0;
1076 }
dtTileRef getTileRef(const dtMeshTile *tile) const
Definition: DetourNavMesh.cpp:1248
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
dtMeshTile ** m_posLookup
Tile hash lookup.
Definition: DetourNavMesh.h:618
int m_tileLutMask
Tile hash lookup mask.
Definition: DetourNavMesh.h:616
int layer
The layer of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:253
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition: DetourNavMesh.h:305
int x
The x-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:251
G3D::int16 y
Definition: Vector2int16.h:38
int computeTileHash(int x, int y, const int mask)
Definition: DetourNavMesh.cpp:114
G3D::int16 x
Definition: Vector2int16.h:37
Definition: DetourNavMesh.h:279
int y
The y-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:252

+ Here is the call graph for this function:

int 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.

This function will not fail if the tiles array is too small to hold the entire result set. It will simply fill the array to capacity.

1037 {
1038  int n = 0;
1039 
1040  // Find tile based on hash.
1041  int h = computeTileHash(x,y,m_tileLutMask);
1042  dtMeshTile* tile = m_posLookup[h];
1043  while (tile)
1044  {
1045  if (tile->header &&
1046  tile->header->x == x &&
1047  tile->header->y == y)
1048  {
1049  if (n < maxTiles)
1050  tiles[n++] = tile;
1051  }
1052  tile = tile->next;
1053  }
1054 
1055  return n;
1056 }
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
dtMeshTile ** m_posLookup
Tile hash lookup.
Definition: DetourNavMesh.h:618
int m_tileLutMask
Tile hash lookup mask.
Definition: DetourNavMesh.h:616
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition: DetourNavMesh.h:305
int x
The x-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:251
G3D::int16 y
Definition: Vector2int16.h:38
int computeTileHash(int x, int y, const int mask)
Definition: DetourNavMesh.cpp:114
G3D::int16 x
Definition: Vector2int16.h:37
Definition: DetourNavMesh.h:279
int y
The y-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:252

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int dtNavMesh::getTilesAt ( const int  x,
const int  y,
dtMeshTile **  tiles,
const int  maxTiles 
) const
private

Returns neighbour tile based on side.

1011 {
1012  int n = 0;
1013 
1014  // Find tile based on hash.
1015  int h = computeTileHash(x,y,m_tileLutMask);
1016  dtMeshTile* tile = m_posLookup[h];
1017  while (tile)
1018  {
1019  if (tile->header &&
1020  tile->header->x == x &&
1021  tile->header->y == y)
1022  {
1023  if (n < maxTiles)
1024  tiles[n++] = tile;
1025  }
1026  tile = tile->next;
1027  }
1028 
1029  return n;
1030 }
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
dtMeshTile ** m_posLookup
Tile hash lookup.
Definition: DetourNavMesh.h:618
int m_tileLutMask
Tile hash lookup mask.
Definition: DetourNavMesh.h:616
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition: DetourNavMesh.h:305
int x
The x-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:251
G3D::int16 y
Definition: Vector2int16.h:38
int computeTileHash(int x, int y, const int mask)
Definition: DetourNavMesh.cpp:114
G3D::int16 x
Definition: Vector2int16.h:37
Definition: DetourNavMesh.h:279
int y
The y-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:252

+ Here is the call graph for this function:

int 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.
See also
storeTileState
1291 {
1292  if (!tile) return 0;
1293  const int headerSize = dtAlign4(sizeof(dtTileState));
1294  const int polyStateSize = dtAlign4(sizeof(dtPolyState) * tile->header->polyCount);
1295  return headerSize + polyStateSize;
1296 }
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
Definition: DetourNavMesh.cpp:1276
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
int dtAlign4(int x)
Definition: DetourCommon.h:441
Definition: DetourNavMesh.cpp:1283

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

dtStatus dtNavMesh::init ( const dtNavMeshParams params)

Initializes the navigation mesh for tiled use.

Parameters
[in]paramsInitialization parameters.
Returns
The status flags for the operation.
223 {
224  memcpy(&m_params, params, sizeof(dtNavMeshParams));
225  dtVcopy(m_orig, params->orig);
226  m_tileWidth = params->tileWidth;
227  m_tileHeight = params->tileHeight;
228 
229  // Init tiles
230  m_maxTiles = params->maxTiles;
231  m_tileLutSize = dtNextPow2(params->maxTiles/4);
232  if (!m_tileLutSize) m_tileLutSize = 1;
234 
236  if (!m_tiles)
237  return DT_FAILURE | DT_OUT_OF_MEMORY;
239  if (!m_posLookup)
240  return DT_FAILURE | DT_OUT_OF_MEMORY;
241  memset(m_tiles, 0, sizeof(dtMeshTile)*m_maxTiles);
242  memset(m_posLookup, 0, sizeof(dtMeshTile*)*m_tileLutSize);
243  m_nextFree = 0;
244  for (int i = m_maxTiles-1; i >= 0; --i)
245  {
246  m_tiles[i].salt = 1;
247  m_tiles[i].next = m_nextFree;
248  m_nextFree = &m_tiles[i];
249  }
250 
251  // Edited by TC
255 
256  return DT_SUCCESS;
257 }
void * dtAlloc(int size, dtAllocHint hint)
Definition: DetourAlloc.cpp:41
dtMeshTile ** m_posLookup
Tile hash lookup.
Definition: DetourNavMesh.h:618
float orig[3]
The world space origin of the navigation mesh's tile space. [(x, y, z)].
Definition: DetourNavMesh.h:314
dtNavMeshParams m_params
Current initialization params. TODO: do not store this info twice.
Definition: DetourNavMesh.h:611
float m_tileHeight
Dimensions of each tile.
Definition: DetourNavMesh.h:613
static const int STATIC_POLY_BITS
Definition: DetourNavMesh.h:95
static const int STATIC_TILE_BITS
Definition: DetourNavMesh.h:94
Memory persist after a function call.
Definition: DetourAlloc.h:26
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
float m_orig[3]
Origin of the tile (0,0)
Definition: DetourNavMesh.h:612
float m_tileWidth
Definition: DetourNavMesh.h:613
unsigned int m_tileBits
Number of tile bits in the tile ID.
Definition: DetourNavMesh.h:623
int m_tileLutMask
Tile hash lookup mask.
Definition: DetourNavMesh.h:616
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition: DetourNavMesh.h:305
unsigned int salt
Counter describing modifications to the tile.
Definition: DetourNavMesh.h:281
unsigned int m_polyBits
Number of poly bits in the tile ID.
Definition: DetourNavMesh.h:624
unsigned int m_saltBits
Number of salt bits in the tile ID.
Definition: DetourNavMesh.h:622
int m_tileLutSize
Tile hash lookup size (must be pot).
Definition: DetourNavMesh.h:615
unsigned int dtNextPow2(unsigned int v)
Definition: DetourCommon.h:417
dtMeshTile * m_nextFree
Freelist of tiles.
Definition: DetourNavMesh.h:619
void dtVcopy(float *dest, const float *a)
Definition: DetourCommon.h:190
float tileWidth
The width of each tile. (Along the x-axis.)
Definition: DetourNavMesh.h:315
Definition: DetourNavMesh.h:312
float tileHeight
The height of each tile. (Along the z-axis.)
Definition: DetourNavMesh.h:316
Definition: DetourNavMesh.h:279
int maxTiles
The maximum number of tiles the navigation mesh can contain.
Definition: DetourNavMesh.h:317
static const int STATIC_SALT_BITS
Definition: DetourNavMesh.h:93
static const unsigned int DT_OUT_OF_MEMORY
Definition: DetourStatus.h:33
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

dtStatus 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
260 {
261  // Make sure the data is in right format.
262  dtMeshHeader* header = (dtMeshHeader*)data;
263  if (header->magic != DT_NAVMESH_MAGIC)
264  return DT_FAILURE | DT_WRONG_MAGIC;
265  if (header->version != DT_NAVMESH_VERSION)
266  return DT_FAILURE | DT_WRONG_VERSION;
267 
269  dtVcopy(params.orig, header->bmin);
270  params.tileWidth = header->bmax[0] - header->bmin[0];
271  params.tileHeight = header->bmax[2] - header->bmin[2];
272  params.maxTiles = 1;
273  params.maxPolys = header->polyCount;
274 
275  dtStatus status = init(&params);
276  if (dtStatusFailed(status))
277  return status;
278 
279  return addTile(data, dataSize, flags, 0, 0);
280 }
static const unsigned int DT_WRONG_VERSION
Definition: DetourStatus.h:32
dtStatus init(const dtNavMeshParams *params)
Definition: DetourNavMesh.cpp:222
float orig[3]
The world space origin of the navigation mesh's tile space. [(x, y, z)].
Definition: DetourNavMesh.h:314
dtStatus addTile(unsigned char *data, int dataSize, int flags, dtTileRef lastRef, dtTileRef *result)
Definition: DetourNavMesh.cpp:834
float bmax[3]
The maximum bounds of the tile's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:271
unsigned int dtStatus
Definition: DetourStatus.h:22
static const unsigned int DT_WRONG_MAGIC
Definition: DetourStatus.h:31
Definition: DetourNavMesh.h:247
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
float bmin[3]
The minimum bounds of the tile's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:270
int version
Tile data format version number.
Definition: DetourNavMesh.h:250
bool dtStatusFailed(dtStatus status)
Definition: DetourStatus.h:47
int maxPolys
The maximum number of polygons each tile can contain.
Definition: DetourNavMesh.h:318
void dtVcopy(float *dest, const float *a)
Definition: DetourCommon.h:190
int magic
Tile magic number. (Used to identify the data format.)
Definition: DetourNavMesh.h:249
float tileWidth
The width of each tile. (Along the x-axis.)
Definition: DetourNavMesh.h:315
Definition: DetourNavMesh.h:312
float tileHeight
The height of each tile. (Along the z-axis.)
Definition: DetourNavMesh.h:316
static const int DT_NAVMESH_MAGIC
A magic number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:66
uint8 flags
Definition: DisableMgr.cpp:44
int maxTiles
The maximum number of tiles the navigation mesh can contain.
Definition: DetourNavMesh.h:317
std::set< uint32 > params[2]
Definition: DisableMgr.cpp:45
static const int DT_NAVMESH_VERSION
A version number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:69
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

bool 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.
1140 {
1141  if (!ref) return false;
1142  unsigned int salt, it, ip;
1143  decodePolyId(ref, salt, it, ip);
1144  if (it >= (unsigned int)m_maxTiles) return false;
1145  if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return false;
1146  if (ip >= (unsigned int)m_tiles[it].header->polyCount) return false;
1147  return true;
1148 }
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Definition: DetourNavMesh.h:526
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int dtNavMesh::queryPolygonsInTile ( const dtMeshTile tile,
const float *  qmin,
const float *  qmax,
dtPolyRef polys,
const int  maxPolys 
) const
private

Queries polygons within a tile.

741 {
742  if (tile->bvTree)
743  {
744  const dtBVNode* node = &tile->bvTree[0];
745  const dtBVNode* end = &tile->bvTree[tile->header->bvNodeCount];
746  const float* tbmin = tile->header->bmin;
747  const float* tbmax = tile->header->bmax;
748  const float qfac = tile->header->bvQuantFactor;
749 
750  // Calculate quantized box
751  unsigned short bmin[3], bmax[3];
752  // dtClamp query box to world box.
753  float minx = dtClamp(qmin[0], tbmin[0], tbmax[0]) - tbmin[0];
754  float miny = dtClamp(qmin[1], tbmin[1], tbmax[1]) - tbmin[1];
755  float minz = dtClamp(qmin[2], tbmin[2], tbmax[2]) - tbmin[2];
756  float maxx = dtClamp(qmax[0], tbmin[0], tbmax[0]) - tbmin[0];
757  float maxy = dtClamp(qmax[1], tbmin[1], tbmax[1]) - tbmin[1];
758  float maxz = dtClamp(qmax[2], tbmin[2], tbmax[2]) - tbmin[2];
759  // Quantize
760  bmin[0] = (unsigned short)(qfac * minx) & 0xfffe;
761  bmin[1] = (unsigned short)(qfac * miny) & 0xfffe;
762  bmin[2] = (unsigned short)(qfac * minz) & 0xfffe;
763  bmax[0] = (unsigned short)(qfac * maxx + 1) | 1;
764  bmax[1] = (unsigned short)(qfac * maxy + 1) | 1;
765  bmax[2] = (unsigned short)(qfac * maxz + 1) | 1;
766 
767  // Traverse tree
768  dtPolyRef base = getPolyRefBase(tile);
769  int n = 0;
770  while (node < end)
771  {
772  const bool overlap = dtOverlapQuantBounds(bmin, bmax, node->bmin, node->bmax);
773  const bool isLeafNode = node->i >= 0;
774 
775  if (isLeafNode && overlap)
776  {
777  if (n < maxPolys)
778  polys[n++] = base | (dtPolyRef)node->i;
779  }
780 
781  if (overlap || isLeafNode)
782  node++;
783  else
784  {
785  const int escapeIndex = -node->i;
786  node += escapeIndex;
787  }
788  }
789 
790  return n;
791  }
792  else
793  {
794  float bmin[3], bmax[3];
795  int n = 0;
796  dtPolyRef base = getPolyRefBase(tile);
797  for (int i = 0; i < tile->header->polyCount; ++i)
798  {
799  dtPoly* p = &tile->polys[i];
800  // Do not return off-mesh connection polygons.
802  continue;
803  // Calc polygon bounds.
804  const float* v = &tile->verts[p->verts[0]*3];
805  dtVcopy(bmin, v);
806  dtVcopy(bmax, v);
807  for (int j = 1; j < p->vertCount; ++j)
808  {
809  v = &tile->verts[p->verts[j]*3];
810  dtVmin(bmin, v);
811  dtVmax(bmax, v);
812  }
813  if (dtOverlapBounds(qmin,qmax, bmin,bmax))
814  {
815  if (n < maxPolys)
816  polys[n++] = base | (dtPolyRef)i;
817  }
818  }
819  return n;
820  }
821 }
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
unsigned short bmax[3]
Maximum bounds of the node's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:216
void dtVmin(float *mn, const float *v)
Definition: DetourCommon.h:160
float bvQuantFactor
The bounding volume quantization factor.
Definition: DetourNavMesh.h:274
void dtVmax(float *mx, const float *v)
Definition: DetourCommon.h:170
dtBVNode * bvTree
Definition: DetourNavMesh.h:298
float bmax[3]
The maximum bounds of the tile's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:271
unsigned short verts[DT_VERTS_PER_POLYGON]
Definition: DetourNavMesh.h:160
int i
The node's index. (Negative for escape sequence.)
Definition: DetourNavMesh.h:217
Definition: DetourNavMesh.h:213
unsigned char getType() const
Gets the polygon type. (See: dtPolyTypes)
Definition: DetourNavMesh.h:185
unsigned short bmin[3]
Minimum bounds of the node's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:215
bool dtOverlapQuantBounds(const unsigned short amin[3], const unsigned short amax[3], const unsigned short bmin[3], const unsigned short bmax[3])
Definition: DetourCommon.h:332
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
int bvNodeCount
The number of bounding volume nodes. (Zero if bounding volumes are disabled.)
Definition: DetourNavMesh.h:264
float bmin[3]
The minimum bounds of the tile's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:270
T dtClamp(T v, T mn, T mx)
Definition: DetourCommon.h:74
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:286
void dtVcopy(float *dest, const float *a)
Definition: DetourCommon.h:190
The polygon is an off-mesh connection consisting of two vertices.
Definition: DetourNavMesh.h:147
dtPolyRef getPolyRefBase(const dtMeshTile *tile) const
Definition: DetourNavMesh.cpp:1269
unsigned char vertCount
The number of vertices in the polygon.
Definition: DetourNavMesh.h:169
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
bool dtOverlapBounds(const float *amin, const float *amax, const float *bmin, const float *bmax)
Definition: DetourCommon.h:349

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

dtStatus 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.

This function returns the data for the tile so that, if desired, it can be added back to the navigation mesh at a later point.

See also
addTile
1157 {
1158  if (!ref)
1159  return DT_FAILURE | DT_INVALID_PARAM;
1160  unsigned int tileIndex = decodePolyIdTile((dtPolyRef)ref);
1161  unsigned int tileSalt = decodePolyIdSalt((dtPolyRef)ref);
1162  if ((int)tileIndex >= m_maxTiles)
1163  return DT_FAILURE | DT_INVALID_PARAM;
1164  dtMeshTile* tile = &m_tiles[tileIndex];
1165  if (tile->salt != tileSalt)
1166  return DT_FAILURE | DT_INVALID_PARAM;
1167 
1168  // Remove tile from hash lookup.
1169  int h = computeTileHash(tile->header->x,tile->header->y,m_tileLutMask);
1170  dtMeshTile* prev = 0;
1171  dtMeshTile* cur = m_posLookup[h];
1172  while (cur)
1173  {
1174  if (cur == tile)
1175  {
1176  if (prev)
1177  prev->next = cur->next;
1178  else
1179  m_posLookup[h] = cur->next;
1180  break;
1181  }
1182  prev = cur;
1183  cur = cur->next;
1184  }
1185 
1186  // Remove connections to neighbour tiles.
1187  // Create connections with neighbour tiles.
1188  static const int MAX_NEIS = 32;
1189  dtMeshTile* neis[MAX_NEIS];
1190  int nneis;
1191 
1192  // Connect with layers in current tile.
1193  nneis = getTilesAt(tile->header->x, tile->header->y, neis, MAX_NEIS);
1194  for (int j = 0; j < nneis; ++j)
1195  {
1196  if (neis[j] == tile) continue;
1197  unconnectExtLinks(neis[j], tile);
1198  }
1199 
1200  // Connect with neighbour tiles.
1201  for (int i = 0; i < 8; ++i)
1202  {
1203  nneis = getNeighbourTilesAt(tile->header->x, tile->header->y, i, neis, MAX_NEIS);
1204  for (int j = 0; j < nneis; ++j)
1205  unconnectExtLinks(neis[j], tile);
1206  }
1207 
1208  // Reset tile.
1209  if (tile->flags & DT_TILE_FREE_DATA)
1210  {
1211  // Owns data
1212  dtFree(tile->data);
1213  tile->data = 0;
1214  tile->dataSize = 0;
1215  if (data) *data = 0;
1216  if (dataSize) *dataSize = 0;
1217  }
1218  else
1219  {
1220  if (data) *data = tile->data;
1221  if (dataSize) *dataSize = tile->dataSize;
1222  }
1223 
1224  tile->header = 0;
1225  tile->flags = 0;
1226  tile->linksFreeList = 0;
1227  tile->polys = 0;
1228  tile->verts = 0;
1229  tile->links = 0;
1230  tile->detailMeshes = 0;
1231  tile->detailVerts = 0;
1232  tile->detailTris = 0;
1233  tile->bvTree = 0;
1234  tile->offMeshCons = 0;
1235 
1236  // Update salt, salt should never be zero.
1237  tile->salt = (tile->salt+1) & ((1<<m_saltBits)-1);
1238  if (tile->salt == 0)
1239  tile->salt++;
1240 
1241  // Add to free list.
1242  tile->next = m_nextFree;
1243  m_nextFree = tile;
1244 
1245  return DT_SUCCESS;
1246 }
unsigned int decodePolyIdTile(dtPolyRef ref) const
Definition: DetourNavMesh.h:550
The navigation mesh owns the tile memory and is responsible for freeing it.
Definition: DetourNavMesh.h:104
uint64_d dtPolyRef
Definition: DetourNavMesh.h:49
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
dtMeshTile ** m_posLookup
Tile hash lookup.
Definition: DetourNavMesh.h:618
unsigned int decodePolyIdSalt(dtPolyRef ref) const
Definition: DetourNavMesh.h:540
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
Definition: DetourNavMesh.h:300
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
dtBVNode * bvTree
Definition: DetourNavMesh.h:298
int m_tileLutMask
Tile hash lookup mask.
Definition: DetourNavMesh.h:616
int flags
Tile flags. (See: dtTileFlags)
Definition: DetourNavMesh.h:304
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition: DetourNavMesh.h:305
int x
The x-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:251
void unconnectExtLinks(dtMeshTile *tile, dtMeshTile *target)
Removes external links at specified side.
Definition: DetourNavMesh.cpp:345
unsigned int linksFreeList
Index to the next free link.
Definition: DetourNavMesh.h:283
unsigned int salt
Counter describing modifications to the tile.
Definition: DetourNavMesh.h:281
unsigned int m_saltBits
Number of salt bits in the tile ID.
Definition: DetourNavMesh.h:622
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:286
static const unsigned int DT_INVALID_PARAM
Definition: DetourStatus.h:34
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:287
int dataSize
Size of the tile data.
Definition: DetourNavMesh.h:303
float * detailVerts
The detail mesh's unique vertices. [(x, y, z) * dtMeshHeader::detailVertCount].
Definition: DetourNavMesh.h:291
unsigned char * detailTris
The detail mesh's triangles. [(vertA, vertB, vertC) * dtMeshHeader::detailTriCount].
Definition: DetourNavMesh.h:294
dtMeshTile * m_nextFree
Freelist of tiles.
Definition: DetourNavMesh.h:619
dtPolyDetail * detailMeshes
The tile's detail sub-meshes. [Size: dtMeshHeader::detailMeshCount].
Definition: DetourNavMesh.h:288
unsigned char * data
The tile data. (Not directly accessed under normal situations.)
Definition: DetourNavMesh.h:302
int prev(int i, int n)
Definition: RecastContour.cpp:468
int computeTileHash(int x, int y, const int mask)
Definition: DetourNavMesh.cpp:114
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
int getNeighbourTilesAt(const int x, const int y, const int side, dtMeshTile **tiles, const int maxTiles) const
Returns neighbour tile based on side.
Definition: DetourNavMesh.cpp:992
Definition: DetourNavMesh.h:279
int y
The y-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:252
int getTilesAt(const int x, const int y, dtMeshTile const **tiles, const int maxTiles) const
Definition: DetourNavMesh.cpp:1036
void dtFree(void *ptr)
Definition: DetourAlloc.cpp:46
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

dtStatus 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.

Tile state includes non-structural data such as polygon flags, area ids, etc.

Note
This function does not impact the tile's dtTileRef and dtPolyRef's.
See also
storeTileState
1336 {
1337  // Make sure there is enough space to store the state.
1338  const int sizeReq = getTileStateSize(tile);
1339  if (maxDataSize < sizeReq)
1340  return DT_FAILURE | DT_INVALID_PARAM;
1341 
1342  const dtTileState* tileState = (const dtTileState*)data; data += dtAlign4(sizeof(dtTileState));
1343  const dtPolyState* polyStates = (const dtPolyState*)data; data += dtAlign4(sizeof(dtPolyState) * tile->header->polyCount);
1344 
1345  // Check that the restore is possible.
1346  if (tileState->magic != DT_NAVMESH_STATE_MAGIC)
1347  return DT_FAILURE | DT_WRONG_MAGIC;
1348  if (tileState->version != DT_NAVMESH_STATE_VERSION)
1349  return DT_FAILURE | DT_WRONG_VERSION;
1350  if (tileState->ref != getTileRef(tile))
1351  return DT_FAILURE | DT_INVALID_PARAM;
1352 
1353  // Restore per poly state.
1354  for (int i = 0; i < tile->header->polyCount; ++i)
1355  {
1356  dtPoly* p = &tile->polys[i];
1357  const dtPolyState* s = &polyStates[i];
1358  p->flags = s->flags;
1359  p->setArea(s->area);
1360  }
1361 
1362  return DT_SUCCESS;
1363 }
dtTileRef getTileRef(const dtMeshTile *tile) const
Definition: DetourNavMesh.cpp:1248
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
static const unsigned int DT_WRONG_VERSION
Definition: DetourStatus.h:32
unsigned short flags
The user defined polygon flags.
Definition: DetourNavMesh.h:166
static const int DT_NAVMESH_STATE_VERSION
A version number used to detect compatibility of navigation tile states.
Definition: DetourNavMesh.h:75
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
void setArea(unsigned char a)
Sets the user defined area id. [Limit: < DT_MAX_AREAS].
Definition: DetourNavMesh.h:176
static const unsigned int DT_WRONG_MAGIC
Definition: DetourStatus.h:31
Definition: DetourNavMesh.cpp:1276
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
int magic
Definition: DetourNavMesh.cpp:1278
dtTileRef ref
Definition: DetourNavMesh.cpp:1280
unsigned short flags
Definition: DetourNavMesh.cpp:1285
static const unsigned int DT_INVALID_PARAM
Definition: DetourStatus.h:34
int getTileStateSize(const dtMeshTile *tile) const
Definition: DetourNavMesh.cpp:1290
int dtAlign4(int x)
Definition: DetourCommon.h:441
int version
Definition: DetourNavMesh.cpp:1279
static const int DT_NAVMESH_STATE_MAGIC
A magic number used to detect the compatibility of navigation tile states.
Definition: DetourNavMesh.h:72
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
unsigned char area
Definition: DetourNavMesh.cpp:1286
Definition: DetourNavMesh.cpp:1283
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

dtStatus 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.
1474 {
1475  if (!ref) return DT_FAILURE;
1476  unsigned int salt, it, ip;
1477  decodePolyId(ref, salt, it, ip);
1478  if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
1479  if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
1480  dtMeshTile* tile = &m_tiles[it];
1481  if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
1482  dtPoly* poly = &tile->polys[ip];
1483 
1484  poly->setArea(area);
1485 
1486  return DT_SUCCESS;
1487 }
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Definition: DetourNavMesh.h:526
void setArea(unsigned char a)
Sets the user defined area id. [Limit: < DT_MAX_AREAS].
Definition: DetourNavMesh.h:176
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
static const unsigned int DT_INVALID_PARAM
Definition: DetourStatus.h:34
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
Definition: DetourNavMesh.h:279
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

dtStatus 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.
1441 {
1442  if (!ref) return DT_FAILURE;
1443  unsigned int salt, it, ip;
1444  decodePolyId(ref, salt, it, ip);
1445  if (it >= (unsigned int)m_maxTiles) return DT_FAILURE | DT_INVALID_PARAM;
1446  if (m_tiles[it].salt != salt || m_tiles[it].header == 0) return DT_FAILURE | DT_INVALID_PARAM;
1447  dtMeshTile* tile = &m_tiles[it];
1448  if (ip >= (unsigned int)tile->header->polyCount) return DT_FAILURE | DT_INVALID_PARAM;
1449  dtPoly* poly = &tile->polys[ip];
1450 
1451  // Change flags.
1452  poly->flags = flags;
1453 
1454  return DT_SUCCESS;
1455 }
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
unsigned short flags
The user defined polygon flags.
Definition: DetourNavMesh.h:166
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Definition: DetourNavMesh.h:526
int m_maxTiles
Max number of tiles.
Definition: DetourNavMesh.h:614
dtMeshTile * m_tiles
List of tiles.
Definition: DetourNavMesh.h:620
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
static const unsigned int DT_INVALID_PARAM
Definition: DetourStatus.h:34
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
uint8 flags
Definition: DisableMgr.cpp:44
Definition: DetourNavMesh.h:279
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

dtStatus 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.

Tile state includes non-structural data such as polygon flags, area ids, etc.

Note
The state data is only valid until the tile reference changes.
See also
getTileStateSize, restoreTileState
1304 {
1305  // Make sure there is enough space to store the state.
1306  const int sizeReq = getTileStateSize(tile);
1307  if (maxDataSize < sizeReq)
1309 
1310  dtTileState* tileState = (dtTileState*)data; data += dtAlign4(sizeof(dtTileState));
1311  dtPolyState* polyStates = (dtPolyState*)data; data += dtAlign4(sizeof(dtPolyState) * tile->header->polyCount);
1312 
1313  // Store tile state.
1314  tileState->magic = DT_NAVMESH_STATE_MAGIC;
1315  tileState->version = DT_NAVMESH_STATE_VERSION;
1316  tileState->ref = getTileRef(tile);
1317 
1318  // Store per poly state.
1319  for (int i = 0; i < tile->header->polyCount; ++i)
1320  {
1321  const dtPoly* p = &tile->polys[i];
1322  dtPolyState* s = &polyStates[i];
1323  s->flags = p->flags;
1324  s->area = p->getArea();
1325  }
1326 
1327  return DT_SUCCESS;
1328 }
dtTileRef getTileRef(const dtMeshTile *tile) const
Definition: DetourNavMesh.cpp:1248
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
unsigned short flags
The user defined polygon flags.
Definition: DetourNavMesh.h:166
static const int DT_NAVMESH_STATE_VERSION
A version number used to detect compatibility of navigation tile states.
Definition: DetourNavMesh.h:75
unsigned char getArea() const
Gets the user defined area id.
Definition: DetourNavMesh.h:182
static const unsigned int DT_SUCCESS
Definition: DetourStatus.h:26
static const unsigned int DT_BUFFER_TOO_SMALL
Definition: DetourStatus.h:35
Definition: DetourNavMesh.cpp:1276
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
int magic
Definition: DetourNavMesh.cpp:1278
dtTileRef ref
Definition: DetourNavMesh.cpp:1280
unsigned short flags
Definition: DetourNavMesh.cpp:1285
int getTileStateSize(const dtMeshTile *tile) const
Definition: DetourNavMesh.cpp:1290
int dtAlign4(int x)
Definition: DetourCommon.h:441
int version
Definition: DetourNavMesh.cpp:1279
static const int DT_NAVMESH_STATE_MAGIC
A magic number used to detect the compatibility of navigation tile states.
Definition: DetourNavMesh.h:72
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
unsigned char area
Definition: DetourNavMesh.cpp:1286
Definition: DetourNavMesh.cpp:1283
static const unsigned int DT_FAILURE
Definition: DetourStatus.h:25

+ Here is the call graph for this function:

void dtNavMesh::unconnectExtLinks ( dtMeshTile tile,
dtMeshTile target 
)
private

Removes external links at specified side.

346 {
347  if (!tile || !target) return;
348 
349  const unsigned int targetNum = decodePolyIdTile(getTileRef(target));
350 
351  for (int i = 0; i < tile->header->polyCount; ++i)
352  {
353  dtPoly* poly = &tile->polys[i];
354  unsigned int j = poly->firstLink;
355  unsigned int pj = DT_NULL_LINK;
356  while (j != DT_NULL_LINK)
357  {
358  if (tile->links[j].side != 0xff &&
359  decodePolyIdTile(tile->links[j].ref) == targetNum)
360  {
361  // Revove link.
362  unsigned int nj = tile->links[j].next;
363  if (pj == DT_NULL_LINK)
364  poly->firstLink = nj;
365  else
366  tile->links[pj].next = nj;
367  freeLink(tile, j);
368  j = nj;
369  }
370  else
371  {
372  // Advance
373  pj = j;
374  j = tile->links[j].next;
375  }
376  }
377  }
378 }
unsigned int decodePolyIdTile(dtPolyRef ref) const
Definition: DetourNavMesh.h:550
dtTileRef getTileRef(const dtMeshTile *tile) const
Definition: DetourNavMesh.cpp:1248
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:284
Definition: DetourNavMesh.h:153
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:255
void freeLink(dtMeshTile *tile, unsigned int link)
Definition: DetourNavMesh.cpp:131
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:287
unsigned int firstLink
Index to first link in linked list. (Or DT_NULL_LINK if there is no link.)
Definition: DetourNavMesh.h:156
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:285
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:84

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

int dtNavMesh::m_maxTiles
private

Max number of tiles.

dtMeshTile* dtNavMesh::m_nextFree
private

Freelist of tiles.

float dtNavMesh::m_orig[3]
private

Origin of the tile (0,0)

dtNavMeshParams dtNavMesh::m_params
private

Current initialization params. TODO: do not store this info twice.

unsigned int dtNavMesh::m_polyBits
private

Number of poly bits in the tile ID.

dtMeshTile** dtNavMesh::m_posLookup
private

Tile hash lookup.

unsigned int dtNavMesh::m_saltBits
private

Number of salt bits in the tile ID.

unsigned int dtNavMesh::m_tileBits
private

Number of tile bits in the tile ID.

float dtNavMesh::m_tileHeight
private

Dimensions of each tile.

int dtNavMesh::m_tileLutMask
private

Tile hash lookup mask.

int dtNavMesh::m_tileLutSize
private

Tile hash lookup size (must be pot).

dtMeshTile* dtNavMesh::m_tiles
private

List of tiles.

float dtNavMesh::m_tileWidth
private

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