From f992f1fb161cebf91db749c2d230bf477fe49b6f Mon Sep 17 00:00:00 2001 From: "C. Andy Martin" Date: Tue, 17 Dec 2019 12:47:36 -1000 Subject: [PATCH] narrowphase distance: fix signed distance when touching In the case of mesh or octree distance checks, we do a collision after distance checking when doing signed distance to find penetration depth. However, the maximum penetration depth was initialized to numeric limits min, which is slightly greater than zero. If the only contact is exactly 0.0 depth, the code fails. Fix this to the negative max. --- include/fcl/narrowphase/distance-inl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fcl/narrowphase/distance-inl.h b/include/fcl/narrowphase/distance-inl.h index 3244631e3..af39bae06 100644 --- a/include/fcl/narrowphase/distance-inl.h +++ b/include/fcl/narrowphase/distance-inl.h @@ -163,7 +163,7 @@ typename NarrowPhaseSolver::S distance( assert(collision_result.isCollision()); std::size_t index = static_cast(-1); - S max_pen_depth = std::numeric_limits::min(); + S max_pen_depth = -std::numeric_limits::max(); for (auto i = 0u; i < collision_result.numContacts(); ++i) { const auto& contact = collision_result.getContact(i);