Vixen
02b45cc4
csharp
public sealed class NavTileCache

The 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 Params

    The tile grid, ready to be handed to a NavMesh.

  • public int Columns

    How many tiles across the grid is.

  • public int Rows

    How many tiles deep.

  • public int PendingTiles

    How many tiles are waiting to be rebuilt.

  • public long ResidentBytes

    Roughly how much memory the kept voxels occupy.

  • public int ObstacleCount

    How many obstacles are in place.

Methods (5)

Used by (2)

  • CrowdRetargetTestsVixen.Navigation.Tests
  • NavTileCacheTestsVixen.Navigation.Tests