Skip to main content

euv_engine/collider/
struct.rs

1use crate::*;
2
3/// The result of a collision check between two colliders, containing
4/// the contact normal and penetration depth if they overlap.
5#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq, PartialOrd)]
6pub struct CollisionResult {
7    /// The minimum translation vector (MTV) pointing from the first collider to the second.
8    #[get(type(copy))]
9    pub(crate) normal: Vector2D,
10    /// The penetration depth (how far the colliders overlap along the normal).
11    #[get(type(copy))]
12    pub(crate) depth: f64,
13    /// The contact point where the collision occurs.
14    #[get(type(copy))]
15    pub(crate) contact_point: Vector2D,
16}
17
18/// An axis-aligned bounding box collider wrapping a `Rect`.
19#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq, PartialOrd)]
20pub struct AabbCollider {
21    /// The underlying rectangle defining the bounding box.
22    #[get(type(copy))]
23    pub(crate) rect: Rect,
24}
25
26/// A circle collider wrapping a `Circle`.
27#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq, PartialOrd)]
28pub struct CircleCollider {
29    /// The underlying circle defining the collider.
30    #[get(type(copy))]
31    pub(crate) circle: Circle,
32}
33
34/// The result of a collision check between two 3D colliders, containing
35/// the contact normal and penetration depth if they overlap.
36#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq, PartialOrd)]
37pub struct CollisionResult3D {
38    /// The minimum translation vector (MTV) pointing from the first collider to the second.
39    #[get(type(copy))]
40    pub(crate) normal: Vector3D,
41    /// The penetration depth (how far the colliders overlap along the normal).
42    #[get(type(copy))]
43    pub(crate) depth: f64,
44    /// The contact point where the collision occurs.
45    #[get(type(copy))]
46    pub(crate) contact_point: Vector3D,
47}
48
49/// A 3D axis-aligned bounding box collider wrapping an `AABB3D`.
50#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq, PartialOrd)]
51pub struct AabbCollider3D {
52    /// The underlying bounding box defining the collider.
53    #[get(type(copy))]
54    pub(crate) aabb: AABB3D,
55}
56
57/// A 3D sphere collider wrapping a `Sphere`.
58#[derive(Clone, Copy, Data, Debug, Default, New, PartialEq, PartialOrd)]
59pub struct SphereCollider3D {
60    /// The underlying sphere defining the collider.
61    #[get(type(copy))]
62    pub(crate) sphere: Sphere,
63}