euv-core 0.53.1

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

/// Blender `extras.euv` metadata attached to a `SceneNode3D` for physics, water buoyancy, and gameplay tags.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct BlenderExtrasTags3D {
    /// Physics collider classification.
    #[get(type(copy))]
    pub(crate) collider: SceneColliderShape3D,
    /// Fluid buoyancy density ratio (`0.0` = disabled, `< 1.0` floats on water).
    #[get(type(copy))]
    pub(crate) buoyancy_density: f32,
    /// Whether this node acts as a non-solid trigger volume.
    #[get(type(copy))]
    pub(crate) is_trigger: bool,
    /// Whether this node casts directional or local shadows.
    #[get(type(copy))]
    pub(crate) cast_shadows: bool,
    /// Raw custom JSON properties preserved verbatim from Blender `extras`.
    pub(crate) custom_json: Option<String>,
}

/// Single named Blender Collection entry mapped to a visibility bit in `CollectionRegistry3D`.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct CollectionEntry3D {
    /// Human-readable Blender collection name.
    pub(crate) name: String,
    /// Assigned bit position (`0..64`).
    #[get(type(copy))]
    pub(crate) bit_index: u8,
    /// Whether this collection is visible in the interactive viewport.
    #[get(type(copy))]
    pub(crate) visible_viewport: bool,
    /// Whether this collection is enabled for final renders.
    #[get(type(copy))]
    pub(crate) visible_render: bool,
}

/// Registry mapping Blender Collections to a 64-bit visibility bitmask for O(1) culling checks.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct CollectionRegistry3D {
    /// Ordered collection descriptors (`len <= 64`).
    pub(crate) entries: Vec<CollectionEntry3D>,
    /// Precomputed bitmask of collections currently visible in viewport (`1 << bit_index`).
    #[get(type(copy))]
    pub(crate) active_mask: u64,
}

/// Hierarchical scene node storing local quaternion TRS, cached world matrices, collection bits, and component links.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct SceneNode3D {
    /// Human-readable node or Blender object name.
    pub(crate) name: String,
    /// Optional parent node index inside `SceneGraph3D::nodes`.
    #[get(type(copy))]
    pub(crate) parent: Option<u32>,
    /// Topological tree depth (`0` = root).
    #[get(type(copy))]
    pub(crate) depth: u16,
    /// Local translation relative to parent.
    #[get(type(copy))]
    pub(crate) local_translation: Vec3,
    /// Local unit quaternion rotation relative to parent.
    #[get(type(copy))]
    pub(crate) local_rotation: Quat,
    /// Local non-uniform scale relative to parent.
    #[get(type(copy))]
    pub(crate) local_scale: Vec3,
    /// Cached current-frame local-to-world transformation matrix.
    #[get(type(copy))]
    pub(crate) world_matrix: Mat4,
    /// Previous-frame local-to-world matrix for motion vectors and TSR reprojection.
    #[get(type(copy))]
    pub(crate) prev_world_matrix: Mat4,
    /// Bitmask of Blender Collections containing this node (`bit 0` = root collection).
    #[get(type(copy))]
    pub(crate) collection_mask: u64,
    /// Explicit per-node visibility toggle.
    #[get(type(copy))]
    pub(crate) visible: bool,
    /// Optional mesh asset index attached to this node.
    #[get(type(copy))]
    pub(crate) mesh_id: Option<u32>,
    /// Optional skeletal skin index attached to this node.
    #[get(type(copy))]
    pub(crate) skin_id: Option<u32>,
    /// Optional camera index attached to this node.
    #[get(type(copy))]
    pub(crate) camera_id: Option<u32>,
    /// Optional punctual/area light index attached to this node.
    #[get(type(copy))]
    pub(crate) light_id: Option<u32>,
    /// First morph weight index inside `SceneGraph3D::morph_weights`.
    #[get(type(copy))]
    pub(crate) morph_weight_offset: u32,
    /// Number of shape-key morph weights owned by this node.
    #[get(type(copy))]
    pub(crate) morph_weight_count: u16,
    /// Imported Blender custom properties and gameplay tags.
    pub(crate) extras: BlenderExtrasTags3D,
}

/// Flat depth-sorted 3D scene graph with zero-allocation dirty-bitset world-matrix propagation and Blender Collections.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct SceneGraph3D {
    /// Arena of all scene nodes indexed by node ID.
    pub(crate) nodes: Vec<SceneNode3D>,
    /// Depth-sorted topological traversal order guaranteeing parents precede children.
    pub(crate) topo_order: Vec<u32>,
    /// Bitset marking nodes whose local or inherited world transforms require recomputation.
    pub(crate) dirty_words: Vec<u64>,
    /// Flat contiguous shape-key morph target weight storage across all nodes.
    pub(crate) morph_weights: Vec<f32>,
    /// Registered Blender Collections and active visibility bitmask.
    pub(crate) collections: CollectionRegistry3D,
    /// Whether `topo_order` must be refreshed before propagation.
    #[get(type(copy))]
    pub(crate) topology_dirty: bool,
    /// Monotonic revision incremented whenever transforms or hierarchy change.
    #[get(type(copy))]
    pub(crate) revision: u64,
}