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.
|
// Encodes a tile id.
|
||||||
inline dtPolyRef encodePolyId(unsigned int salt, unsigned int it, unsigned int ip) const
|
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.
|
// Decodes a tile id.
|
||||||
inline void decodePolyId(dtPolyRef ref, unsigned int& salt, unsigned int& it, unsigned int& ip) const
|
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);
|
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);
|
ip = ref & ((1<<m_polyBits)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,7 +472,7 @@ public:
|
|||||||
// Decodes a tile id.
|
// Decodes a tile id.
|
||||||
inline unsigned int decodePolyIdTile(dtPolyRef ref) const
|
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.
|
// Decodes a poly id.
|
||||||
|
@ -214,6 +214,7 @@ bool dtNavMesh::init(const dtNavMeshParams* params)
|
|||||||
m_nextFree = 0;
|
m_nextFree = 0;
|
||||||
for (int i = m_maxTiles-1; i >= 0; --i)
|
for (int i = m_maxTiles-1; i >= 0; --i)
|
||||||
{
|
{
|
||||||
|
m_tiles[i].salt = 1;
|
||||||
m_tiles[i].next = m_nextFree;
|
m_tiles[i].next = m_nextFree;
|
||||||
m_nextFree = &m_tiles[i];
|
m_nextFree = &m_tiles[i];
|
||||||
}
|
}
|
||||||
@ -832,8 +833,11 @@ bool dtNavMesh::removeTile(dtTileRef ref, unsigned char** data, int* dataSize)
|
|||||||
tile->detailTris = 0;
|
tile->detailTris = 0;
|
||||||
tile->bvTree = 0;
|
tile->bvTree = 0;
|
||||||
tile->offMeshCons = 0;
|
tile->offMeshCons = 0;
|
||||||
|
|
||||||
tile->salt++;
|
// 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.
|
// Add to free list.
|
||||||
tile->next = m_nextFree;
|
tile->next = m_nextFree;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user