Tesselation: Only set valid when successful
Tesselation can fail for a number of reasons. When this happens, we set the triangulationValid flag to false to prevent using the broken triangulation. This will fall back to the slow OpenGL triangulation when DrawPolygon is called.
This commit is contained in:
parent
388397f97d
commit
2498da2745
|
@ -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<TRIANGULATED_POLYGON>() );
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -651,9 +651,6 @@ public:
|
|||
{
|
||||
ClipperLib::Clipper c;
|
||||
|
||||
if( aPoly.PointCount() < 3 ) // Malformed polygon
|
||||
return false;
|
||||
|
||||
m_bbox = aPoly.BBox();
|
||||
m_result.Clear();
|
||||
|
||||
|
|
Loading…
Reference in New Issue