euv-core 0.47.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::*;

/// Dynamic or static 3D rigid body with axis-aligned box collider and physical restitution/friction.
#[derive(Clone, Copy, Data, Debug, PartialEq)]
pub struct RigidBody3D {
    /// Center position in world meters.
    #[get(type(copy))]
    pub(crate) position: Vec3,
    /// Linear velocity in meters per second.
    #[get(type(copy))]
    pub(crate) velocity: Vec3,
    /// Axis-aligned box collider half-extents `(hx, hy, hz)`.
    #[get(type(copy))]
    pub(crate) half_extents: Vec3,
    /// Inverse mass (`0.0` = immovable static collider).
    #[get(type(copy))]
    pub(crate) inv_mass: f32,
    /// Coefficient of restitution (`0.0` = inelastic, `1.0` = perfectly bouncy).
    #[get(type(copy))]
    pub(crate) restitution: f32,
    /// Linear velocity damping factor per second (`0.0..=1.0`).
    #[get(type(copy))]
    pub(crate) linear_damping: f32,
    /// Whether this body is currently resting on the ground or another solid surface.
    #[get(type(copy))]
    pub(crate) grounded: bool,
}

/// Result of a 3D physics raycast against `PhysicsWorld3D` rigid bodies.
#[derive(Clone, Copy, Data, Debug, New, PartialEq)]
pub struct RayHitPhysics3D {
    /// Index of the hit `RigidBody3D`.
    #[get(type(copy))]
    pub(crate) body_index: usize,
    /// Hit distance along the query ray in meters.
    #[get(type(copy))]
    pub(crate) distance: f32,
    /// World-space contact point.
    #[get(type(copy))]
    pub(crate) point: Vec3,
}

/// Deterministic 3D rigid-body physics world with gravity, ground plane, spatial-hash broadphase, impulse resolution, and raycasting.
#[derive(Clone, Data, Debug)]
pub struct PhysicsWorld3D {
    /// Uniform gravitational acceleration vector (defaults to `(0.0, -9.81, 0.0)`).
    #[get(type(copy))]
    pub(crate) gravity: Vec3,
    /// Horizontal ground plane height in meters (`y = ground_y`).
    #[get(type(copy))]
    pub(crate) ground_y: f32,
    /// Simulated 3D rigid bodies.
    pub(crate) bodies: Vec<RigidBody3D>,
    /// Reusable fixed-bucket spatial hash heads (`u32::MAX` = empty bucket) for O(N) 3D broadphase.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) hash_heads: Vec<u32>,
    /// Reusable linked-list next indices for entries inserted into `hash_heads`.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) hash_next: Vec<u32>,
    /// Reusable body index payload per hash-grid entry.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) hash_body: Vec<u32>,
    /// Indices of buckets touched during the current step so clearing touches only occupied slots.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) touched_buckets: Vec<usize>,
    /// Reusable deduplicated candidate pair buffer `(i, j)` with `i < j`.
    #[get(skip)]
    #[get_mut(skip)]
    #[set(skip)]
    pub(crate) pair_scratch: Vec<(usize, usize)>,
}