Partial revert of 1a7cef2950

The referenced commit broke the unit tests, creating invalid
connectivity for polygon fills.
This commit is contained in:
Seth Hillbrand 2019-07-16 05:08:29 -07:00
parent 6388189f48
commit f2db7ecbe4
1 changed files with 27 additions and 7 deletions

View File

@ -1195,18 +1195,28 @@ bool SHAPE_POLY_SET::PointOnEdge( const VECTOR2I& aP ) const
bool SHAPE_POLY_SET::Collide( const SEG& aSeg, int aClearance ) const
{
// We are going to check to see if the segment crosses an external boundary. However, if
// the full segment is inside the polyset, this will not be true. So we first test to see
// if one of the points is inside. If true, then we collide. Use an accuracy of "1" to
// indicate that a collision with the edge should be treated the same as inside.
if( Collide( aSeg.A, 1 ) )
SHAPE_POLY_SET polySet = SHAPE_POLY_SET( *this );
// Inflate the polygon if necessary.
if( aClearance > 0 )
{
// fixme: the number of arc segments should not be hardcoded
polySet.Inflate( aClearance, 8 );
}
// We are going to check to see if the segment crosses an external
// boundary. However, if the full segment is inside the polyset, this
// will not be true. So we first test to see if one of the points is
// inside. If true, then we collide
if( polySet.Contains( aSeg.A ) )
return true;
for( SEGMENT_ITERATOR it = ( (SHAPE_POLY_SET*) this )->IterateSegmentsWithHoles(); it; it++ )
{
SEG polygonEdge = *it;
if( polygonEdge.Collide( aSeg, aClearance ) )
if( polygonEdge.Intersect( aSeg, true ) )
return true;
}
@ -1216,7 +1226,17 @@ bool SHAPE_POLY_SET::Collide( const SEG& aSeg, int aClearance ) const
bool SHAPE_POLY_SET::Collide( const VECTOR2I& aP, int aClearance ) const
{
return Contains( aP, -1, aClearance );
SHAPE_POLY_SET polySet = SHAPE_POLY_SET( *this );
// Inflate the polygon if necessary.
if( aClearance > 0 )
{
// fixme: the number of arc segments should not be hardcoded
polySet.Inflate( aClearance, 8 );
}
// There is a collision if and only if the point is inside of the polygon.
return polySet.Contains( aP );
}