Using GraphModifier.OnPostScan, how to know which Tiles have been updated?

I am writing an Off-Mesh-Link Generator (just using some Physics.CapsuleCast checks, based on the one made by ToastyStoemp)
… and I did notice that it takes ages to calculate it for the whole map.
Now I do have destructible buildings, and I want to automatically generate off-mesh-links at runtime, when the graph updates. Instead of generating them for the entire map, I’d like to just generate them on the tiles that were updated.

Now how to get the information which Tiles have been updated, from within the GraphModifier? (I tried to check the source code but it’s not really obvious how tiles are selected …)

This information is not available in that callback. However, each recast graph has a callback named OnRecalculatedTiles that does provide this. += (NavmeshTile[] tiles) => {
    // ...
1 Like

This works. Now I just need to calculate the unity-space world bounds for these tiles, so I can remove all NavMeshLinks which start/end inside of those bounds and generate new ones with the tris/verts from the tile.

I tried various things with bbtree.intRect of the NavMeshTile. Also the “width” and “depth” of the NavMeshTile say, that they will always be “1”, but I doubt that tiles are just 1 unit wide? Kinda clueless how to calculate the World Bounds for a tile.

You can use the RecastGraph.TileBounds method:

1 Like

Immediatly after writing this, I realized that there is an overload of this method which just takes in an x and z coordinate, with width and depth both at “1”.

And yea, adding the NavmeshTile.x and NavmeshTile.z returns the correct Bounds.

Now I have everything I need. Thanks for the super fast reply. ^^

1 Like