pub struct LodScheduler {
pub lod_thresholds: Vec<f32>,
pub hysteresis_margin: f32,
/* private fields */
}Expand description
Decides when to upgrade/downgrade chunk LOD.
Uses hysteresis to prevent LOD thrashing: upgrade requires distance < threshold, downgrade requires distance > threshold + hysteresis_margin.
Fields§
§lod_thresholds: Vec<f32>Distance thresholds for each LOD level. lod_thresholds[n] = max dist for LOD n.
hysteresis_margin: f32Hysteresis margin to prevent thrashing.
Implementations§
Source§impl LodScheduler
impl LodScheduler
pub fn new(lod_levels: usize, chunk_size: f32) -> Self
Sourcepub fn desired_lod(&self, dist: f32, current_lod: u8) -> u8
pub fn desired_lod(&self, dist: f32, current_lod: u8) -> u8
Compute the desired LOD for a chunk at a given world distance.
Sourcepub fn update(
&mut self,
camera_pos: Vec3,
chunks: &HashMap<ChunkCoord, u8>,
config: &TerrainConfig,
)
pub fn update( &mut self, camera_pos: Vec3, chunks: &HashMap<ChunkCoord, u8>, config: &TerrainConfig, )
Update LOD decisions for all visible chunks.
Sourcepub fn pending_changes(&self) -> &HashMap<ChunkCoord, u8>
pub fn pending_changes(&self) -> &HashMap<ChunkCoord, u8>
Get the pending LOD changes.
Sourcepub fn load_priority(
coord: ChunkCoord,
camera_pos: Vec3,
chunk_size: f32,
in_frustum: bool,
) -> i64
pub fn load_priority( coord: ChunkCoord, camera_pos: Vec3, chunk_size: f32, in_frustum: bool, ) -> i64
Compute priority for loading a chunk (used by LoadQueue). In-frustum and close chunks have highest priority.
Auto Trait Implementations§
impl Freeze for LodScheduler
impl RefUnwindSafe for LodScheduler
impl Send for LodScheduler
impl Sync for LodScheduler
impl Unpin for LodScheduler
impl UnsafeUnpin for LodScheduler
impl UnwindSafe for LodScheduler
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.