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