Lethal Company
Install with App

Details

Latest version
1.0.0
Last Updated
First Uploaded
Downloads
198
Likes
0
Size
11KB
Dependants

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

  1. 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.
  2. It triangulates the full-detail mesh on a background thread, the same way TerraMesh's own MeshifyAsync does.
  3. When the full mesh is ready, usually a couple of seconds later, TerraMeshAsync writes it into the same Mesh object. 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)
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.