You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The functions for_each_block_optimized and for_each_block_mut_optimized
in the mchprs_world crate can in some cases not invoke the given callback on
block positions which contains block (i.e., which aren't air).
So for example if we're looking at a region between BlockPos{x: 15, y:15, z:15}
and BlockPos{x: 40, y:40, z:40}, the previous logic would check if the chunk
section to which BlockPos{x: 15, y:15, z:15} belongs is empty (i.e., section 0
of chunk 0,0), and if it is, it would skip all the blocks between that point
and BlockPos{x: 31, y:31, z:31}, despite some of these being in other chunks/sections
not tested for emptiness yet; so e.g. if everything is air except a block
at BlockPos{x: 25, y:25, z:25}, this block would be skipped as its chunk section (section 1 of chunk 1,1)
is only checked for emptiness when deciding whether to iterate over batches that don't
include this point; the batch that would iterate over it has looked at section 0 of chunk 0,0.
(Incidentally this also reduces the effectiveness of the optimization
since some areas that are empty are still checked).
I hope this explanation makes sense, happy to clarify further if needed.
The text was updated successfully, but these errors were encountered:
The functions
for_each_block_optimized
andfor_each_block_mut_optimized
in the
mchprs_world
crate can in some cases not invoke the given callback onblock positions which contains block (i.e., which aren't air).
This could happen because the iteration loops over batches of 16x16x16 blocks
that aren't aligned to chunk boundaries and the check for emptyness looks at the
chunk section where one of the corners of the batch is located, see:
https://github.com/MCHPR/MCHPRS/blob/76b9b8cf575ee4419eca5c2cd9dac56405a2cafe/crates/world/src/lib.rs#L156~L161
however the iteration then proceeds to all the blocks inside this batch, which can
include blocks in other chunks/section:
https://github.com/MCHPR/MCHPRS/blob/76b9b8cf575ee4419eca5c2cd9dac56405a2cafe/crates/world/src/lib.rs#L164~L166
So for example if we're looking at a region between
BlockPos{x: 15, y:15, z:15}
and
BlockPos{x: 40, y:40, z:40}
, the previous logic would check if the chunksection to which
BlockPos{x: 15, y:15, z:15}
belongs is empty (i.e., section 0of chunk 0,0), and if it is, it would skip all the blocks between that point
and
BlockPos{x: 31, y:31, z:31}
, despite some of these being in other chunks/sectionsnot tested for emptiness yet; so e.g. if everything is air except a block
at
BlockPos{x: 25, y:25, z:25}
, this block would be skipped as its chunk section (section 1 of chunk 1,1)is only checked for emptiness when deciding whether to iterate over batches that don't
include this point; the batch that would iterate over it has looked at section 0 of chunk 0,0.
(Incidentally this also reduces the effectiveness of the optimization
since some areas that are empty are still checked).
I hope this explanation makes sense, happy to clarify further if needed.
The text was updated successfully, but these errors were encountered: