Ensure triangulation follows moving zone
Dragging filled zones in OpenGL was extremely slow due to the invalidated triangulation cache. Moving the zone should also move the triangles and keep the cache valid.
This commit is contained in:
parent
eb89d1c68b
commit
08c61e6788
|
@ -875,7 +875,7 @@ void BOARD_ADAPTER::AddSolidAreasShapesToContainer( const ZONE_CONTAINER* aZoneC
|
||||||
PCB_LAYER_ID aLayerId )
|
PCB_LAYER_ID aLayerId )
|
||||||
{
|
{
|
||||||
// Copy the polys list because we have to simplify it
|
// Copy the polys list because we have to simplify it
|
||||||
SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZoneContainer->GetFilledPolysList(), true );
|
SHAPE_POLY_SET polyList = SHAPE_POLY_SET( aZoneContainer->GetFilledPolysList() );
|
||||||
|
|
||||||
// This convert the poly in outline and holes
|
// This convert the poly in outline and holes
|
||||||
Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
|
Convert_shape_line_polygon_to_triangles( polyList, *aDstContainer, m_biuTo3Dunits,
|
||||||
|
|
|
@ -119,6 +119,12 @@ class SHAPE_POLY_SET : public SHAPE
|
||||||
return m_vertices.size();
|
return m_vertices.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Move( const VECTOR2I& aVec )
|
||||||
|
{
|
||||||
|
for( auto& vertex : m_vertices )
|
||||||
|
vertex += aVec;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
std::deque<TRI> m_triangles;
|
std::deque<TRI> m_triangles;
|
||||||
|
@ -448,9 +454,8 @@ class SHAPE_POLY_SET : public SHAPE
|
||||||
* Copy constructor SHAPE_POLY_SET
|
* Copy constructor SHAPE_POLY_SET
|
||||||
* Performs a deep copy of \p aOther into \p this.
|
* Performs a deep copy of \p aOther into \p this.
|
||||||
* @param aOther is the SHAPE_POLY_SET object that will be copied.
|
* @param aOther is the SHAPE_POLY_SET object that will be copied.
|
||||||
* @param aDeepCopy if true, make new copies of the triangulated unique_ptr vector
|
|
||||||
*/
|
*/
|
||||||
SHAPE_POLY_SET( const SHAPE_POLY_SET& aOther, bool aDeepCopy = false );
|
SHAPE_POLY_SET( const SHAPE_POLY_SET& aOther );
|
||||||
|
|
||||||
~SHAPE_POLY_SET();
|
~SHAPE_POLY_SET();
|
||||||
|
|
||||||
|
|
|
@ -67,8 +67,8 @@ SHAPE_POLY_SET::SHAPE_POLY_SET( const SHAPE_LINE_CHAIN& aOutline ) :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SHAPE_POLY_SET::SHAPE_POLY_SET( const SHAPE_POLY_SET& aOther, bool aDeepCopy ) :
|
SHAPE_POLY_SET::SHAPE_POLY_SET( const SHAPE_POLY_SET& aOther ) :
|
||||||
SHAPE( SH_POLY_SET ), m_polys( aOther.m_polys )
|
SHAPE( aOther ), m_polys( aOther.m_polys )
|
||||||
{
|
{
|
||||||
if( aOther.IsTriangulationUpToDate() )
|
if( aOther.IsTriangulationUpToDate() )
|
||||||
{
|
{
|
||||||
|
@ -79,6 +79,12 @@ SHAPE_POLY_SET::SHAPE_POLY_SET( const SHAPE_POLY_SET& aOther, bool aDeepCopy ) :
|
||||||
m_hash = aOther.GetHash();
|
m_hash = aOther.GetHash();
|
||||||
m_triangulationValid = true;
|
m_triangulationValid = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_triangulationValid = false;
|
||||||
|
m_hash = MD5_HASH();
|
||||||
|
m_triangulatedPolys.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1519,6 +1525,11 @@ void SHAPE_POLY_SET::Move( const VECTOR2I& aVector )
|
||||||
for( SHAPE_LINE_CHAIN& path : poly )
|
for( SHAPE_LINE_CHAIN& path : poly )
|
||||||
path.Move( aVector );
|
path.Move( aVector );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for( auto& tri : m_triangulatedPolys )
|
||||||
|
tri->Move( aVector );
|
||||||
|
|
||||||
|
m_hash = checksum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1873,11 +1884,19 @@ SHAPE_POLY_SET &SHAPE_POLY_SET::operator=( const SHAPE_POLY_SET& aOther )
|
||||||
{
|
{
|
||||||
static_cast<SHAPE&>(*this) = aOther;
|
static_cast<SHAPE&>(*this) = aOther;
|
||||||
m_polys = aOther.m_polys;
|
m_polys = aOther.m_polys;
|
||||||
|
|
||||||
// reset poly cache:
|
|
||||||
m_hash = MD5_HASH{};
|
|
||||||
m_triangulationValid = false;
|
|
||||||
m_triangulatedPolys.clear();
|
m_triangulatedPolys.clear();
|
||||||
|
m_triangulationValid = false;
|
||||||
|
|
||||||
|
if( aOther.IsTriangulationUpToDate() )
|
||||||
|
{
|
||||||
|
for( unsigned i = 0; i < aOther.TriangulatedPolyCount(); i++ )
|
||||||
|
m_triangulatedPolys.push_back(
|
||||||
|
std::make_unique<TRIANGULATED_POLYGON>( *aOther.TriangulatedPolygon( i ) ) );
|
||||||
|
|
||||||
|
m_hash = aOther.GetHash();
|
||||||
|
m_triangulationValid = true;
|
||||||
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,10 +107,11 @@ ZONE_CONTAINER& ZONE_CONTAINER::operator=( const ZONE_CONTAINER& aOther )
|
||||||
SetHatchStyle( aOther.GetHatchStyle() );
|
SetHatchStyle( aOther.GetHatchStyle() );
|
||||||
SetHatchPitch( aOther.GetHatchPitch() );
|
SetHatchPitch( aOther.GetHatchPitch() );
|
||||||
m_HatchLines = aOther.m_HatchLines; // copy vector <SEG>
|
m_HatchLines = aOther.m_HatchLines; // copy vector <SEG>
|
||||||
m_FilledPolysList.RemoveAllContours();
|
|
||||||
m_FilledPolysList.Append( aOther.m_FilledPolysList );
|
m_FilledPolysList = aOther.m_FilledPolysList;
|
||||||
m_FillSegmList.clear();
|
m_RawPolysList = aOther.m_RawPolysList;
|
||||||
m_FillSegmList = aOther.m_FillSegmList;
|
m_filledPolysHash = aOther.m_filledPolysHash;
|
||||||
|
m_FillSegmList = aOther.m_FillSegmList; // vector <> copy
|
||||||
|
|
||||||
m_HatchFillTypeThickness = aOther.m_HatchFillTypeThickness;
|
m_HatchFillTypeThickness = aOther.m_HatchFillTypeThickness;
|
||||||
m_HatchFillTypeGap = aOther.m_HatchFillTypeGap;
|
m_HatchFillTypeGap = aOther.m_HatchFillTypeGap;
|
||||||
|
@ -158,7 +159,9 @@ void ZONE_CONTAINER::initDataFromSrcInCopyCtor( const ZONE_CONTAINER& aZone )
|
||||||
m_PadConnection = aZone.m_PadConnection;
|
m_PadConnection = aZone.m_PadConnection;
|
||||||
m_ThermalReliefGap = aZone.m_ThermalReliefGap;
|
m_ThermalReliefGap = aZone.m_ThermalReliefGap;
|
||||||
m_ThermalReliefCopperBridge = aZone.m_ThermalReliefCopperBridge;
|
m_ThermalReliefCopperBridge = aZone.m_ThermalReliefCopperBridge;
|
||||||
m_FilledPolysList.Append( aZone.m_FilledPolysList );
|
m_FilledPolysList = aZone.m_FilledPolysList;
|
||||||
|
m_RawPolysList = aZone.m_RawPolysList;
|
||||||
|
m_filledPolysHash = aZone.m_filledPolysHash;
|
||||||
m_FillSegmList = aZone.m_FillSegmList; // vector <> copy
|
m_FillSegmList = aZone.m_FillSegmList; // vector <> copy
|
||||||
|
|
||||||
m_doNotAllowCopperPour = aZone.m_doNotAllowCopperPour;
|
m_doNotAllowCopperPour = aZone.m_doNotAllowCopperPour;
|
||||||
|
|
Loading…
Reference in New Issue