From 0570c227325baec47888a96fc68bff6551009116 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 27 Nov 2021 09:08:23 -0500 Subject: [PATCH] Use point collision test for zero-length segments SEG::SquaredDistance( SEG& ) does not do the right thing for segments with zero length at the moment. Fixes https://gitlab.com/kicad/code/kicad/-/issues/9791 --- libs/kimath/include/geometry/shape_segment.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libs/kimath/include/geometry/shape_segment.h b/libs/kimath/include/geometry/shape_segment.h index 5a5f833ee4..ac3ddabdf3 100644 --- a/libs/kimath/include/geometry/shape_segment.h +++ b/libs/kimath/include/geometry/shape_segment.h @@ -78,6 +78,9 @@ public: bool Collide( const SEG& aSeg, int aClearance = 0, int* aActual = nullptr, VECTOR2I* aLocation = nullptr ) const override { + if( aSeg.A == aSeg.B ) + return Collide( aSeg.A, aClearance, aActual, aLocation ); + int min_dist = ( m_width + 1 ) / 2 + aClearance; ecoord dist_sq = m_seg.SquaredDistance( aSeg );