NavMesh error on big mesh

Hi i have problem with create navmesh, when ground is big plane. In console i can see

recast.js:24 OOM
abort	@	recast.js:24
abortOnCannotGrowMemory	@	recast.js:10

https://www.babylonjs-playground.com/#X5XCVT#14 playground to reproduce problem.

Hi @FurcaTomasz

The navmesh is computed thanks to a voxelization of the geometry. If the cell size (cs and ch parameters) are too small compared to the geometry, this leads to many many cells being allocated (which is failing).
The number of cells on a side = side length / cs. In your case: 300/0.2 = 1500. For an horizontal slice 1500 * 1500 = 2M+ cells.
Even if it was possible to allocate that much memory, the cpu time used to compute the navmesh would take ages.
Try with bigger values for the cell size or try scaling down the geometry.

1 Like

Thanks for help! :slight_smile:

@Cedric,

As far as I know, the cell size and cell height are directly responsible for the accuracy of the navmesh. A smaller cell size attribute leads to a much better defined navmesh am I correct? Wouldn’t increasing the cell size lead to a less accurate navmesh?

It would be great if we could feed it an already generated navmesh and use the Path finding functionalities later on. This would make it possible to use big meshes and have a detailed navmesh without losing anything performance wise. I think it would be worth it to take a look into it.

Yes, you are right. bigger cs/ch will give less precision. You’ll have to tweak (mesh simplification values too) to get a precise enough mesh will trying to not blow up with memory allocation.