Add upToDate param for dtTileCache::update (#203)
This changes dtTileCache::update to add an optional parameter that indicates whether the tile cache is up to date. This is useful to determine whether calling the function again would do anything.
This commit is contained in:
parent
b05e45492e
commit
36183edb55
@ -111,7 +111,13 @@ public:
|
|||||||
dtStatus queryTiles(const float* bmin, const float* bmax,
|
dtStatus queryTiles(const float* bmin, const float* bmax,
|
||||||
dtCompressedTileRef* results, int* resultCount, const int maxResults) const;
|
dtCompressedTileRef* results, int* resultCount, const int maxResults) const;
|
||||||
|
|
||||||
dtStatus update(const float /*dt*/, class dtNavMesh* navmesh);
|
/// Updates the tile cache by rebuilding tiles touched by unfinished obstacle requests.
|
||||||
|
/// @param[in] dt The time step size. Currently not used.
|
||||||
|
/// @param[in] navmesh The mesh to affect when rebuilding tiles.
|
||||||
|
/// @param[out] upToDate Whether the tile cache is fully up to date with obstacle requests and tile rebuilds.
|
||||||
|
/// If the tile cache is up to date another (immediate) call to update will have no effect;
|
||||||
|
/// otherwise another call will continue processing obstacle requests and tile rebuilds.
|
||||||
|
dtStatus update(const float dt, class dtNavMesh* navmesh, bool* upToDate = 0);
|
||||||
|
|
||||||
dtStatus buildNavMeshTilesAt(const int tx, const int ty, class dtNavMesh* navmesh);
|
dtStatus buildNavMeshTilesAt(const int tx, const int ty, class dtNavMesh* navmesh);
|
||||||
|
|
||||||
|
@ -441,7 +441,8 @@ dtStatus dtTileCache::queryTiles(const float* bmin, const float* bmax,
|
|||||||
return DT_SUCCESS;
|
return DT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
dtStatus dtTileCache::update(const float /*dt*/, dtNavMesh* navmesh)
|
dtStatus dtTileCache::update(const float /*dt*/, dtNavMesh* navmesh,
|
||||||
|
bool* upToDate)
|
||||||
{
|
{
|
||||||
if (m_nupdate == 0)
|
if (m_nupdate == 0)
|
||||||
{
|
{
|
||||||
@ -500,12 +501,13 @@ dtStatus dtTileCache::update(const float /*dt*/, dtNavMesh* navmesh)
|
|||||||
m_nreqs = 0;
|
m_nreqs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dtStatus status = DT_SUCCESS;
|
||||||
// Process updates
|
// Process updates
|
||||||
if (m_nupdate)
|
if (m_nupdate)
|
||||||
{
|
{
|
||||||
// Build mesh
|
// Build mesh
|
||||||
const dtCompressedTileRef ref = m_update[0];
|
const dtCompressedTileRef ref = m_update[0];
|
||||||
dtStatus status = buildNavMeshTile(ref, navmesh);
|
status = buildNavMeshTile(ref, navmesh);
|
||||||
m_nupdate--;
|
m_nupdate--;
|
||||||
if (m_nupdate > 0)
|
if (m_nupdate > 0)
|
||||||
memmove(m_update, m_update+1, m_nupdate*sizeof(dtCompressedTileRef));
|
memmove(m_update, m_update+1, m_nupdate*sizeof(dtCompressedTileRef));
|
||||||
@ -548,12 +550,12 @@ dtStatus dtTileCache::update(const float /*dt*/, dtNavMesh* navmesh)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dtStatusFailed(status))
|
|
||||||
return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DT_SUCCESS;
|
if (upToDate)
|
||||||
|
*upToDate = m_nupdate == 0 && m_nreqs == 0;
|
||||||
|
|
||||||
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user