euv_engine/collider/trait.rs
1use crate::*;
2
3/// A trait for objects that can participate in collision detection.
4pub trait Collider {
5 /// Returns the geometric shape of this collider.
6 ///
7 /// # Returns
8 ///
9 /// - `ColliderShape` - The shape variant.
10 fn shape(&self) -> ColliderShape;
11
12 /// Returns the axis-aligned bounding box that encloses this collider.
13 ///
14 /// # Returns
15 ///
16 /// - `Rect` - The bounding box.
17 fn bounding_box(&self) -> Rect;
18
19 /// Tests whether this collider contains the given point.
20 ///
21 /// # Arguments
22 ///
23 /// - `Vector2D` - The point to test.
24 ///
25 /// # Returns
26 ///
27 /// - `bool` - True if the point is inside.
28 fn contains_point(&self, point: Vector2D) -> bool;
29
30 /// Returns the center point of this collider.
31 ///
32 /// # Returns
33 ///
34 /// - `Vector2D` - The center point.
35 fn center(&self) -> Vector2D;
36}
37
38/// A trait for 3D objects that can participate in collision detection.
39pub trait Collider3D {
40 /// Returns the geometric shape of this 3D collider.
41 ///
42 /// # Returns
43 ///
44 /// - `ColliderShape3D` - The shape variant.
45 fn shape(&self) -> ColliderShape3D;
46
47 /// Returns the 3D axis-aligned bounding box that encloses this collider.
48 ///
49 /// # Returns
50 ///
51 /// - `AABB3D` - The bounding box.
52 fn bounding_box(&self) -> AABB3D;
53
54 /// Tests whether this collider contains the given 3D point.
55 ///
56 /// # Arguments
57 ///
58 /// - `Vector3D` - The point to test.
59 ///
60 /// # Returns
61 ///
62 /// - `bool` - True if the point is inside.
63 fn contains_point(&self, point: Vector3D) -> bool;
64
65 /// Returns the center point of this 3D collider.
66 ///
67 /// # Returns
68 ///
69 /// - `Vector3D` - The center point.
70 fn center(&self) -> Vector3D;
71}