Fix and simplify world::for_each_block_optimized
#169
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.
First time contributor, so please let me know if I'm doing anything wrong.
I was looking at the source for no particular reason at all and decided to take a stab at this:
MCHPRS/crates/world/src/lib.rs
Line 84 in 76b9b8c
finding a bug in the process.
This PR replaces the duplicated implementation of
for_each_block_optimized
andfor_each_block_mut_optimized
in themchprs_world
crate with a simpler implementationthat abstracts the iteration logic.
Also this adds tests for the iteration logic and for the
for_each_block_optimized
function(which is how I realised that the current implementation had a bug that could lead
to some non-air block being skipped, see #168 for more details); let me know if
they're too verbose or if there should be other cases covered.
With the new implementation #168 should be fixed, since the new iteration special-cases
the bounding box boundaries and otherwise checks the block in batches corresponding
to chunk sections.