Skip to main content

LodThresholds

Struct LodThresholds 

Source
pub struct LodThresholds {
    pub r_near: f64,
    pub r_mid: f64,
    pub mid_mip_levels: Option<u32>,
    pub mid_mip_scan_dist: Option<i32>,
}
Expand description

Per-grid LOD picker configuration: world-distance thresholds for tier dispatch + optional Mid-tier render overrides.

Tier dispatch (centre-to-centre distance d):

All thresholds default to f64::INFINITY via Default / Self::always_near, so a freshly-constructed crate::Grid always lands on Lod::Near — the S5-and-earlier byte-stable behaviour. Callers that want real LOD opt in by writing a non-default value into crate::Grid::lod_thresholds.

NaN thresholds are treated as “always Lod::Far” because every d <= NaN comparison is false. No assert — callers shouldn’t be passing NaN and we don’t want runtime cost in a per-frame per-grid hot path.

§S6.1 — Mid-tier mip overrides

When the picker returns Lod::Mid, Self::mid_mip_levels and Self::mid_mip_scan_dist (if Some) override the corresponding roxlap_core::opticast::OpticastSettings fields for that grid’s render. The intent: force coarser-mip rendering at Mid distance to recover performance, using the existing R4.5 multi-mip infrastructure with no new rasterizer code.

Semantics:

  • mid_mip_levels = Some(n) — clamp OpticastSettings.mip_levels to n for this grid. n is then further clamped to [1, settings.mip_levels] at the call site.
  • mid_mip_scan_dist = Some(d) — set OpticastSettings.mip_scan_dist to min(settings.mip_scan_dist, d). The renderer floors mip_scan_dist at 4 internally; smaller values transition to coarser mips closer to the camera, biasing the whole frame toward higher mips.
  • Both None ⇒ Mid path renders identically to Near (graceful degrade — callers can opt into the Mid plumbing without committing to a mip override).
  • crate::Grid::mip_levels_override continues to apply on top as a global per-grid cap regardless of tier (the ship anti-beam workaround is preserved at all LOD tiers).

Fields§

§r_near: f64

Maximum world-distance at which the grid renders at Lod::Near. Grids closer than this are full voxel.

§r_mid: f64

Maximum world-distance at which the grid renders at Lod::Mid. Beyond r_mid the grid uses Lod::Far. Must satisfy r_mid >= r_near for monotonic tier dispatch; not enforced (an inverted pair just means the Lod::Mid band is empty).

§mid_mip_levels: Option<u32>

S6.1 — OpticastSettings.mip_levels override applied only when the picker returns Lod::Mid. None ⇒ Mid uses the caller’s settings.mip_levels unchanged (graceful degrade to Near-equivalent behaviour). See struct doc for semantics.

§mid_mip_scan_dist: Option<i32>

S6.1 — OpticastSettings.mip_scan_dist override applied only when the picker returns Lod::Mid. None ⇒ Mid uses the caller’s value unchanged. Smaller values bias the grid toward coarser mips earlier in the ray walk (floor of 4 inside the renderer).

Implementations§

Source§

impl LodThresholds

Source

pub const fn always_near() -> Self

Always-Near thresholds. Both distance fields set to f64::INFINITY; the picker can never enter the Mid/Far branches. Mid-tier mip overrides set to None (irrelevant since Mid is never selected). Use as the byte-identical default during the S6.0..S6.3 staged rollout.

Source

pub fn from_radius(bounding_radius: f64) -> Self

Derived distance thresholds from the grid’s bounding-sphere radius (PORTING-SCENE.md § S6):

  • r_near = bounding_radius — Near while the camera is inside the bounding sphere.
  • r_mid = 10 * bounding_radius — Mid up to ~10× radius, Far beyond.
  • mid_mip_levels / mid_mip_scan_distNone (Mid degrades to Near; opt in via Self::from_radius_with_mid_mip).

A 0.0 (or negative) bounding radius collapses both thresholds to zero; the picker returns Lod::Far for any non-zero distance. That’s correct: an empty grid has no near range.

Source

pub fn from_radius_with_mid_mip( bounding_radius: f64, mid_mip_levels: u32, mid_mip_scan_dist: i32, ) -> Self

Self::from_radius + an explicit Mid-tier mip override pair. Convenience for S6.1 consumers that want Mid LOD wired without hand-constructing the struct.

Typical values for a mip_levels = 4, mip_scan_dist = 128 world: mid_mip_levels = 4, mid_mip_scan_dist = 16. The reduced scan distance biases the Mid grid into coarser mips across the whole frame.

Trait Implementations§

Source§

impl Clone for LodThresholds

Source§

fn clone(&self) -> LodThresholds

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 Debug for LodThresholds

Source§

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

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

impl Default for LodThresholds

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for LodThresholds

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for LodThresholds

Source§

impl StructuralPartialEq for LodThresholds

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.