pub struct LightCacheLayout {
center_chunk: ChunkPos,
range: LightSectionRange,
cached_min_section_y: i32,
cached_section_count: usize,
chunk_index_offset: i64,
chunk_section_index_offset: i64,
encode_offset_x: i64,
encode_offset_y: i64,
encode_offset_z: i64,
encoded_min_block_x: i64,
encoded_min_block_z: i64,
}Expand description
ScalableLux cache-window layout for chunk, section, and nibble arrays.
ScalableLux keeps a 5x5 chunk window around the active chunk and stores
light sections in flat arrays with one extra cached section below and above
the vanilla light-section range. This type owns that index math so the
light engine can share the same slots for chunk sections, nibbles, and
update notifications without repeating coordinate transforms.
Fields§
§center_chunk: ChunkPos§range: LightSectionRange§cached_min_section_y: i32§cached_section_count: usize§chunk_index_offset: i64§chunk_section_index_offset: i64§encode_offset_x: i64§encode_offset_y: i64§encode_offset_z: i64§encoded_min_block_x: i64§encoded_min_block_z: i64Implementations§
Source§impl LightCacheLayout
impl LightCacheLayout
Sourcepub fn new(center_chunk: ChunkPos, range: LightSectionRange) -> Self
pub fn new(center_chunk: ChunkPos, range: LightSectionRange) -> Self
Creates a cache layout centered on one chunk.
Sourcepub const fn center_chunk(self) -> ChunkPos
pub const fn center_chunk(self) -> ChunkPos
Returns the chunk at the center of this cache window.
Sourcepub const fn range(self) -> LightSectionRange
pub const fn range(self) -> LightSectionRange
Returns the vanilla padded light-section range.
Sourcepub const fn cached_min_section_y(self) -> i32
pub const fn cached_min_section_y(self) -> i32
Returns the first cached section Y coordinate, including the lower buffer.
Sourcepub const fn cached_max_section_y_exclusive(self) -> i32
pub const fn cached_max_section_y_exclusive(self) -> i32
Returns the section Y coordinate one past the last cached section.
Sourcepub const fn cached_section_count(self) -> usize
pub const fn cached_section_count(self) -> usize
Returns the number of cached vertical sections, including both buffers.
Sourcepub const fn section_slot_count(self) -> usize
pub const fn section_slot_count(self) -> usize
Returns the number of section/nibble slots in this cache window.
Sourcepub const fn setup_chunks(
self,
radius: LightCacheSetupRadius,
) -> LightCacheSetupChunks ⓘ
pub const fn setup_chunks( self, radius: LightCacheSetupRadius, ) -> LightCacheSetupChunks ⓘ
Iterates chunks in ScalableLux setupCaches scan order.
Sourcepub fn cached_chunk(self, chunk_pos: ChunkPos) -> Option<CachedLightChunk>
pub fn cached_chunk(self, chunk_pos: ChunkPos) -> Option<CachedLightChunk>
Returns cached chunk slot data for a chunk column.
Sourcepub fn cached_chunk_by_coords(
self,
chunk_x: i32,
chunk_z: i32,
) -> Option<CachedLightChunk>
pub fn cached_chunk_by_coords( self, chunk_x: i32, chunk_z: i32, ) -> Option<CachedLightChunk>
Returns cached chunk slot data for chunk coordinates.
Sourcepub fn chunk_slot(self, chunk_pos: ChunkPos) -> Option<usize>
pub fn chunk_slot(self, chunk_pos: ChunkPos) -> Option<usize>
Returns the slot for a cached chunk column.
Sourcepub fn chunk_slot_by_coords(self, chunk_x: i32, chunk_z: i32) -> Option<usize>
pub fn chunk_slot_by_coords(self, chunk_x: i32, chunk_z: i32) -> Option<usize>
Returns the slot for a cached chunk column by chunk coordinates.
Sourcepub const fn chunk_pos_for_slot(self, chunk_slot: usize) -> Option<ChunkPos>
pub const fn chunk_pos_for_slot(self, chunk_slot: usize) -> Option<ChunkPos>
Converts a chunk slot back to its cached chunk position.
Sourcepub fn section_slot(self, section_pos: SectionPos) -> Option<usize>
pub fn section_slot(self, section_pos: SectionPos) -> Option<usize>
Returns the section/nibble slot for a section position.
Sourcepub fn cached_section(
self,
section_pos: SectionPos,
) -> Option<CachedLightSection>
pub fn cached_section( self, section_pos: SectionPos, ) -> Option<CachedLightSection>
Returns cached section slot data for a section position.
Sourcepub const fn section_pos_for_slot(
self,
section_slot: usize,
) -> Option<SectionPos>
pub const fn section_pos_for_slot( self, section_slot: usize, ) -> Option<SectionPos>
Converts a section/nibble slot back to its cached section position.
Sourcepub fn inner_light_section_slots_for_chunk(
self,
chunk_pos: ChunkPos,
) -> Option<LightChunkSectionSlots>
pub fn inner_light_section_slots_for_chunk( self, chunk_pos: ChunkPos, ) -> Option<LightChunkSectionSlots>
Iterates the vanilla light-section slots for an inner cached chunk.
Returns None for the outer radius-2 ring because ScalableLux keeps
those chunks available for chunk/emptiness lookups but does not
populate section or nibble cache data for them during normal setup.
Sourcepub fn cached_block(self, block_pos: BlockPos) -> Option<CachedLightBlock>
pub fn cached_block(self, block_pos: BlockPos) -> Option<CachedLightBlock>
Returns cache slot data for a block position.
Sourcepub fn cached_block_by_coords(
self,
block_x: i32,
block_y: i32,
block_z: i32,
) -> Option<CachedLightBlock>
pub fn cached_block_by_coords( self, block_x: i32, block_y: i32, block_z: i32, ) -> Option<CachedLightBlock>
Returns cache slot data for block coordinates.
Sourcepub fn cached_neighbor(
self,
cached_block: CachedLightBlock,
direction: Direction,
) -> Option<CachedLightBlock>
pub fn cached_neighbor( self, cached_block: CachedLightBlock, direction: Direction, ) -> Option<CachedLightBlock>
Returns cache slot data for a cached block’s neighboring block.
Sourcepub fn cached_block_from_packed(
self,
packed: PackedLightBlockPos,
) -> Option<CachedLightBlock>
pub fn cached_block_from_packed( self, packed: PackedLightBlockPos, ) -> Option<CachedLightBlock>
Decodes a packed queue position and returns its cache slot data.
Sourcepub const fn local_block_index(block_pos: BlockPos) -> usize
pub const fn local_block_index(block_pos: BlockPos) -> usize
Returns the local light-section index for a block position.
Sourcepub const fn local_block_index_by_coords(
block_x: i32,
block_y: i32,
block_z: i32,
) -> usize
pub const fn local_block_index_by_coords( block_x: i32, block_y: i32, block_z: i32, ) -> usize
Returns the local light-section index for block coordinates.
Sourcepub const fn encoded_min_block_x(self) -> i32
pub const fn encoded_min_block_x(self) -> i32
Returns the first block X coordinate that can be packed into queue entries.
Sourcepub const fn encoded_max_block_x_exclusive(self) -> i32
pub const fn encoded_max_block_x_exclusive(self) -> i32
Returns the block X coordinate one past the packed queue window.
Sourcepub const fn encoded_min_block_z(self) -> i32
pub const fn encoded_min_block_z(self) -> i32
Returns the first block Z coordinate that can be packed into queue entries.
Sourcepub const fn encoded_max_block_z_exclusive(self) -> i32
pub const fn encoded_max_block_z_exclusive(self) -> i32
Returns the block Z coordinate one past the packed queue window.
Sourcepub fn encode_block_pos(
self,
block_pos: BlockPos,
) -> Option<PackedLightBlockPos>
pub fn encode_block_pos( self, block_pos: BlockPos, ) -> Option<PackedLightBlockPos>
Packs a block position for ScalableLux queue storage.
Sourcepub fn decode_block_pos(self, packed: PackedLightBlockPos) -> Option<BlockPos>
pub fn decode_block_pos(self, packed: PackedLightBlockPos) -> Option<BlockPos>
Decodes ScalableLux queue-position bits back to a world block position.
Sourcepub fn contains_encoded_block_pos(self, block_pos: BlockPos) -> bool
pub fn contains_encoded_block_pos(self, block_pos: BlockPos) -> bool
Returns true if a block position is inside the packed queue-coordinate window.
Sourcepub fn section_slot_by_coords(
self,
section_x: i32,
section_y: i32,
section_z: i32,
) -> Option<usize>
pub fn section_slot_by_coords( self, section_x: i32, section_y: i32, section_z: i32, ) -> Option<usize>
Returns the section/nibble slot for section coordinates.
Sourcepub fn cached_section_index(self, section_y: i32) -> Option<usize>
pub fn cached_section_index(self, section_y: i32) -> Option<usize>
Returns the cached vertical index for a section Y coordinate.
Sourcepub const fn cached_section_y(self, index: usize) -> Option<i32>
pub const fn cached_section_y(self, index: usize) -> Option<i32>
Converts a cached vertical index back to section Y.
Sourcepub fn contains_chunk_coords(self, chunk_x: i32, chunk_z: i32) -> bool
pub fn contains_chunk_coords(self, chunk_x: i32, chunk_z: i32) -> bool
Returns true if a chunk coordinate is inside the 5x5 cache window.
Sourcepub fn contains_inner_chunk_coords(self, chunk_x: i32, chunk_z: i32) -> bool
pub fn contains_inner_chunk_coords(self, chunk_x: i32, chunk_z: i32) -> bool
Returns true if a chunk coordinate is inside the inner section/nibble cache radius.
Sourcepub const fn contains_light_section_y(self, section_y: i32) -> bool
pub const fn contains_light_section_y(self, section_y: i32) -> bool
Returns true if a section Y is inside vanilla’s padded light-section range.
Sourcepub const fn contains_section_y(self, section_y: i32) -> bool
pub const fn contains_section_y(self, section_y: i32) -> bool
Returns true if a section Y coordinate is inside the cached vertical range.
Trait Implementations§
Source§impl Clone for LightCacheLayout
impl Clone for LightCacheLayout
Source§fn clone(&self) -> LightCacheLayout
fn clone(&self) -> LightCacheLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for LightCacheLayout
Source§impl Debug for LightCacheLayout
impl Debug for LightCacheLayout
impl Eq for LightCacheLayout
Source§impl PartialEq for LightCacheLayout
impl PartialEq for LightCacheLayout
impl StructuralPartialEq for LightCacheLayout
Auto Trait Implementations§
impl Freeze for LightCacheLayout
impl RefUnwindSafe for LightCacheLayout
impl Send for LightCacheLayout
impl Sync for LightCacheLayout
impl Unpin for LightCacheLayout
impl UnsafeUnpin for LightCacheLayout
impl UnwindSafe for LightCacheLayout
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
self with key and returns true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreArc<SyncMutex<>>