Gerbview: seriously speed up the calculation time to draw polygons on OpenGL.
Mainly CacheTriangulation() was creating triangles using partition mode. But this mode is optimized for Pcbnew and Gerbview and different internal units. Now CacheTriangulation() is used in no partition, much faster in GERBVIEW_PAINTER. Fixes #11549 https://gitlab.com/kicad/code/kicad/issues/11549
This commit is contained in:
parent
d252ce9026
commit
9108404efe
|
@ -282,8 +282,11 @@ void GERBVIEW_PAINTER::draw( /*const*/ GERBER_DRAW_ITEM* aItem, int aLayer )
|
||||||
// On Opengl, a not convex filled polygon is usually drawn by using triangles as
|
// On Opengl, a not convex filled polygon is usually drawn by using triangles as
|
||||||
// primitives. CacheTriangulation() can create basic triangle primitives to draw the
|
// primitives. CacheTriangulation() can create basic triangle primitives to draw the
|
||||||
// polygon solid shape on Opengl
|
// polygon solid shape on Opengl
|
||||||
|
// We use the fastest CacheTriangulation calculation mode: no partition created because
|
||||||
|
// the partition is useless in Gerbview, and very time consumming (optimized only
|
||||||
|
// for pcbnew that has different internal unit)
|
||||||
if( m_gal->IsOpenGlEngine() && !aItem->m_AbsolutePolygon.IsTriangulationUpToDate() )
|
if( m_gal->IsOpenGlEngine() && !aItem->m_AbsolutePolygon.IsTriangulationUpToDate() )
|
||||||
aItem->m_AbsolutePolygon.CacheTriangulation();
|
aItem->m_AbsolutePolygon.CacheTriangulation( false /* fastest triangulation calculation mode */ );
|
||||||
|
|
||||||
m_gal->DrawPolygon( aItem->m_AbsolutePolygon );
|
m_gal->DrawPolygon( aItem->m_AbsolutePolygon );
|
||||||
}
|
}
|
||||||
|
|
|
@ -498,6 +498,16 @@ public:
|
||||||
|
|
||||||
SHAPE_POLY_SET& operator=( const SHAPE_POLY_SET& aOther );
|
SHAPE_POLY_SET& operator=( const SHAPE_POLY_SET& aOther );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a polygon triangulation, needed to draw a polygon on OpenGL and in some
|
||||||
|
* other calculations
|
||||||
|
* @param aPartition = true to created a trinagulation in a partition on a grid
|
||||||
|
* false to create a more basic triangulation of the polygons
|
||||||
|
* Note
|
||||||
|
* in partition calculations the grid size is hard coded to 1e7.
|
||||||
|
* This is a good value for Pcbnew: 1cm, in internal units.
|
||||||
|
* But not good for Gerbview (1e7 = 10cm), however using a partition is not useful.
|
||||||
|
*/
|
||||||
void CacheTriangulation( bool aPartition = true );
|
void CacheTriangulation( bool aPartition = true );
|
||||||
bool IsTriangulationUpToDate() const;
|
bool IsTriangulationUpToDate() const;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue