Navmesh generation is split into two steps:
1. Heightfield/Voxelfield Generation
2. Polygon Mesh Generation
This PR focuses on Step 2.
Step 2 still needs to run even when loading a navmesh from disk, since during baking we write the compressed Heightfield rather than the final polygon mesh. Step 2 is the cheaper of the two steps and already quite fast, but while profiling I noticed some additional optimization potential.
This PR makes Step 2 roughly 20–30% faster, which will directly translate into faster navmesh loads from baked data. Looking at the whole pipeline (Step 1 + Step 2), I expect we'll see roughly a 10% improvement in our navmesh_gen benchmark.
Optimizations primarily include:
- Smarter caching of resources between tile generation runs
- Reducing algorithmic complexity (O(n²) → O(n)) in some hot paths (at the cost of a small amount of memory)
- Unrolling some loops
- Loads of micro-optimizations