euv-core 0.48.3

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::*;

/// Persistent zero-allocation photorealistic optical liquid renderer producing RGBA8 frames with Snell refraction, Beer-Lambert depth absorption, Fresnel reflections, optical caustics, buoyant bodies, foam, and glass vessel framing.
#[derive(Clone, Data, Debug)]
pub struct LiquidOpticalRenderer {
    /// Active scalar field grid width in cells.
    #[get(type(copy))]
    pub(crate) field_w: usize,
    /// Active scalar field grid height in cells.
    #[get(type(copy))]
    pub(crate) field_h: usize,
    /// Smoothed liquid density isosurface field `φ(x, y)`.
    pub(crate) phi: Vec<f32>,
    /// Separable horizontal smoothing scratch buffer for `φ`.
    pub(crate) phi_tmp: Vec<f32>,
    /// Optical fluid thickness field driving Beer-Lambert absorption and Snell ray depth.
    pub(crate) thickness: Vec<f32>,
    /// Separable horizontal smoothing scratch buffer for `thickness`.
    pub(crate) thick_tmp: Vec<f32>,
    /// Aerated wave-crest foam intensity field.
    pub(crate) foam: Vec<f32>,
    /// Precomputed surface gradient x-component `∂φ/∂x`.
    pub(crate) grad_x: Vec<f32>,
    /// Precomputed surface gradient y-component `∂φ/∂y`.
    pub(crate) grad_y: Vec<f32>,
    /// Precomputed optical caustic focusing intensity field derived from surface curvature.
    pub(crate) caustic: Vec<f32>,
    /// Last rendered output width in pixels.
    #[get(type(copy))]
    pub(crate) last_width: u32,
    /// Last rendered output height in pixels.
    #[get(type(copy))]
    pub(crate) last_height: u32,
}

/// Immutable per-frame optical shading context shared safely across parallel horizontal scanline bands.
#[derive(Clone, Copy, Debug)]
pub(crate) struct FluidShadeParams {
    /// Output framebuffer width in pixels.
    pub(crate) out_w: usize,
    /// Output framebuffer height in pixels.
    pub(crate) out_h: usize,
    /// Scalar field width in cells.
    pub(crate) field_w: usize,
    /// Scalar field height in cells.
    pub(crate) field_h: usize,
    /// Physical vessel width in meters.
    pub(crate) vessel_w: f32,
    /// Physical vessel height in meters.
    pub(crate) vessel_h: f32,
    /// Normalized gravity up-vector x-component for sky reflection alignment.
    pub(crate) up_x: f32,
    /// Normalized gravity up-vector y-component for sky reflection alignment.
    pub(crate) up_y: f32,
    /// Glass vessel inner margin in pixels.
    pub(crate) bezel_px: f32,
    /// Glass vessel outer corner radius in pixels.
    pub(crate) corner_px: f32,
    /// Active buoyant floating body count.
    pub(crate) body_count: usize,
    /// Snapshot of active buoyant bodies copied onto stack for lock-free parallel shading.
    pub(crate) bodies: [BuoyantBody; FLUID_MAX_BUOYANT_BODIES],
}

/// Read-only borrowed slice bundle of precomputed scalar optical fields for parallel scanline shading.
#[derive(Clone, Copy, Debug)]
pub(crate) struct FluidFieldViews<'a> {
    /// Smoothed liquid density isosurface field `φ`.
    pub(crate) phi: &'a [f32],
    /// Smoothed optical fluid thickness field.
    pub(crate) thickness: &'a [f32],
    /// Aerated wave-crest foam intensity field.
    pub(crate) foam: &'a [f32],
    /// Precomputed surface gradient x-component.
    pub(crate) grad_x: &'a [f32],
    /// Precomputed surface gradient y-component.
    pub(crate) grad_y: &'a [f32],
    /// Precomputed optical caustic focusing intensity field.
    pub(crate) caustic: &'a [f32],
}