Recast: allow setting table count in dtNavMesh::init

Needed for pre-allocation on solo mesh.
This commit is contained in:
Kawe Mazidjatari 2024-07-12 12:53:43 +02:00
parent 5d34723773
commit 59a8f12e0e
2 changed files with 4 additions and 3 deletions

View File

@ -431,10 +431,11 @@ public:
/// Initializes the navigation mesh for single tile use. /// Initializes the navigation mesh for single tile use.
/// @param[in] data Data of the new tile. (See: #dtCreateNavMeshData) /// @param[in] data Data of the new tile. (See: #dtCreateNavMeshData)
/// @param[in] dataSize The data size of the new tile. /// @param[in] dataSize The data size of the new tile.
/// @param[in] tableCount The number of traversal tables this navmesh will use.
/// @param[in] flags The tile flags. (See: #dtTileFlags) /// @param[in] flags The tile flags. (See: #dtTileFlags)
/// @return The status flags for the operation. /// @return The status flags for the operation.
/// @see dtCreateNavMeshData /// @see dtCreateNavMeshData
dtStatus init(unsigned char* data, const int dataSize, const int flags); dtStatus init(unsigned char* data, const int dataSize, const int tableCount, const int flags);
/// The navigation mesh initialization params. /// The navigation mesh initialization params.
const dtNavMeshParams* getParams() const; const dtNavMeshParams* getParams() const;

View File

@ -301,7 +301,7 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params)
return DT_SUCCESS; return DT_SUCCESS;
} }
dtStatus dtNavMesh::init(unsigned char* data, const int dataSize, const int flags) dtStatus dtNavMesh::init(unsigned char* data, const int dataSize, const int tableCount, const int flags)
{ {
// Make sure the data is in right format. // Make sure the data is in right format.
dtMeshHeader* header = (dtMeshHeader*)data; dtMeshHeader* header = (dtMeshHeader*)data;
@ -319,7 +319,7 @@ dtStatus dtNavMesh::init(unsigned char* data, const int dataSize, const int flag
params.maxPolys = header->polyCount; params.maxPolys = header->polyCount;
params.polyGroupCount = 0; params.polyGroupCount = 0;
params.traversalTableSize = 0; params.traversalTableSize = 0;
params.traversalTableCount = 0; params.traversalTableCount = tableCount;
params.magicDataCount = 0; params.magicDataCount = 0;
dtStatus status = init(&params); dtStatus status = init(&params);