Performance fixes for the board from hell....
(cherry picked from commit e4b56ab7f1
)
This commit is contained in:
parent
02252be29d
commit
53bd87d792
|
@ -1518,7 +1518,7 @@ bool SHAPE_POLY_SET::Collide( const SHAPE* aShape, int aClearance, int* aActual,
|
|||
return false;
|
||||
}
|
||||
|
||||
const_cast<SHAPE_POLY_SET*>( this )->CacheTriangulation( true );
|
||||
const_cast<SHAPE_POLY_SET*>( this )->CacheTriangulation( false );
|
||||
|
||||
int actual = INT_MAX;
|
||||
VECTOR2I location;
|
||||
|
|
|
@ -310,11 +310,37 @@ public:
|
|||
*/
|
||||
bool QueryColliding( EDA_RECT aBox, SHAPE* aRefShape, PCB_LAYER_ID aLayer ) const
|
||||
{
|
||||
SHAPE_POLY_SET* poly = dynamic_cast<SHAPE_POLY_SET*>( aRefShape );
|
||||
|
||||
int min[2] = { aBox.GetX(), aBox.GetY() };
|
||||
int max[2] = { aBox.GetRight(), aBox.GetBottom() };
|
||||
bool collision = false;
|
||||
|
||||
auto visit =
|
||||
// Special case the polygon case. Otherwise we'll call its Collide() method which will
|
||||
// triangulate it as well and then do triangle/triangle collisions. This ends up being
|
||||
// slower than 4 calls to PointInside().
|
||||
auto polyVisitor =
|
||||
[&]( ITEM_WITH_SHAPE* aItem ) -> bool
|
||||
{
|
||||
SHAPE* shape = aItem->shape;
|
||||
wxASSERT( dynamic_cast<SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI*>( shape ) );
|
||||
auto tri = static_cast<SHAPE_POLY_SET::TRIANGULATED_POLYGON::TRI*>( shape );
|
||||
|
||||
const SHAPE_LINE_CHAIN& outline = poly->Outline( 0 );
|
||||
|
||||
if( outline.PointInside( tri->GetPoint( 0 ) )
|
||||
|| outline.PointInside( tri->GetPoint( 1 ) )
|
||||
|| outline.PointInside( tri->GetPoint( 2 ) )
|
||||
|| tri->PointInside( outline.CPoint( 0 ) ) )
|
||||
{
|
||||
collision = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
auto visitor =
|
||||
[&]( ITEM_WITH_SHAPE* aItem ) -> bool
|
||||
{
|
||||
if( aRefShape->Collide( aItem->shape, 0 ) )
|
||||
|
@ -326,7 +352,10 @@ public:
|
|||
return true;
|
||||
};
|
||||
|
||||
this->m_tree[aLayer]->Search( min, max, visit );
|
||||
if( poly && poly->OutlineCount() == 1 )
|
||||
this->m_tree[aLayer]->Search( min, max, polyVisitor );
|
||||
else
|
||||
this->m_tree[aLayer]->Search( min, max, visitor );
|
||||
|
||||
return collision;
|
||||
}
|
||||
|
|
|
@ -1090,6 +1090,8 @@ void ZONE::CacheTriangulation( PCB_LAYER_ID aLayer )
|
|||
{
|
||||
for( std::pair<const PCB_LAYER_ID, SHAPE_POLY_SET>& pair : m_FilledPolysList )
|
||||
pair.second.CacheTriangulation();
|
||||
|
||||
m_Poly->CacheTriangulation( false );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue