From 2a00fc962bd8bc6d34887dff810254d80ea2f69b Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 16 Apr 2019 20:21:04 -0700 Subject: [PATCH] Fix error in contour check Correct mistake in bool() that prevented checking correct contour for end of vertex list. --- include/geometry/shape_poly_set.h | 8 +++++--- qa/common/geometry/test_shape_poly_set_collision.cpp | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) 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" ); } }