void IUpdatableGraph.UpdateArea(GraphUpdateObject guo)
{
// Figure out which tiles are affected
// Expand TileBorderSizeInWorldUnits voxels in all directions to make sure
// all tiles that could be affected by the update are recalculated.
var affectedTiles = GetTouchingTiles(guo.bounds, TileBorderSizeInWorldUnits);
if (!guo.updatePhysics)
{
for (int z = affectedTiles.ymin; z <= affectedTiles.ymax; z++)
{
for (int x = affectedTiles.xmin; x <= affectedTiles.xmax; x++)
{
NavmeshTile tile = tiles[z * tileXCount + x];
NavMeshGraph.UpdateArea(guo, tile);
}
}
return;
}
Voxelize vox = globalVox;
if (vox == null)
{
throw new System.InvalidOperationException("No Voxelizer object. UpdateAreaInit should have been called before this function.");
}
AstarProfiler.StartProfile("Build Tiles");
// Build the new tiles
for (int x = affectedTiles.xmin; x <= affectedTiles.xmax; x++)
{
for (int z = affectedTiles.ymin; z <= affectedTiles.ymax; z++)
{
stagingTiles.Add(BuildTileMesh(vox, x, z));
}
}
uint graphIndex = (uint)AstarPath.active.data.GetGraphIndex(this);
// Set the correct graph index
for (int i = 0; i < stagingTiles.Count; i++)
{
NavmeshTile tile = stagingTiles[i];
GraphNode[] nodes = tile.nodes;
for (int j = 0; j < nodes.Length; j++)
{
nodes[j].GraphIndex = graphIndex;
}
}
for (int i = 0; i < vox.inputMeshes.Count; i++)
{
vox.inputMeshes[i].Pool();
}
ListPool <RasterizationMesh> .Release(ref vox.inputMeshes);
AstarProfiler.EndProfile("Build Tiles");
}