diff --git a/pcbnew/drc/drc_rtree.h b/pcbnew/drc/drc_rtree.h index 67207a9fe7..faf7e21f65 100644 --- a/pcbnew/drc/drc_rtree.h +++ b/pcbnew/drc/drc_rtree.h @@ -232,16 +232,13 @@ public: * It checks all items in the bbox overlap to find the minimal actual distance and * position. */ - bool QueryColliding( BOARD_ITEM* aRefItem, PCB_LAYER_ID aLayer, - int aClearance, int* aActual, VECTOR2I* aPos ) const + bool QueryColliding( EDA_RECT aBox, SHAPE* aRefShape, PCB_LAYER_ID aLayer, int aClearance, + int* aActual, VECTOR2I* aPos ) const { - EDA_RECT box = aRefItem->GetBoundingBox(); - box.Inflate( aClearance ); + aBox.Inflate( aClearance ); - int min[2] = { box.GetX(), box.GetY() }; - int max[2] = { box.GetRight(), box.GetBottom() }; - - std::shared_ptr refShape = aRefItem->GetEffectiveShape( aLayer ); + int min[2] = { aBox.GetX(), aBox.GetY() }; + int max[2] = { aBox.GetRight(), aBox.GetBottom() }; bool collision = false; int actual = INT_MAX; @@ -253,7 +250,7 @@ public: int curActual; VECTOR2I curPos; - if( refShape->Collide( aItem->shape, aClearance, &curActual, &curPos ) ) + if( aRefShape->Collide( aItem->shape, aClearance, &curActual, &curPos ) ) { collision = true; diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp index d78fc40d34..88bf820a8b 100644 --- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp @@ -341,7 +341,33 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aItem VECTOR2I pos; DRC_RTREE* zoneTree = m_zoneTrees[ zone ].get(); - if( zoneTree->QueryColliding( aItem, aLayer, clearance - m_drcEpsilon, &actual, &pos ) ) + EDA_RECT itemBBox = aItem->GetBoundingBox(); + std::shared_ptr itemShape = aItem->GetEffectiveShape( aLayer ); + + if( aItem->Type() == PCB_PAD_T ) + { + PAD* pad = static_cast( aItem ); + + if( !pad->FlashLayer( aLayer ) ) + { + if( pad->GetDrillSize().x == 0 && pad->GetDrillSize().y == 0 ) + continue; + + const SHAPE_SEGMENT* hole = pad->GetEffectiveHoleShape(); + int size = hole->GetWidth(); + + // Note: drill size represents finish size, which means the actual hole + // size is the plating thickness larger. + if( pad->GetAttribute() == PAD_ATTRIB_PTH ) + size += m_board->GetDesignSettings().GetHolePlatingThickness(); + + itemShape = std::make_shared( hole->GetSeg(), size ); + } + } + + if( zoneTree->QueryColliding( itemBBox, itemShape.get(), aLayer, + clearance - m_drcEpsilon, + &actual, &pos ) ) { std::shared_ptr drce = DRC_ITEM::Create( DRCE_CLEARANCE );