euv-core 0.56.0

Core cross-platform runtime for euv featuring arena-based fine-grained reactivity, deterministic layout, flat scene graph, multi-mode rendering, and direct OS platform adapters.
Documentation
use super::*;

/// Declarative configuration for the interactive 2D shallow-water `WaveHeightfield2D` solver.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct WaveHeightfieldConfig {
    /// Grid cell count along the X axis (`WAKE_MIN_GRID_DIM..=WAKE_MAX_GRID_DIM`).
    #[get(type(copy))]
    pub(crate) width: usize,
    /// Grid cell count along the Z axis (`WAKE_MIN_GRID_DIM..=WAKE_MAX_GRID_DIM`).
    #[get(type(copy))]
    pub(crate) height: usize,
    /// Uniform physical cell spacing in meters.
    #[get(type(copy))]
    pub(crate) cell_size_m: f32,
    /// Shallow-water wave propagation speed `c` in meters per second.
    #[get(type(copy))]
    pub(crate) wave_speed_mps: f32,
    /// Uniform interior viscous wave damping rate in `s^-1`.
    #[get(type(copy))]
    pub(crate) damping: f32,
    /// Width in cells of the perimeter absorbing sponge boundary layer.
    #[get(type(copy))]
    pub(crate) sponge_width: usize,
    /// Peak damping rate added at the outer boundary of the sponge layer.
    #[get(type(copy))]
    pub(crate) sponge_strength: f32,
    /// Exponential decay rate per second for accumulated surface wake foam.
    #[get(type(copy))]
    pub(crate) foam_decay_rate: f32,
    /// World-space `(x, z)` coordinate of cell `(0, 0)`.
    #[get(type(copy))]
    pub(crate) origin_xz: Vec2,
    /// Mean resting world-space water surface elevation along `+Y`.
    #[get(type(copy))]
    pub(crate) base_water_y: f32,
}

/// Internal substep scalar parameters for `WaveHeightfield2D` integration.
#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
pub(crate) struct WakeSubstepParams {
    /// Grid cell count along X.
    #[get(type(copy))]
    pub(crate) width: usize,
    /// Grid cell count along Z.
    #[get(type(copy))]
    pub(crate) height: usize,
    /// Dimensionless squared Courant number `(c * dt / dx)^2`.
    #[get(type(copy))]
    pub(crate) courant_sq: f32,
    /// Substep time interval in seconds.
    #[get(type(copy))]
    pub(crate) dt_sub: f32,
    /// Exponential foam decay rate per second.
    #[get(type(copy))]
    pub(crate) foam_decay_rate: f32,
}

/// Internal radial impulse descriptor for splash and wake injection.
#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
pub(crate) struct WakeImpulseDesc {
    /// World X center coordinate.
    #[get(type(copy))]
    pub(crate) world_x: f32,
    /// World Z center coordinate.
    #[get(type(copy))]
    pub(crate) world_z: f32,
    /// Influence footprint radius in meters.
    #[get(type(copy))]
    pub(crate) radius_m: f32,
    /// Peak vertical displacement amplitude in meters.
    #[get(type(copy))]
    pub(crate) amplitude_m: f32,
    /// Peak wake foam boost in `[0.0, 1.0]`.
    #[get(type(copy))]
    pub(crate) foam_boost: f32,
}

/// Interactive 2D shallow-water damped wave heightfield with absorbing sponge boundaries and solid obstacle reflections.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct WaveHeightfield2D {
    /// Sanitized solver configuration.
    #[get(type(copy))]
    pub(crate) config: WaveHeightfieldConfig,
    /// Current wave surface displacement field in meters (`width * height`).
    pub(crate) heights_curr: Vec<f32>,
    /// Previous substep wave surface displacement field in meters (`width * height`).
    pub(crate) heights_prev: Vec<f32>,
    /// Pre-allocated next-step displacement buffer avoiding steady-state allocations (`width * height`).
    pub(crate) heights_next: Vec<f32>,
    /// Solid obstacle cell mask (`0` = fluid, `1` = solid reflective wall, `width * height`).
    pub(crate) obstacle_mask: Vec<u8>,
    /// Accumulated whitewater wake foam intensity in `[0.0, 1.0]` (`width * height`).
    pub(crate) foam: Vec<f32>,
    /// Precomputed per-cell total damping rate combining interior and sponge absorption (`width * height`).
    pub(crate) cell_damping: Vec<f32>,
    /// Most recent substep duration in seconds used for exact discrete kinetic-energy diagnostics.
    #[get(type(copy))]
    pub(crate) last_dt_sub: f32,
    /// Accumulated simulation time in seconds.
    #[get(type(copy))]
    pub(crate) sim_time_secs: f32,
}