Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requires #75 to work.
Chunks are still loaded and unloaded one by one, but multiple chunks can be loaded somewhat at the same time. What happens is that the levelgenerator will load a chunk, and when it's ready and does some basic stuff, it will signal that it's partially loaded and the next chunk can start loading.
I also increased the chunk loading radius from 1 to 2 and the unloading radius from 2 to 3. This means we play in a bigger area, which could impact memory. The benefit is that it is more seamless.
It still runs well even when I set the player speed to 4 instead of 1.
I did try simultaneous loading and unloading of chunks, but this leads to stuttering. The profiler shows about 120 ms on physic process at the peak which is noticable. I think this is because of the collision shapes of the blocks and furniture. I tried to spread out the unloading of physics shapes for blocks, but somehow the stuttering became worse. This could be because the amount of unloading calls makes it stutter. When one chunk is unloaded in a single moment, it takes less unloading calls then when each separate collision shape is loaded over multiple frames?
The game runs okay now so this will be it for now in with regards to chunks. We can optimize more: