Fix SHAPE_POLY_SET::SquaredDistanceToPolygon ignoring aNearest if unlucky

This commit is contained in:
Jon Evans 2021-04-04 19:11:54 -04:00
parent 41c54d383e
commit bd6539885b
1 changed files with 3 additions and 0 deletions

View File

@ -1740,6 +1740,9 @@ SEG::ecoord SHAPE_POLY_SET::SquaredDistanceToPolygon( const SEG& aSegment, int a
CONST_SEGMENT_ITERATOR iterator = CIterateSegmentsWithHoles( aPolygonIndex );
SEG::ecoord minDistance = (*iterator).SquaredDistance( aSegment );
if( aNearest && minDistance == 0 )
*aNearest = ( *iterator ).NearestPoint( aSegment );
for( iterator++; iterator && minDistance > 0; iterator++ )
{
SEG::ecoord currentDistance = (*iterator).SquaredDistance( aSegment );