I have visualized the vertices I am interested in. The small box is a 1x1x1 unit reference. Ideally, the vertices around the big box are no further apart the 1 unit, i.e. 1 small box.
Judging by the descripton of the navmesh parameter “maxEdgeLength” it sounds like the one I need. But as you can see in the playground it is not the case.
Why?
To fix this particular example you can
change the walls’ x-position to 3 (line 100) or
lower maxEdgeLength by 1
But I need this to be more reliable in general. How can I get those vertices to be 1 world unit apart - guaranteed?
Note: Setting maxEdgeLength too low results in extreme loading times (on bigger maps).
Note also: I do not use the navmesh for navigation but for finding cover spots. It is a tile-based game. So if vertices are further apart than 1 world unit (=1 tile), some cover tiles are missing.
yes, the ‘ideal’ way to do it is to use maxEdgeLen. It’s the only way I know to get distant vertices within 1 unit.
I would search for alternative ways:
Is it possible to store the navmesh if the map is not dynamic?
can you do a process that lists the edges and generate as many intermediate vertices along that edge (problem: edge length might not be an integer)
If the game is tile based, can you do a process that call getClosestPoint on each tile center, if the returned point is close enough, then it’s part of the navmesh, otherwise, it’s outside
I have tested the point-sampling alternative: just a quick hack but it appears to be really fast. I did pretty much what you said: loop over tiles, getClosesetPoint, eval distance, if obstacle, proceed with cover analysis. So, for tile-based maps, this does work.
However, I have not given up on the navmesh approach yet. Partly because, they did it with Recast. So it has to work somehow. I will report back if I figure out sth.
Some progress. Going over the docs again I noticed that maxEdgeLength is in voxels not in world units. And 1 voxel is how much you specified in the cs/ch parameters. Adjusting the values accordingly and it seems to work - also in my local more complex project.
However, wth regards to the above playground, it is still puzzlng why setting the walls to x=3 lowers the edge length.
Anyway, I am marking this as solution for now but report back if anything goes wrong.