pub struct ChunkSkyLightSources {
min_y: i32,
pub(super) heightmap: [i32; 256],
}Expand description
Per-chunk cache of the lowest skylight source edge in each X/Z column.
Vanilla stores this in a 256-entry SimpleBitStorage. Steel keeps absolute
i32 Y values instead; the cached semantics are the same, and this avoids a
new bit-storage abstraction before another system needs one.
Fields§
§min_y: i32§heightmap: [i32; 256]Implementations§
Source§impl ChunkSkyLightSources
impl ChunkSkyLightSources
Sourcepub const fn new(
min_y: i32,
height: i32,
) -> Result<Self, LightSectionRangeError>
pub const fn new( min_y: i32, height: i32, ) -> Result<Self, LightSectionRangeError>
Creates an empty skylight-source cache for a level height.
Sourcepub fn for_valid_world_height(min_y: i32, height: i32) -> Self
pub fn for_valid_world_height(min_y: i32, height: i32) -> Self
Creates a cache for world heights already accepted by chunk construction.
Invalid world heights are fatal because chunks and light sections cannot be indexed coherently without a valid vertical range.
§Panics
Panics when the supplied world height cannot form a valid light-section range.
Sourcepub fn fill_from_sections(&mut self, sections: &Sections)
pub fn fill_from_sections(&mut self, sections: &Sections)
Fills this cache from a chunk’s sections.
Sourcepub fn update(
&mut self,
x: usize,
y: i32,
z: usize,
state_at: impl FnMut(usize, i32, usize) -> BlockStateId,
) -> bool
pub fn update( &mut self, x: usize, y: i32, z: usize, state_at: impl FnMut(usize, i32, usize) -> BlockStateId, ) -> bool
Updates one column after a block change.
state_at is called with section-local X/Z and world Y coordinates.
Returns true when the cached source edge changed.
Sourcepub const fn get_lowest_source_y(&self, x: usize, z: usize) -> i32
pub const fn get_lowest_source_y(&self, x: usize, z: usize) -> i32
Returns the lowest skylight source Y for a local X/Z column.
Sourcepub fn get_highest_lowest_source_y(&self) -> i32
pub fn get_highest_lowest_source_y(&self) -> i32
Returns the highest cached lowest-source Y across all columns.
fn find_lowest_source_y( &self, sections: &Sections, top_section_index: usize, x: usize, z: usize, ) -> i32
fn update_edge( &mut self, index: usize, old_top_edge_y: i32, x: usize, z: usize, checked_edge_y: i32, top_state: BlockStateId, bottom_y: i32, bottom_state: BlockStateId, state_at: &mut impl FnMut(usize, i32, usize) -> BlockStateId, ) -> bool
fn find_lowest_source_below( &self, x: usize, z: usize, start_y: i32, start_state: BlockStateId, state_at: &mut impl FnMut(usize, i32, usize) -> BlockStateId, ) -> i32
fn is_edge_occluded(top_state: BlockStateId, bottom_state: BlockStateId) -> bool
fn fill(&mut self, lowest_source_y: i32)
const fn set(&mut self, index: usize, value: i32)
const fn get(&self, index: usize) -> i32
const fn extend_sources_below_world(&self, value: i32) -> i32
const fn section_y_from_index(&self, section_index: usize) -> i32
const fn section_to_block_coord(section_y: i32) -> i32
const fn index(x: usize, z: usize) -> usize
fn air_state() -> BlockStateId
Trait Implementations§
Source§impl Clone for ChunkSkyLightSources
impl Clone for ChunkSkyLightSources
Source§fn clone(&self) -> ChunkSkyLightSources
fn clone(&self) -> ChunkSkyLightSources
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChunkSkyLightSources
impl Debug for ChunkSkyLightSources
impl Eq for ChunkSkyLightSources
Source§impl PartialEq for ChunkSkyLightSources
impl PartialEq for ChunkSkyLightSources
impl StructuralPartialEq for ChunkSkyLightSources
Auto Trait Implementations§
impl Freeze for ChunkSkyLightSources
impl RefUnwindSafe for ChunkSkyLightSources
impl Send for ChunkSkyLightSources
impl Sync for ChunkSkyLightSources
impl Unpin for ChunkSkyLightSources
impl UnsafeUnpin for ChunkSkyLightSources
impl UnwindSafe for ChunkSkyLightSources
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<>>