aboutsummaryrefslogtreecommitdiff
path: root/src/geometry/broad_phase_multi_sap.rs
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2020-10-06 11:37:48 +0200
committerCrozet Sébastien <developer@crozet.re>2020-10-06 11:37:48 +0200
commit60c4d01e0a756ce0af142ac698fd0adcb8c22042 (patch)
treee1877ae21257aeee88399f62493984458f4391e0 /src/geometry/broad_phase_multi_sap.rs
parent17c31bcc57ec8d037ba6cc6ab5f7cfb6fa4bb09b (diff)
downloadrapier-60c4d01e0a756ce0af142ac698fd0adcb8c22042.tar.gz
rapier-60c4d01e0a756ce0af142ac698fd0adcb8c22042.tar.bz2
rapier-60c4d01e0a756ce0af142ac698fd0adcb8c22042.zip
Completely remove the WAABBHierarchy structure.
It is now replaced by the WQuadtree.
Diffstat (limited to 'src/geometry/broad_phase_multi_sap.rs')
-rw-r--r--src/geometry/broad_phase_multi_sap.rs37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/geometry/broad_phase_multi_sap.rs b/src/geometry/broad_phase_multi_sap.rs
index 5c80e0e..0add089 100644
--- a/src/geometry/broad_phase_multi_sap.rs
+++ b/src/geometry/broad_phase_multi_sap.rs
@@ -1,6 +1,6 @@
use crate::data::pubsub::PubSubCursor;
use crate::dynamics::RigidBodySet;
-use crate::geometry::{Collider, ColliderHandle, ColliderPair, ColliderSet, RemovedCollider};
+use crate::geometry::{Collider, ColliderHandle, ColliderSet, RemovedCollider};
use crate::math::{Point, Vector, DIM};
#[cfg(feature = "enhanced-determinism")]
use crate::utils::FxHashMap32 as HashMap;
@@ -16,6 +16,41 @@ const NEXT_FREE_SENTINEL: u32 = u32::MAX;
const SENTINEL_VALUE: f32 = f32::MAX;
const CELL_WIDTH: f32 = 20.0;
+#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
+#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
+pub struct ColliderPair {
+ pub collider1: ColliderHandle,
+ pub collider2: ColliderHandle,
+}
+
+impl ColliderPair {
+ pub fn new(collider1: ColliderHandle, collider2: ColliderHandle) -> Self {
+ ColliderPair {
+ collider1,
+ collider2,
+ }
+ }
+
+ pub fn new_sorted(collider1: ColliderHandle, collider2: ColliderHandle) -> Self {
+ if collider1.into_raw_parts().0 <= collider2.into_raw_parts().0 {
+ Self::new(collider1, collider2)
+ } else {
+ Self::new(collider2, collider1)
+ }
+ }
+
+ pub fn swap(self) -> Self {
+ Self::new(self.collider2, self.collider1)
+ }
+
+ pub fn zero() -> Self {
+ Self {
+ collider1: ColliderHandle::from_raw_parts(0, 0),
+ collider2: ColliderHandle::from_raw_parts(0, 0),
+ }
+ }
+}
+
pub enum BroadPhasePairEvent {
AddPair(ColliderPair),
DeletePair(ColliderPair),