public sealed class NavTileCacheThe voxelised level, kept, so that a crate can be dropped on it and the tiles under the crate rebuilt without touching the geometry again.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
A bake is two halves. The first turns triangles into a walkable surface: rasterise, filter, compact, resolve the neighbours. The second decides what shape that surface is: erode, partition, trace, polygonise. An obstacle changes only the second half — the ground under a crate is the same ground, it is just not walkable while the crate is there — so this keeps the first half per tile and replays the second.
What that costs is memory, and it is not small. A compact heightfield is a span per walkable surface per column, so an eighty-metre level at a 0.3 m cell size is on the order of a megabyte. That is the trade being made: a level that wants dynamic obstacles keeps its voxels resident, and one that does not should bake and drop them. Recast's tile cache compresses its layers to avoid exactly this; compression is a thing to add when a project has measured that it needs it, and adding it first would be inventing a requirement.
Rebuilding is not free and is not meant to be hidden. Update takes a budget in tiles, and a caller that hands it one tile per frame gets an obstacle that appears over several frames rather than a frame that stalls. Tiles are the unit because a tile is the unit the mesh can swap: AddTile relinks the borders, and a path already crossing the replaced tile is invalidated by its polygons' salt rather than by anything having to hunt for it.
Fields and properties (6)
public NavMeshParams ParamsThe tile grid, ready to be handed to a NavMesh.
public int ColumnsHow many tiles across the grid is.
public int RowsHow many tiles deep.
public int PendingTilesHow many tiles are waiting to be rebuilt.
public long ResidentBytesRoughly how much memory the kept voxels occupy.
public int ObstacleCountHow many obstacles are in place.
Methods (5)
public static NavTileCache Build(ReadOnlySpan<Vector3> vertices, ReadOnlySpan<int> indices, BoundingBox bounds, NavMeshBuildSettings settings, int tileSize = 48, ReadOnlySpan<NavAreaVolume> volumes = default(ReadOnlySpan<NavAreaVolume>), ReadOnlySpan<NavOffMeshConnectionData> connections = default(ReadOnlySpan<NavOffMeshConnectionData>))Voxelises a level and keeps it.
public NavMesh CreateNavMesh()Builds every tile and returns a mesh holding them.
public NavObstacleHandle AddObstacle(NavAreaVolume shape)Adds an obstacle and marks the tiles it touches for rebuilding.
public bool RemoveObstacle(NavObstacleHandle handle)Removes an obstacle and marks the tiles it touched for rebuilding.
public int Update(NavMesh mesh, int maxTiles = 1)Rebuilds up to a budget of the tiles waiting for it, into a live mesh.
Used by (2)
- CrowdRetargetTestsVixen.Navigation.Tests
- NavTileCacheTestsVixen.Navigation.Tests