From 38945b429587cbbe77a5c50b519954d7c9c4a43e Mon Sep 17 00:00:00 2001 From: Joona Aalto Date: Fri, 22 Mar 2024 18:58:23 +0200 Subject: [PATCH] Fix normal direction for GJK ray casting inside non-solid shapes --- src/query/ray/ray_support_map.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/query/ray/ray_support_map.rs b/src/query/ray/ray_support_map.rs index 21d6c720..8db3e8bd 100644 --- a/src/query/ray/ray_support_map.rs +++ b/src/query/ray/ray_support_map.rs @@ -47,10 +47,14 @@ where simplex.reset(CSOPoint::single_point(supp - new_ray.origin.coords)); gjk::cast_local_ray(shape, simplex, &new_ray, shift + eps).and_then( - |(toi, normal)| { + |(toi, outward_normal)| { let toi = shift - toi; if toi <= max_toi { - Some(RayIntersection::new(toi, normal, FeatureId::Unknown)) + Some(RayIntersection::new( + toi, + -outward_normal, + FeatureId::Unknown, + )) } else { None }