Currently if the player goes fast enough they can catch up to terrain generation, and the problem is even worse with higher render distances.
To fix this, terrain generation and meshing need to be in separate threads, so they can be decoupled from the game loop and work as fast as possible. Meshing and generation also needs to priorize nearby chunks, which is kind of the case atm but only if the player doesn't move.
Also worth exploring: using DashMap in the chunk storage structure so that generation doesn't require mut.
TODO
[x] Prioritize generation queue with distance to player
[x] Prioritize meshing queue with distance to player
[x] Have 1 generation thread and 1 meshing thread consuming their order queue
Currently if the player goes fast enough they can catch up to terrain generation, and the problem is even worse with higher render distances.
To fix this, terrain generation and meshing need to be in separate threads, so they can be decoupled from the game loop and work as fast as possible. Meshing and generation also needs to priorize nearby chunks, which is kind of the case atm but only if the player doesn't move.
Also worth exploring: using DashMap in the chunk storage structure so that generation doesn't require mut.
TODO