euv-core 0.48.3

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

/// Timestamped discrete gameplay event carried without interpolation on a simulation snapshot.
#[derive(Clone, Copy, Data, Debug, Default, Eq, Hash, New, PartialEq)]
pub struct DiscreteGameEvent {
    /// Semantic discrete event category.
    #[get(type(copy))]
    pub(crate) kind: DiscreteGameEventKind,
    /// Simulation tick on which this event occurred.
    #[get(type(copy))]
    pub(crate) tick: u64,
    /// Associated entity or object slot identifier (`u32::MAX` when global).
    #[get(type(copy))]
    pub(crate) subject_id: u32,
}

/// Three-slot double-buffered snapshot store decoupling fixed-step simulation commits from zero-allocation high-refresh render interpolation.
#[derive(Clone, Data, Debug, PartialEq)]
pub struct DoubleBufferedSnapshot<S> {
    /// Persistent snapshot slot captured at the previous fixed simulation step.
    pub(crate) prev_state: S,
    /// Persistent snapshot slot captured at the latest fixed simulation step.
    pub(crate) curr_state: S,
    /// Third persistent scratch slot overwritten in place during zero-allocation `sample_cached` calls.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) interp_scratch: S,
    /// Monotonic simulation tick counter incremented on every commit.
    #[get(type(copy))]
    pub(crate) tick: u64,
    /// Tick at which the last global discontinuity occurred (camera cut or world reset).
    #[get(type(copy))]
    pub(crate) discontinuity_tick: u64,
    /// Whether `prev_state` represents a valid prior simulation step distinct from `curr_state`.
    #[get(type(copy))]
    pub(crate) has_prev: bool,
}

/// Immutable 2D entity pose captured for render-time interpolation with teleport and spawn guards.
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct EntityPose2D {
    /// Generational entity handle identifying continuity across ticks.
    #[get(type(copy))]
    pub(crate) id: EntityId,
    /// Entity transform at snapshot time.
    #[get(type(copy))]
    pub(crate) transform: EntityTransform,
    /// Teleport discontinuity counter incremented whenever the entity snaps instantaneously.
    #[get(type(copy))]
    pub(crate) teleport_epoch: u32,
    /// Simulation tick on which this entity was spawned.
    #[get(type(copy))]
    pub(crate) spawn_tick: u64,
    /// Whether the entity slot is alive in this snapshot.
    #[get(type(copy))]
    pub(crate) alive: bool,
}

/// Immutable 2D simulation snapshot pairing camera state, continuous entity poses, and discrete events.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct World2DSnapshot {
    /// Simulation tick corresponding to this snapshot.
    #[get(type(copy))]
    pub(crate) tick: u64,
    /// 2D camera state at this simulation step.
    #[get(type(copy))]
    pub(crate) camera: Camera2D,
    /// When `true`, camera motion snapped via an instant cut and must not interpolate.
    #[get(type(copy))]
    pub(crate) camera_cut: bool,
    /// Dense entity poses indexed identically to `GameWorld::entities`.
    pub(crate) entities: Vec<EntityPose2D>,
    /// Un-interpolated discrete events emitted during this simulation tick.
    pub(crate) discrete_events: Vec<DiscreteGameEvent>,
}

/// Immutable 3D object pose captured for render-time interpolation with teleport guards.
#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq)]
pub struct ObjectPose3D {
    /// Index of the object inside `World3D::objects`.
    #[get(type(copy))]
    pub(crate) object_index: usize,
    /// World-space 3D transform at snapshot time.
    #[get(type(copy))]
    pub(crate) transform: Transform3D,
    /// Teleport epoch preventing continuous interpolation across instant relocations.
    #[get(type(copy))]
    pub(crate) teleport_epoch: u32,
    /// Whether the object is visible in this snapshot.
    #[get(type(copy))]
    pub(crate) visible: bool,
}

/// Immutable skeletal joint pose snapshot supporting continuous interpolation unless a cut occurs.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct SkeletonPoseSnapshot {
    /// Local joint transforms ordered identically to `SkeletonRig3D::joints`.
    pub(crate) joint_transforms: Vec<Transform3D>,
    /// When `true`, skeletal pose snapped cleanly (e.g. animation cut or respawn).
    #[get(type(copy))]
    pub(crate) cut: bool,
}

/// Immutable 3D world snapshot pairing camera state, object transforms, skeletal poses, and discrete events.
#[derive(Clone, Data, Debug, Default, PartialEq)]
pub struct World3DSnapshot {
    /// Simulation tick corresponding to this snapshot.
    #[get(type(copy))]
    pub(crate) tick: u64,
    /// 3D perspective camera state at this simulation step.
    #[get(type(copy))]
    pub(crate) camera: Camera3D,
    /// When `true`, camera perspective cut instantaneously and must not interpolate.
    #[get(type(copy))]
    pub(crate) camera_cut: bool,
    /// Continuous object poses indexed identically to `World3D::objects`.
    pub(crate) objects: Vec<ObjectPose3D>,
    /// Optional skeletal pose snapshots interpolated alongside world transforms.
    pub(crate) skeletons: Vec<SkeletonPoseSnapshot>,
    /// Un-interpolated discrete events emitted during this simulation tick.
    pub(crate) discrete_events: Vec<DiscreteGameEvent>,
}