From 25fa2131d2d8cd0cfc4a1910458389d422bcb7b1 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 10 Sep 2019 10:56:11 +0100 Subject: [PATCH] Restore PointCloserThan() behaviour to really be "closer than". Change calls which really want it to be "closer than or equal" to distance + 1. Fixes: lp:1843329 * https://bugs.launchpad.net/kicad/+bug/1843329 --- common/geometry/seg.cpp | 4 ++-- common/geometry/trigo.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/geometry/seg.cpp b/common/geometry/seg.cpp index ec8e980337..a0f8a56405 100644 --- a/common/geometry/seg.cpp +++ b/common/geometry/seg.cpp @@ -40,9 +40,9 @@ bool SEG::PointCloserThan( const VECTOR2I& aP, int aDist ) const SEG::ecoord t = d.Dot( aP - A ); if( t <= 0 || !l_squared ) - return ( aP - A ).SquaredEuclideanNorm() <= dist_sq; + return ( aP - A ).SquaredEuclideanNorm() < dist_sq; else if( t >= l_squared ) - return ( aP - B ).SquaredEuclideanNorm() <= dist_sq; + return ( aP - B ).SquaredEuclideanNorm() < dist_sq; int dxdy = abs( d.x ) - abs( d.y ); diff --git a/common/geometry/trigo.cpp b/common/geometry/trigo.cpp index 79377ea36c..e2128a6158 100644 --- a/common/geometry/trigo.cpp +++ b/common/geometry/trigo.cpp @@ -153,7 +153,7 @@ bool TestSegmentHit( const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int return std::abs( delta.y ) <= aDist; SEG segment( aStart, aEnd ); - return segment.PointCloserThan( aRefPoint, aDist ); + return segment.PointCloserThan( aRefPoint, aDist + 1 ); }