aboutsummaryrefslogtreecommitdiff
path: root/src/geometry
diff options
context:
space:
mode:
authorSébastien Crozet <developer@crozet.re>2021-02-18 18:39:52 +0100
committerGitHub <noreply@github.com>2021-02-18 18:39:52 +0100
commitc650bb1feff8763b309e0705fe6427ce94ed2b2e (patch)
tree7dd9e71cc6b4e44028989779e07c108facb20461 /src/geometry
parent9a15838ad568958273218b678ac22e53bb0a0842 (diff)
parent5e7eedc3fdf74b49ecd999b003570bf352ee3f11 (diff)
downloadrapier-c650bb1feff8763b309e0705fe6427ce94ed2b2e.tar.gz
rapier-c650bb1feff8763b309e0705fe6427ce94ed2b2e.tar.bz2
rapier-c650bb1feff8763b309e0705fe6427ce94ed2b2e.zip
Merge pull request #114 from EmbarkStudios/split-contacts-2
Split bouncy and resting contacts (take 2)
Diffstat (limited to 'src/geometry')
-rw-r--r--src/geometry/contact_pair.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/geometry/contact_pair.rs b/src/geometry/contact_pair.rs
index 47f6678..462d3ef 100644
--- a/src/geometry/contact_pair.rs
+++ b/src/geometry/contact_pair.rs
@@ -128,6 +128,22 @@ pub struct SolverContact {
pub data: ContactData,
}
+impl SolverContact {
+ /// Should we treat this contact as a bouncy contact?
+ /// If `true`, use [`Self::restitution`].
+ pub fn is_bouncy(&self) -> bool {
+ let is_new = self.data.impulse == 0.0;
+ if is_new {
+ // Treat new collisions as bouncing at first, unless we have zero restitution.
+ self.restitution > 0.0
+ } else {
+ // If the contact is still here one step later, it is now a resting contact.
+ // The exception is very high restitutions, which can never rest
+ self.restitution >= 1.0
+ }
+ }
+}
+
impl Default for ContactManifoldData {
fn default() -> Self {
Self::new(