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

Chunk Management Overhaul: Improving Performance #12

Closed
Ven0maus opened this issue Sep 28, 2023 · 0 comments
Closed

Chunk Management Overhaul: Improving Performance #12

Ven0maus opened this issue Sep 28, 2023 · 0 comments
Assignees
Labels
Overhaul Rework an existing feature Performance This issue impacts performance

Comments

@Ven0maus
Copy link
Owner

Ven0maus commented Sep 28, 2023

Current behaviour

  • Always load the current chunk
  • Always load the 8 neighbor chunks around the current chunk
  • When current chunk is changed to another chunk, it loads the new chunks and unloads the unused chunks.

Proposed new behaviour

How many chunks to have active at once?:

  • Based on the screen width/height and chunk width/height calculate the amount of chunks needed active at all times.

Calculation could be something like:
We need x amount of chunks to fill the whole screen, how many chunks
do we still need to fill all the chunks outside of the direct screen borders,
so centering is not triggering new chunk loads on the main thread?

When centering:

  • Load all the calculated chunks based on the center coordinate
  • Unload unneeded chunks based on the center coordinate

Threading default behaviour

  • Visible chunks on the screen should be loaded on the main thread
  • Invisible chunks that are not on the screen should be loaded on a seperate thread

This effectively means that when the grid is gradually centered to a certain direction and new chunks need to be loaded,
these new chunks are most likely to be situated not yet in the screen bounds as we always load extra chunks around the screen bounds.
These new chunks don't immediately need to be visible for the screen so the overhead on the main thread
is not needed.
This should keep performance drain to a minimal during movement on the grid, (ideally only loading outer chunks off-threaded) not impacting the main thread while moving.

The only times chunks should be loaded on the main thread, is when a big jump is done, eg jump from one position to another somewhere in a region where no or insufficient chunks have been loaded.
This is because the player needs immediate visual input on the chunks visible.

Full threading option
An option to load all chunks on a seperate thread should also be available.
This implies we simply display black cells on the screen before the thread is started, for the screen region that has no valid cells visible yet.

@Ven0maus Ven0maus added the Overhaul Rework an existing feature label Sep 28, 2023
@Ven0maus Ven0maus changed the title Improve chunk loading / unloading when centering Chunk Management Overhaul: Improving Game Performance Sep 29, 2023
@Ven0maus Ven0maus changed the title Chunk Management Overhaul: Improving Game Performance Chunk Management Overhaul: Improving Performance Sep 29, 2023
@Ven0maus Ven0maus added the Performance This issue impacts performance label Sep 29, 2023
@Ven0maus Ven0maus self-assigned this Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Overhaul Rework an existing feature Performance This issue impacts performance
Projects
None yet
Development

No branches or pull requests

1 participant