pub struct ChunkTracker<const MAX_LEVEL: u8> {
source_levels: FxHashMap<ChunkPos, u8>,
pending_source_levels: FxHashMap<ChunkPos, u8>,
levels: FxHashMap<ChunkPos, ChunkTicketLevel>,
pending_levels: FxHashMap<ChunkPos, u8>,
propagation_queue: LeveledPropagationQueue,
changes: Vec<ChunkLevelChange>,
}Expand description
Tracks sources and their minimum propagated levels through MAX_LEVEL.
Fields§
§source_levels: FxHashMap<ChunkPos, u8>§pending_source_levels: FxHashMap<ChunkPos, u8>§levels: FxHashMap<ChunkPos, ChunkTicketLevel>§pending_levels: FxHashMap<ChunkPos, u8>§propagation_queue: LeveledPropagationQueue§changes: Vec<ChunkLevelChange>Implementations§
Source§impl<const MAX_LEVEL: u8> ChunkTracker<MAX_LEVEL>
impl<const MAX_LEVEL: u8> ChunkTracker<MAX_LEVEL>
const ABSENT_LEVEL: u8
Sourcepub(crate) fn apply_source_update(&mut self, update: SourceLevelUpdate)
pub(crate) fn apply_source_update(&mut self, update: SourceLevelUpdate)
Applies the latest effective ticket source level at one position.
Sourcepub(crate) fn apply_source_updates(
&mut self,
updates: impl IntoIterator<Item = SourceLevelUpdate>,
)
pub(crate) fn apply_source_updates( &mut self, updates: impl IntoIterator<Item = SourceLevelUpdate>, )
Applies effective source updates in iterator order.
Sourcepub fn run_all_updates(&mut self) -> &[ChunkLevelChange]
pub fn run_all_updates(&mut self) -> &[ChunkLevelChange]
Applies pending source changes with minimum 8-neighbor propagation. The returned changes include additions, updates, and removals.
Sourcepub(crate) fn take_changes(&mut self) -> Vec<ChunkLevelChange>
pub(crate) fn take_changes(&mut self) -> Vec<ChunkLevelChange>
Takes the change buffer produced by the last propagation pass.
Sourcepub(crate) fn recycle_changes(&mut self, changes: Vec<ChunkLevelChange>)
pub(crate) fn recycle_changes(&mut self, changes: Vec<ChunkLevelChange>)
Reuses a drained change buffer on the next propagation pass.
Sourcepub fn get_level(&self, pos: ChunkPos) -> Option<ChunkTicketLevel>
pub fn get_level(&self, pos: ChunkPos) -> Option<ChunkTicketLevel>
Returns the last propagated ticket level at pos.
fn source_level(&self, pos: ChunkPos) -> u8
fn level(&self, pos: ChunkPos) -> u8
fn apply_pending_level( &mut self, pos: ChunkPos, computed_level: u8, original_levels: &mut FxHashMap<ChunkPos, Option<ChunkTicketLevel>>, )
fn set_level( &mut self, pos: ChunkPos, level: u8, original_levels: &mut FxHashMap<ChunkPos, Option<ChunkTicketLevel>>, )
fn check_neighbors_after_update( &mut self, pos: ChunkPos, level: u8, only_decrease: bool, )
fn check_neighbor( &mut self, from: ChunkPos, to: ChunkPos, from_level: u8, only_decrease: bool, )
fn check_edge( &mut self, known_parent: Option<ChunkPos>, pos: ChunkPos, level_from_parent: u8, only_decrease: bool, )
fn compute_level( &self, pos: ChunkPos, known_parent: Option<ChunkPos>, level_from_parent: u8, ) -> u8
fn replace_pending_level( &mut self, pos: ChunkPos, current_level: u8, computed_level: u8, )
fn schedule_level(&mut self, pos: ChunkPos, computed_level: u8)
Trait Implementations§
Source§impl<const MAX_LEVEL: u8> Debug for ChunkTracker<MAX_LEVEL>
impl<const MAX_LEVEL: u8> Debug for ChunkTracker<MAX_LEVEL>
Auto Trait Implementations§
impl<const MAX_LEVEL: u8> Freeze for ChunkTracker<MAX_LEVEL>
impl<const MAX_LEVEL: u8> RefUnwindSafe for ChunkTracker<MAX_LEVEL>
impl<const MAX_LEVEL: u8> Send for ChunkTracker<MAX_LEVEL>
impl<const MAX_LEVEL: u8> Sync for ChunkTracker<MAX_LEVEL>
impl<const MAX_LEVEL: u8> Unpin for ChunkTracker<MAX_LEVEL>
impl<const MAX_LEVEL: u8> UnsafeUnpin for ChunkTracker<MAX_LEVEL>
impl<const MAX_LEVEL: u8> UnwindSafe for ChunkTracker<MAX_LEVEL>
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
Mutably borrows from an owned value. Read more
§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> ⓘ
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 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> ⓘ
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 moreWraps this value in an
Arc<SyncMutex<>>