Pick location closest to aSeg.A in SHAPE_COMPOUND and SHAPE_RECT Collide.
This commit is contained in:
parent
92ef40327d
commit
f9efed692d
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2020-2022 KiCad Developers
|
||||
* Copyright (C) 2020-2023 KiCad Developers
|
||||
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
|
@ -134,9 +134,17 @@ bool SHAPE_COMPOUND::Collide( const SEG& aSeg, int aClearance, int* aActual,
|
|||
nearest = pn;
|
||||
closest_dist = actual;
|
||||
|
||||
if( closest_dist == 0 || !aActual )
|
||||
if( !aLocation && !aActual )
|
||||
break;
|
||||
}
|
||||
else if( aLocation && actual == closest_dist )
|
||||
{
|
||||
if( ( pn - aSeg.A ).SquaredEuclideanNorm()
|
||||
< ( nearest - aSeg.A ).SquaredEuclideanNorm() )
|
||||
{
|
||||
nearest = pn;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,16 @@ bool SHAPE_RECT::Collide( const SEG& aSeg, int aClearance, int* aActual, VECTOR2
|
|||
|
||||
closest_dist_sq = dist_sq;
|
||||
}
|
||||
else if( aLocation && dist_sq == closest_dist_sq )
|
||||
{
|
||||
VECTOR2I near = side.NearestPoint( aSeg );
|
||||
|
||||
if( ( near - aSeg.A ).SquaredEuclideanNorm()
|
||||
< ( nearest - aSeg.A ).SquaredEuclideanNorm() )
|
||||
{
|
||||
nearest = near;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( closest_dist_sq == 0 || closest_dist_sq < SEG::Square( aClearance ) )
|
||||
|
|
Loading…
Reference in New Issue