Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chunks are more seamless #76

Merged
merged 5 commits into from
Apr 3, 2024

Conversation

snipercup
Copy link
Collaborator

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:

  • use the physicsserver to attempt creation and destruction of physicsshapes on a thread (for blocks and furniture)
  • Try to spread out the destruction of furniture when unloading a chunk
  • Use object pooling so destruction is not needed as much
  • Somehow merge collision shapes for blocks so fewer collisionshapes are added. Probably not an option if this prevents determining where the user wants to place a new block during construction

@snipercup snipercup merged commit a6d856c into Khaligufzel:main Apr 3, 2024
@snipercup snipercup deleted the Chunks-are-more-seamless branch April 3, 2024 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant