RosaryMala / armok-vision

A 3d realtime visualizer for Dwarf Fortress
MIT License
319 stars 27 forks source link

Talk to DF with a background thread #3

Closed kazimuth closed 9 years ago

kazimuth commented 9 years ago

I'm doing a little profiling, and currently the call to RemoteClient.suspend_game() from GameMap.Update() is taking up 6-25ms most frames. GameMap.GetBlockList() also takes 2-3ms.

Running these on a background thread could speed up the main thread a lot. Any results could be put into a queue to be processed by the main thread, so that it doesn't have to wait.

It might even be possible to compute meshes on a background thread, at least the vertices / edges for the blocky parts of the world - it wouldn't be possible to copy existing meshes, though, because no Unity API in other threads.

RosaryMala commented 9 years ago

Actually, the most time consuming part of the meshing can pretty easily be put into a separate thread. It doesn't need any connection to Unity for it. It's only applying the mesh to the gameobject, but that's instant. (ish)

kazimuth commented 9 years ago

29a1f87