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

Simplify heightmap calculation and avoid loading empty sections #3045

Merged
merged 2 commits into from
Dec 24, 2024

Conversation

SirYwell
Copy link
Member

Overview

Description

There are two relevant changes:

  1. Instead of a two-dimensional boolean array, we can use one byte array and mark specific bits per heightmap type. This reduces memory loads and simplifies the skip logic a bit. The skip bitset is also replaced by a simple counting variable, which also means we can avoid the array equals check.
  2. Add a method hasNonEmptySection that can return false if the section is present but only contains air. As minecraft already tracks that information, we can use it and avoid unnecessary array comparisons.

In my tests, the time spent in the HeightmapProcessor was 8 times less than before.

Submitter Checklist

Preview Give feedback

@SirYwell SirYwell requested a review from a team as a code owner December 24, 2024 11:23
@dordsor21 dordsor21 requested a review from a team December 24, 2024 12:00
@dordsor21 dordsor21 requested a review from a team December 24, 2024 12:07
@NotMyFault NotMyFault merged commit b95bcde into main Dec 24, 2024
11 checks passed
@NotMyFault NotMyFault deleted the perf/HeightmapProcessor-simplify branch December 24, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants