Issue 86:Tiled world consisting of one tile - dtNavMesh::init fails. ___NOTE: dtPolyRef format changed___
This commit is contained in:
parent
fca9709196
commit
122ee3a7a1
@ -452,14 +452,14 @@ public:
|
||||
// Encodes a tile id.
|
||||
inline dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
|
||||
{
|
||||
return (salt << (m_polyBits+m_tileBits)) | ((it+1) << m_polyBits) | ip;
|
||||
return (salt << (m_polyBits+m_tileBits)) | (it << m_polyBits) | ip;
|
||||
}
|
||||
|
||||
// Decodes a tile id.
|
||||
inline void decodePolyId(dtPolyRef ref, unsigned int& salt, unsigned int& it, unsigned int& ip) const
|
||||
{
|
||||
salt = (ref >> (m_polyBits+m_tileBits)) & ((1<<m_saltBits)-1);
|
||||
it = ((ref >> m_polyBits) - 1) & ((1<<m_tileBits)-1);
|
||||
it = (ref >> m_polyBits) & ((1<<m_tileBits)-1);
|
||||
ip = ref & ((1<<m_polyBits)-1);
|
||||
}
|
||||
|
||||
@ -472,7 +472,7 @@ public:
|
||||
// Decodes a tile id.
|
||||
inline unsigned int decodePolyIdTile(dtPolyRef ref) const
|
||||
{
|
||||
return ((ref >> m_polyBits) - 1) & ((1<<m_tileBits)-1);
|
||||
return (ref >> m_polyBits) & ((1<<m_tileBits)-1);
|
||||
}
|
||||
|
||||
// Decodes a poly id.
|
||||
|
@ -214,6 +214,7 @@ bool dtNavMesh::init(const dtNavMeshParams* params)
|
||||
m_nextFree = 0;
|
||||
for (int i = m_maxTiles-1; i >= 0; --i)
|
||||
{
|
||||
m_tiles[i].salt = 1;
|
||||
m_tiles[i].next = m_nextFree;
|
||||
m_nextFree = &m_tiles[i];
|
||||
}
|
||||
@ -833,6 +834,9 @@ bool dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSize)
|
||||
tile->bvTree = 0;
|
||||
tile->offMeshCons = 0;
|
||||
|
||||
// Update salt, salt should never be zero.
|
||||
tile->salt = (tile->salt+1) & ((1<<m_saltBits)-1);
|
||||
if (tile->salt == 0)
|
||||
tile->salt++;
|
||||
|
||||
// Add to free list.
|
||||
|
Loading…
x
Reference in New Issue
Block a user