Move CN_VISITOR from HitTest() to Collide().

The former isn't sufficiently aware of layer differences (such as for
pads with some layers unflashed).

(cherry picked from commit 6e063247e5)
This commit is contained in:
Jeff Young 2022-02-11 00:28:21 +00:00
parent 7cba8e847d
commit f561f85ebb
1 changed files with 5 additions and 28 deletions

View File

@ -765,7 +765,9 @@ bool CN_VISITOR::operator()( CN_ITEM* aCandidate )
if( parentA == parentB )
return true;
if( !( parentA->GetLayerSet() & parentB->GetLayerSet() ).any() )
LSET commonLayers = parentA->GetLayerSet() & parentB->GetLayerSet();
if( !commonLayers.any() )
return true;
// If both m_item and aCandidate are marked dirty, they will both be searched
@ -794,34 +796,9 @@ bool CN_VISITOR::operator()( CN_ITEM* aCandidate )
return true;
}
int accuracyA = 0;
int accuracyB = 0;
if( parentA->Type() == PCB_VIA_T
|| parentA->Type() == PCB_TRACE_T
|| parentA->Type() == PCB_ARC_T)
accuracyA = ( static_cast<const PCB_TRACK*>( parentA )->GetWidth() + 1 ) / 2;
if( parentB->Type() == PCB_VIA_T
|| parentB->Type() == PCB_TRACE_T
|| parentB->Type() == PCB_ARC_T )
accuracyB = ( static_cast<const PCB_TRACK*>( parentB )->GetWidth() + 1 ) / 2;
// Items do not necessarily have reciprocity as we only check for anchors
// therefore, we check HitTest both directions A->B & B->A
for( int i = 0; i < aCandidate->AnchorCount(); ++i )
for( PCB_LAYER_ID layer : commonLayers.Seq() )
{
if( parentB->HitTest( wxPoint( aCandidate->GetAnchor( i ) ), accuracyA ) )
{
m_item->Connect( aCandidate );
aCandidate->Connect( m_item );
return true;
}
}
for( int i = 0; i < m_item->AnchorCount(); ++i )
{
if( parentA->HitTest( wxPoint( m_item->GetAnchor( i ) ), accuracyB ) )
if( parentA->GetEffectiveShape( layer )->Collide( parentB->GetEffectiveShape( layer ).get() ) )
{
m_item->Connect( aCandidate );
aCandidate->Connect( m_item );