euv-core 0.54.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
/// Maps a 3D world-space coordinate to its integer uniform spatial grid cell index.
///
/// # Arguments
///
/// - `[f32; 3]` - World-space position `[x, y, z]`.
/// - `f32` - Positive uniform cell size in meters.
///
/// # Returns
///
/// - `(i32, i32, i32)` - Quantized grid cell coordinates `(cx, cy, cz)`.
#[must_use]
pub(crate) fn world_to_prefetch_cell(pos: [f32; 3], cell_size: f32) -> (i32, i32, i32) {
    let inv: f32 = 1.0 / cell_size.max(0.25);
    (
        (pos[0] * inv).floor() as i32,
        (pos[1] * inv).floor() as i32,
        (pos[2] * inv).floor() as i32,
    )
}

/// Computes the squared Euclidean distance between two 3D points.
///
/// # Arguments
///
/// - `[f32; 3]` - First 3D point.
/// - `[f32; 3]` - Second 3D point.
///
/// # Returns
///
/// - `f32` - Squared distance.
#[must_use]
pub(crate) fn prefetch_dist_sq_3d(a: [f32; 3], b: [f32; 3]) -> f32 {
    let dx: f32 = a[0] - b[0];
    let dy: f32 = a[1] - b[1];
    let dz: f32 = a[2] - b[2];
    dx * dx + dy * dy + dz * dz
}

/// Computes the dot product of two 3D vectors.
///
/// # Arguments
///
/// - `[f32; 3]` - First 3D vector.
/// - `[f32; 3]` - Second 3D vector.
///
/// # Returns
///
/// - `f32` - Scalar dot product.
#[must_use]
pub(crate) fn prefetch_dot_3d(a: [f32; 3], b: [f32; 3]) -> f32 {
    a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
}