Skip to content

Navmesh disk cache (#6189)

elsid requested to merge elsid/openmw:navmeshtool into master

Based on the forum post, some prior discussions and issues about navmesh generation being slow/causing a loading screen especially on systems with low CPU performance.

This MR is a starting point for having navmesh being generated and stored outside OpenMW process and memory but also being accessible in game sessions. There is a new binary called navmeshtool that allows to generate a navmesh database (SQLite based) out of all content listed in openmw.cfg. No manual configuration is required, just like the engine it will read all config files and load all listed content files including mods, etc. The navmesh generation is done in parallel based on ACTI, CELL, CONT, DOOR, GMST, LAND, STAT ESM records utilizing all CPUs by default or given number of threads. Interior cells are not processed by default but supported via the --process-interior-cells flag. Basically the content loading algorithm repeats the engine, but still may have some issues. Tool correctly handles an existing database. If tile is already present with exact match it will not be regenerated.

Generated database file size is about 435 MiB for exterior cells from all official Morrowind content and mods. It contains 2 tables: shapes (all used collision meshes) and tiles (content of navmesh tiles). On my system it takes about 6 minutes to generate a database for all cells.

Prepared by navmeshtool database is used by the engine to get navmesh tiles that are not present in memory cache. Navmesh tile key is a composition of worldspace, tile coordinate and a binary structure serialized containing (recast scale factor, rcConfig, RecastMesh). Navmesh tile data is PreparedNavMeshData also binary serialized in a way that it can be deserialized later. That is basically an input for the last step of creating a navmesh tile excluding off mesh connections (door ways, pathgrids).

New settings are added:

  1. nav mesh version that is used to avoid using cached tiles that have different versions.
  2. enable nav mesh disk cache controls whether navmesh disk cache is used by the engine.
  3. write to navmeshdb to enable/disable writing into disk cache from the engine.

Task left:

  • Allow to run navmesh db generator from the launcher.
  • Try to compress binary serialized data.
  • Write generated navmesh tiles into database from the engine game session.

Should resolve #6189 (closed).

Edited by elsid

Merge request reports