Skip to main content

TerrainManager

Struct TerrainManager 

Source
pub struct TerrainManager { /* private fields */ }
Expand description

Manages terrain elevation data and mesh generation.

Implementations§

Source§

impl TerrainManager

Source

pub fn new(config: TerrainConfig, max_cache: usize) -> Self

Create a new terrain manager.

Source

pub fn enabled(&self) -> bool

Whether terrain is enabled.

Source

pub fn set_enabled(&mut self, enabled: bool)

Set terrain enabled/disabled.

Source

pub fn vertical_exaggeration(&self) -> f64

Get the vertical exaggeration.

Source

pub fn set_vertical_exaggeration(&mut self, exaggeration: f64)

Set vertical exaggeration.

Source

pub fn mesh_resolution(&self) -> u16

Mesh resolution (vertices per tile edge) from the current configuration.

Source

pub fn pending_count(&self) -> usize

Number of tile elevation requests currently pending (sent but not yet received).

Used by the TileRequestCoordinator to estimate terrain demand for global budget allocation.

Source

pub fn cache_entries(&self) -> usize

Number of cached elevation tiles currently retained.

Source

pub fn last_desired_zoom(&self) -> u8

Most recent desired terrain zoom requested by the manager.

Source

pub fn diagnostics(&self) -> TerrainDiagnostics

Snapshot diagnostics for the current terrain state.

Source

pub fn update( &mut self, viewport_bounds: &WorldBounds, zoom: u8, camera_world: (f64, f64), projection: CameraProjection, camera_distance: f64, camera_pitch: f64, ) -> Vec<TerrainMeshData>

Update terrain data for the current frame.

Returns terrain meshes for all visible tiles that have elevation data.

Source

pub fn update_with_tiles( &mut self, desired: &[TileId], zoom: u8, projection: CameraProjection, ) -> Vec<TerrainMeshData>

Update terrain using an externally-provided tile set.

This is used when the tile layer has already computed the desired visible tile set (e.g. via covering-tiles traversal) and the terrain manager should use the same tiles to ensure texture availability for every terrain mesh entity.

Source

pub fn update_sources( &mut self, viewport_bounds: &WorldBounds, zoom: u8, camera_world: (f64, f64), camera_distance: f64, camera_pitch: f64, ) -> Vec<(TileId, ElevationGrid, u64)>

Lightweight source-only update: poll elevation fetches, determine visible tiles, request missing elevation data, and return the desired tile set with their cached elevation grids.

This does not build terrain meshes or hillshade rasters. It is the first half of the split pipeline used by the async data path, where mesh building is dispatched to background tasks.

Source

pub fn update_sources_with_tiles( &mut self, desired: &[TileId], zoom: u8, ) -> Vec<(TileId, ElevationGrid, u64)>

Lightweight source-only update using an externally-provided tile set.

This mirrors update_with_tiles for the async terrain path: poll elevation fetches, request missing source tiles, and return the desired tile set paired with cached (or flat fallback) elevation grids and per-tile generations.

Source

pub fn elevation_at(&self, coord: &GeoCoord) -> Option<f64>

Query elevation at a geographic coordinate.

Uses a targeted tile lookup: computes which tile contains the coordinate at the most recent zoom level, then falls back to parent zoom levels if the exact tile is not cached. This is O(zoom) instead of O(cache_size).

Returns None if terrain is disabled or no cached tile covers the coordinate.

Source

pub fn config(&self) -> &TerrainConfig

Access the configuration.

Source

pub fn config_mut(&mut self) -> &mut TerrainConfig

Access the configuration mutably.

Source

pub fn visible_hillshade_rasters(&self) -> &[PreparedHillshadeRaster]

Prepared hillshade rasters for the most recently visible terrain set.

Source

pub fn source_max_zoom(&self) -> u8

The source max zoom for elevation data.

Source

pub fn elevation_source_tile_for(&self, tile: TileId) -> TileId

Return the DEM source tile used to back a visible terrain tile.

Source

pub fn elevation_region_for(&self, tile: TileId) -> TileTextureRegion

Return the DEM sub-region sampled by a visible terrain tile.

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> 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, 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.