UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DetourNavMesh.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2// Modified version of Recast/Detour's source file
3
4//
5// Copyright (c) 2009-2010 Mikko Mononen memon@inside.org
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10// Permission is granted to anyone to use this software for any purpose,
11// including commercial applications, and to alter it and redistribute it
12// freely, subject to the following restrictions:
13// 1. The origin of this software must not be misrepresented; you must not
14// claim that you wrote the original software. If you use this software
15// in a product, an acknowledgment in the product documentation would be
16// appreciated but is not required.
17// 2. Altered source versions must be plainly marked as such, and must not be
18// misrepresented as being the original software.
19// 3. This notice may not be removed or altered from any source distribution.
20//
21
22#ifndef DETOURNAVMESH_H
23#define DETOURNAVMESH_H
24
25#include "CoreMinimal.h"
26#include "Detour/DetourAlloc.h"
27#include "Detour/DetourStatus.h"
29#include "Logging/LogMacros.h"
30
32
33#if WITH_NAVMESH_SEGMENT_LINKS
35#endif
36
37// Note: If you want to use 64-bit refs, change the types of both dtPolyRef & dtTileRef.
38// It is also recommended that you change dtHashRef() to a proper 64-bit hash.
39
40#ifndef USE_64BIT_ADDRESS
41#define USE_64BIT_ADDRESS 1
42#endif
43
44#if USE_64BIT_ADDRESS
45
46#if defined(__LP64__)
47// LP64 (Linux/OS X): UE will define its uint64 type as "unsigned long long" so we need to match this
48typedef unsigned long long UEType_uint64;
49#else
50#include <stdint.h>
52#endif
53
57
61
64
65#else
66
69typedef unsigned int dtPolyRef;
70
73typedef unsigned int dtTileRef;
74
76typedef unsigned int dtClusterRef;
77
78#endif // USE_64BIT_ADDRESS
79
82static const int DT_VERTS_PER_POLYGON = 6;
83
89
92//static const int DT_NAVMESH_MAGIC = 'D'<<24 | 'N'<<16 | 'A'<<8 | 'V';
93
95static const int DT_NAVMESH_VERSION = 7;
96
98static const int DT_NAVMESH_STATE_MAGIC = 'D'<<24 | 'N'<<16 | 'M'<<8 | 'S';
99
101static const int DT_NAVMESH_STATE_VERSION = 1;
102
104
107static const unsigned short DT_EXT_LINK = 0x8000;
108
110inline const unsigned int DT_NULL_LINK = 0xffffffff;
111
113static const unsigned char DT_OFFMESH_CON_BIDIR = 0x01;
114static const unsigned char DT_OFFMESH_CON_POINT = 0x02; //UE
115static const unsigned char DT_OFFMESH_CON_SEGMENT = 0x04; //UE
116static const unsigned char DT_OFFMESH_CON_CHEAPAREA = 0x08; //UE
117static const unsigned char DT_OFFMESH_CON_GENERATED = 0x10; //UE
118
121static const int DT_MAX_AREAS = 64;
122
123//@UE BEGIN
125static const int DT_MIN_SALT_BITS = 5;
126static const int DT_SALT_BASE = 1;
127
128static const int DT_RESOLUTION_COUNT = 3;
129
130#if WITH_NAVMESH_SEGMENT_LINKS
132static const int DT_MAX_OFFMESH_SEGMENT_PARTS = 4;
133static const int DT_INVALID_SEGMENT_PART = 0xffff;
134#endif // WITH_NAVMESH_SEGMENT_LINKS
135
137static const unsigned char DT_CONNECTION_INTERNAL = (1 << 7);
138static const unsigned char DT_LINK_FLAG_OFFMESH_CON = (1 << 6);
139static const unsigned char DT_LINK_FLAG_OFFMESH_CON_BIDIR = (1 << 5);
140static const unsigned char DT_LINK_FLAG_OFFMESH_CON_BACKTRACKER = (1 << 4);
141static const unsigned char DT_LINK_FLAG_OFFMESH_CON_ENABLED = (1 << 3);
142static const unsigned char DT_LINK_FLAG_SIDE_MASK = 7;
143
144#if WITH_NAVMESH_CLUSTER_LINKS
146static const unsigned char DT_CLINK_VALID_FWD = 0x01;
147static const unsigned char DT_CLINK_VALID_BCK = 0x02;
148
150static const unsigned int DT_CLINK_FIRST = 0x80000000;
151#endif // WITH_NAVMESH_CLUSTER_LINKS
152//@UE END
153
154//@UE BEGIN Adding support for memory tracking.
155struct dtMeshTile;
156
158
160
162//@UE END Adding support for memory tracking.
163
167{
169};
170
178
185
188{
193
194 //@UE BEGIN
195#if WITH_NAVMESH_SEGMENT_LINKS
198#endif // WITH_NAVMESH_SEGMENT_LINKS
199 //@UE END
200};
201
202
205struct dtPoly
206{
208 unsigned int firstLink;
209
212 unsigned short verts[DT_VERTS_PER_POLYGON];
213
215 unsigned short neis[DT_VERTS_PER_POLYGON];
216
218 unsigned short flags;
219
221 unsigned char vertCount;
222
225 unsigned char areaAndtype;
226
228 inline void setArea(unsigned char a) { areaAndtype = static_cast<unsigned char>((areaAndtype & 0xc0) | (a & 0x3f)); }
229
231 inline void setType(unsigned char t) { areaAndtype = static_cast<unsigned char>((areaAndtype & 0x3f) | (t << 6)); }
232
234 inline unsigned char getArea() const { return areaAndtype & 0x3f; }
235
237 inline unsigned char getType() const { return areaAndtype >> 6; }
238};
239
242{
243 unsigned short vertBase;
244 unsigned short triBase;
245 unsigned char vertCount;
246 unsigned char triCount;
247};
248
252struct dtLink
253{
255 unsigned int next;
256 unsigned char edge;
257 unsigned char side;
258 unsigned char bmin;
259 unsigned char bmax;
260};
261
266{
267 unsigned short bmin[3];
268 unsigned short bmax[3];
269 int i;
270};
271
272//@UE BEGIN
273#if WITH_NAVMESH_SEGMENT_LINKS
276{
277 dtReal startA[3];
278 dtReal endA[3];
279 dtReal startB[3];
280 dtReal endB[3];
281
283 dtReal rad;
284
286 unsigned int userId;
287
289 unsigned short firstPoly;
290
292 unsigned char npolys;
293
295 unsigned char flags;
296
298 inline void setFlags(unsigned char conFlags)
299 {
300 flags = ((conFlags & DT_OFFMESH_CON_BIDIR) ? 0x80 : 0);
301 }
302
304 inline bool getBiDirectional() const { return (flags & 0x80) != 0; }
305};
306#endif // WITH_NAVMESH_SEGMENT_LINKS
307//@UE END
308
312{
315
318
319 //@UE BEGIN
322 //@UE END
323
325 unsigned long long int userId;
326
328 unsigned short poly;
329
331 unsigned char side;
332
334 unsigned char flags;
335
336 //@UE BEGIN
338 inline void setFlags(unsigned char conTypeFlags)
339 {
340 flags = ((conTypeFlags & DT_OFFMESH_CON_BIDIR) ? 0x80 : 0) |
341 ((conTypeFlags & DT_OFFMESH_CON_CHEAPAREA) ? 0x40 : 0) |
342 ((conTypeFlags & DT_OFFMESH_CON_GENERATED) ? 0x20 : 0);
343 }
344
346 inline bool getBiDirectional() const { return (flags & 0x80) != 0; }
347
349 inline bool getSnapToCheapestArea() const { return (flags & 0x40) != 0; }
350
352 inline bool getIsGenerated() const { return (flags & 0x20) != 0; }
353 //@UE END
354};
355
356//@UE BEGIN
357#if WITH_NAVMESH_CLUSTER_LINKS
359struct dtCluster
360{
361 dtReal center[3];
362 unsigned int firstLink;
363 unsigned int numLinks;
364};
365
367struct dtClusterLink
368{
369 dtClusterRef ref;
370 unsigned int next;
371 unsigned char flags;
372};
373#endif // WITH_NAVMESH_CLUSTER_LINKS
374//@UE END
375
379{
380 unsigned short version;
381 unsigned short layer;
382
383 unsigned short polyCount;
384 unsigned short vertCount;
385
386 int x;
387 int y;
388
389 unsigned short maxLinkCount;
390 unsigned short detailMeshCount;
391
393 unsigned short detailVertCount;
394
395 unsigned short detailTriCount;
396 unsigned short bvNodeCount;
397 unsigned short offMeshConCount;
398 unsigned short offMeshBase;
399
400 //@UE BEGIN
401#if WITH_NAVMESH_SEGMENT_LINKS
402 unsigned short offMeshSegConCount;
403 unsigned short offMeshSegPolyBase;
404 unsigned short offMeshSegVertBase;
405#endif // WITH_NAVMESH_SEGMENT_LINKS
406
407#if WITH_NAVMESH_CLUSTER_LINKS
408 unsigned short clusterCount;
409#endif // WITH_NAVMESH_CLUSTER_LINKS
410
411 unsigned char resolution;
412 //@UE END
413
414 // These should be at the bottom, as they are less often used than the rest of the data. The rest will fit in one cache line.
417};
418
422{
423 unsigned int salt;
424
425 unsigned int linksFreeList;
431
434
436 unsigned char* detailTris;
437
441
443
444 unsigned char* data;
446 int flags;
448
449 //@UE BEGIN
450#if WITH_NAVMESH_SEGMENT_LINKS
452#endif // WITH_NAVMESH_SEGMENT_LINKS
453
454#if WITH_NAVMESH_CLUSTER_LINKS
456 unsigned short* polyClusters;
457
459#endif // WITH_NAVMESH_CLUSTER_LINKS
460
462 unsigned int dynamicFreeListO;
463
464#if WITH_NAVMESH_CLUSTER_LINKS
465 unsigned int dynamicFreeListC;
466#endif // WITH_NAVMESH_CLUSTER_LINKS
467
468 //@UE END
469};
470
471//@UE BEGIN
477//@UE END
478
499
503{
504public:
507
510
515
522 NAVMESH_API dtStatus init(unsigned char* data, const int dataSize, const int flags);
523
526
534 NAVMESH_API dtStatus addTile(unsigned char* data, int dataSize, int flags, dtTileRef lastRef, dtTileRef* result);
535
536#if WITH_NAVMESH_SEGMENT_LINKS
543#endif // WITH_NAVMESH_SEGMENT_LINKS
544
550 NAVMESH_API dtStatus removeTile(dtTileRef ref, unsigned char** data, int* dataSize);
551
553
556
561 NAVMESH_API void calcTileLoc(const dtReal* pos, int* tx, int* ty) const;
562
563
567 NAVMESH_API bool isTileLocInValidRange(const dtReal* pos) const;
568
574 NAVMESH_API const dtMeshTile* getTileAt(const int x, const int y, const int layer) const;
575
576// @UE BEGIN
581 NAVMESH_API int getTileCountAt(const int x, const int y) const;
582// @UE END
583
590 NAVMESH_API int getTilesAt(const int x, const int y,
591 dtMeshTile const** tiles, const int maxTiles) const;
592
598 NAVMESH_API dtTileRef getTileRefAt(int x, int y, int layer) const;
599
604
610
616
619 NAVMESH_API int getMaxTiles() const;
620
624 NAVMESH_API const dtMeshTile* getTile(int i) const;
625
631 NAVMESH_API dtStatus getTileAndPolyByRef(const dtPolyRef ref, const dtMeshTile** tile, const dtPoly** poly) const;
632
637 NAVMESH_API void getTileAndPolyByRefUnsafe(const dtPolyRef ref, const dtMeshTile** tile, const dtPoly** poly) const;
638
642 NAVMESH_API bool isValidPolyRef(dtPolyRef ref) const;
643
648
653
662
667
671 NAVMESH_API void updateOffMeshConnectionByUserId(unsigned long long int userId, unsigned char newArea, unsigned short newFlags);
672
673 //@UE BEGIN
674#if WITH_NAVMESH_SEGMENT_LINKS
679
683 NAVMESH_API void updateOffMeshSegmentConnectionByUserId(unsigned int userId, unsigned char newArea, unsigned short newFlags);
684#endif // WITH_NAVMESH_SEGMENT_LINKS
685 //@UE END
686
688
692
697 NAVMESH_API dtStatus setPolyFlags(dtPolyRef ref, unsigned short flags);
698
703 NAVMESH_API dtStatus getPolyFlags(dtPolyRef ref, unsigned short* resultFlags) const;
704
709 NAVMESH_API dtStatus setPolyArea(dtPolyRef ref, unsigned char area);
710
715 NAVMESH_API dtStatus getPolyArea(dtPolyRef ref, unsigned char* resultArea) const;
716
721
727 NAVMESH_API dtStatus storeTileState(const dtMeshTile* tile, unsigned char* data, const int maxDataSize) const;
728
734 NAVMESH_API dtStatus restoreTileState(dtMeshTile* tile, const unsigned char* data, const int maxDataSize);
735
737
741
747 inline dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
748 {
749 return ((dtPolyRef)salt << (m_polyBits+m_tileBits)) | ((dtPolyRef)it << m_polyBits) | (dtPolyRef)ip;
750 }
751
759 inline void decodePolyId(dtPolyRef ref, unsigned int& salt, unsigned int& it, unsigned int& ip) const
760 {
761 const dtPolyRef saltMask = ((dtPolyRef)1<<m_saltBits)-1;
762 const dtPolyRef tileMask = ((dtPolyRef)1<<m_tileBits)-1;
763 const dtPolyRef polyMask = ((dtPolyRef)1<<m_polyBits)-1;
764 salt = (unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
765 it = (unsigned int)((ref >> m_polyBits) & tileMask);
766 ip = (unsigned int)(ref & polyMask);
767 }
768
773 inline unsigned int decodePolyIdSalt(dtPolyRef ref) const
774 {
775 const dtPolyRef saltMask = ((dtPolyRef)1<<m_saltBits)-1;
776 return (unsigned int)((ref >> (m_polyBits+m_tileBits)) & saltMask);
777 }
778
783 inline unsigned int decodePolyIdTile(dtPolyRef ref) const
784 {
785 const dtPolyRef tileMask = ((dtPolyRef)1<<m_tileBits)-1;
786 return (unsigned int)((ref >> m_polyBits) & tileMask);
787 }
788
793 inline unsigned int decodePolyIdPoly(dtPolyRef ref) const
794 {
795 const dtPolyRef polyMask = ((dtPolyRef)1<<m_polyBits)-1;
796 return (unsigned int)(ref & polyMask);
797 }
798
802 inline unsigned int decodeClusterIdTile(dtClusterRef ref) const
803 {
804 return decodePolyIdTile(ref);
805 }
806
807 //@UE BEGIN
808#if WITH_NAVMESH_CLUSTER_LINKS
812 inline unsigned int decodeClusterIdCluster(dtClusterRef ref) const
813 {
814 return decodePolyIdPoly(ref);
815 }
816#endif // WITH_NAVMESH_CLUSTER_LINKS
817
819 NAVMESH_API void applyWorldOffset(const dtReal* offset);
820
822 inline dtLink& getLink(dtMeshTile* tile, unsigned int linkIdx)
823 {
824 return (linkIdx < (unsigned int)tile->header->maxLinkCount) ? tile->links[linkIdx] : tile->dynamicLinksO[linkIdx - tile->header->maxLinkCount];
825 }
826
827 inline const dtLink& getLink(const dtMeshTile* tile, unsigned int linkIdx) const
828 {
829 return (linkIdx < (unsigned int)tile->header->maxLinkCount) ? tile->links[linkIdx] : tile->dynamicLinksO[linkIdx - tile->header->maxLinkCount];
830 }
831
832#if WITH_NAVMESH_CLUSTER_LINKS
834 inline dtClusterLink& getClusterLink(dtMeshTile* tile, unsigned int linkIdx)
835 {
836 return tile->dynamicLinksC[linkIdx - DT_CLINK_FIRST];
837 }
838
839 inline const dtClusterLink& getClusterLink(const dtMeshTile* tile, unsigned int linkIdx) const
840 {
841 return tile->dynamicLinksC[linkIdx - DT_CLINK_FIRST];
842 }
843#endif // WITH_NAVMESH_CLUSTER_LINKS
844
846 NAVMESH_API void linkOffMeshHelper(dtMeshTile* tile0, unsigned int polyIdx0, const dtMeshTile* tile1, unsigned int polyIdx1, unsigned char side, unsigned char edge);
847
848 inline bool isEmpty() const
849 {
850 // has no tile grid set up
851 return (m_tileWidth > 0 && m_tileHeight > 0) == false;
852 }
853
854 inline unsigned int getSaltBits() const
855 {
856 return m_saltBits;
857 }
858
859 NAVMESH_API void applyAreaCostOrder(unsigned char* costOrder);
860
862 NAVMESH_API int getNeighbourTilesCountAt(const int x, const int y, const int side) const;
863
864 bool getNeighbourCoords(const int x, const int y, const int side, int& outX, int& outY) const
865 {
866 outX = x;
867 outY = y;
868 switch (side)
869 {
870 case 0: ++outX; break;
871 case 1: ++outX; ++outY; break;
872 case 2: ++outY; break;
873 case 3: --outX; ++outY; break;
874 case 4: --outX; break;
875 case 5: --outX; --outY; break;
876 case 6: --outY; break;
877 case 7: ++outX; --outY; break;
878 };
879 // @todo we might want to do some validation
880 return true;
881 }
882
883 unsigned int getTileIndex(const dtMeshTile* tile) const
884 {
885 return (unsigned int)(tile - m_tiles);
886 }
887 //@UE END
889
890 //@UE Begin LWCoords
894 dtReal getBVQuantFactor(const unsigned char resolution) const { return m_params.resolutionParams[resolution].bvQuantFactor; }
895 //@UE END LWCoords
896
897private:
898
899 // [UE] result struct for findConnectingPolys
900 struct FConnectingPolyData
901 {
902 dtReal min;
903 dtReal max;
904 dtPolyRef ref;
905 };
906
909
911 NAVMESH_API int getTilesAt(const int x, const int y,
912 dtMeshTile** tiles, const int maxTiles) const;
913
915 NAVMESH_API int getNeighbourTilesAt(const int x, const int y, const int side,
916 dtMeshTile** tiles, const int maxTiles) const;
917
919 NAVMESH_API int findConnectingPolys(const dtReal* va, const dtReal* vb,
920 const dtMeshTile* fromTile, int fromPolyIdx,
921 const dtMeshTile* tile, int side,
923
925 NAVMESH_API void connectIntLinks(dtMeshTile* tile);
927 NAVMESH_API void baseOffMeshLinks(dtMeshTile* tile);
928
930 NAVMESH_API void connectExtLinks(dtMeshTile* tile, dtMeshTile* target, int side, bool updateCLinks);
932 NAVMESH_API void connectExtOffMeshLinks(dtMeshTile* tile, dtMeshTile* target, int side, bool updateCLinks);
933
935 NAVMESH_API void unconnectExtLinks(dtMeshTile* tile, dtMeshTile* target);
936
937 //@UE BEGIN
938#if WITH_NAVMESH_CLUSTER_LINKS
941 dtMeshTile* tile1, unsigned int cluster1,
942 unsigned char flags, bool bCheckExisting = true);
943
946#endif // WITH_NAVMESH_CLUSTER_LINKS
947 //@UE END
948
949 // TODO: These methods are duplicates from dtNavMeshQuery, but are needed for off-mesh connection finding.
950
952 NAVMESH_API int queryPolygonsInTile(const dtMeshTile* tile, const dtReal* qmin, const dtReal* qmax,
953 dtPolyRef* polys, const int maxPolys, bool bExcludeUnwalkable = false) const;
955 NAVMESH_API dtPolyRef findNearestPolyInTile(const dtMeshTile* tile, const dtReal* center,
956 const dtReal* extents, dtReal* nearestPt, bool bExcludeUnwalkable = false) const;
957 NAVMESH_API dtPolyRef findCheapestNearPolyInTile(const dtMeshTile* tile, const dtReal* center,
958 const dtReal* extents, dtReal* nearestPt) const;
960 NAVMESH_API void closestPointOnPolyInTile(const dtMeshTile* tile, unsigned int ip,
961 const dtReal* pos, dtReal* closest) const;
962
963private:
967 NAVMESH_API bool isTileLocInValidRange(const dtReal tx, const dtReal ty) const;
968 NAVMESH_API void calcTileLoc(const dtReal* pos, dtReal* tx, dtReal* ty) const;
969
970public:
974
978
979 unsigned char m_areaCostOrder[DT_MAX_AREAS];
980
984
985 unsigned int m_saltBits;
986 unsigned int m_tileBits;
987 unsigned int m_polyBits;
988};
989
994
999
1000// @UE BEGIN: helper for reading tiles
1002{
1003 static const int MaxTiles = 32;
1005
1008
1014
1015 dtMeshTile** PrepareArray(int RequestedSize)
1016 {
1017 if (RequestedSize < MaxTiles)
1018 {
1019 return Tiles;
1020 }
1021
1022 if (NumAllocated < RequestedSize)
1023 {
1025 AllocatedTiles = (dtMeshTile**)dtAlloc(RequestedSize * sizeof(dtMeshTile*), DT_ALLOC_TEMP);
1026 NumAllocated = AllocatedTiles != nullptr ? RequestedSize : 0;
1027 }
1028
1029 return AllocatedTiles;
1030 }
1031};
1032// @UE END
1033
1034#endif // DETOURNAVMESH_H
1035
1037
1038// This section contains detailed documentation for members that don't have
1039// a source file. It reduces clutter in the main section of the header.
1040
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
void dtFree(void *ptr, dtAllocHint hint)
Definition DetourAlloc.cpp:49
void * dtAlloc(int size, dtAllocHint hint)
Definition DetourAlloc.cpp:43
@ DT_ALLOC_TEMP
Memory used temporarily within a function.
Definition DetourAlloc.h:32
double dtReal
Definition DetourLargeWorldCoordinates.h:15
dtPolyTypes
Flags representing the type of a navigation mesh polygon.
Definition DetourNavMesh.h:188
@ DT_POLYTYPE_GROUND
The polygon is a standard convex polygon that is part of the surface of the mesh.
Definition DetourNavMesh.h:190
@ DT_POLYTYPE_OFFMESH_POINT
The polygon is an off-mesh connection consisting of two vertices.
Definition DetourNavMesh.h:192
dtStraightPathOptions
Options for dtNavMeshQuery::findStraightPath.
Definition DetourNavMesh.h:181
@ DT_STRAIGHTPATH_AREA_CROSSINGS
Add a vertex at every polygon edge crossing where area changes.
Definition DetourNavMesh.h:182
@ DT_STRAIGHTPATH_ALL_CROSSINGS
Add a vertex at every polygon edge crossing.
Definition DetourNavMesh.h:183
NAVMESH_API void dtStatsSetCustom(dtStatsPostAddTileFunc *addFunc, dtStatsPreRemoveTileFunc *removeFunc)
Definition DetourNavMesh.cpp:36
void() dtStatsPreRemoveTileFunc(const dtMeshTile &tileRemove)
Definition DetourNavMesh.h:159
uint64_t UEType_uint64
Definition DetourNavMesh.h:51
void() dtStatsPostAddTileFunc(const dtMeshTile &TileAdd)
Definition DetourNavMesh.h:157
dtStraightPathFlags
Vertex flags returned by dtNavMeshQuery::findStraightPath.
Definition DetourNavMesh.h:173
@ DT_STRAIGHTPATH_END
The vertex is the end position in the path.
Definition DetourNavMesh.h:175
@ DT_STRAIGHTPATH_START
The vertex is the start position in the path.
Definition DetourNavMesh.h:174
@ DT_STRAIGHTPATH_OFFMESH_CONNECTION
The vertex is the start of an off-mesh connection.
Definition DetourNavMesh.h:176
const unsigned int DT_NULL_LINK
A value that indicates the entity does not link to anything.
Definition DetourNavMesh.h:110
dtTileFlags
Definition DetourNavMesh.h:167
@ DT_TILE_FREE_DATA
The navigation mesh owns the tile memory and is responsible for freeing it.
Definition DetourNavMesh.h:168
UEType_uint64 dtClusterRef
A handle to a cluster within a navigation mesh tile.
Definition DetourNavMesh.h:63
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
unsigned int dtStatus
Definition RecastGraphAStar.h:29
uint64 dtPolyRef
Definition RecastGraphAStar.h:28
int next(int i, int n)
Definition RecastMesh.cpp:164
A simple dynamic array of integers.
Definition DetourAlloc.h:168
Definition DetourNavMesh.h:503
NAVMESH_API dtStatus init(const dtNavMeshParams *params)
Definition DetourNavMesh.cpp:951
NAVMESH_API dtPolyRef getPolyRefBase(const dtMeshTile *tile) const
Definition DetourNavMesh.cpp:2552
NAVMESH_API ~dtNavMesh()
Definition DetourNavMesh.cpp:929
NAVMESH_API bool isTileLocInValidRange(const dtReal *pos) const
Definition DetourNavMesh.cpp:2365
NAVMESH_API dtStatus storeTileState(const dtMeshTile *tile, unsigned char *data, const int maxDataSize) const
Definition DetourNavMesh.cpp:2593
dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
Definition DetourNavMesh.h:747
unsigned int decodeClusterIdTile(dtClusterRef ref) const
Definition DetourNavMesh.h:802
NAVMESH_API int getMaxTiles() const
Definition DetourNavMesh.cpp:2325
NAVMESH_API int getTilesAt(const int x, const int y, dtMeshTile const **tiles, const int maxTiles) const
Definition DetourNavMesh.cpp:2255
NAVMESH_API const dtOffMeshConnection * getOffMeshConnectionByRef(dtPolyRef ref) const
Definition DetourNavMesh.cpp:2748
NAVMESH_API dtNavMesh()
Definition DetourNavMesh.cpp:909
dtReal getWalkableRadius() const
Definition DetourNavMesh.h:892
NAVMESH_API dtStatus getTileAndPolyByRef(const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const
Definition DetourNavMesh.cpp:2374
dtMeshTile * m_nextFree
Freelist of tiles.
Definition DetourNavMesh.h:982
unsigned char m_areaCostOrder[DT_MAX_AREAS]
Definition DetourNavMesh.h:979
NAVMESH_API void calcTileLoc(const dtReal *pos, int *tx, int *ty) const
Definition DetourNavMesh.cpp:2354
unsigned int m_tileBits
Number of tile bits in the tile ID.
Definition DetourNavMesh.h:986
bool getNeighbourCoords(const int x, const int y, const int side, int &outX, int &outY) const
Definition DetourNavMesh.h:864
bool isEmpty() const
Definition DetourNavMesh.h:848
NAVMESH_API const dtMeshTile * getTile(int i) const
Definition DetourNavMesh.cpp:2335
unsigned int m_polyBits
Number of poly bits in the tile ID.
Definition DetourNavMesh.h:987
unsigned int decodePolyIdSalt(dtPolyRef ref) const
Definition DetourNavMesh.h:773
NAVMESH_API dtStatus addTile(unsigned char *data, int dataSize, int flags, dtTileRef lastRef, dtTileRef *result)
Definition DetourNavMesh.cpp:1855
NAVMESH_API dtStatus removeTile(dtTileRef ref, unsigned char **data, int *dataSize)
Definition DetourNavMesh.cpp:2417
NAVMESH_API int getNeighbourTilesCountAt(const int x, const int y, const int side) const
Returns neighbour tile count based on side of given tile.
Definition DetourNavMesh.cpp:2189
dtReal m_tileWidth
Definition DetourNavMesh.h:973
NAVMESH_API dtTileRef getTileRef(const dtMeshTile *tile) const
Definition DetourNavMesh.cpp:2531
dtReal m_orig[3]
Origin of the tile (0,0)
Definition DetourNavMesh.h:972
int m_tileLutSize
Tile hash lookup size (must be pot).
Definition DetourNavMesh.h:976
NAVMESH_API dtStatus setPolyArea(dtPolyRef ref, unsigned char area)
Definition DetourNavMesh.cpp:2878
NAVMESH_API void applyWorldOffset(const dtReal *offset)
Shift navigation mesh by provided offset.
Definition DetourNavMesh.cpp:2911
unsigned int m_saltBits
Number of salt bits in the tile ID.
Definition DetourNavMesh.h:985
NAVMESH_API bool isValidPolyRef(dtPolyRef ref) const
Definition DetourNavMesh.cpp:2400
dtReal getWalkableClimb() const
Definition DetourNavMesh.h:893
NAVMESH_API dtTileRef getTileRefAt(int x, int y, int layer) const
Definition DetourNavMesh.cpp:2278
NAVMESH_API dtStatus getPolyFlags(dtPolyRef ref, unsigned short *resultFlags) const
Definition DetourNavMesh.cpp:2862
dtReal getWalkableHeight() const
Definition DetourNavMesh.h:891
NAVMESH_API const dtNavMeshParams * getParams() const
The navigation mesh initialization params.
Definition DetourNavMesh.cpp:1030
unsigned int decodePolyIdPoly(dtPolyRef ref) const
Definition DetourNavMesh.h:793
unsigned int decodePolyIdTile(dtPolyRef ref) const
Definition DetourNavMesh.h:783
dtLink & getLink(dtMeshTile *tile, unsigned int linkIdx)
Helper for accessing links.
Definition DetourNavMesh.h:822
NAVMESH_API void linkOffMeshHelper(dtMeshTile *tile0, unsigned int polyIdx0, const dtMeshTile *tile1, unsigned int polyIdx1, unsigned char side, unsigned char edge)
Helper for creating links in off-mesh connections.
Definition DetourNavMesh.cpp:1256
NAVMESH_API void updateOffMeshConnectionByUserId(unsigned long long int userId, unsigned char newArea, unsigned short newFlags)
Definition DetourNavMesh.cpp:2824
unsigned int getTileIndex(const dtMeshTile *tile) const
Definition DetourNavMesh.h:883
NAVMESH_API dtMeshTile * getMutableTileByRef(dtTileRef ref) const
Definition DetourNavMesh.cpp:2311
NAVMESH_API dtStatus getPolyArea(dtPolyRef ref, unsigned char *resultArea) const
Definition DetourNavMesh.cpp:2894
NAVMESH_API int getTileStateSize(const dtMeshTile *tile) const
Definition DetourNavMesh.cpp:2580
dtMeshTile ** m_posLookup
Tile hash lookup.
Definition DetourNavMesh.h:981
dtNavMeshParams m_params
Current initialization params.
Definition DetourNavMesh.h:971
int m_tileLutMask
Tile hash lookup mask.
Definition DetourNavMesh.h:977
dtMeshTile * m_tiles
List of tiles.
Definition DetourNavMesh.h:983
int m_maxTiles
Max number of tiles.
Definition DetourNavMesh.h:975
NAVMESH_API void getTileAndPolyByRefUnsafe(const dtPolyRef ref, const dtMeshTile **tile, const dtPoly **poly) const
Definition DetourNavMesh.cpp:2392
const dtLink & getLink(const dtMeshTile *tile, unsigned int linkIdx) const
Definition DetourNavMesh.h:827
NAVMESH_API const dtMeshTile * getTileByRef(dtTileRef ref) const
Definition DetourNavMesh.cpp:2297
NAVMESH_API dtStatus getOffMeshConnectionPolyEndPoints(dtPolyRef prevRef, dtPolyRef polyRef, const dtReal *currentPos, dtReal *startPos, dtReal *endPos) const
Definition DetourNavMesh.cpp:2662
NAVMESH_API int getTileCountAt(const int x, const int y) const
Definition DetourNavMesh.cpp:2207
NAVMESH_API dtClusterRef getClusterRefBase(const dtMeshTile *tile) const
Definition DetourNavMesh.cpp:2559
dtReal getBVQuantFactor(const unsigned char resolution) const
Definition DetourNavMesh.h:894
dtReal m_tileHeight
Dimensions of each tile.
Definition DetourNavMesh.h:973
NAVMESH_API const dtMeshTile * getTileAt(const int x, const int y, const int layer) const
Definition DetourNavMesh.cpp:2151
NAVMESH_API dtStatus restoreTileState(dtMeshTile *tile, const unsigned char *data, const int maxDataSize)
Definition DetourNavMesh.cpp:2625
NAVMESH_API dtStatus setPolyFlags(dtPolyRef ref, unsigned short flags)
Definition DetourNavMesh.cpp:2845
unsigned int getSaltBits() const
Definition DetourNavMesh.h:854
void decodePolyId(dtPolyRef ref, unsigned int &salt, unsigned int &it, unsigned int &ip) const
Definition DetourNavMesh.h:759
NAVMESH_API void applyAreaCostOrder(unsigned char *costOrder)
Definition DetourNavMesh.cpp:2968
NAVMESH_API dtNavMesh * dtAllocNavMesh()
Definition DetourNavMesh.cpp:304
UEType_uint64 dtTileRef
Definition DetourNavMesh.h:60
NAVMESH_API void dtFreeNavMesh(dtNavMesh *navmesh)
Definition DetourNavMesh.cpp:315
UEType_uint64 dtPolyRef
Definition DetourNavMesh.h:56
#define ip
Definition DetourNavMesh.h:1002
dtMeshTile ** PrepareArray(int RequestedSize)
Definition DetourNavMesh.h:1015
ReadTilesHelper()
Definition DetourNavMesh.h:1009
int NumAllocated
Definition DetourNavMesh.h:1006
dtMeshTile ** AllocatedTiles
Definition DetourNavMesh.h:1007
~ReadTilesHelper()
Definition DetourNavMesh.h:1010
static const int MaxTiles
Definition DetourNavMesh.h:1003
dtMeshTile * Tiles[MaxTiles]
Definition DetourNavMesh.h:1004
Definition DetourNavMesh.h:266
unsigned short bmin[3]
Minimum bounds of the node's AABB. [(x, y, z)].
Definition DetourNavMesh.h:267
int i
The node's index. (Negative for escape sequence.)
Definition DetourNavMesh.h:269
unsigned short bmax[3]
Maximum bounds of the node's AABB. [(x, y, z)].
Definition DetourNavMesh.h:268
Definition DetourNavMesh.h:379
unsigned short polyCount
The number of polygons in the tile.
Definition DetourNavMesh.h:383
unsigned short maxLinkCount
The number of allocated links.
Definition DetourNavMesh.h:389
dtReal bmax[3]
The maximum bounds of the tile's AABB. [(x, y, z)].
Definition DetourNavMesh.h:416
unsigned short detailTriCount
The number of triangles in the detail mesh.
Definition DetourNavMesh.h:395
unsigned short detailMeshCount
The number of sub-meshes in the detail mesh.
Definition DetourNavMesh.h:390
unsigned short version
Tile data format version number.
Definition DetourNavMesh.h:380
unsigned char resolution
The resolution index used for the tile.
Definition DetourNavMesh.h:411
int y
The y-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition DetourNavMesh.h:387
unsigned short offMeshConCount
The number of point type off-mesh connections.
Definition DetourNavMesh.h:397
dtReal bmin[3]
The minimum bounds of the tile's AABB. [(x, y, z)].
Definition DetourNavMesh.h:415
unsigned short bvNodeCount
The number of bounding volume nodes. (Zero if bounding volumes are disabled.)
Definition DetourNavMesh.h:396
int x
The x-position of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition DetourNavMesh.h:386
unsigned short detailVertCount
The number of unique vertices in the detail mesh. (In addition to the polygon vertices....
Definition DetourNavMesh.h:393
unsigned short vertCount
The number of vertices in the tile.
Definition DetourNavMesh.h:384
unsigned short offMeshBase
The index of the first polygon which is a point type off-mesh connection.
Definition DetourNavMesh.h:398
unsigned short layer
The layer of the tile within the dtNavMesh tile grid. (x, y, layer)
Definition DetourNavMesh.h:381
Definition DetourNavMesh.h:422
unsigned int dynamicFreeListO
Index of the next free dynamic link.
Definition DetourNavMesh.h:462
dtLink * links
The tile links. [Size: dtMeshHeader::maxLinkCount].
Definition DetourNavMesh.h:429
int dataSize
Size of the tile data.
Definition DetourNavMesh.h:445
dtBVNode * bvTree
Definition DetourNavMesh.h:440
unsigned int salt
Counter describing modifications to the tile.
Definition DetourNavMesh.h:423
unsigned char * detailTris
The detail mesh's triangles. [(vertA, vertB, vertC) * dtMeshHeader::detailTriCount].
Definition DetourNavMesh.h:436
dtMeshTile * next
The next free tile, or the next tile in the spatial grid.
Definition DetourNavMesh.h:447
dtReal * detailVerts
The detail mesh's unique vertices. [(x, y, z) * dtMeshHeader::detailVertCount].
Definition DetourNavMesh.h:433
dtMeshHeader * header
The tile header.
Definition DetourNavMesh.h:426
dtChunkArray< dtLink, DT_ALLOC_PERM_TILE_DYNLINK_OFFMESH > dynamicLinksO
Dynamic links array (indices starting from dtMeshHeader::maxLinkCount)
Definition DetourNavMesh.h:461
int flags
Tile flags. (See: dtTileFlags)
Definition DetourNavMesh.h:446
dtReal * verts
The tile vertices. [Size: dtMeshHeader::vertCount (3 real per vertex)].
Definition DetourNavMesh.h:428
dtPolyDetail * detailMeshes
The tile's detail sub-meshes. [Size: dtMeshHeader::detailMeshCount].
Definition DetourNavMesh.h:430
dtOffMeshConnection * offMeshCons
The tile off-mesh connections. [Size: dtMeshHeader::offMeshConCount].
Definition DetourNavMesh.h:442
dtPoly * polys
The tile polygons. [Size: dtMeshHeader::polyCount].
Definition DetourNavMesh.h:427
unsigned int linksFreeList
Index to the next free link.
Definition DetourNavMesh.h:425
unsigned char * data
The tile data. (Not directly accessed under normal situations.)
Definition DetourNavMesh.h:444
Definition DetourNavMesh.h:484
dtReal walkableHeight
The height of the agents using the tile.
Definition DetourNavMesh.h:486
int maxPolys
The maximum number of polygons each tile can contain.
Definition DetourNavMesh.h:497
dtReal tileHeight
The height of each tile. (Along the z-axis.)
Definition DetourNavMesh.h:495
dtReal walkableRadius
The radius of the agents using the tile.
Definition DetourNavMesh.h:487
dtReal tileWidth
The width of each tile. (Along the x-axis.)
Definition DetourNavMesh.h:494
dtReal orig[3]
The world space origin of the navigation mesh's tile space. [(x, y, z)].
Definition DetourNavMesh.h:493
int maxTiles
The maximum number of tiles the navigation mesh can contain.
Definition DetourNavMesh.h:496
dtNavMeshResParams resolutionParams[DT_RESOLUTION_COUNT]
Parameters depending on resolutions.
Definition DetourNavMesh.h:490
dtReal walkableClimb
The maximum climb height of the agents using the tile.
Definition DetourNavMesh.h:488
Configuration parameters depending on navmesh resolution.
Definition DetourNavMesh.h:474
dtReal bvQuantFactor
The bounding volume quantization factor.
Definition DetourNavMesh.h:475
Definition DetourNavMesh.h:312
dtReal height
The snap height of endpoints (less than 0 = use step height)
Definition DetourNavMesh.h:321
bool getBiDirectional() const
Gets the link direction.
Definition DetourNavMesh.h:346
unsigned short poly
The polygon reference of the connection within the tile.
Definition DetourNavMesh.h:328
bool getSnapToCheapestArea() const
Gets the link snap mode.
Definition DetourNavMesh.h:349
unsigned char side
End point side.
Definition DetourNavMesh.h:331
unsigned long long int userId
The id of the offmesh connection. (User assigned when the navigation mesh is built....
Definition DetourNavMesh.h:325
dtReal pos[6]
The endpoints of the connection. [(ax, ay, az, bx, by, bz)].
Definition DetourNavMesh.h:314
void setFlags(unsigned char conTypeFlags)
Sets link flags.
Definition DetourNavMesh.h:338
bool getIsGenerated() const
Indicates if the link was automatically generated.
Definition DetourNavMesh.h:352
dtReal rad
The radius of the endpoints. [Limit: >= 0].
Definition DetourNavMesh.h:317
unsigned char flags
Link flags.
Definition DetourNavMesh.h:334
Defines the location of detail sub-mesh data within a dtMeshTile.
Definition DetourNavMesh.h:242
unsigned char vertCount
The number of vertices in the sub-mesh.
Definition DetourNavMesh.h:245
unsigned short vertBase
The offset of the vertices in the dtMeshTile::detailVerts array.
Definition DetourNavMesh.h:243
unsigned short triBase
The offset of the triangles in the dtMeshTile::detailTris array.
Definition DetourNavMesh.h:244
unsigned char triCount
The number of triangles in the sub-mesh.
Definition DetourNavMesh.h:246
Definition DetourNavMesh.h:206
unsigned char getType() const
Gets the polygon type. (See: dtPolyTypes)
Definition DetourNavMesh.h:237
unsigned short flags
The user defined polygon flags.
Definition DetourNavMesh.h:218
unsigned int firstLink
Index to first link in linked list. (Or DT_NULL_LINK if there is no link.)
Definition DetourNavMesh.h:208
void setArea(unsigned char a)
Sets the user defined area id. [Limit: < DT_MAX_AREAS].
Definition DetourNavMesh.h:228
unsigned char getArea() const
Gets the user defined area id.
Definition DetourNavMesh.h:234
unsigned short neis[DT_VERTS_PER_POLYGON]
Packed data representing neighbor polygons references and flags for each edge.
Definition DetourNavMesh.h:215
void setType(unsigned char t)
Sets the polygon type. (See: dtPolyTypes.)
Definition DetourNavMesh.h:231
unsigned short verts[DT_VERTS_PER_POLYGON]
Definition DetourNavMesh.h:212
unsigned char areaAndtype
Definition DetourNavMesh.h:225
unsigned char vertCount
The number of vertices in the polygon.
Definition DetourNavMesh.h:221