pub struct CityStreamer<P>{ /* 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>
impl<P> CityStreamer<P>
Sourcepub fn new(config: CityStreamerConfig, provider: P) -> Self
pub fn new(config: CityStreamerConfig, provider: P) -> Self
Sourcepub fn cached_tile_count(&self) -> usize
pub fn cached_tile_count(&self) -> usize
Number of tiles currently cached in memory.
Sourcepub fn tile_coord_for(&self, world_pos: Vec2) -> (i32, i32)
pub fn tile_coord_for(&self, world_pos: Vec2) -> (i32, i32)
Returns the integer tile coordinate that contains world_pos.
Sourcepub fn ensure_tile(
&mut self,
tile_x: i32,
tile_z: i32,
) -> Result<&CityTile, GenerationError>
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.
Sourcepub fn query_region(
&mut self,
min: Vec2,
max: Vec2,
) -> Result<Vec<&CityTile>, GenerationError>
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.
Sourcepub fn evict_outside(&mut self, center: Vec2, max_distance: f32) -> usize
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> 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