pub struct TerrainManager { /* private fields */ }Expand description
Manages terrain elevation data and mesh generation.
Implementations§
Source§impl TerrainManager
impl TerrainManager
Sourcepub fn new(config: TerrainConfig, max_cache: usize) -> Self
pub fn new(config: TerrainConfig, max_cache: usize) -> Self
Create a new terrain manager.
Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Set terrain enabled/disabled.
Sourcepub fn vertical_exaggeration(&self) -> f64
pub fn vertical_exaggeration(&self) -> f64
Get the vertical exaggeration.
Sourcepub fn set_vertical_exaggeration(&mut self, exaggeration: f64)
pub fn set_vertical_exaggeration(&mut self, exaggeration: f64)
Set vertical exaggeration.
Sourcepub fn mesh_resolution(&self) -> u16
pub fn mesh_resolution(&self) -> u16
Mesh resolution (vertices per tile edge) from the current configuration.
Sourcepub fn pending_count(&self) -> usize
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.
Sourcepub fn cache_entries(&self) -> usize
pub fn cache_entries(&self) -> usize
Number of cached elevation tiles currently retained.
Sourcepub fn last_desired_zoom(&self) -> u8
pub fn last_desired_zoom(&self) -> u8
Most recent desired terrain zoom requested by the manager.
Sourcepub fn diagnostics(&self) -> TerrainDiagnostics
pub fn diagnostics(&self) -> TerrainDiagnostics
Snapshot diagnostics for the current terrain state.
Sourcepub fn update(
&mut self,
viewport_bounds: &WorldBounds,
zoom: u8,
camera_world: (f64, f64),
projection: CameraProjection,
camera_distance: f64,
camera_pitch: f64,
) -> Vec<TerrainMeshData>
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.
Sourcepub fn update_with_tiles(
&mut self,
desired: &[TileId],
zoom: u8,
projection: CameraProjection,
) -> Vec<TerrainMeshData>
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.
Sourcepub fn update_sources(
&mut self,
viewport_bounds: &WorldBounds,
zoom: u8,
camera_world: (f64, f64),
camera_distance: f64,
camera_pitch: f64,
) -> Vec<(TileId, ElevationGrid, u64)>
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.
Sourcepub fn update_sources_with_tiles(
&mut self,
desired: &[TileId],
zoom: u8,
) -> Vec<(TileId, ElevationGrid, u64)>
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.
Sourcepub fn elevation_at(&self, coord: &GeoCoord) -> Option<f64>
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.
Sourcepub fn config(&self) -> &TerrainConfig
pub fn config(&self) -> &TerrainConfig
Access the configuration.
Sourcepub fn config_mut(&mut self) -> &mut TerrainConfig
pub fn config_mut(&mut self) -> &mut TerrainConfig
Access the configuration mutably.
Sourcepub fn visible_hillshade_rasters(&self) -> &[PreparedHillshadeRaster]
pub fn visible_hillshade_rasters(&self) -> &[PreparedHillshadeRaster]
Prepared hillshade rasters for the most recently visible terrain set.
Sourcepub fn source_max_zoom(&self) -> u8
pub fn source_max_zoom(&self) -> u8
The source max zoom for elevation data.
Sourcepub fn elevation_source_tile_for(&self, tile: TileId) -> TileId
pub fn elevation_source_tile_for(&self, tile: TileId) -> TileId
Return the DEM source tile used to back a visible terrain tile.
Sourcepub fn elevation_region_for(&self, tile: TileId) -> TileTextureRegion
pub fn elevation_region_for(&self, tile: TileId) -> TileTextureRegion
Return the DEM sub-region sampled by a visible terrain tile.