22#ifndef DETOURNAVMESH_H
23#define DETOURNAVMESH_H
33#if WITH_NAVMESH_SEGMENT_LINKS
40#ifndef USE_64BIT_ADDRESS
41#define USE_64BIT_ADDRESS 1
82static const int DT_VERTS_PER_POLYGON = 6;
95static const int DT_NAVMESH_VERSION = 7;
98static const int DT_NAVMESH_STATE_MAGIC =
'D'<<24 |
'N'<<16 |
'M'<<8 |
'S';
101static const int DT_NAVMESH_STATE_VERSION = 1;
107static const unsigned short DT_EXT_LINK = 0x8000;
113static const unsigned char DT_OFFMESH_CON_BIDIR = 0x01;
114static const unsigned char DT_OFFMESH_CON_POINT = 0x02;
115static const unsigned char DT_OFFMESH_CON_SEGMENT = 0x04;
116static const unsigned char DT_OFFMESH_CON_CHEAPAREA = 0x08;
117static const unsigned char DT_OFFMESH_CON_GENERATED = 0x10;
121static const int DT_MAX_AREAS = 64;
125static const int DT_MIN_SALT_BITS = 5;
126static const int DT_SALT_BASE = 1;
128static const int DT_RESOLUTION_COUNT = 3;
130#if WITH_NAVMESH_SEGMENT_LINKS
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;
144#if WITH_NAVMESH_CLUSTER_LINKS
195#if WITH_NAVMESH_SEGMENT_LINKS
212 unsigned short verts[DT_VERTS_PER_POLYGON];
215 unsigned short neis[DT_VERTS_PER_POLYGON];
273#if WITH_NAVMESH_SEGMENT_LINKS
292 unsigned char npolys;
298 inline void setFlags(
unsigned char conFlags)
300 flags = ((
conFlags & DT_OFFMESH_CON_BIDIR) ? 0x80 : 0);
304 inline bool getBiDirectional()
const {
return (flags & 0x80) != 0; }
341 ((
conTypeFlags & DT_OFFMESH_CON_CHEAPAREA) ? 0x40 : 0) |
357#if WITH_NAVMESH_CLUSTER_LINKS
362 unsigned int firstLink;
401#if WITH_NAVMESH_SEGMENT_LINKS
407#if WITH_NAVMESH_CLUSTER_LINKS
450#if WITH_NAVMESH_SEGMENT_LINKS
454#if WITH_NAVMESH_CLUSTER_LINKS
464#if WITH_NAVMESH_CLUSTER_LINKS
536#if WITH_NAVMESH_SEGMENT_LINKS
674#if WITH_NAVMESH_SEGMENT_LINKS
796 return (
unsigned int)(ref &
polyMask);
808#if WITH_NAVMESH_CLUSTER_LINKS
832#if WITH_NAVMESH_CLUSTER_LINKS
870 case 0: ++
outX;
break;
872 case 2: ++
outY;
break;
874 case 4: --
outX;
break;
876 case 6: --
outY;
break;
900 struct FConnectingPolyData
915 NAVMESH_API int getNeighbourTilesAt(
const int x,
const int y,
const int side,
938#if WITH_NAVMESH_CLUSTER_LINKS
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
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:253
unsigned char bmin
If a boundary link, defines the minimum sub-edge area.
Definition DetourNavMesh.h:258
unsigned char edge
Index of the polygon edge that owns this link.
Definition DetourNavMesh.h:256
dtPolyRef ref
Neighbour reference. (The neighbor that is linked to.)
Definition DetourNavMesh.h:254
unsigned int next
Index of the next link.
Definition DetourNavMesh.h:255
unsigned char side
If a boundary link, defines on which side the link is.
Definition DetourNavMesh.h:257
unsigned char bmax
If a boundary link, defines the maximum sub-edge area.
Definition DetourNavMesh.h:259
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