19 #ifndef DETOURTILECACHE_H
20 #define DETOURTILECACHE_H
22 #include <AtomsUtils/Globals.h>
23 #include <AtomsUtils/NavigationMesh/Detour/DetourStatus.h>
27 struct dtTileCacheAlloc;
28 struct dtTileCacheCompressor;
30 typedef unsigned int dtObstacleRef;
32 typedef unsigned int dtCompressedTileRef;
44 unsigned char* compressed;
55 DT_OBSTACLE_PROCESSING,
56 DT_OBSTACLE_PROCESSED,
60 static const int DT_MAX_TOUCHED_TILES = 8;
63 float pos[3], radius, height;
64 dtCompressedTileRef touched[DT_MAX_TOUCHED_TILES];
65 dtCompressedTileRef pending[DT_MAX_TOUCHED_TILES];
68 unsigned char ntouched;
69 unsigned char npending;
81 float maxSimplificationError;
85 float detailSampleDist;
86 float detailSampleMaxError;
90 int regionPartitioning;
96 virtual void markAreas(
struct dtTileCacheLayer* layer,
const float* orig,
const float cs,
const float ch) = 0;
98 unsigned char* polyAreas,
unsigned short* polyFlags) = 0;
113 inline int getTileCount()
const {
return m_params.maxTiles; }
114 inline const dtCompressedTile* getTile(
const int i)
const {
return &m_tiles[i]; }
116 inline int getObstacleCount()
const {
return m_params.maxObstacles; }
117 inline const dtTileCacheObstacle* getObstacle(
const int i)
const {
return &m_obstacles[i]; }
128 int getTilesAt(
const int tx,
const int ty, dtCompressedTileRef* tiles,
const int maxTiles)
const ;
134 dtStatus addTile(
unsigned char* data,
const int dataSize,
unsigned char flags, dtCompressedTileRef* result);
136 dtStatus removeTile(dtCompressedTileRef ref,
unsigned char** data,
int* dataSize);
138 dtStatus addObstacle(
const float* pos,
const float radius,
const float height, dtObstacleRef* result);
139 dtStatus removeObstacle(
const dtObstacleRef ref);
141 dtStatus queryTiles(
const float* bmin,
const float* bmax,
142 dtCompressedTileRef* results,
int* resultCount,
const int maxResults)
const;
144 dtStatus update(
const float ,
class dtNavMesh* navmesh);
146 dtStatus buildNavMeshTilesAt(
const int tx,
const int ty,
class dtNavMesh* navmesh);
148 dtStatus buildNavMeshTile(
const dtCompressedTileRef ref,
class dtNavMesh* navmesh);
152 void getObstacleBounds(
const struct dtTileCacheObstacle* ob,
float* bmin,
float* bmax)
const;
156 inline dtCompressedTileRef
encodeTileId(
unsigned int salt,
unsigned int it)
const
158 return ((dtCompressedTileRef)salt << m_tileBits) | (dtCompressedTileRef)it;
164 const dtCompressedTileRef saltMask = ((dtCompressedTileRef)1<<m_saltBits)-1;
165 return (
unsigned int)((ref >> m_tileBits) & saltMask);
171 const dtCompressedTileRef tileMask = ((dtCompressedTileRef)1<<m_tileBits)-1;
172 return (
unsigned int)(ref & tileMask);
178 return ((dtObstacleRef)salt << 16) | (dtObstacleRef)it;
184 const dtObstacleRef saltMask = ((dtObstacleRef)1<<16)-1;
185 return (
unsigned int)((ref >> 16) & saltMask);
191 const dtObstacleRef tileMask = ((dtObstacleRef)1<<16)-1;
192 return (
unsigned int)(ref & tileMask);
198 enum ObstacleRequestAction
204 struct ObstacleRequest
213 dtCompressedTile** m_posLookup;
214 dtCompressedTile* m_nextFreeTile;
215 dtCompressedTile* m_tiles;
217 unsigned int m_saltBits;
218 unsigned int m_tileBits;
220 dtTileCacheParams m_params;
222 dtTileCacheAlloc* m_talloc;
223 dtTileCacheCompressor* m_tcomp;
224 dtTileCacheMeshProcess* m_tmproc;
226 dtTileCacheObstacle* m_obstacles;
227 dtTileCacheObstacle* m_nextFreeObstacle;
229 static const int MAX_REQUESTS = 64;
230 ObstacleRequest m_reqs[MAX_REQUESTS];
233 static const int MAX_UPDATE = 64;
234 dtCompressedTileRef m_update[MAX_UPDATE];
239 ATOMSUTILS_EXPORT dtTileCache* dtAllocTileCache();
240 ATOMSUTILS_EXPORT
void dtFreeTileCache(dtTileCache* tc);
Definition: DetourNavMesh.h:427
Definition: DetourTileCache.h:103
unsigned int decodeObstacleIdSalt(dtObstacleRef ref) const
Decodes an obstacle salt.
Definition: DetourTileCache.h:182
dtCompressedTileRef encodeTileId(unsigned int salt, unsigned int it) const
Encodes a tile id.
Definition: DetourTileCache.h:156
unsigned int decodeObstacleIdObstacle(dtObstacleRef ref) const
Decodes an obstacle id.
Definition: DetourTileCache.h:189
unsigned int decodeTileIdTile(dtCompressedTileRef ref) const
Decodes a tile id.
Definition: DetourTileCache.h:169
dtObstacleRef encodeObstacleId(unsigned int salt, unsigned int it) const
Encodes an obstacle id.
Definition: DetourTileCache.h:176
unsigned int decodeTileIdSalt(dtCompressedTileRef ref) const
Decodes a tile salt.
Definition: DetourTileCache.h:162
AtomsCore namespace.
Definition: Base64.h:13
dtCompressedTileFlags
Flags for addTile.
Definition: DetourTileCache.h:36
@ DT_COMPRESSEDTILE_FREE_DATA
Navmesh owns the tile memory and should free it.
Definition: DetourTileCache.h:37
Definition: DetourTileCache.h:41
unsigned int salt
Counter describing modifications to the tile.
Definition: DetourTileCache.h:42
Definition: DetourNavMeshBuilder.h:62
Definition: DetourTileCacheBuilder.h:128
Definition: DetourTileCacheBuilder.h:147
Definition: DetourTileCacheBuilder.h:47
Definition: DetourTileCache.h:95
Definition: DetourTileCache.h:62
Definition: DetourTileCache.h:74