Tiles for manually created navmesh

Hi there,

I’m working on a large-ish 3D map (3 sqkm), and I’m just switching to this project from unity’s built-in pathfinding. I am now trying to build a navmesh for my map.

I am planning on using navmesh cutting for trees (which can be removed at runtime), so I think having tiles is pretty important. However, generating the recast graph generates a lot of disconnected regions despite the minimum region value (which largely seems to have no effect), and I need a “clean” navmesh because a range of other functionality depends on it.

I tried “cleaning up” the navmesh in blender after exporting the recast graph, but when trying to then put the mesh in as a navmesh graph, I get the error “Too many vertices in the tile” (NavmeshBase.cs:927). I had tried to keep the structure of the recast mesh exactly, so did not merge the duplicate verts, but it looks like NavMeshGenerator (at 250) removes duplicates anyway.

Is there a way for me to import tiles into a navmesh graph? Or for me to “manually” remove regions from a recast graph while retaining the tiles? Version is 4.2.17.

Thank you for your help!

After investigating this some more, I think my best shot is probably to figure out how to discard the areas that aren’t needed at recastgraph generation, which I assume is being done in VoxelRegion.FilterSmallRegions()?

However, I am not quite sure how those regions are actually filtered out. At the very end of the method it seems to set reg[i] = 0 for any regions that too small and not border regions, but reg[] itself is a parameter that seems to be passed by value.

I feel like I am missing something here - any help?

Hi

Sorry for the late reply.

An annoying thing about the minimum region value is that it can only clean up small regions that are completely inside a single recast tile. Otherwise, there’s the risk that the other tile connects the small region with a larger region. This is because all tiles are calculated independently in parallel. Though, I am considering adding a post-processing step so that people have the option of filtering all small regions at scan time. It’s such a common request.

There is the RelevantGraphSurface component which can be used for this. Depending on if you always know which part of a tile that you want.

reg is an array, so it’s always passed by reference.

I haven’t tested this, but you might be able to remove this line:

// Adjacent to border
if ((bits[ctr] & BorderBit) != 0) counter[ctr] = -minRegionSize-2;

in the FilterSmallRegions method to make it work sort of like you want it to.

Hi!

All good, a few days don’t make a difference in years of development ;).

Yeah, I had played around with the code a little bit, including deleting the line you suggested, and this was the main problem - it ended up deleting small regions from tiles that were connected to larger regions right next to them. It generally happened along longer lines right through the map, so I’m assuming one side was handled by a different thread from the other. The smaller I made the tiles, the more prominent the problem became.

I ended up using the graph with all its disconnected regions, as well as using the cleaned up mesh as an invisible step to rely on for the other operations, which works for now - but if you ever do introduce that post processing step to filter out all smaller regions, it would make my workflow much cleaner.

In any case - the pathfinding is running super smoothly for me so far, and aside from perfectionism with the graph, the transition was really easy - so thank you for all your hard work!

1 Like