Skip to main content

LightCacheLayout

Struct LightCacheLayout 

Source
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: i64

Implementations§

Source§

impl LightCacheLayout

Source

pub fn new(center_chunk: ChunkPos, range: LightSectionRange) -> Self

Creates a cache layout centered on one chunk.

Source

pub const fn center_chunk(self) -> ChunkPos

Returns the chunk at the center of this cache window.

Source

pub const fn range(self) -> LightSectionRange

Returns the vanilla padded light-section range.

Source

pub const fn cached_min_section_y(self) -> i32

Returns the first cached section Y coordinate, including the lower buffer.

Source

pub const fn cached_max_section_y_exclusive(self) -> i32

Returns the section Y coordinate one past the last cached section.

Source

pub const fn cached_section_count(self) -> usize

Returns the number of cached vertical sections, including both buffers.

Source

pub const fn section_slot_count(self) -> usize

Returns the number of section/nibble slots in this cache window.

Source

pub const fn setup_chunks( self, radius: LightCacheSetupRadius, ) -> LightCacheSetupChunks

Iterates chunks in ScalableLux setupCaches scan order.

Source

pub fn cached_chunk(self, chunk_pos: ChunkPos) -> Option<CachedLightChunk>

Returns cached chunk slot data for a chunk column.

Source

pub fn cached_chunk_by_coords( self, chunk_x: i32, chunk_z: i32, ) -> Option<CachedLightChunk>

Returns cached chunk slot data for chunk coordinates.

Source

pub fn chunk_slot(self, chunk_pos: ChunkPos) -> Option<usize>

Returns the slot for a cached chunk column.

Source

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.

Source

pub const fn chunk_pos_for_slot(self, chunk_slot: usize) -> Option<ChunkPos>

Converts a chunk slot back to its cached chunk position.

Source

pub fn section_slot(self, section_pos: SectionPos) -> Option<usize>

Returns the section/nibble slot for a section position.

Source

pub fn cached_section( self, section_pos: SectionPos, ) -> Option<CachedLightSection>

Returns cached section slot data for a section position.

Source

pub const fn section_pos_for_slot( self, section_slot: usize, ) -> Option<SectionPos>

Converts a section/nibble slot back to its cached section position.

Source

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.

Source

pub fn cached_block(self, block_pos: BlockPos) -> Option<CachedLightBlock>

Returns cache slot data for a block position.

Source

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.

Source

pub fn cached_neighbor( self, cached_block: CachedLightBlock, direction: Direction, ) -> Option<CachedLightBlock>

Returns cache slot data for a cached block’s neighboring block.

Source

pub fn cached_block_from_packed( self, packed: PackedLightBlockPos, ) -> Option<CachedLightBlock>

Decodes a packed queue position and returns its cache slot data.

Source

pub const fn local_block_index(block_pos: BlockPos) -> usize

Returns the local light-section index for a block position.

Source

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.

Source

pub const fn encoded_min_block_x(self) -> i32

Returns the first block X coordinate that can be packed into queue entries.

Source

pub const fn encoded_max_block_x_exclusive(self) -> i32

Returns the block X coordinate one past the packed queue window.

Source

pub const fn encoded_min_block_z(self) -> i32

Returns the first block Z coordinate that can be packed into queue entries.

Source

pub const fn encoded_max_block_z_exclusive(self) -> i32

Returns the block Z coordinate one past the packed queue window.

Source

pub fn encode_block_pos( self, block_pos: BlockPos, ) -> Option<PackedLightBlockPos>

Packs a block position for ScalableLux queue storage.

Source

pub fn decode_block_pos(self, packed: PackedLightBlockPos) -> Option<BlockPos>

Decodes ScalableLux queue-position bits back to a world block position.

Source

pub fn contains_encoded_block_pos(self, block_pos: BlockPos) -> bool

Returns true if a block position is inside the packed queue-coordinate window.

Source

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.

Source

pub fn cached_section_index(self, section_y: i32) -> Option<usize>

Returns the cached vertical index for a section Y coordinate.

Source

pub const fn cached_section_y(self, index: usize) -> Option<i32>

Converts a cached vertical index back to section Y.

Source

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.

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> LightCacheLayout

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for LightCacheLayout

Source§

impl Debug for LightCacheLayout

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for LightCacheLayout

Source§

impl PartialEq for LightCacheLayout

Source§

fn eq(&self, other: &LightCacheLayout) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for LightCacheLayout

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compares self with key and returns true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> IntoShared for T

Source§

fn into_shared(self) -> Arc<Mutex<RawMutex, Self>>

Wraps this value in an Arc<SyncMutex<>>
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more