Skip to main content

CityStreamer

Struct CityStreamer 

Source
pub struct CityStreamer<P>
where P: FnMut(i32, i32) -> HeightMap,
{ /* private fields */ }
Expand description

Streams city tiles on demand.

P produces a heightmap for tile (tile_x, tile_z) whose world coordinates run from 0 to config.tile_size along each axis. Returning a heightmap of any other size is a programmer error; the streamer asserts on world-size mismatch.

Implementations§

Source§

impl<P> CityStreamer<P>
where P: FnMut(i32, i32) -> HeightMap,

Source

pub fn new(config: CityStreamerConfig, provider: P) -> Self

Creates a new streamer.

§Panics

Panics if config.tile_size <= 0.0 or non-finite.

Source

pub fn tile_size(&self) -> f32

Returns the configured tile size.

Source

pub fn cached_tile_count(&self) -> usize

Number of tiles currently cached in memory.

Source

pub fn tile_coord_for(&self, world_pos: Vec2) -> (i32, i32)

Returns the integer tile coordinate that contains world_pos.

Source

pub fn ensure_tile( &mut self, tile_x: i32, tile_z: i32, ) -> Result<&CityTile, GenerationError>

Generates tile (tile_x, tile_z) if not cached and returns a reference to it.

Source

pub fn query_region( &mut self, min: Vec2, max: Vec2, ) -> Result<Vec<&CityTile>, GenerationError>

Ensures every tile overlapping the AABB [min, max] is generated and returns references to all of them in unspecified order.

Source

pub fn evict_outside(&mut self, center: Vec2, max_distance: f32) -> usize

Evicts every cached tile whose center is farther than max_distance from center. Returns the number of tiles evicted.

Auto Trait Implementations§

§

impl<P> Freeze for CityStreamer<P>
where P: Freeze,

§

impl<P> RefUnwindSafe for CityStreamer<P>
where P: RefUnwindSafe,

§

impl<P> Send for CityStreamer<P>
where P: Send,

§

impl<P> Sync for CityStreamer<P>
where P: Sync,

§

impl<P> Unpin for CityStreamer<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for CityStreamer<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for CityStreamer<P>
where P: UnwindSafe,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V