Recast Navigation  1.0.35
DetourNavMesh.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
3 //
4 // This software is provided 'as-is', without any express or implied
5 // warranty. In no event will the authors be held liable for any damages
6 // arising from the use of this software.
7 // Permission is granted to anyone to use this software for any purpose,
8 // including commercial applications, and to alter it and redistribute it
9 // freely, subject to the following restrictions:
10 // 1. The origin of this software must not be misrepresented; you must not
11 // claim that you wrote the original software. If you use this software
12 // in a product, an acknowledgment in the product documentation would be
13 // appreciated but is not required.
14 // 2. Altered source versions must be plainly marked as such, and must not be
15 // misrepresented as being the original software.
16 // 3. This notice may not be removed or altered from any source distribution.
17 //
18 
19 #ifndef DETOURNAVMESH_H
20 #define DETOURNAVMESH_H
21 
22 #include "SharedConfig.h"
23 #include "DetourAlloc.h"
24 #include "DetourStatus.h"
25 
26 #ifdef DT_POLYREF64
27 // TODO: figure out a multiplatform version of uint64_t
28 // - maybe: https://code.google.com/p/msinttypes/
29 // - or: http://www.azillionmonkeys.com/qed/pstdint.h
30 #include <stdint.h>
31 #endif
32 
33 // Note: If you want to use 64-bit refs, change the types of both dtPolyRef & dtTileRef.
34 // It is also recommended that you change dtHashRef() to a proper 64-bit hash.
35 
38 #ifdef DT_POLYREF64
39 static const unsigned int DT_SALT_BITS = 16;
40 static const unsigned int DT_TILE_BITS = 28;
41 static const unsigned int DT_POLY_BITS = 20;
42 typedef uint64_t dtPolyRef;
43 #else
44 typedef unsigned int dtPolyRef;
45 #endif
46 
49 #ifdef DT_POLYREF64
50 typedef uint64_t dtTileRef;
51 #else
52 typedef unsigned int dtTileRef;
53 #endif
54 
57 static const int DT_VERTS_PER_POLYGON = 6;
58 
59 enum dtTeam
60 {
66 };
67 
73 
75 static const int DT_NAVMESH_MAGIC = 'D'<<24 | 'N'<<16 | 'A'<<8 | 'V';
76 
78 static const int DT_NAVMESH_VERSION = 7;
79 
81 static const int DT_NAVMESH_STATE_MAGIC = 'D'<<24 | 'N'<<16 | 'M'<<8 | 'S';
82 
84 static const int DT_NAVMESH_STATE_VERSION = 1;
85 
87 
90 static const unsigned short DT_EXT_LINK = 0x8000;
91 
93 static const unsigned int DT_NULL_LINK = 0xffffffff;
94 
96 static const unsigned int DT_OFFMESH_CON_BIDIR = 1;
97 
101 {
104 };
105 
108 {
112 };
113 
116 {
120 };
121 
122 
125 {
128 };
129 
132 {
134 };
135 
136 
139 static const float DT_RAY_CAST_LIMIT_PROPORTIONS = 50.0f;
140 
143 {
148 };
149 
150 
153 struct dtPoly
154 {
156  unsigned int firstLink;
157 
160  unsigned short verts[DT_VERTS_PER_POLYGON];
161 
163  unsigned short neis[DT_VERTS_PER_POLYGON];
164 
166  navAreaMask areaMask;
167 
169  unsigned char vertCount;
170 
173  unsigned char polyType;
174 
175  // dynamically adjustable penalty
177 
179  inline void setPolyType(unsigned char t) { polyType = t; }
180 
182  inline unsigned char getPolyType() const { return polyType; }
183 
185  inline void setTeamCost( dtTeam team, float cost ) { teamCost[team] = cost; }
186 
188  inline float getTeamCost( dtTeam team ) const { return teamCost[team]; }
189 };
190 
193 {
194  unsigned int vertBase;
195  unsigned int triBase;
196  unsigned char vertCount;
197  unsigned char triCount;
198 };
199 
203 struct dtLink
204 {
206  unsigned int next;
207  unsigned char edge;
208  unsigned char side;
209  unsigned char bmin;
210  unsigned char bmax;
211 };
212 
216 struct dtBVNode
217 {
218  unsigned short bmin[3];
219  unsigned short bmax[3];
220  int i;
221 };
222 
226 {
228  float pos[6];
229 
231  float rad;
232 
234  unsigned short poly;
235 
239  unsigned char flags;
240 
242  unsigned char side;
243 
245  unsigned int userId;
246 };
247 
251 {
252  int magic;
253  int version;
254  int x;
255  int y;
256  int layer;
257  unsigned int userId;
258  int polyCount;
259  int vertCount;
262 
265 
273  float bmin[3];
274  float bmax[3];
275 
278 };
279 
283 {
284  unsigned int salt;
285 
286  unsigned int linksFreeList;
289  float* verts;
292 
294  float* detailVerts;
295 
297  unsigned char* detailTris;
298 
302 
304 
305  unsigned char* data;
306  int dataSize;
307  int flags;
309 };
310 
316 {
317  float orig[3];
318  float tileWidth;
319  float tileHeight;
320  int maxTiles;
321  int maxPolys;
322 };
323 
324 typedef void( *dtTileCallback )( const dtMeshTile * tile, void * userdata );
325 
329 {
330 public:
331  dtNavMesh();
332  ~dtNavMesh();
333 
336 
340  dtStatus init(const dtNavMeshParams* params);
341 
348  dtStatus init(unsigned char* data, const int dataSize, const int flags);
349 
351  const dtNavMeshParams* getParams() const;
352 
360  dtStatus addTile(unsigned char* data, int dataSize, int flags, dtTileRef lastRef, dtTileRef* result);
361 
367  dtStatus removeTile(dtTileRef ref, unsigned char** data, int* dataSize);
368 
370 
373 
378  void calcTileLoc(const float* pos, int* tx, int* ty) const;
379 
385  const dtMeshTile* getTileAt(const int x, const int y, const int layer) const;
386 
393  int getTilesAt(const int x, const int y,
394  dtMeshTile const** tiles, const int maxTiles) const;
395 
396  void queryTiles( const float mins[ 3 ], const float maxs[ 3 ], dtTileCallback callback, void * userdata ) const;
397 
403  dtTileRef getTileRefAt(int x, int y, int layer) const;
404 
408  dtTileRef getTileRef(const dtMeshTile* tile) const;
409 
414  const dtMeshTile* getTileByRef(dtTileRef ref) const;
415 
418  int getMaxTiles() const;
419 
423  const dtMeshTile* getTile(int i) const;
424 
430  dtStatus getTileAndPolyByRef(const dtPolyRef ref, const dtMeshTile** tile, const dtPoly** poly) const;
431 
436  void getTileAndPolyByRefUnsafe(const dtPolyRef ref, const dtMeshTile** tile, const dtPoly** poly) const;
437 
441  bool isValidPolyRef(dtPolyRef ref) const;
442 
446  dtPolyRef getPolyRefBase(const dtMeshTile* tile) const;
447 
454  dtStatus getOffMeshConnectionPolyEndPoints(dtPolyRef prevRef, dtPolyRef polyRef, float* startPos, float* endPos) const;
455 
460 
462 
466 
471  dtStatus setPolyFlags(dtPolyRef ref, navAreaMask areaMask);
472 
477  dtStatus getPolyFlags(dtPolyRef ref, navAreaMask* resultFlags) const;
478 
479  dtStatus addPolyTeamCost( dtPolyRef ref, dtTeam team, float cost );
480  dtStatus setPolyTeamCost( dtPolyRef ref, dtTeam team, float cost );
481  dtStatus getPolyTeamCost( dtPolyRef ref, dtTeam team, float* costResult ) const;
482 
486  int getTileStateSize(const dtMeshTile* tile) const;
487 
493  dtStatus storeTileState(const dtMeshTile* tile, unsigned char* data, const int maxDataSize) const;
494 
500  dtStatus restoreTileState(dtMeshTile* tile, const unsigned char* data, const int maxDataSize);
501 
503 
507 
513  inline dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
514  {
515 #ifdef DT_POLYREF64
516  return ((dtPolyRef)salt << (DT_POLY_BITS+DT_TILE_BITS)) | ((dtPolyRef)it << DT_POLY_BITS) | (dtPolyRef)ip;
517 #else
518  return ((dtPolyRef)salt << (m_polyBits+m_tileBits)) | ((dtPolyRef)it << m_polyBits) | (dtPolyRef)ip;
519 #endif
520  }
521 
529  inline void decodePolyId(dtPolyRef ref, unsigned int& salt, unsigned int& it, unsigned int& ip) const
530  {
531 #ifdef DT_POLYREF64
532  const dtPolyRef saltMask = ((dtPolyRef)1<<DT_SALT_BITS)-1;
533  const dtPolyRef tileMask = ((dtPolyRef)1<<DT_TILE_BITS)-1;
534  const dtPolyRef polyMask = ((dtPolyRef)1<<DT_POLY_BITS)-1;
535  salt = (unsigned int)((ref >> (DT_POLY_BITS+DT_TILE_BITS)) & saltMask);
536  it = (unsigned int)((ref >> DT_POLY_BITS) & tileMask);
537  ip = (unsigned int)(ref & polyMask);
538 #else
539  const dtPolyRef saltMask = ((dtPolyRef)1<<m_saltBits)-1;
540  const dtPolyRef tileMask = ((dtPolyRef)1<<m_tileBits)-1;
541  const dtPolyRef polyMask = ((dtPolyRef)1<<m_polyBits)-1;
542  salt = (unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
543  it = (unsigned int)((ref >> m_polyBits) & tileMask);
544  ip = (unsigned int)(ref & polyMask);
545 #endif
546  }
547 
552  inline unsigned int decodePolyIdSalt(dtPolyRef ref) const
553  {
554 #ifdef DT_POLYREF64
555  const dtPolyRef saltMask = ((dtPolyRef)1<<DT_SALT_BITS)-1;
556  return (unsigned int)((ref >> (DT_POLY_BITS+DT_TILE_BITS)) & saltMask);
557 #else
558  const dtPolyRef saltMask = ((dtPolyRef)1<<m_saltBits)-1;
559  return (unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
560 #endif
561  }
562 
567  inline unsigned int decodePolyIdTile(dtPolyRef ref) const
568  {
569 #ifdef DT_POLYREF64
570  const dtPolyRef tileMask = ((dtPolyRef)1<<DT_TILE_BITS)-1;
571  return (unsigned int)((ref >> DT_POLY_BITS) & tileMask);
572 #else
573  const dtPolyRef tileMask = ((dtPolyRef)1<<m_tileBits)-1;
574  return (unsigned int)((ref >> m_polyBits) & tileMask);
575 #endif
576  }
577 
582  inline unsigned int decodePolyIdPoly(dtPolyRef ref) const
583  {
584 #ifdef DT_POLYREF64
585  const dtPolyRef polyMask = ((dtPolyRef)1<<DT_POLY_BITS)-1;
586  return (unsigned int)(ref & polyMask);
587 #else
588  const dtPolyRef polyMask = ((dtPolyRef)1<<m_polyBits)-1;
589  return (unsigned int)(ref & polyMask);
590 #endif
591  }
592 
594 
595 private:
596 
598  dtMeshTile* getTile(int i);
600 
602  int getTilesAt(const int x, const int y,
603  dtMeshTile** tiles, const int maxTiles) const;
604 
606  int getNeighbourTilesAt(const int x, const int y, const int side,
607  dtMeshTile** tiles, const int maxTiles) const;
608 
610  int findConnectingPolys(const float* va, const float* vb,
611  const dtMeshTile* tile, int side,
612  dtPolyRef* con, float* conarea, int maxcon) const;
613 
615  void connectIntLinks(dtMeshTile* tile);
617  void baseOffMeshLinks(dtMeshTile* tile);
618 
620  void connectExtLinks(dtMeshTile* tile, dtMeshTile* target, int side);
622  void connectExtOffMeshLinks(dtMeshTile* tile, dtMeshTile* target, int side);
623 
625  void unconnectExtLinks(dtMeshTile* tile, dtMeshTile* target);
626 
627 
628  // TODO: These methods are duplicates from dtNavMeshQuery, but are needed for off-mesh connection finding.
629 
631  int queryPolygonsInTile(const dtMeshTile* tile, const float* qmin, const float* qmax,
632  dtPolyRef* polys, const int maxPolys) const;
634  dtPolyRef findNearestPolyInTile(const dtMeshTile* tile, const float* center,
635  const float* extents, float* nearestPt) const;
637  void closestPointOnPoly(dtPolyRef ref, const float* pos, float* closest, bool* posOverPoly) const;
638 
639  dtNavMeshParams m_params;
640  float m_orig[3];
641  float m_tileWidth, m_tileHeight;
642  int m_maxTiles;
643  int m_tileLutSize;
644  int m_tileLutMask;
645 
646  dtMeshTile** m_posLookup;
647  dtMeshTile* m_nextFree;
648  dtMeshTile* m_tiles;
649 
650 #ifndef DT_POLYREF64
651  unsigned int m_saltBits;
652  unsigned int m_tileBits;
653  unsigned int m_polyBits;
654 #endif
655 };
656 
661 
665 void dtFreeNavMesh(dtNavMesh* navmesh);
666 
667 #endif // DETOURNAVMESH_H
668 
670 
671 // This section contains detailed documentation for members that don't have
672 // a source file. It reduces clutter in the main section of the header.
673 
unsigned int decodePolyIdTile(dtPolyRef ref) const
Extracts the tile's index from the specified polygon reference.
Definition: DetourNavMesh.h:567
The navigation mesh owns the tile memory and is responsible for freeing it.
Definition: DetourNavMesh.h:103
dtTileRef getTileRef(const dtMeshTile *tile) const
Gets the tile reference for the specified tile.
Definition: DetourNavMesh.cpp:1298
unsigned int dtPolyRef
A handle to a polygon within a navigation mesh tile.
Definition: DetourNavMesh.h:44
dtMeshHeader * header
The tile header.
Definition: DetourNavMesh.h:287
unsigned short poly
The polygon reference of the connection within the tile.
Definition: DetourNavMesh.h:234
dtStraightPathOptions
Options for dtNavMeshQuery::findStraightPath.
Definition: DetourNavMesh.h:115
dtStraightPathFlags
Vertex flags returned by dtNavMeshQuery::findStraightPath.
Definition: DetourNavMesh.h:107
unsigned int dtTileRef
A handle to a tile within a navigation mesh.
Definition: DetourNavMesh.h:52
unsigned short bmax[3]
Maximum bounds of the node's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:219
static const float DT_RAY_CAST_LIMIT_PROPORTIONS
Limit raycasting during any angle pahfinding The limit is given as a multiple of the character radius...
Definition: DetourNavMesh.h:139
[provisional] trade quality for performance far from the origin. The idea is that by then a new query...
Definition: DetourNavMesh.h:126
unsigned char side
End point side.
Definition: DetourNavMesh.h:242
Defines the location of detail sub-mesh data within a dtMeshTile.
Definition: DetourNavMesh.h:192
float walkableHeight
The height of the agents using the tile.
Definition: DetourNavMesh.h:270
float walkableClimb
The maximum climb height of the agents using the tile.
Definition: DetourNavMesh.h:272
unsigned int decodePolyIdSalt(dtPolyRef ref) const
Extracts a tile's salt value from the specified polygon reference.
Definition: DetourNavMesh.h:552
dtStatus getOffMeshConnectionPolyEndPoints(dtPolyRef prevRef, dtPolyRef polyRef, float *startPos, float *endPos) const
Gets the endpoints for an off-mesh connection, ordered by "direction of travel".
Definition: DetourNavMesh.cpp:1419
dtStatus init(const dtNavMeshParams *params)
Initializes the navigation mesh for tiled use.
Definition: DetourNavMesh.cpp:224
static const int DT_NAVMESH_STATE_VERSION
A version number used to detect compatibility of navigation tile states.
Definition: DetourNavMesh.h:84
float orig[3]
The world space origin of the navigation mesh's tile space. [(x, y, z)].
Definition: DetourNavMesh.h:317
unsigned char triCount
The number of triangles in the sub-mesh.
Definition: DetourNavMesh.h:197
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
Definition: DetourNavMesh.h:303
float walkableRadius
The radius of the agents using the tile.
Definition: DetourNavMesh.h:271
bool isValidPolyRef(dtPolyRef ref) const
Checks the validity of a polygon reference.
Definition: DetourNavMesh.cpp:1185
void getTileAndPolyByRefUnsafe(const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const
Returns the tile and polygon for the specified polygon reference.
Definition: DetourNavMesh.cpp:1177
const dtNavMeshParams * getParams() const
The navigation mesh initialization params.
Definition: DetourNavMesh.cpp:294
float teamCost[DT_MAX_TEAMS]
Definition: DetourNavMesh.h:176
float bvQuantFactor
The bounding volume quantization factor.
Definition: DetourNavMesh.h:277
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Decodes a standard polygon reference.
Definition: DetourNavMesh.h:529
unsigned char flags
Link flags.
Definition: DetourNavMesh.h:239
dtStatus addTile(unsigned char *data, int dataSize, int flags, dtTileRef lastRef, dtTileRef *result)
Adds a tile to the navigation mesh.
Definition: DetourNavMesh.cpp:841
dtStatus getPolyFlags(dtPolyRef ref, navAreaMask *resultFlags) const
Gets the user defined flags for the specified polygon.
Definition: DetourNavMesh.cpp:1504
Raycast should calculate movement cost along the ray and fill RaycastHit::cost.
Definition: DetourNavMesh.h:133
int offMeshConCount
The number of off-mesh connections.
Definition: DetourNavMesh.h:268
const dtMeshTile * getTileByRef(dtTileRef ref) const
Gets the tile for the specified tile reference.
Definition: DetourNavMesh.cpp:1110
dtBVNode * bvTree
The tile bounding volume nodes.
Definition: DetourNavMesh.h:301
static const unsigned int DT_OFFMESH_CON_BIDIR
A flag that indicates that an off-mesh connection can be traversed in both directions. (Is bidirectional.)
Definition: DetourNavMesh.h:96
float bmax[3]
The maximum bounds of the tile's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:274
int detailMeshCount
The number of sub-meshes in the detail mesh.
Definition: DetourNavMesh.h:261
dtStatus storeTileState(const dtMeshTile *tile, unsigned char *data, const int maxDataSize) const
Stores the non-structural state of the tile in the specified buffer.
Definition: DetourNavMesh.cpp:1352
unsigned short verts[DT_VERTS_PER_POLYGON]
The indices of the polygon's vertices.
Definition: DetourNavMesh.h:160
navAreaMask areaMask
The user defined polygon flags.
Definition: DetourNavMesh.h:166
const dtOffMeshConnection * getOffMeshConnectionByRef(dtPolyRef ref) const
Gets the specified off-mesh connection.
Definition: DetourNavMesh.cpp:1462
unsigned int dtStatus
Definition: DetourStatus.h:22
unsigned char polyType
The bit packed area id and polygon type.
Definition: DetourNavMesh.h:173
void setTeamCost(dtTeam team, float cost)
Sets the polygon type. (See: dtPolyTypes.)
Definition: DetourNavMesh.h:185
void dtFreeNavMesh(dtNavMesh *navmesh)
Frees the specified navigation mesh object using the Detour allocator.
Definition: DetourNavMesh.cpp:149
unsigned char vertCount
The number of vertices in the sub-mesh.
Definition: DetourNavMesh.h:196
dtPolyTypes
Flags representing the type of a navigation mesh polygon.
Definition: DetourNavMesh.h:142
dtNavMesh()
Definition: DetourNavMesh.cpp:188
The vertex is the start position in the path.
Definition: DetourNavMesh.h:109
unsigned int userId
The id of the offmesh connection. (User assigned when the navigation mesh is built.)
Definition: DetourNavMesh.h:245
A navigation mesh based on tiles of convex polygons.
Definition: DetourNavMesh.h:328
int i
The node's index. (Negative for escape sequence.)
Definition: DetourNavMesh.h:220
int offMeshBase
The index of the first polygon which is an off-mesh connection.
Definition: DetourNavMesh.h:269
Bounding volume node.
Definition: DetourNavMesh.h:216
unsigned int vertBase
The offset of the vertices in the dtMeshTile::detailVerts array.
Definition: DetourNavMesh.h:194
int layer
The layer of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:256
int flags
Tile flags. (See: dtTileFlags)
Definition: DetourNavMesh.h:307
unsigned short bmin[3]
Minimum bounds of the node's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:218
Provides high level information related to a dtMeshTile object.
Definition: DetourNavMesh.h:250
unsigned short neis[DT_VERTS_PER_POLYGON]
Packed data representing neighbor polygons references and flags for each edge.
Definition: DetourNavMesh.h:163
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition: DetourNavMesh.h:308
dtStatus setPolyTeamCost(dtPolyRef ref, dtTeam team, float cost)
Definition: DetourNavMesh.cpp:1538
The vertex is the end position in the path.
Definition: DetourNavMesh.h:110
dtStatus restoreTileState(dtMeshTile *tile, const unsigned char *data, const int maxDataSize)
Restores the state of the tile.
Definition: DetourNavMesh.cpp:1383
Definition: DetourNavMesh.h:63
Defines a polyogn within a dtMeshTile object.
Definition: DetourNavMesh.h:153
float rad
The radius of the endpoints. [Limit: >= 0].
Definition: DetourNavMesh.h:231
dtTileFlags
Tile flags used for various functions and fields.
Definition: DetourNavMesh.h:100
int polyCount
The number of polygons in the tile.
Definition: DetourNavMesh.h:258
int bvNodeCount
The number of bounding volume nodes. (Zero if bounding volumes are disabled.)
Definition: DetourNavMesh.h:267
Add a vertex at every polygon edge crossing.
Definition: DetourNavMesh.h:119
int x
The x-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:254
unsigned int linksFreeList
Index to the next free link.
Definition: DetourNavMesh.h:286
dtStatus getPolyTeamCost(dtPolyRef ref, dtTeam team, float *costResult) const
Definition: DetourNavMesh.cpp:1555
unsigned int salt
Counter describing modifications to the tile.
Definition: DetourNavMesh.h:284
dtFindPathOptions
Options for dtNavMeshQuery::findPath.
Definition: DetourNavMesh.h:124
float bmin[3]
The minimum bounds of the tile's AABB. [(x, y, z)].
Definition: DetourNavMesh.h:273
int version
Tile data format version number.
Definition: DetourNavMesh.h:253
int detailVertCount
The number of unique vertices in the detail mesh. (In addition to the polygon vertices.)
Definition: DetourNavMesh.h:264
int maxLinkCount
The number of allocated links.
Definition: DetourNavMesh.h:260
~dtNavMesh()
Definition: DetourNavMesh.cpp:209
dtStatus getTileAndPolyByRef(const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const
Gets the tile and polygon for the specified polygon reference.
Definition: DetourNavMesh.cpp:1159
float * verts
The tile vertices. [Size: dtMeshHeader::vertCount].
Definition: DetourNavMesh.h:289
unsigned int userId
The user defined id of the tile.
Definition: DetourNavMesh.h:257
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition: DetourNavMesh.h:290
int dataSize
Size of the tile data.
Definition: DetourNavMesh.h:306
float * detailVerts
The detail mesh's unique vertices. [(x, y, z) * dtMeshHeader::detailVertCount].
Definition: DetourNavMesh.h:294
unsigned char * detailTris
The detail mesh's triangles. [(vertA, vertB, vertC) * dtMeshHeader::detailTriCount].
Definition: DetourNavMesh.h:297
void queryTiles(const float mins[3], const float maxs[3], dtTileCallback callback, void *userdata) const
Definition: DetourNavMesh.cpp:1065
static const unsigned short DT_EXT_LINK
A flag that indicates that an entity links to an external entity.
Definition: DetourNavMesh.h:90
Definition: DetourNavMesh.h:117
void setPolyType(unsigned char t)
Sets the polygon type. (See: dtPolyTypes.)
Definition: DetourNavMesh.h:179
unsigned int decodePolyIdPoly(dtPolyRef ref) const
Extracts the polygon's index (within its tile) from the specified polygon reference.
Definition: DetourNavMesh.h:582
int getTileStateSize(const dtMeshTile *tile) const
Gets the size of the buffer required by storeTileState to store the specified tile's state...
Definition: DetourNavMesh.cpp:1339
dtStatus setPolyFlags(dtPolyRef ref, navAreaMask areaMask)
Sets the user defined flags for the specified polygon.
Definition: DetourNavMesh.cpp:1487
dtPolyDetail * detailMeshes
The tile's detail sub-meshes. [Size: dtMeshHeader::detailMeshCount].
Definition: DetourNavMesh.h:291
int maxPolys
The maximum number of polygons each tile can contain.
Definition: DetourNavMesh.h:321
Add a vertex at every polygon edge crossing where area changes.
Definition: DetourNavMesh.h:118
int magic
Tile magic number. (Used to identify the data format.)
Definition: DetourNavMesh.h:252
const dtMeshTile * getTile(int i) const
Gets the tile at the specified index.
Definition: DetourNavMesh.cpp:1148
use raycasts during pathfind to "shortcut" (raycast still consider costs)
Definition: DetourNavMesh.h:127
void calcTileLoc(const float *pos, int *tx, int *ty) const
Calculates the tile grid location for the specified world position.
Definition: DetourNavMesh.cpp:1153
int detailTriCount
The number of triangles in the detail mesh.
Definition: DetourNavMesh.h:266
unsigned char * data
The tile data. (Not directly accessed under normal situations.)
Definition: DetourNavMesh.h:305
float tileWidth
The width of each tile. (Along the x-axis.)
Definition: DetourNavMesh.h:318
Definition: DetourNavMesh.h:64
The polygon is an off-mesh connection consisting of two vertices.
Definition: DetourNavMesh.h:147
unsigned int firstLink
Index to first link in linked list. (Or DT_NULL_LINK if there is no link.)
Definition: DetourNavMesh.h:156
dtPolyRef getPolyRefBase(const dtMeshTile *tile) const
Gets the polygon reference for the tile's base polygon.
Definition: DetourNavMesh.cpp:1319
static const int DT_NAVMESH_STATE_MAGIC
A magic number used to detect the compatibility of navigation tile states.
Definition: DetourNavMesh.h:81
Configuration parameters used to define multi-tile navigation meshes.
Definition: DetourNavMesh.h:315
unsigned char vertCount
The number of vertices in the polygon.
Definition: DetourNavMesh.h:169
dtNavMesh * dtAllocNavMesh()
Allocates a navigation mesh object using the Detour allocator.
Definition: DetourNavMesh.cpp:138
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition: DetourNavMesh.h:288
float tileHeight
The height of each tile. (Along the z-axis.)
Definition: DetourNavMesh.h:319
unsigned int triBase
The offset of the triangles in the dtMeshTile::detailTris array.
Definition: DetourNavMesh.h:195
dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
Derives a standard polygon reference.
Definition: DetourNavMesh.h:513
static const int DT_NAVMESH_MAGIC
A magic number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:75
dtRaycastOptions
Options for dtNavMeshQuery::raycast.
Definition: DetourNavMesh.h:131
Defines a navigation mesh tile.
Definition: DetourNavMesh.h:282
Definition: DetourNavMesh.h:61
int maxTiles
The maximum number of tiles the navigation mesh can contain.
Definition: DetourNavMesh.h:320
int y
The y-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition: DetourNavMesh.h:255
float pos[6]
The endpoints of the connection. [(ax, ay, az, bx, by, bz)].
Definition: DetourNavMesh.h:228
dtStatus removeTile(dtTileRef ref, unsigned char **data, int *dataSize)
Removes the specified tile from the navigation mesh.
Definition: DetourNavMesh.cpp:1202
Definition: DetourNavMesh.h:65
The vertex is the start of an off-mesh connection.
Definition: DetourNavMesh.h:111
dtTileRef getTileRefAt(int x, int y, int layer) const
Gets the tile reference for the tile at specified grid location.
Definition: DetourNavMesh.cpp:1091
dtStatus addPolyTeamCost(dtPolyRef ref, dtTeam team, float cost)
Definition: DetourNavMesh.cpp:1521
void(* dtTileCallback)(const dtMeshTile *tile, void *userdata)
Definition: DetourNavMesh.h:324
static const int DT_NAVMESH_VERSION
A version number used to detect compatibility of navigation tile data.
Definition: DetourNavMesh.h:78
const dtMeshTile * getTileAt(const int x, const int y, const int layer) const
Gets the tile at the specified grid location.
Definition: DetourNavMesh.cpp:980
The polygon is a standard convex polygon that is part of the surface of the mesh. ...
Definition: DetourNavMesh.h:145
Definition: DetourNavMesh.h:62
int vertCount
The number of vertices in the tile.
Definition: DetourNavMesh.h:259
int getTilesAt(const int x, const int y, dtMeshTile const **tiles, const int maxTiles) const
Gets all tiles at the specified grid location.
Definition: DetourNavMesh.cpp:1043
Defines an navigation mesh off-mesh connection within a dtMeshTile object.
Definition: DetourNavMesh.h:225
unsigned char getPolyType() const
Gets the polygon type. (See: dtPolyTypes)
Definition: DetourNavMesh.h:182
int getMaxTiles() const
The maximum number of tiles supported by the navigation mesh.
Definition: DetourNavMesh.cpp:1138
dtTeam
Definition: DetourNavMesh.h:59
static const int DT_VERTS_PER_POLYGON
The maximum number of vertices per navigation polygon.
Definition: DetourNavMesh.h:57
static const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition: DetourNavMesh.h:93
float getTeamCost(dtTeam team) const
Gets the polygon type. (See: dtPolyTypes)
Definition: DetourNavMesh.h:188