1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
use crate::geometry::ColliderHandle;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
/// A pair of collider handles.
pub struct ColliderPair {
/// The handle of the first collider involved in this pair.
pub collider1: ColliderHandle,
/// The handle of the second ocllider involved in this pair.
pub collider2: ColliderHandle,
}
impl ColliderPair {
/// Creates a new pair of collider handles.
pub fn new(collider1: ColliderHandle, collider2: ColliderHandle) -> Self {
ColliderPair {
collider1,
collider2,
}
}
/// Swaps the two collider handles in `self`.
pub fn swap(self) -> Self {
Self::new(self.collider2, self.collider1)
}
/// Constructs a pair of artificial handles that are not guaranteed to be valid..
pub fn zero() -> Self {
Self {
collider1: ColliderHandle::from_raw_parts(0, 0),
collider2: ColliderHandle::from_raw_parts(0, 0),
}
}
}
impl Default for ColliderPair {
fn default() -> Self {
ColliderPair::zero()
}
}
/// An event emitted by the broad-phase.
pub enum BroadPhasePairEvent {
/// A potential new collision pair has been detected by the broad-phase.
AddPair(ColliderPair),
/// The two colliders are guaranteed not to touch any more.
DeletePair(ColliderPair),
}
|