Browse Source

Fix error in contour check

Correct mistake in bool() that prevented checking correct contour for
end of vertex list.
pull/15/head
Seth Hillbrand 7 years ago
parent
commit
2a00fc962b
  1. 8
      include/geometry/shape_poly_set.h
  2. 3
      qa/common/geometry/test_shape_poly_set_collision.cpp

8
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<int>( m_poly->CPolygon( m_currentPolygon ).size() ) ||
( IsEndContour() && m_currentVertex < m_poly->CPolygon( m_currentPolygon )[m_currentContour].PointCount() )
)
) );
}
/**

3
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" );
}
}

Loading…
Cancel
Save