mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 13:09:42 +00:00
Report navmesh change for not posted tiles
Corresponding recast mesh tiles can be updated but navmesh tiles may never appear for them. Report back zero navmesh version to allow oscillating recast objects detection to work. This version is always less than any generated navmesh tile version so any report for generated navmesh will override it. If zero navmesh version is reported after recast mesh tile got report about generated navmesh tile it is a no-op since generated version is always greater than zero.
This commit is contained in:
parent
4c4218f70d
commit
d122e184cc
7 changed files with 23 additions and 7 deletions
|
@ -54,7 +54,7 @@ namespace
|
||||||
{
|
{
|
||||||
TileCachedRecastMeshManager manager(mSettings);
|
TileCachedRecastMeshManager manager(mSettings);
|
||||||
std::size_t calls = 0;
|
std::size_t calls = 0;
|
||||||
manager.forEachTilePosition([&] (const TilePosition&) { ++calls; });
|
manager.forEachTile([&] (const TilePosition&, const CachedRecastMeshManager&) { ++calls; });
|
||||||
EXPECT_EQ(calls, 0);
|
EXPECT_EQ(calls, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,4 +66,9 @@ namespace DetourNavigator
|
||||||
{
|
{
|
||||||
mImpl.reportNavMeshChange(recastMeshVersion, navMeshVersion);
|
mImpl.reportNavMeshChange(recastMeshVersion, navMeshVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Version CachedRecastMeshManager::getVersion() const
|
||||||
|
{
|
||||||
|
return mImpl.getVersion();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ namespace DetourNavigator
|
||||||
|
|
||||||
void reportNavMeshChange(Version recastMeshVersion, Version navMeshVersion);
|
void reportNavMeshChange(Version recastMeshVersion, Version navMeshVersion);
|
||||||
|
|
||||||
|
Version getVersion() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RecastMeshManager mImpl;
|
RecastMeshManager mImpl;
|
||||||
std::shared_ptr<RecastMesh> mCached;
|
std::shared_ptr<RecastMesh> mCached;
|
||||||
|
|
|
@ -171,7 +171,7 @@ namespace DetourNavigator
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto maxTiles = std::min(mSettings.mMaxTilesNumber, navMesh.getParams()->maxTiles);
|
const auto maxTiles = std::min(mSettings.mMaxTilesNumber, navMesh.getParams()->maxTiles);
|
||||||
mRecastMeshManager.forEachTilePosition([&] (const TilePosition& tile)
|
mRecastMeshManager.forEachTile([&] (const TilePosition& tile, CachedRecastMeshManager& recastMeshManager)
|
||||||
{
|
{
|
||||||
if (tilesToPost.count(tile))
|
if (tilesToPost.count(tile))
|
||||||
return;
|
return;
|
||||||
|
@ -181,6 +181,8 @@ namespace DetourNavigator
|
||||||
tilesToPost.insert(std::make_pair(tile, ChangeType::add));
|
tilesToPost.insert(std::make_pair(tile, ChangeType::add));
|
||||||
else if (!shouldAdd && presentInNavMesh)
|
else if (!shouldAdd && presentInNavMesh)
|
||||||
tilesToPost.insert(std::make_pair(tile, ChangeType::mixed));
|
tilesToPost.insert(std::make_pair(tile, ChangeType::mixed));
|
||||||
|
else
|
||||||
|
recastMeshManager.reportNavMeshChange(recastMeshManager.getVersion(), Version {0, 0});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
mAsyncNavMeshUpdater.post(agentHalfExtents, cached, playerTile, tilesToPost);
|
mAsyncNavMeshUpdater.post(agentHalfExtents, cached, playerTile, tilesToPost);
|
||||||
|
@ -214,8 +216,8 @@ namespace DetourNavigator
|
||||||
RecastMeshTiles NavMeshManager::getRecastMeshTiles()
|
RecastMeshTiles NavMeshManager::getRecastMeshTiles()
|
||||||
{
|
{
|
||||||
std::vector<TilePosition> tiles;
|
std::vector<TilePosition> tiles;
|
||||||
mRecastMeshManager.forEachTilePosition(
|
mRecastMeshManager.forEachTile(
|
||||||
[&tiles] (const TilePosition& tile) { tiles.push_back(tile); });
|
[&tiles] (const TilePosition& tile, const CachedRecastMeshManager&) { tiles.push_back(tile); });
|
||||||
RecastMeshTiles result;
|
RecastMeshTiles result;
|
||||||
std::transform(tiles.begin(), tiles.end(), std::inserter(result, result.end()),
|
std::transform(tiles.begin(), tiles.end(), std::inserter(result, result.end()),
|
||||||
[this] (const TilePosition& tile) { return std::make_pair(tile, mRecastMeshManager.getMesh(tile)); });
|
[this] (const TilePosition& tile) { return std::make_pair(tile, mRecastMeshManager.getMesh(tile)); });
|
||||||
|
|
|
@ -95,6 +95,11 @@ namespace DetourNavigator
|
||||||
mLastNavMeshReportedChange = mLastNavMeshReport;
|
mLastNavMeshReportedChange = mLastNavMeshReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Version RecastMeshManager::getVersion() const
|
||||||
|
{
|
||||||
|
return Version {mGeneration, mRevision};
|
||||||
|
}
|
||||||
|
|
||||||
void RecastMeshManager::rebuild()
|
void RecastMeshManager::rebuild()
|
||||||
{
|
{
|
||||||
mMeshBuilder.reset();
|
mMeshBuilder.reset();
|
||||||
|
|
|
@ -53,6 +53,8 @@ namespace DetourNavigator
|
||||||
|
|
||||||
void reportNavMeshChange(Version recastMeshVersion, Version navMeshVersion);
|
void reportNavMeshChange(Version recastMeshVersion, Version navMeshVersion);
|
||||||
|
|
||||||
|
Version getVersion() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Report
|
struct Report
|
||||||
{
|
{
|
||||||
|
|
|
@ -81,10 +81,10 @@ namespace DetourNavigator
|
||||||
bool hasTile(const TilePosition& tilePosition);
|
bool hasTile(const TilePosition& tilePosition);
|
||||||
|
|
||||||
template <class Function>
|
template <class Function>
|
||||||
void forEachTilePosition(Function&& function)
|
void forEachTile(Function&& function)
|
||||||
{
|
{
|
||||||
for (const auto& tile : *mTiles.lock())
|
for (auto& [tilePosition, recastMeshManager] : *mTiles.lock())
|
||||||
function(tile.first);
|
function(tilePosition, recastMeshManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t getRevision() const;
|
std::size_t getRevision() const;
|
||||||
|
|
Loading…
Reference in a new issue