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. From Master branch
This commit is contained in:
parent
f25d74628b
commit
c07ac8b3db
|
@ -2,7 +2,7 @@
|
|||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2017 Jon Evans <jon@craftyjon.com>
|
||||
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
|
@ -299,8 +299,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 primitives.
|
||||
// CacheTriangulation() can create basic triangle primitives to draw the 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() )
|
||||
aItem->m_AbsolutePolygon.CacheTriangulation();
|
||||
aItem->m_AbsolutePolygon.CacheTriangulation( false /* fastest triangulation calculation mode */ );
|
||||
|
||||
m_gal->DrawPolygon( aItem->m_AbsolutePolygon );
|
||||
}
|
||||
|
|
|
@ -499,6 +499,16 @@ public:
|
|||
|
||||
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 );
|
||||
bool IsTriangulationUpToDate() const;
|
||||
|
||||
|
@ -1352,7 +1362,7 @@ public:
|
|||
|
||||
/**
|
||||
* Build a SHAPE_POLY_SET from a bunch of outlines in provided in random order.
|
||||
*
|
||||
*
|
||||
* @param aPath set of closed outlines forming the polygon. Positive orientation = outline, negative = hole
|
||||
* @param aReverseOrientation inverts the sign of the orientation of aPaths (so negative = outline)
|
||||
* @param aEvenOdd forces the even-off fill rule (default is non zero)
|
||||
|
|
Loading…
Reference in New Issue