From ed733942759cf794e92cae2d0a0479be06796e6d Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 5 May 2020 16:33:20 +0200 Subject: [PATCH] collide: fix erroneous collision if sphere is under edge of polygon Reproducible by the code in #907, occurs if the sphere is close to the edge, but its center is off and under the polygon. --- panda/src/collide/collisionPolygon.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index a2e7b7d44f..791cbdea87 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/panda/src/collide/collisionPolygon.cxx @@ -508,8 +508,8 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { max_dist = csqrt(max_dist_2); } - if (dist > max_dist) { - // There's no intersection: the sphere is hanging off the edge. + if (dist > max_dist || -dist > max_dist) { + // There's no intersection: the sphere is hanging above or under the edge. return nullptr; }