diff --git a/pcbnew/drc/drc_interactive_courtyard_clearance.cpp b/pcbnew/drc/drc_interactive_courtyard_clearance.cpp index 6a89c590e8..9205519f0f 100644 --- a/pcbnew/drc/drc_interactive_courtyard_clearance.cpp +++ b/pcbnew/drc/drc_interactive_courtyard_clearance.cpp @@ -33,23 +33,29 @@ void DRC_INTERACTIVE_COURTYARD_CLEARANCE::testCourtyardClearances() { std::vector fpBBBoxes( m_FpInMove.size() ); - std::vector frontBBBoxes( m_FpInMove.size() ); - std::vector backBBBoxes( m_FpInMove.size() ); + BOX2I movingBBox; - // GetCourtyard updates courtyard caches if needed for( size_t i = 0; i < m_FpInMove.size(); i++ ) { FOOTPRINT* fpB = m_FpInMove[i]; - fpBBBoxes[i] = fpB->GetBoundingBox(); - frontBBBoxes[i] = fpB->GetCourtyard( F_CrtYd ).BBoxFromCaches(); - backBBBoxes[i] = fpB->GetCourtyard( B_CrtYd ).BBoxFromCaches(); + + BOX2I bbox = fpB->GetBoundingBox( true, false ); + movingBBox.Merge( bbox ); + fpBBBoxes[i] = bbox; } + movingBBox.Inflate( m_largestCourtyardClearance ); + for( FOOTPRINT* fpA: m_board->Footprints() ) { if( fpA->IsSelected() ) continue; + BOX2I fpABBox = fpA->GetBoundingBox( true, false ); + + if( !movingBBox.Intersects( fpABBox ) ) + continue; + const SHAPE_POLY_SET& frontA = fpA->GetCourtyard( F_CrtYd ); const SHAPE_POLY_SET& backA = fpA->GetCourtyard( B_CrtYd ); @@ -63,19 +69,19 @@ void DRC_INTERACTIVE_COURTYARD_CLEARANCE::testCourtyardClearances() frontABBox.Inflate( m_largestCourtyardClearance ); backABBox.Inflate( m_largestCourtyardClearance ); - BOX2I fpABBox = fpA->GetBoundingBox(); - for( size_t inMoveId = 0; inMoveId < m_FpInMove.size(); inMoveId++ ) { FOOTPRINT* fpB = m_FpInMove[inMoveId]; - const SHAPE_POLY_SET& frontB = fpB->GetCachedCourtyard( F_CrtYd ); - const SHAPE_POLY_SET& backB = fpB->GetCachedCourtyard( B_CrtYd ); - const BOX2I fpBBBox = fpBBBoxes[inMoveId]; - const BOX2I frontBBBox = frontBBBoxes[inMoveId]; - const BOX2I backBBBox = backBBBoxes[inMoveId]; - int clearance; - int actual; - VECTOR2I pos; + const SHAPE_POLY_SET& frontB = fpB->GetCourtyard( F_CrtYd ); + const SHAPE_POLY_SET& backB = fpB->GetCourtyard( B_CrtYd ); + + const BOX2I fpBBBox = fpBBBoxes[inMoveId]; + const BOX2I frontBBBox = frontB.BBoxFromCaches(); + const BOX2I backBBBox = backB.BBoxFromCaches(); + + int clearance; + int actual; + VECTOR2I pos; if( frontA.OutlineCount() > 0 && frontB.OutlineCount() > 0 && frontABBox.Intersects( frontBBBox ) ) diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index 116cbaa372..b8dfd9ba8d 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -1243,9 +1243,7 @@ const BOX2I FOOTPRINT::GetBoundingBox() const const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisibleText ) const { - std::vector texts; const BOARD* board = GetBoard(); - bool isFPEdit = board && board->IsFootprintHolder(); if( board ) { @@ -1266,6 +1264,9 @@ const BOX2I FOOTPRINT::GetBoundingBox( bool aIncludeText, bool aIncludeInvisible } } + std::vector texts; + bool isFPEdit = board && board->IsFootprintHolder(); + BOX2I bbox( m_pos ); bbox.Inflate( pcbIUScale.mmToIU( 0.25 ) ); // Give a min size to the bbox