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

/// Composable Signed Distance Field (SDF) and Constructive Solid Geometry (CSG) expression tree.
#[derive(Clone, Debug, PartialEq)]
pub enum SdfNode {
    /// Sphere centered at the origin with radius `radius`.
    Sphere {
        /// Sphere radius.
        radius: f32,
    },
    /// Axis-aligned box centered at the origin with `half_extents`.
    Box {
        /// Half-size along `(X, Y, Z)`.
        half_extents: Vec3,
    },
    /// Beveled axis-aligned box with outer `half_extents` and corner rounding `radius`.
    RoundedBox {
        /// Outer half-size along `(X, Y, Z)`.
        half_extents: Vec3,
        /// Corner and edge bevel radius.
        radius: f32,
    },
    /// Torus in the XZ plane around the Y axis.
    Torus {
        /// Major ring radius.
        major_radius: f32,
        /// Minor tube radius.
        minor_radius: f32,
    },
    /// Capped vertical cylinder centered at the origin along Y.
    Cylinder {
        /// Cylinder radius.
        radius: f32,
        /// Half height along Y.
        half_height: f32,
    },
    /// Capsule segment spanning from `start` to `end` with spherical cap `radius`.
    Capsule {
        /// Segment start endpoint.
        start: Vec3,
        /// Segment end endpoint.
        end: Vec3,
        /// Capsule radius.
        radius: f32,
    },
    /// Bounded upright cone centered at the origin along Y with base radius `radius` and height `height`.
    Cone {
        /// Base disk radius.
        radius: f32,
        /// Total cone height from base to apex.
        height: f32,
    },
    /// Infinite half-space bounded by plane `dot(p, normal) = offset`.
    Plane {
        /// Outward unit plane normal.
        normal: Vec3,
        /// Signed plane offset along `normal`.
        offset: f32,
    },
    /// Exact CSG union (`min(left, right)`).
    Union(Box<SdfNode>, Box<SdfNode>),
    /// Exact CSG subtraction carving `right` out of `left` (`max(left, -right)`).
    Subtract(Box<SdfNode>, Box<SdfNode>),
    /// Exact CSG intersection (`max(left, right)`).
    Intersect(Box<SdfNode>, Box<SdfNode>),
    /// Polynomial smooth CSG union blending two fields across radius `k`.
    SmoothUnion {
        /// First child SDF.
        left: Box<SdfNode>,
        /// Second child SDF.
        right: Box<SdfNode>,
        /// Smooth blend radius `k > 0`.
        k: f32,
    },
    /// Polynomial smooth CSG subtraction carving `right` out of `left` with fillet radius `k`.
    SmoothSubtract {
        /// Base solid SDF.
        left: Box<SdfNode>,
        /// Carving solid SDF.
        right: Box<SdfNode>,
        /// Smooth fillet radius `k > 0`.
        k: f32,
    },
    /// Polynomial smooth CSG intersection blending the overlap boundary across radius `k`.
    SmoothIntersect {
        /// First child SDF.
        left: Box<SdfNode>,
        /// Second child SDF.
        right: Box<SdfNode>,
        /// Smooth blend radius `k > 0`.
        k: f32,
    },
    /// Translates `child` by `offset`.
    Translate {
        /// Transformed child SDF.
        child: Box<SdfNode>,
        /// World-space translation offset.
        offset: Vec3,
    },
    /// Rotates `child` by unit quaternion `rotation`.
    Rotate {
        /// Transformed child SDF.
        child: Box<SdfNode>,
        /// Object rotation quaternion.
        rotation: Quat,
    },
    /// Uniformly scales `child` by positive `factor` with exact distance compensation.
    Scale {
        /// Transformed child SDF.
        child: Box<SdfNode>,
        /// Uniform scale multiplier.
        factor: f32,
    },
    /// Mirrors `child` across any combination of the X, Y, and Z coordinate planes.
    Mirror {
        /// Mirrored child SDF.
        child: Box<SdfNode>,
        /// Per-axis mirror flags `[mirror_x, mirror_y, mirror_z]`.
        axes: [bool; 3],
    },
    /// Repeats `child` on a finite 3D lattice with cell `spacing` and half-count `limit`.
    RepeatFinite {
        /// Repeated child SDF.
        child: Box<SdfNode>,
        /// Lattice cell spacing `(sx, sy, sz)`.
        spacing: Vec3,
        /// Maximum cell index extent `[lx, ly, lz]` on each side of the origin.
        limit: [u32; 3],
    },
    /// Twists `child` smoothly around the Y axis at `rate` radians per unit height.
    Twist {
        /// Deformed child SDF.
        child: Box<SdfNode>,
        /// Twist angle rate in radians per unit Y.
        rate: f32,
    },
    /// Bends `child` smoothly in the XY plane at `rate` radians per unit X.
    Bend {
        /// Deformed child SDF.
        child: Box<SdfNode>,
        /// Bend curvature rate in radians per unit X.
        rate: f32,
    },
    /// Hollows `child` into a thin shell of wall half-thickness `thickness` (`|d| - thickness`).
    Onion {
        /// Shelled child SDF.
        child: Box<SdfNode>,
        /// Shell half-thickness.
        thickness: f32,
    },
    /// Perturbs `child` with deterministic analytic trigonometric displacement.
    Displace {
        /// Displaced child SDF.
        child: Box<SdfNode>,
        /// Peak displacement amplitude.
        amplitude: f32,
        /// Spatial angular frequency.
        frequency: f32,
    },
}