aboutsummaryrefslogtreecommitdiff
path: root/src/geometry/proximity_pair.rs
diff options
context:
space:
mode:
authorCrozet Sébastien <developer@crozet.re>2020-12-17 10:24:36 +0100
committerCrozet Sébastien <developer@crozet.re>2020-12-29 11:31:00 +0100
commite231bacec608fa5efd24f7a876572927dbd6c9c4 (patch)
tree596f0b6a1fc666586ffcd71d07a39a7c182c6ef8 /src/geometry/proximity_pair.rs
parentcc6d1b973002b4d366bc81ec6bf9e8240ad7b404 (diff)
downloadrapier-e231bacec608fa5efd24f7a876572927dbd6c9c4.tar.gz
rapier-e231bacec608fa5efd24f7a876572927dbd6c9c4.tar.bz2
rapier-e231bacec608fa5efd24f7a876572927dbd6c9c4.zip
Move all the contact manifold computations out of Rapier.
Diffstat (limited to 'src/geometry/proximity_pair.rs')
-rw-r--r--src/geometry/proximity_pair.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/geometry/proximity_pair.rs b/src/geometry/proximity_pair.rs
new file mode 100644
index 0000000..d3e0dc4
--- /dev/null
+++ b/src/geometry/proximity_pair.rs
@@ -0,0 +1,43 @@
+use crate::geometry::proximity_detector::ProximityPhase;
+use crate::geometry::{ColliderPair, Proximity};
+use std::any::Any;
+
+#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
+/// The description of the proximity of two colliders.
+pub struct ProximityPair {
+ /// The pair of collider involved.
+ pub pair: ColliderPair,
+ /// The state of proximity between the two colliders.
+ pub proximity: Proximity,
+ #[cfg_attr(feature = "serde-serialize", serde(skip))]
+ pub(crate) detector: Option<ProximityPhase>,
+ #[cfg_attr(feature = "serde-serialize", serde(skip))]
+ pub(crate) detector_workspace: Option<Box<dyn Any + Send + Sync>>,
+}
+
+// TODO: use the `derive(Clone)` instead?
+impl Clone for ProximityPair {
+ fn clone(&self) -> Self {
+ ProximityPair {
+ pair: self.pair.clone(),
+ proximity: self.proximity.clone(),
+ detector: None,
+ detector_workspace: None,
+ }
+ }
+}
+
+impl ProximityPair {
+ pub(crate) fn new(
+ pair: ColliderPair,
+ detector: ProximityPhase,
+ detector_workspace: Option<Box<dyn Any + Send + Sync>>,
+ ) -> Self {
+ Self {
+ pair,
+ proximity: Proximity::Disjoint,
+ detector: Some(detector),
+ detector_workspace,
+ }
+ }
+}