pcbnew: prevent assert with first pt
Finding the pt-to-end intersection requires a segment, so check for multiple points. Fixes: lp:1846431 * https://bugs.launchpad.net/kicad/+bug/1846431
This commit is contained in:
parent
846397c692
commit
70c64d93e4
|
@ -152,24 +152,28 @@ void POLYGON_GEOM_MANAGER::updateLeaderPoints( const VECTOR2I& aEndPoint, LEADER
|
||||||
const VECTOR2I lineVector( aEndPoint - lastPt );
|
const VECTOR2I lineVector( aEndPoint - lastPt );
|
||||||
// get a restricted 45/H/V line from the last fixed point to the cursor
|
// get a restricted 45/H/V line from the last fixed point to the cursor
|
||||||
auto newEnd = lastPt + GetVectorSnapped45( lineVector );
|
auto newEnd = lastPt + GetVectorSnapped45( lineVector );
|
||||||
|
OPT_VECTOR2I pt;
|
||||||
|
|
||||||
SEG first( lastPt, newEnd );
|
if( m_lockedPoints.SegmentCount() >0 )
|
||||||
SEG test_seg = m_lockedPoints.CSegment( 0 );
|
|
||||||
|
|
||||||
auto pt = first.IntersectLines( m_lockedPoints.CSegment( 0 ) );
|
|
||||||
int dist = pt ? ( aEndPoint - *pt ).EuclideanNorm() : std::numeric_limits<int>::max();
|
|
||||||
|
|
||||||
for( int i = 1; i < 8; i++ )
|
|
||||||
{
|
{
|
||||||
test_seg.B = ( test_seg.B - test_seg.A ).Rotate( M_PI_4 ) + test_seg.A;
|
SEG first( lastPt, newEnd );
|
||||||
auto pt2 = first.IntersectLines( test_seg );
|
SEG test_seg = m_lockedPoints.CSegment( 0 );
|
||||||
if( pt2 )
|
|
||||||
|
pt = first.IntersectLines( m_lockedPoints.CSegment( 0 ) );
|
||||||
|
int dist = pt ? ( aEndPoint - *pt ).EuclideanNorm() : std::numeric_limits<int>::max();
|
||||||
|
|
||||||
|
for( int i = 1; i < 8; i++ )
|
||||||
{
|
{
|
||||||
int dist2 = ( aEndPoint - *pt2 ).EuclideanNorm();
|
test_seg.B = ( test_seg.B - test_seg.A ).Rotate( M_PI_4 ) + test_seg.A;
|
||||||
if( dist2 < dist )
|
auto pt2 = first.IntersectLines( test_seg );
|
||||||
|
if( pt2 )
|
||||||
{
|
{
|
||||||
dist = dist2;
|
int dist2 = ( aEndPoint - *pt2 ).EuclideanNorm();
|
||||||
pt = pt2;
|
if( dist2 < dist )
|
||||||
|
{
|
||||||
|
dist = dist2;
|
||||||
|
pt = pt2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue