Pcbnew: DRAWSEGMENT polygonal shape: use triangulation (CacheTriangulation) to draw the shape (similar to zones).
On opengl, creating triangles by CacheTriangulation instead of GLU tesselator is much faster (one order of magnitude)
This commit is contained in:
parent
26765161c1
commit
0bceb69fe9
|
@ -555,14 +555,14 @@ public:
|
|||
* returns a reference to the list of filled polygons.
|
||||
* @return Reference to the list of filled polygons.
|
||||
*/
|
||||
|
||||
//TODO - This should be called for each layer on which the zone exists
|
||||
|
||||
const SHAPE_POLY_SET& GetFilledPolysList() const
|
||||
{
|
||||
return m_FilledPolysList;
|
||||
}
|
||||
|
||||
/** (re)create a list of triangles that "fill" the solid areas.
|
||||
* used for instance to draw these solid areas on opengl
|
||||
*/
|
||||
void CacheTriangulation();
|
||||
|
||||
/**
|
||||
|
|
|
@ -968,12 +968,16 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
|
|||
|
||||
case S_POLYGON:
|
||||
{
|
||||
const auto& points = aSegment->BuildPolyPointsList();
|
||||
std::deque<VECTOR2D> pointsList;
|
||||
SHAPE_POLY_SET& shape = ((DRAWSEGMENT*)aSegment)->GetPolyShape();
|
||||
|
||||
if( points.empty() )
|
||||
if( shape.OutlineCount() == 0 )
|
||||
break;
|
||||
|
||||
if( !shape.IsTriangulationUpToDate() )
|
||||
{
|
||||
shape.CacheTriangulation();
|
||||
}
|
||||
|
||||
m_gal->Save();
|
||||
|
||||
if( MODULE* module = aSegment->GetParentModule() )
|
||||
|
@ -982,13 +986,10 @@ void PCB_PAINTER::draw( const DRAWSEGMENT* aSegment, int aLayer )
|
|||
m_gal->Rotate( -module->GetOrientationRadians() );
|
||||
}
|
||||
|
||||
std::copy( points.begin(), points.end(), std::back_inserter( pointsList ) );
|
||||
pointsList.push_back( points[0] );
|
||||
|
||||
m_gal->SetLineWidth( thickness );
|
||||
m_gal->SetIsFill( true );
|
||||
m_gal->SetIsStroke( true );
|
||||
m_gal->DrawPolygon( pointsList );
|
||||
m_gal->DrawPolygon( shape );
|
||||
|
||||
m_gal->Restore();
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue