From f561f85ebb0b722e3046045d7448803ba54d0f24 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 11 Feb 2022 00:28:21 +0000 Subject: [PATCH] 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 6e063247e575795a1ce49aedac4848ccb39b296a) --- pcbnew/connectivity/connectivity_algo.cpp | 33 ++++------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/pcbnew/connectivity/connectivity_algo.cpp b/pcbnew/connectivity/connectivity_algo.cpp index 2196065605..8c5e8e0c2b 100644 --- a/pcbnew/connectivity/connectivity_algo.cpp +++ b/pcbnew/connectivity/connectivity_algo.cpp @@ -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( parentA )->GetWidth() + 1 ) / 2; - - if( parentB->Type() == PCB_VIA_T - || parentB->Type() == PCB_TRACE_T - || parentB->Type() == PCB_ARC_T ) - accuracyB = ( static_cast( 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 );