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

/// Single stochastic or deterministic L-system production rule (`predecessor -> successor`).
#[derive(Clone, Data, Debug, New, PartialEq)]
pub struct LSystemRule {
    /// Non-terminal symbol replaced during rewriting.
    #[get(type(copy))]
    pub(crate) predecessor: char,
    /// Replacement string emitted when this production fires.
    pub(crate) successor: String,
    /// Relative selection weight when multiple rules share the same `predecessor`.
    #[get(type(copy))]
    pub(crate) weight: f32,
}

/// Deterministic seeded L-system rewriting grammar used to generate botanical branch skeletons.
#[derive(Clone, Data, Debug, New, PartialEq)]
pub struct LSystemGrammar {
    /// Starting axiom string at iteration `0`.
    pub(crate) axiom: String,
    /// Ordered list of production rules.
    pub(crate) rules: Vec<LSystemRule>,
}

/// Parametric configuration controlling procedural tree geometry, taper, branching, and canopy scale.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct ProceduralTreeConfig {
    /// Target botanical species preset.
    #[get(type(copy))]
    pub(crate) species: TreeSpecies,
    /// Number of L-system rewriting iterations (`1..=6`).
    #[get(type(copy))]
    pub(crate) iterations: u32,
    /// Initial trunk base radius.
    #[get(type(copy))]
    pub(crate) trunk_radius: f32,
    /// Base length of a single forward turtle step (`F`).
    #[get(type(copy))]
    pub(crate) segment_length: f32,
    /// Branch turning angle in degrees for `+`, `-`, `&`, `^`, `\`, `/`.
    #[get(type(copy))]
    pub(crate) branch_angle_deg: f32,
    /// Radius taper factor applied on each `!` or segment transition.
    #[get(type(copy))]
    pub(crate) radius_decay: f32,
    /// Segment length decay applied when entering nested branches.
    #[get(type(copy))]
    pub(crate) length_decay: f32,
    /// Radial segment count for tubular branches (`3..=16`).
    #[get(type(copy))]
    pub(crate) radial_segments: u32,
    /// Radius scale of emitted canopy foliage clusters.
    #[get(type(copy))]
    pub(crate) leaf_cluster_size: f32,
    /// Vertical tropism bias (`> 0` grows skyward, `< 0` droops downward).
    #[get(type(copy))]
    pub(crate) gravity_bias: f32,
}

/// Output asset bundle produced by `generate_procedural_tree`.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct ProceduralTreeResult {
    /// Combined multi-material mesh merging trunk/branches and canopy foliage.
    pub(crate) combined_mesh: Mesh3D,
    /// Standalone tapered tubular bark/branch skeleton mesh.
    pub(crate) branch_mesh: Mesh3D,
    /// Standalone canopy foliage leaf cluster mesh.
    pub(crate) foliage_mesh: Mesh3D,
    /// Number of emitted tubular branch segments.
    #[get(type(copy))]
    pub(crate) branch_segment_count: usize,
    /// Number of emitted foliage leaf clusters.
    #[get(type(copy))]
    pub(crate) leaf_cluster_count: usize,
}

/// Internal 3D turtle state pushed and popped on `[` and `]` branch tokens.
#[derive(Clone, Copy, Data, Debug)]
pub(crate) struct TurtleState3D {
    /// Current 3D turtle position.
    #[get(type(copy))]
    pub(crate) position: Vec3,
    /// Unit forward growth heading.
    #[get(type(copy))]
    pub(crate) heading: Vec3,
    /// Unit local left axis orthogonal to `heading`.
    #[get(type(copy))]
    pub(crate) left: Vec3,
    /// Unit local up axis completing the orthonormal frame.
    #[get(type(copy))]
    pub(crate) up: Vec3,
    /// Current branch tube radius.
    #[get(type(copy))]
    pub(crate) radius: f32,
    /// Current forward segment length.
    #[get(type(copy))]
    pub(crate) step_length: f32,
    /// Current branching recursion depth.
    #[get(type(copy))]
    pub(crate) depth: u32,
}