Fix H/V/45 zone snapping behavior

Fixes https://gitlab.com/kicad/code/kicad/-/issues/5122
This commit is contained in:
Jon Evans 2020-09-26 14:27:08 -04:00
parent 7300640da0
commit 56ca842ec4
1 changed files with 9 additions and 2 deletions

View File

@ -187,8 +187,15 @@ void POLYGON_GEOM_MANAGER::updateLeaderPoints( const VECTOR2I& aEndPoint, LEADER
if( pt ) if( pt )
{ {
// This checks for backtracking from the point to intersection SEG drawn( last_pt, new_end );
if( SEG( last_pt, new_end ).Collinear( SEG( new_end, *pt ) ) ) SEG completed( new_end, *pt );
/*
* Check for backtracking from the point to intersection. If the snapped path to
* completion is shorter than what the user actually drew, we want to discard the
* drawn point and just use the snapped completion point.
*/
if( drawn.Collinear( completed ) && drawn.SquaredLength() > completed.SquaredLength() )
m_leaderPts = SHAPE_LINE_CHAIN( { last_pt, *pt } ); m_leaderPts = SHAPE_LINE_CHAIN( { last_pt, *pt } );
else else
m_leaderPts.Append( *pt ); m_leaderPts.Append( *pt );