NavMesh Cut/Add caching

Hi!
I am using recast graph with navmesh cuts/adds, but I could not find way to serialize state after game is saved. Navmesh cut/adds are presented in serialized graph, but after loading all nav mesh cuts/adds are executed again, because ForceUpdate in NavmeshUpdates is called because at start up anyInvalidHandlers is not empty. It is not empty because forcedReloadRects is filled from NavmeshUpdates.Refresh which does not have tile handler at startup and adds entity to forcedReloadRects.

Do you have suggestion how to use caching with navmesh cut/adds?

Hi

I’d recommend that you just load the same mesh as you did when the graph started, that wouldn’t have any navmesh cuts applied. If the components are in the scene then they will be applied appropriately when the graph is loaded.

I do agree that this could be handled better in the package though.

If you need to save the graph again, then I’d recommend first disabling all navmesh cuts/adds. Call

// Disable all cuts
AstarPath.active.navmeshUpdates.ForceUpdate();
AstarPath.active.FlushWorkItems();

// Save graph

// Possibly enable them all again unless the game just exits here

@aron_granberg, looks like I should reformulate my question to be more correct:
I want to serialize navmesh cuts (it is working right now). When scene is loaded graph is restored correctly with navmesh cuts, but navmesh cutting algorithm is applied again and of course do nothing, just waste CPU time, cuts are existed already due to restoring from cache. How can I skip first force update if I know that all navmesh cut are restored in graph where cuts is already applied?

Context: RTS game, navmesh cuts are used for buildings. User save games with buildings, user load saved game with serialized nav mesh graph and I want to speed up loading and do not calculate navmesh cut again for buildings which are already put

That’s not possible right now I’m afraid.

Well. I suppose technically you could just leave the cuts you know already exist as disabled. However they will be baked into the navmesh so you will no longer be able to remove them if for example the building is destroyed.

:frowning:
but, thanks for answer! :slight_smile: