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

/// Symmetric 4x4 Garland-Heckbert quadric error matrix stored in 10 upper-triangular floats.
#[derive(Clone, Copy, Data, Debug, Default, PartialEq)]
pub(crate) struct QuadricErrorMatrix {
    /// Entry `(0, 0)` of the symmetric quadric matrix.
    #[get(type(copy))]
    pub(crate) a00: f32,
    /// Entry `(0, 1)` of the symmetric quadric matrix.
    #[get(type(copy))]
    pub(crate) a01: f32,
    /// Entry `(0, 2)` of the symmetric quadric matrix.
    #[get(type(copy))]
    pub(crate) a02: f32,
    /// Entry `(0, 3)` of the symmetric quadric matrix.
    #[get(type(copy))]
    pub(crate) a03: f32,
    /// Entry `(1, 1)` of the symmetric quadric matrix.
    #[get(type(copy))]
    pub(crate) a11: f32,
    /// Entry `(1, 2)` of the symmetric quadric matrix.
    #[get(type(copy))]
    pub(crate) a12: f32,
    /// Entry `(1, 3)` of the symmetric quadric matrix.
    #[get(type(copy))]
    pub(crate) a13: f32,
    /// Entry `(2, 2)` of the symmetric quadric matrix.
    #[get(type(copy))]
    pub(crate) a22: f32,
    /// Entry `(2, 3)` of the symmetric quadric matrix.
    #[get(type(copy))]
    pub(crate) a23: f32,
    /// Entry `(3, 3)` of the symmetric quadric matrix.
    #[get(type(copy))]
    pub(crate) a33: f32,
}

/// Active vertex state maintained during iterative QEM edge collapse.
#[derive(Clone, Copy, Data, Debug)]
pub(crate) struct DecimationVertex {
    /// Current 3D position of the vertex.
    #[get(type(copy))]
    pub(crate) position: Vec3,
    /// Current unit normal of the vertex.
    #[get(type(copy))]
    pub(crate) normal: Vec3,
    /// Primary texture coordinate of the vertex.
    #[get(type(copy))]
    pub(crate) uv0: [f32; 2],
    /// Secondary texture coordinate of the vertex.
    #[get(type(copy))]
    pub(crate) uv1: [f32; 2],
    /// Linearized floating-point RGBA color for smooth collapse blending.
    #[get(type(copy))]
    pub(crate) color: [f32; 4],
    /// Attribute bitmask flags copied onto emitted vertices.
    #[get(type(copy))]
    pub(crate) flags: u32,
    /// Accumulated Garland-Heckbert quadric error matrix.
    #[get(type(copy))]
    pub(crate) quadric: QuadricErrorMatrix,
    /// Monotonic version counter used to invalidate stale heap entries.
    #[get(type(copy))]
    pub(crate) version: u32,
    /// Whether this vertex is still active in the simplified mesh.
    #[get(type(copy))]
    pub(crate) alive: bool,
}

/// Active triangle state maintained during iterative QEM edge collapse.
#[derive(Clone, Copy, Data, Debug)]
pub(crate) struct DecimationTriangle {
    /// Vertex index triplet `[v0, v1, v2]`.
    #[get(type(copy))]
    pub(crate) indices: [u32; 3],
    /// Material slot preserved from the source mesh.
    #[get(type(copy))]
    pub(crate) material_slot: u16,
    /// Whether this triangle is still active in the simplified mesh.
    #[get(type(copy))]
    pub(crate) alive: bool,
}

/// Priority-queue candidate edge collapse evaluated by QEM cost.
#[derive(Clone, Copy, Data, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub(crate) struct DecimationCandidate {
    /// Total-ordered IEEE-754 cost key for deterministic ascending pop order.
    #[get(type(copy))]
    pub(crate) cost_key: u64,
    /// Monotonic insertion sequence number breaking equal-cost ties deterministically.
    #[get(type(copy))]
    pub(crate) sequence: u64,
    /// First endpoint vertex index (`v0 < v1`).
    #[get(type(copy))]
    pub(crate) v0: u32,
    /// Second endpoint vertex index (`v1 > v0`).
    #[get(type(copy))]
    pub(crate) v1: u32,
    /// Snapshot version of `v0` when enqueued.
    #[get(type(copy))]
    pub(crate) ver0: u32,
    /// Snapshot version of `v1` when enqueued.
    #[get(type(copy))]
    pub(crate) ver1: u32,
}

/// Spatial hash weld accumulator averaging attributes across merged vertices.
#[derive(Clone, Copy, Data, Debug)]
pub(crate) struct WeldAccumulator {
    /// Sum of welded positions.
    #[get(type(copy))]
    pub(crate) pos_sum: Vec3,
    /// Sum of welded normals.
    #[get(type(copy))]
    pub(crate) normal_sum: Vec3,
    /// Sum of primary UVs.
    #[get(type(copy))]
    pub(crate) uv0_sum: [f32; 2],
    /// Sum of secondary UVs.
    #[get(type(copy))]
    pub(crate) uv1_sum: [f32; 2],
    /// Sum of RGBA color channels.
    #[get(type(copy))]
    pub(crate) color_sum: [f32; 4],
    /// Bitwise OR of attribute flags.
    #[get(type(copy))]
    pub(crate) flags: u32,
    /// Representative position used for epsilon neighborhood distance tests.
    #[get(type(copy))]
    pub(crate) anchor: Vec3,
    /// Number of vertices merged into this cluster.
    #[get(type(copy))]
    pub(crate) count: u32,
}