diff --git a/include/geometry/shape_poly_set.h b/include/geometry/shape_poly_set.h index 17c1d2d1b6..099aca63a2 100644 --- a/include/geometry/shape_poly_set.h +++ b/include/geometry/shape_poly_set.h @@ -165,9 +165,11 @@ class SHAPE_POLY_SET : public SHAPE operator bool() const { - return ( ( m_currentPolygon < m_lastPolygon ) || - ( m_currentPolygon == m_lastPolygon && - m_currentVertex < m_poly->CPolygon( m_currentPolygon )[0].PointCount() ) ); + return ( ( m_currentPolygon < m_lastPolygon ) || ( IsLastPolygon() && + ( m_currentContour < static_cast( m_poly->CPolygon( m_currentPolygon ).size() ) || + ( IsEndContour() && m_currentVertex < m_poly->CPolygon( m_currentPolygon )[m_currentContour].PointCount() ) + ) + ) ); } /** diff --git a/qa/common/geometry/test_shape_poly_set_collision.cpp b/qa/common/geometry/test_shape_poly_set_collision.cpp index 11aa8bb5d7..280b531a4c 100644 --- a/qa/common/geometry/test_shape_poly_set_collision.cpp +++ b/qa/common/geometry/test_shape_poly_set_collision.cpp @@ -176,7 +176,8 @@ BOOST_AUTO_TEST_CASE( CollideVertex ) // Check that the set collides with the colliding points for( const VECTOR2I& point : common.holeyPoints ) { - BOOST_CHECK( common.holeyPolySet.CollideVertex( point, cornerHit, 0 ) ); + BOOST_CHECK_MESSAGE( common.holeyPolySet.CollideVertex( point, cornerHit, 0 ), " Point " + << point.x << ", " << point.y << " does not collide with holeyPolySet polygon" ); } }