TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Detour

Classes

struct  dtPoly
 
struct  dtMeshHeader
 
struct  dtMeshTile
 
struct  dtNavMeshParams
 
class  dtNavMesh
 
struct  dtNavMeshCreateParams
 
class  dtQueryFilter
 
struct  dtRaycastHit
 
class  dtNavMeshQuery
 
struct  dtNavMeshQuery::dtQueryData
 

Typedefs

typedef uint64_d dtPolyRef
 
typedef uint64_d dtTileRef
 

Functions

dtNavMeshdtAllocNavMesh ()
 
void dtFreeNavMesh (dtNavMesh *navmesh)
 
bool dtCreateNavMeshData (dtNavMeshCreateParams *params, unsigned char **outData, int *outDataSize)
 
dtNavMeshQuerydtAllocNavMeshQuery ()
 
void dtFreeNavMeshQuery (dtNavMeshQuery *query)
 

Variables

static const int DT_VERTS_PER_POLYGON = 6
 
static const int DT_MAX_AREAS = 64
 

Detailed Description

Members in this module are used to create, manipulate, and query navigation meshes.

Note
This is a summary list of members. Use the index or search feature to find minor members.

Members in this module are wrappers around the standard math library

Typedef Documentation

A handle to a polygon within a navigation mesh tile.

Polygon references are subject to the same invalidate/preserve/restore rules that apply to dtTileRef's. If the dtTileRef for the polygon's tile changes, the polygon reference becomes invalid.

Changing a polygon's flags, area id, etc. does not impact its polygon reference.

A handle to a tile within a navigation mesh.

The following changes will invalidate a tile reference:

  • The referenced tile has been removed from the navigation mesh.
  • The navigation mesh has been initialized using a different set of dtNavMeshParams.

A tile reference is preserved/restored if the tile is added to a navigation mesh initialized with the original dtNavMeshParams and is added at the original reference location. (E.g. The lastRef parameter is used with dtNavMesh::addTile.)

Basically, if the storage structure of a tile changes, its associated tile reference changes.

Function Documentation

dtNavMesh* dtAllocNavMesh ( )

Allocates a navigation mesh object using the Detour allocator.

Returns
A navigation mesh that is ready for initialization, or null on failure.
139 {
140  void* mem = dtAlloc(sizeof(dtNavMesh), DT_ALLOC_PERM);
141  if (!mem) return 0;
142  return new(mem) dtNavMesh;
143 }
void * dtAlloc(int size, dtAllocHint hint)
Definition: DetourAlloc.cpp:41
Memory persist after a function call.
Definition: DetourAlloc.h:26
Definition: DetourNavMesh.h:323

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

dtNavMeshQuery* dtAllocNavMeshQuery ( )

Allocates a query object using the Detour allocator.

Returns
An allocated query object, or null on failure.
108 {
109  void* mem = dtAlloc(sizeof(dtNavMeshQuery), DT_ALLOC_PERM);
110  if (!mem) return 0;
111  return new(mem) dtNavMeshQuery;
112 }
void * dtAlloc(int size, dtAllocHint hint)
Definition: DetourAlloc.cpp:41
Memory persist after a function call.
Definition: DetourAlloc.h:26
Definition: DetourNavMeshQuery.h:153

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool dtCreateNavMeshData ( dtNavMeshCreateParams params,
unsigned char **  outData,
int *  outDataSize 
)

Builds navigation mesh tile data from the provided tile creation data.

Parameters
[in]paramsTile creation data.
[out]outDataThe resulting tile data.
[out]outDataSizeThe size of the tile data array.
Returns
True if the tile data was successfully created.

The output data array is allocated using the detour allocator (dtAlloc()). The method used to free the memory will be determined by how the tile is added to the navigation mesh.

See also
dtNavMesh, dtNavMesh::addTile()
255 {
256  if (params->nvp > DT_VERTS_PER_POLYGON)
257  return false;
258  if (params->vertCount >= 0xffff)
259  return false;
260  if (!params->vertCount || !params->verts)
261  return false;
262  if (!params->polyCount || !params->polys)
263  return false;
264 
265  const int nvp = params->nvp;
266 
267  // Classify off-mesh connection points. We store only the connections
268  // whose start point is inside the tile.
269  unsigned char* offMeshConClass = 0;
270  int storedOffMeshConCount = 0;
271  int offMeshConLinkCount = 0;
272 
273  if (params->offMeshConCount > 0)
274  {
275  offMeshConClass = (unsigned char*)dtAlloc(sizeof(unsigned char)*params->offMeshConCount*2, DT_ALLOC_TEMP);
276  if (!offMeshConClass)
277  return false;
278 
279  // Find tight heigh bounds, used for culling out off-mesh start locations.
280  float hmin = FLT_MAX;
281  float hmax = -FLT_MAX;
282 
283  if (params->detailVerts && params->detailVertsCount)
284  {
285  for (int i = 0; i < params->detailVertsCount; ++i)
286  {
287  const float h = params->detailVerts[i*3+1];
288  hmin = dtMin(hmin,h);
289  hmax = dtMax(hmax,h);
290  }
291  }
292  else
293  {
294  for (int i = 0; i < params->vertCount; ++i)
295  {
296  const unsigned short* iv = &params->verts[i*3];
297  const float h = params->bmin[1] + iv[1] * params->ch;
298  hmin = dtMin(hmin,h);
299  hmax = dtMax(hmax,h);
300  }
301  }
302  hmin -= params->walkableClimb;
303  hmax += params->walkableClimb;
304  float bmin[3], bmax[3];
305  dtVcopy(bmin, params->bmin);
306  dtVcopy(bmax, params->bmax);
307  bmin[1] = hmin;
308  bmax[1] = hmax;
309 
310  for (int i = 0; i < params->offMeshConCount; ++i)
311  {
312  const float* p0 = &params->offMeshConVerts[(i*2+0)*3];
313  const float* p1 = &params->offMeshConVerts[(i*2+1)*3];
314  offMeshConClass[i*2+0] = classifyOffMeshPoint(p0, bmin, bmax);
315  offMeshConClass[i*2+1] = classifyOffMeshPoint(p1, bmin, bmax);
316 
317  // Zero out off-mesh start positions which are not even potentially touching the mesh.
318  if (offMeshConClass[i*2+0] == 0xff)
319  {
320  if (p0[1] < bmin[1] || p0[1] > bmax[1])
321  offMeshConClass[i*2+0] = 0;
322  }
323 
324  // Cound how many links should be allocated for off-mesh connections.
325  if (offMeshConClass[i*2+0] == 0xff)
326  offMeshConLinkCount++;
327  if (offMeshConClass[i*2+1] == 0xff)
328  offMeshConLinkCount++;
329 
330  if (offMeshConClass[i*2+0] == 0xff)
331  storedOffMeshConCount++;
332  }
333  }
334 
335  // Off-mesh connectionss are stored as polygons, adjust values.
336  const int totPolyCount = params->polyCount + storedOffMeshConCount;
337  const int totVertCount = params->vertCount + storedOffMeshConCount*2;
338 
339  // Find portal edges which are at tile borders.
340  int edgeCount = 0;
341  int portalCount = 0;
342  for (int i = 0; i < params->polyCount; ++i)
343  {
344  const unsigned short* p = &params->polys[i*2*nvp];
345  for (int j = 0; j < nvp; ++j)
346  {
347  if (p[j] == MESH_NULL_IDX) break;
348  edgeCount++;
349 
350  if (p[nvp+j] & 0x8000)
351  {
352  unsigned short dir = p[nvp+j] & 0xf;
353  if (dir != 0xf)
354  portalCount++;
355  }
356  }
357  }
358 
359  const int maxLinkCount = edgeCount + portalCount*2 + offMeshConLinkCount*2;
360 
361  // Find unique detail vertices.
362  int uniqueDetailVertCount = 0;
363  int detailTriCount = 0;
364  if (params->detailMeshes)
365  {
366  // Has detail mesh, count unique detail vertex count and use input detail tri count.
367  detailTriCount = params->detailTriCount;
368  for (int i = 0; i < params->polyCount; ++i)
369  {
370  const unsigned short* p = &params->polys[i*nvp*2];
371  int ndv = params->detailMeshes[i*4+1];
372  int nv = 0;
373  for (int j = 0; j < nvp; ++j)
374  {
375  if (p[j] == MESH_NULL_IDX) break;
376  nv++;
377  }
378  ndv -= nv;
379  uniqueDetailVertCount += ndv;
380  }
381  }
382  else
383  {
384  // No input detail mesh, build detail mesh from nav polys.
385  uniqueDetailVertCount = 0; // No extra detail verts.
386  detailTriCount = 0;
387  for (int i = 0; i < params->polyCount; ++i)
388  {
389  const unsigned short* p = &params->polys[i*nvp*2];
390  int nv = 0;
391  for (int j = 0; j < nvp; ++j)
392  {
393  if (p[j] == MESH_NULL_IDX) break;
394  nv++;
395  }
396  detailTriCount += nv-2;
397  }
398  }
399 
400  // Calculate data size
401  const int headerSize = dtAlign4(sizeof(dtMeshHeader));
402  const int vertsSize = dtAlign4(sizeof(float)*3*totVertCount);
403  const int polysSize = dtAlign4(sizeof(dtPoly)*totPolyCount);
404  const int linksSize = dtAlign4(sizeof(dtLink)*maxLinkCount);
405  const int detailMeshesSize = dtAlign4(sizeof(dtPolyDetail)*params->polyCount);
406  const int detailVertsSize = dtAlign4(sizeof(float)*3*uniqueDetailVertCount);
407  const int detailTrisSize = dtAlign4(sizeof(unsigned char)*4*detailTriCount);
408  const int bvTreeSize = params->buildBvTree ? dtAlign4(sizeof(dtBVNode)*params->polyCount*2) : 0;
409  const int offMeshConsSize = dtAlign4(sizeof(dtOffMeshConnection)*storedOffMeshConCount);
410 
411  const int dataSize = headerSize + vertsSize + polysSize + linksSize +
412  detailMeshesSize + detailVertsSize + detailTrisSize +
413  bvTreeSize + offMeshConsSize;
414 
415  unsigned char* data = (unsigned char*)dtAlloc(sizeof(unsigned char)*dataSize, DT_ALLOC_PERM);
416  if (!data)
417  {
418  dtFree(offMeshConClass);
419  return false;
420  }
421  memset(data, 0, dataSize);
422 
423  unsigned char* d = data;
424  dtMeshHeader* header = (dtMeshHeader*)d; d += headerSize;
425  float* navVerts = (float*)d; d += vertsSize;
426  dtPoly* navPolys = (dtPoly*)d; d += polysSize;
427  d += linksSize;
428  dtPolyDetail* navDMeshes = (dtPolyDetail*)d; d += detailMeshesSize;
429  float* navDVerts = (float*)d; d += detailVertsSize;
430  unsigned char* navDTris = (unsigned char*)d; d += detailTrisSize;
431  dtBVNode* navBvtree = (dtBVNode*)d; d += bvTreeSize;
432  dtOffMeshConnection* offMeshCons = (dtOffMeshConnection*)d; d += offMeshConsSize;
433 
434 
435  // Store header
436  header->magic = DT_NAVMESH_MAGIC;
437  header->version = DT_NAVMESH_VERSION;
438  header->x = params->tileX;
439  header->y = params->tileY;
440  header->layer = params->tileLayer;
441  header->userId = params->userId;
442  header->polyCount = totPolyCount;
443  header->vertCount = totVertCount;
444  header->maxLinkCount = maxLinkCount;
445  dtVcopy(header->bmin, params->bmin);
446  dtVcopy(header->bmax, params->bmax);
447  header->detailMeshCount = params->polyCount;
448  header->detailVertCount = uniqueDetailVertCount;
449  header->detailTriCount = detailTriCount;
450  header->bvQuantFactor = 1.0f / params->cs;
451  header->offMeshBase = params->polyCount;
452  header->walkableHeight = params->walkableHeight;
453  header->walkableRadius = params->walkableRadius;
454  header->walkableClimb = params->walkableClimb;
455  header->offMeshConCount = storedOffMeshConCount;
456  header->bvNodeCount = params->buildBvTree ? params->polyCount*2 : 0;
457 
458  const int offMeshVertsBase = params->vertCount;
459  const int offMeshPolyBase = params->polyCount;
460 
461  // Store vertices
462  // Mesh vertices
463  for (int i = 0; i < params->vertCount; ++i)
464  {
465  const unsigned short* iv = &params->verts[i*3];
466  float* v = &navVerts[i*3];
467  v[0] = params->bmin[0] + iv[0] * params->cs;
468  v[1] = params->bmin[1] + iv[1] * params->ch;
469  v[2] = params->bmin[2] + iv[2] * params->cs;
470  }
471  // Off-mesh link vertices.
472  int n = 0;
473  for (int i = 0; i < params->offMeshConCount; ++i)
474  {
475  // Only store connections which start from this tile.
476  if (offMeshConClass[i*2+0] == 0xff)
477  {
478  const float* linkv = &params->offMeshConVerts[i*2*3];
479  float* v = &navVerts[(offMeshVertsBase + n*2)*3];
480  dtVcopy(&v[0], &linkv[0]);
481  dtVcopy(&v[3], &linkv[3]);
482  n++;
483  }
484  }
485 
486  // Store polygons
487  // Mesh polys
488  const unsigned short* src = params->polys;
489  for (int i = 0; i < params->polyCount; ++i)
490  {
491  dtPoly* p = &navPolys[i];
492  p->vertCount = 0;
493  p->flags = params->polyFlags[i];
494  p->setArea(params->polyAreas[i]);
496  for (int j = 0; j < nvp; ++j)
497  {
498  if (src[j] == MESH_NULL_IDX) break;
499  p->verts[j] = src[j];
500  if (src[nvp+j] & 0x8000)
501  {
502  // Border or portal edge.
503  unsigned short dir = src[nvp+j] & 0xf;
504  if (dir == 0xf) // Border
505  p->neis[j] = 0;
506  else if (dir == 0) // Portal x-
507  p->neis[j] = DT_EXT_LINK | 4;
508  else if (dir == 1) // Portal z+
509  p->neis[j] = DT_EXT_LINK | 2;
510  else if (dir == 2) // Portal x+
511  p->neis[j] = DT_EXT_LINK | 0;
512  else if (dir == 3) // Portal z-
513  p->neis[j] = DT_EXT_LINK | 6;
514  }
515  else
516  {
517  // Normal connection
518  p->neis[j] = src[nvp+j]+1;
519  }
520 
521  p->vertCount++;
522  }
523  src += nvp*2;
524  }
525  // Off-mesh connection vertices.
526  n = 0;
527  for (int i = 0; i < params->offMeshConCount; ++i)
528  {
529  // Only store connections which start from this tile.
530  if (offMeshConClass[i*2+0] == 0xff)
531  {
532  dtPoly* p = &navPolys[offMeshPolyBase+n];
533  p->vertCount = 2;
534  p->verts[0] = (unsigned short)(offMeshVertsBase + n*2+0);
535  p->verts[1] = (unsigned short)(offMeshVertsBase + n*2+1);
536  p->flags = params->offMeshConFlags[i];
537  p->setArea(params->offMeshConAreas[i]);
539  n++;
540  }
541  }
542 
543  // Store detail meshes and vertices.
544  // The nav polygon vertices are stored as the first vertices on each mesh.
545  // We compress the mesh data by skipping them and using the navmesh coordinates.
546  if (params->detailMeshes)
547  {
548  unsigned short vbase = 0;
549  for (int i = 0; i < params->polyCount; ++i)
550  {
551  dtPolyDetail& dtl = navDMeshes[i];
552  const int vb = (int)params->detailMeshes[i*4+0];
553  const int ndv = (int)params->detailMeshes[i*4+1];
554  const int nv = navPolys[i].vertCount;
555  dtl.vertBase = (unsigned int)vbase;
556  dtl.vertCount = (unsigned char)(ndv-nv);
557  dtl.triBase = (unsigned int)params->detailMeshes[i*4+2];
558  dtl.triCount = (unsigned char)params->detailMeshes[i*4+3];
559  // Copy vertices except the first 'nv' verts which are equal to nav poly verts.
560  if (ndv-nv)
561  {
562  memcpy(&navDVerts[vbase*3], &params->detailVerts[(vb+nv)*3], sizeof(float)*3*(ndv-nv));
563  vbase += (unsigned short)(ndv-nv);
564  }
565  }
566  // Store triangles.
567  memcpy(navDTris, params->detailTris, sizeof(unsigned char)*4*params->detailTriCount);
568  }
569  else
570  {
571  // Create dummy detail mesh by triangulating polys.
572  int tbase = 0;
573  for (int i = 0; i < params->polyCount; ++i)
574  {
575  dtPolyDetail& dtl = navDMeshes[i];
576  const int nv = navPolys[i].vertCount;
577  dtl.vertBase = 0;
578  dtl.vertCount = 0;
579  dtl.triBase = (unsigned int)tbase;
580  dtl.triCount = (unsigned char)(nv-2);
581  // Triangulate polygon (local indices).
582  for (int j = 2; j < nv; ++j)
583  {
584  unsigned char* t = &navDTris[tbase*4];
585  t[0] = 0;
586  t[1] = (unsigned char)(j-1);
587  t[2] = (unsigned char)j;
588  // Bit for each edge that belongs to poly boundary.
589  t[3] = (1<<2);
590  if (j == 2) t[3] |= (1<<0);
591  if (j == nv-1) t[3] |= (1<<4);
592  tbase++;
593  }
594  }
595  }
596 
597  // Store and create BVtree.
598  // TODO: take detail mesh into account! use byte per bbox extent?
599  if (params->buildBvTree)
600  {
601  createBVTree(params->verts, params->vertCount, params->polys, params->polyCount,
602  nvp, params->cs, params->ch, params->polyCount*2, navBvtree);
603  }
604 
605  // Store Off-Mesh connections.
606  n = 0;
607  for (int i = 0; i < params->offMeshConCount; ++i)
608  {
609  // Only store connections which start from this tile.
610  if (offMeshConClass[i*2+0] == 0xff)
611  {
612  dtOffMeshConnection* con = &offMeshCons[n];
613  con->poly = (unsigned short)(offMeshPolyBase + n);
614  // Copy connection end-points.
615  const float* endPts = &params->offMeshConVerts[i*2*3];
616  dtVcopy(&con->pos[0], &endPts[0]);
617  dtVcopy(&con->pos[3], &endPts[3]);
618  con->rad = params->offMeshConRad[i];
619  con->flags = params->offMeshConDir[i] ? DT_OFFMESH_CON_BIDIR : 0;
620  con->side = offMeshConClass[i*2+1];
621  if (params->offMeshConUserID)
622  con->userId = params->offMeshConUserID[i];
623  n++;
624  }
625  }
626 
627  dtFree(offMeshConClass);
628 
629  *outData = data;
630  *outDataSize = dataSize;
631 
632  return true;
633 }
int tileLayer
The tile's layer within the layered destination mesh. Limit: >= 0
Definition: DetourNavMeshBuilder.h:86
float cs
The xz-plane cell size of the polygon mesh. [Limit: > 0] [Unit: wu].
Definition: DetourNavMeshBuilder.h:97
unsigned short poly
The polygon reference of the connection within the tile.
Definition: DetourNavMesh.h:231
void * dtAlloc(int size, dtAllocHint hint)
Definition: DetourAlloc.cpp:41
const unsigned char * offMeshConDir
Definition: DetourNavMeshBuilder.h:72
unsigned char side
End point side.
Definition: DetourNavMesh.h:239
Defines the location of detail sub-mesh data within a dtMeshTile.
Definition: DetourNavMesh.h:189
float walkableHeight
The height of the agents using the tile.
Definition: DetourNavMesh.h:267
float walkableClimb
The maximum climb height of the agents using the tile.
Definition: DetourNavMesh.h:269
const unsigned char * polyAreas
The user defined area ids assigned to each polygon. [Size: polyCount].
Definition: DetourNavMeshBuilder.h:38
const float * offMeshConVerts
Off-mesh connection vertices. [(ax, ay, az, bx, by, bz) * offMeshConCount] [Unit: wu]...
Definition: DetourNavMeshBuilder.h:61
unsigned short flags
The user defined polygon flags.
Definition: DetourNavMesh.h:166
const unsigned short * polys
The polygon data. [Size: polyCount * 2 * nvp].
Definition: DetourNavMeshBuilder.h:36
int nvp
Number maximum number of vertices per polygon. [Limit: >= 3].
Definition: DetourNavMeshBuilder.h:40
static unsigned short MESH_NULL_IDX
Definition: DetourNavMeshBuilder.cpp:30
unsigned char triCount
The number of triangles in the sub-mesh.
Definition: DetourNavMesh.h:194
float walkableHeight
The agent height. [Unit: wu].
Definition: DetourNavMeshBuilder.h:94
float walkableRadius
The radius of the agents using the tile.
Definition: DetourNavMesh.h:268
static int createBVTree(const unsigned short *verts, const int, const unsigned short *polys, const int npolys, const int nvp, const float cs, const float ch, const int, dtBVNode *nodes)
Definition: DetourNavMeshBuilder.cpp:172
const unsigned char * detailTris
The detail mesh triangles. [Size: 4 * detailTriCount].
Definition: DetourNavMeshBuilder.h:50
float ch
The y-axis cell height of the polygon mesh. [Limit: > 0] [Unit: wu].
Definition: DetourNavMeshBuilder.h:98
Memory persist after a function call.
Definition: DetourAlloc.h:26
float bmax[3]
The maximum bounds of the tile. [(x, y, z)] [Unit: wu].
Definition: DetourNavMeshBuilder.h:88
float bvQuantFactor
The bounding volume quantization factor.
Definition: DetourNavMesh.h:274
unsigned char flags
Definition: DetourNavMesh.h:236
void setArea(unsigned char a)
Sets the user defined area id. [Limit: < DT_MAX_AREAS].
Definition: DetourNavMesh.h:176
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
float bmax[3]
The maximum bounds of the tile's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:271
int detailMeshCount
The number of sub-meshes in the detail mesh.
Definition: DetourNavMesh.h:258
float walkableClimb
The agent maximum traversable ledge. (Up/Down) [Unit: wu].
Definition: DetourNavMeshBuilder.h:96
unsigned int userId
The user defined id of the tile.
Definition: DetourNavMeshBuilder.h:83
unsigned short verts[DT_VERTS_PER_POLYGON]
Definition: DetourNavMesh.h:160
unsigned char vertCount
The number of vertices in the sub-mesh.
Definition: DetourNavMesh.h:193
const unsigned short * offMeshConFlags
User defined flags assigned to the off-mesh connections. [Size: offMeshConCount]. ...
Definition: DetourNavMeshBuilder.h:65
unsigned int userId
The id of the offmesh connection. (User assigned when the navigation mesh is built.)
Definition: DetourNavMesh.h:242
int offMeshBase
The index of the first polygon which is an off-mesh connection.
Definition: DetourNavMesh.h:266
Definition: DetourNavMesh.h:213
unsigned int vertBase
The offset of the vertices in the dtMeshTile::detailVerts array.
Definition: DetourNavMesh.h:191
int layer
The layer of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:253
bool buildBvTree
Definition: DetourNavMeshBuilder.h:102
Definition: DetourNavMesh.h:247
int detailTriCount
The number of triangles in the detail mesh.
Definition: DetourNavMeshBuilder.h:51
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
float rad
The radius of the endpoints. [Limit: >= 0].
Definition: DetourNavMesh.h:228
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 offMeshConCount
The number of off-mesh connections. [Limit: >= 0].
Definition: DetourNavMeshBuilder.h:76
int x
The x-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:251
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
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
const unsigned short * verts
The polygon mesh vertices. [(x, y, z) * vertCount] [Unit: vx].
Definition: DetourNavMeshBuilder.h:34
float bmin[3]
The minimum bounds of the tile. [(x, y, z)] [Unit: wu].
Definition: DetourNavMeshBuilder.h:87
T dtMax(T a, T b)
Definition: DetourCommon.h:57
unsigned int userId
The user defined id of the tile.
Definition: DetourNavMesh.h:254
float walkableRadius
The agent radius. [Unit: wu].
Definition: DetourNavMeshBuilder.h:95
const float * detailVerts
The detail mesh vertices. [Size: 3 * detailVertsCount] [Unit: wu].
Definition: DetourNavMeshBuilder.h:48
static const unsigned short DT_EXT_LINK
Definition: DetourNavMesh.h:81
Memory used temporarily within a function.
Definition: DetourAlloc.h:27
void dtVcopy(float *dest, const float *a)
Definition: DetourCommon.h:190
T dtMin(T a, T b)
Definition: DetourCommon.h:51
int magic
Tile magic number. (Used to identify the data format.)
Definition: DetourNavMesh.h:249
int tileY
The tile's y-grid location within the multi-tile desitation mesh. (Along the z-axis.)
Definition: DetourNavMeshBuilder.h:85
int polyCount
Number of polygons in the mesh. [Limit: >= 1].
Definition: DetourNavMeshBuilder.h:39
int dtAlign4(int x)
Definition: DetourCommon.h:441
int detailTriCount
The number of triangles in the detail mesh.
Definition: DetourNavMesh.h:263
The polygon is an off-mesh connection consisting of two vertices.
Definition: DetourNavMesh.h:147
const unsigned int * detailMeshes
The height detail sub-mesh data. [Size: 4 * polyCount].
Definition: DetourNavMeshBuilder.h:47
unsigned char vertCount
The number of vertices in the polygon.
Definition: DetourNavMesh.h:169
int tileX
The tile's x-grid location within the multi-tile destination mesh. (Along the x-axis.)
Definition: DetourNavMeshBuilder.h:84
static unsigned char classifyOffMeshPoint(const float *pt, const float *bmin, const float *bmax)
Definition: DetourNavMeshBuilder.cpp:217
const unsigned short * polyFlags
The user defined flags assigned to each polygon. [Size: polyCount].
Definition: DetourNavMeshBuilder.h:37
unsigned int triBase
The offset of the triangles in the dtMeshTile::detailTris array.
Definition: DetourNavMesh.h:192
int vertCount
The number vertices in the polygon mesh. [Limit: >= 3].
Definition: DetourNavMeshBuilder.h:35
static const int DT_NAVMESH_MAGIC
A magic number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:66
const float * offMeshConRad
Off-mesh connection radii. [Size: offMeshConCount] [Unit: wu].
Definition: DetourNavMeshBuilder.h:63
const unsigned int * offMeshConUserID
The user defined ids of the off-mesh connection. [Size: offMeshConCount].
Definition: DetourNavMeshBuilder.h:74
int y
The y-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:252
float pos[6]
The endpoints of the connection. [(ax, ay, az, bx, by, bz)].
Definition: DetourNavMesh.h:225
int detailVertsCount
The number of vertices in the detail mesh.
Definition: DetourNavMeshBuilder.h:49
void setType(unsigned char t)
Sets the polygon type. (See: dtPolyTypes.)
Definition: DetourNavMesh.h:179
static const int DT_NAVMESH_VERSION
A version number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:69
The polygon is a standard convex polygon that is part of the surface of the mesh. ...
Definition: DetourNavMesh.h:145
int vertCount
The number of vertices in the tile.
Definition: DetourNavMesh.h:256
Definition: DetourNavMesh.h:222
void dtFree(void *ptr)
Definition: DetourAlloc.cpp:46
const unsigned char * offMeshConAreas
User defined area ids assigned to the off-mesh connections. [Size: offMeshConCount].
Definition: DetourNavMeshBuilder.h:67
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 dtFreeNavMesh ( dtNavMesh navmesh)

Frees the specified navigation mesh object using the Detour allocator.

Parameters
[in]navmeshA navigation mesh allocated using dtAllocNavMesh

This function will only free the memory for tiles with the DT_TILE_FREE_DATA flag set.

150 {
151  if (!navmesh) return;
152  navmesh->~dtNavMesh();
153  dtFree(navmesh);
154 }
~dtNavMesh()
Definition: DetourNavMesh.cpp:207
void dtFree(void *ptr)
Definition: DetourAlloc.cpp:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void dtFreeNavMeshQuery ( dtNavMeshQuery query)

Frees the specified query object using the Detour allocator.

Parameters
[in]queryA query object allocated using dtAllocNavMeshQuery
115 {
116  if (!navmesh) return;
117  navmesh->~dtNavMeshQuery();
118  dtFree(navmesh);
119 }
void dtFree(void *ptr)
Definition: DetourAlloc.cpp:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const int DT_MAX_AREAS = 64
static

The maximum number of user defined area ids.

const int DT_VERTS_PER_POLYGON = 6
static

The maximum number of vertices per navigation polygon.