GRID_HELPER: fixed arithmetic issue in segment snap distance check disguised as 'excessive optimization' by the dragger in the router

This commit is contained in:
Tomasz Wlostowski 2021-02-12 00:05:46 +01:00
parent 325300bd76
commit e221b11e3b
3 changed files with 17 additions and 1 deletions

View File

@ -257,5 +257,18 @@ void MOUSE_TRAIL_TRACER::FlipPosture()
m_manuallyForced = true;
}
VECTOR2I MOUSE_TRAIL_TRACER::GetTrailLeadVector() const
{
if( m_trail.PointCount() < 2 )
{
return VECTOR2I(0, 0);
}
else
{
return m_trail.CPoint( -1 ) - m_trail.CPoint( 0 );
}
}
}

View File

@ -59,6 +59,7 @@ public:
bool IsManuallyForced() const { return m_manuallyForced; }
VECTOR2I GetTrailLeadVector() const;
private:
SHAPE_LINE_CHAIN m_trail;
int m_tolerance;

View File

@ -79,6 +79,8 @@ VECTOR2I PCB_GRID_HELPER::AlignToSegment( const VECTOR2I& aPoint, const SEG& aSe
{
OPT_VECTOR2I pts[6];
const int c_gridSnapEpsilon = 2;
if( !m_enableSnap )
return aPoint;
@ -97,7 +99,7 @@ VECTOR2I PCB_GRID_HELPER::AlignToSegment( const VECTOR2I& aPoint, const SEG& aSe
for( int i = 0; i < 4; i++ )
{
if( pts[i] && aSeg.Contains( *pts[i] ) )
if( pts[i] && aSeg.Distance( *pts[i] ) <= c_gridSnapEpsilon )
{
int d = (*pts[i] - aPoint).EuclideanNorm();