Skip to main content

rustial_engine/terrain/
config.rs

1//! Terrain configuration.
2
3use crate::terrain::elevation_source::{ElevationSource, FlatElevationSource};
4
5/// Configuration for the terrain elevation system.
6pub struct TerrainConfig {
7    /// Whether terrain rendering is enabled.
8    pub enabled: bool,
9    /// Vertical exaggeration factor (1.0 = real scale).
10    pub vertical_exaggeration: f64,
11    /// Number of vertices per tile edge for terrain mesh subdivision.
12    pub mesh_resolution: u16,
13    /// Skirt depth in meters (hides seams between tiles at different LODs).
14    pub skirt_depth: f64,
15    /// Maximum zoom level supported by the elevation source.
16    ///
17    /// When a desired terrain tile exceeds this zoom, the manager
18    /// fetches elevation from a clamped parent tile and reuses that
19    /// data.  This prevents flat/missing terrain for tiles near the
20    /// camera whose covering-tiles zoom exceeds the source's max.
21    ///
22    /// Defaults to 15 (common for AWS / Mapbox terrain services).
23    pub source_max_zoom: u8,
24    /// The elevation data source.
25    pub source: Box<dyn ElevationSource>,
26}
27
28impl Default for TerrainConfig {
29    fn default() -> Self {
30        Self {
31            enabled: false,
32            vertical_exaggeration: 1.0,
33            mesh_resolution: 64,
34            skirt_depth: 100.0,
35            source_max_zoom: 15,
36            source: Box::new(FlatElevationSource::new(64, 64)),
37        }
38    }
39}