diff --git a/common/geometry/shape_poly_set.cpp b/common/geometry/shape_poly_set.cpp index 99302e2f5e..a00a903d1a 100644 --- a/common/geometry/shape_poly_set.cpp +++ b/common/geometry/shape_poly_set.cpp @@ -1869,12 +1869,10 @@ void SHAPE_POLY_SET::CacheTriangulation() tmpSet.Fracture( PM_FAST ); m_triangulatedPolys.clear(); + m_triangulationValid = true; for( int i = 0; i < tmpSet.OutlineCount(); i++ ) { - if( tmpSet.Outline( i ).PointCount() < 3 ) // malformed polygon - continue; - m_triangulatedPolys.push_back( std::make_unique() ); PolygonTriangulation tess( *m_triangulatedPolys.back() ); @@ -1883,12 +1881,17 @@ void SHAPE_POLY_SET::CacheTriangulation() if( !tess.TesselatePolygon( tmpSet.Polygon( i ).front() ) ) { tmpSet.Fracture( PM_FAST ); - tess.TesselatePolygon( tmpSet.Polygon( i ).front() ); + + if( !tess.TesselatePolygon( tmpSet.Polygon( i ).front() ) ) + { + m_triangulatedPolys.pop_back(); + m_triangulationValid = false; + } } } - m_triangulationValid = true; - m_hash = checksum(); + if( m_triangulationValid ) + m_hash = checksum(); } diff --git a/include/geometry/polygon_triangulation.h b/include/geometry/polygon_triangulation.h index 8d9ad102df..335eee49da 100644 --- a/include/geometry/polygon_triangulation.h +++ b/include/geometry/polygon_triangulation.h @@ -651,9 +651,6 @@ public: { ClipperLib::Clipper c; - if( aPoly.PointCount() < 3 ) // Malformed polygon - return false; - m_bbox = aPoly.BBox(); m_result.Clear();