Close a polygon that is marked as filled before hit-testing.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16096
This commit is contained in:
Jeff Young 2023-11-16 14:06:31 +00:00
parent ed9dd55fde
commit 7277ae93fa
1 changed files with 14 additions and 1 deletions

View File

@ -922,9 +922,22 @@ bool EDA_SHAPE::hitTest( const VECTOR2I& aPosition, int aAccuracy ) const
case SHAPE_T::POLY: case SHAPE_T::POLY:
if( IsFilled() ) if( IsFilled() )
return m_poly.Collide( aPosition, maxdist ); {
if( !m_poly.COutline( 0 ).IsClosed() )
{
SHAPE_POLY_SET copy( m_poly );
copy.Outline( 0 ).Append( copy.Outline( 0 ).CPoint( 0 ) );
return copy.Collide( aPosition, maxdist );
}
else
{
return m_poly.Collide( aPosition, maxdist );
}
}
else else
{
return m_poly.CollideEdge( aPosition, nullptr, maxdist ); return m_poly.CollideEdge( aPosition, nullptr, maxdist );
}
default: default:
UNIMPLEMENTED_FOR( SHAPE_T_asString() ); UNIMPLEMENTED_FOR( SHAPE_T_asString() );