avian3d/data_structures/
pair_key.rs1use bevy::prelude::*;
4
5#[derive(Clone, Copy, Debug, Deref, DerefMut, PartialEq, Eq, Hash)]
9#[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
10pub struct PairKey(pub u64);
11
12impl PairKey {
13 #[inline]
15 pub const fn new(id1: u32, id2: u32) -> Self {
16 if id1 < id2 {
17 Self(((id1 as u64) << 32) | id2 as u64)
18 } else {
19 Self(((id2 as u64) << 32) | id1 as u64)
20 }
21 }
22
23 #[inline]
25 pub fn get(&self) -> (u32, u32) {
26 (
27 ((self.0 >> 32) & 0xFFFF_FFFF) as u32,
28 (self.0 & 0xFFFF_FFFF) as u32,
29 )
30 }
31}