From 98d3958223de97024b2223d8d0391cfb83a4fb3a Mon Sep 17 00:00:00 2001 From: Kirill Lysenko Date: Tue, 11 Jun 2024 16:10:46 +0300 Subject: [PATCH 1/2] Fix Issue 511: Fix losing information about hit details when converting from ShapeCastHit in parry to ShapeCastHit in bevy --- CHANGELOG.md | 1 + src/geometry/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c2fe847..484453f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ ### Fix - Fix rigidbodies never going to sleep when a scale was applied to their `Transform`. +- Fix losing information about hit details when converting from `ShapeCastHit` in parry to `ShapeCastHit` in bevy_rapier ## v0.26.0 (05 May 2024) diff --git a/src/geometry/mod.rs b/src/geometry/mod.rs index b1fcaa1d..33f76c4b 100644 --- a/src/geometry/mod.rs +++ b/src/geometry/mod.rs @@ -107,8 +107,8 @@ impl ShapeCastHit { hit: rapier::parry::query::ShapeCastHit, details_always_computed: bool, ) -> Self { - let details = if !details_always_computed - && hit.status != ShapeCastStatus::PenetratingOrWithinTargetDist + let details = if details_always_computed + || hit.status != ShapeCastStatus::PenetratingOrWithinTargetDist { Some(ShapeCastHitDetails { witness1: hit.witness1.into(), From c4ce2d1344118ea68a2f3da030956937c993cde1 Mon Sep 17 00:00:00 2001 From: Kirill Lysenko Date: Fri, 14 Jun 2024 18:33:36 +0300 Subject: [PATCH 2/2] Fix Issue 511: Fix losing information about hit details when converting from ShapeCastHit in parry to ShapeCastHit in bevy --- src/geometry/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/geometry/mod.rs b/src/geometry/mod.rs index 33f76c4b..f89198e3 100644 --- a/src/geometry/mod.rs +++ b/src/geometry/mod.rs @@ -107,17 +107,15 @@ impl ShapeCastHit { hit: rapier::parry::query::ShapeCastHit, details_always_computed: bool, ) -> Self { - let details = if details_always_computed - || hit.status != ShapeCastStatus::PenetratingOrWithinTargetDist - { - Some(ShapeCastHitDetails { + let details = match (details_always_computed, hit.status) { + (_, ShapeCastStatus::Failed) => None, + (false, ShapeCastStatus::PenetratingOrWithinTargetDist) => None, + _ => Some(ShapeCastHitDetails { witness1: hit.witness1.into(), witness2: hit.witness2.into(), normal1: hit.normal1.into(), normal2: hit.normal2.into(), - }) - } else { - None + }), }; Self { time_of_impact: hit.time_of_impact,