Skip to main content

euv_engine/collider/
struct.rs

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