I’d like to introduce support of sparse navigation meshes with dynamically streamed tiles.
Urho3D branch with this feature and two samples is available here:
https://github.com/eugeneko/Urho3D/tree/navmesh-streaming
It’s a kind of sketch, so I would be happy if someone test and/or review it.
Guide
First of all, NavigationMesh::Allocate()
shall be used instead of NavigationMesh::Build()
:
navMesh->Allocate(boundingBox, maxTiles);
The bounding box of the entire area is almost unlimited (I hope), but it shall be somehow computed on the user side. Then, user shall provide the limit for simultaneously loaded mesh tiles.
Then, navigation mesh shall be built. It is actually fine to use NavigationMesh::Build()
first time and NavigationMesh::Allocate()
other times, but huge areas may cause out of memory
.
NavigationMesh::Build(fromTile, toTile)
could be used to build few tiles in the rectangular area specified.
Then, these tiles could be received via NavigationMesh::GetTileData(x, z)
and e.g. saved onto disk.
To build next bucket of tiles, do NavigationMesh::RemoveAllTiles()
first.
The simplest example:
for each tile
{
navMesh->Build(tile, tile);
tileData = navMesh->GetTileData(tile.x, tile.y);
SaveToDisk(tileData);
navMesh->RemoveAllTiles();
}
Stored tiles could be added to and removed from navigation mesh via NavigationMesh::AddTile(tileData)
and NavigationMesh::RemoveTile(x, z)
.
Known issues
Obstacle
s shall be re-added on the user side once AddTile
is called in order to be correctly rendered into navigation mesh.
CrowdAgent
s linked to removed chunks become invalid and stuck. This shall be handled somehow at the user side.
OffMeshConnection
sometimes doesn’t work properly.
OffMeshConnection
sometimes doesn’t work properly even without streaming.
CrowdAgent
may behave strangely if its path lays through removed tile.
Any streaming logic shall be implemented on the user side.