
You are viewing a potentially older version of this package. View Latest Version
TerraMeshAsync
Removes the ~2 s freeze when TerraMesh (used by UniversalRadar's contour maps) converts terrain on landing. Builds a low-detail mesh instantly and swaps in full detail from a background thread.TerraMeshAsync
Removes the freeze when TerraMesh converts a moon's terrain to a mesh on landing. UniversalRadar uses that conversion for its contour maps. On large terrains like March or Adamance, it takes about 2 s.
How it works
TerraMesh.Meshify(terrain, config)normally triangulates the whole heightmap on the main thread. TerraMeshAsync returns a low-detail mesh instead, built in about 60 ms.- It triangulates the full-detail mesh on a background thread, the same way TerraMesh's own
MeshifyAsyncdoes. - When the full mesh is ready, usually a couple of seconds later, TerraMeshAsync writes it into the same
Meshobject. Anything that holds that mesh picks up the full detail, including UniversalRadar's radar copies.
Measured on Adamance, the 2.2 s freeze became 60 ms + 47 ms on the main thread.
Notes
- The contour map looks a little blocky for the first couple of seconds after landing.
- UniversalRadar reads the terrain's height range from the first mesh it gets. The low-detail mesh's range is within about 0.3% of the full one, so the contour shading looks the same.
- The final swap skips
Mesh.Optimize, which only reorders vertices for the GPU's cache. That keeps the swap frame short. - TerraMeshAsync runs on your game only and only changes visuals. Other players don't need it.
- If TerraMesh's internals change, TerraMeshAsync logs a warning and leaves the conversion as it is.
Log
Your log will show lines like these:
[Info :TerraMeshAsync] AdamanceTerrain: low-detail mesh in 60 ms, full detail building in the background
[Info :TerraMeshAsync] AdamanceTerrain: full-detail mesh in place after 2.7 s (47 ms on the main thread)