pub struct TickAllocation {
pub max_divisor: u64,
pub min_divisor: u64,
pub curve: AllocationCurve,
}Expand description
Maps transition probability to tick divisor.
Fields§
§max_divisor: u64Ceiling: least-likely screens tick at most every max_divisor frames.
min_divisor: u64Floor: most-likely screens tick at least every min_divisor frames.
curve: AllocationCurveHow probability maps to divisor.
Implementations§
Source§impl TickAllocation
impl TickAllocation
Sourcepub fn new() -> Self
pub fn new() -> Self
Create with exponential curve (recommended default).
Exponent=2.0, max_divisor=20, min_divisor=1.
Sourcepub fn exponential(min_divisor: u64, max_divisor: u64, exponent: f64) -> Self
pub fn exponential(min_divisor: u64, max_divisor: u64, exponent: f64) -> Self
Create with an exponential curve.
Sourcepub fn stepped(thresholds: Vec<(f64, u64)>) -> Self
pub fn stepped(thresholds: Vec<(f64, u64)>) -> Self
Create with stepped thresholds.
§Panics
Panics if thresholds are not sorted descending by threshold value.
Sourcepub fn divisor_for(&self, probability: f64) -> u64
pub fn divisor_for(&self, probability: f64) -> u64
Map a probability (0.0..1.0) to a tick divisor.
Higher probability → lower divisor (faster ticking).
Result is always clamped to [min_divisor, max_divisor].
Trait Implementations§
Source§impl Clone for TickAllocation
impl Clone for TickAllocation
Source§fn clone(&self) -> TickAllocation
fn clone(&self) -> TickAllocation
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TickAllocation
impl Debug for TickAllocation
Auto Trait Implementations§
impl Freeze for TickAllocation
impl RefUnwindSafe for TickAllocation
impl Send for TickAllocation
impl Sync for TickAllocation
impl Unpin for TickAllocation
impl UnsafeUnpin for TickAllocation
impl UnwindSafe for TickAllocation
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