Run collision check on correct layer.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/21586
This commit is contained in:
Jeff Young 2025-08-29 17:11:26 +01:00
parent e8cec41355
commit 9525fae7c8

View File

@ -761,7 +761,7 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt
if( !testClearance && !testHoles )
return;
DRC_RTREE* zoneTree = m_board->m_CopperZoneRTreeCache[ zone ].get();
DRC_RTREE* zoneRTree = m_board->m_CopperZoneRTreeCache[ zone ].get();
DRC_CONSTRAINT constraint;
bool colliding;
int clearance = -1;
@ -770,8 +770,7 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt
if( testClearance )
{
constraint = m_drcEngine->EvalRules( PHYSICAL_CLEARANCE_CONSTRAINT, aItem, zone,
aLayer );
constraint = m_drcEngine->EvalRules( PHYSICAL_CLEARANCE_CONSTRAINT, aItem, zone, aLayer );
clearance = constraint.GetValue().Min();
}
@ -795,10 +794,10 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt
}
}
if( zoneTree )
if( IsCopperLayer( aLayer ) && zoneRTree )
{
colliding = zoneTree->QueryColliding( itemBBox, itemShape.get(), aLayer, clearance,
&actual, &pos );
colliding = zoneRTree->QueryColliding( itemBBox, itemShape.get(), aLayer, clearance,
&actual, &pos );
}
else
{
@ -837,26 +836,35 @@ void DRC_TEST_PROVIDER_PHYSICAL_CLEARANCE::testItemAgainstZones( BOARD_ITEM* aIt
if( holeShape )
{
constraint = m_drcEngine->EvalRules( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, aItem,
zone, aLayer );
constraint = m_drcEngine->EvalRules( PHYSICAL_HOLE_CLEARANCE_CONSTRAINT, aItem, zone, aLayer );
clearance = constraint.GetValue().Min();
if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE
&& clearance > 0
&& zoneTree->QueryColliding( itemBBox, holeShape.get(), aLayer, clearance,
&actual, &pos ) )
if( constraint.GetSeverity() != RPT_SEVERITY_IGNORE && clearance > 0 )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
clearance,
actual );
if( IsCopperLayer( aLayer ) && zoneRTree )
{
colliding = zoneRTree->QueryColliding( itemBBox, holeShape.get(), aLayer,
clearance, &actual, &pos );
}
else
{
colliding = zone->Outline()->Collide( holeShape.get(), clearance, &actual, &pos );
}
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, zone );
drce->SetViolatingRule( constraint.GetParentRule() );
if( colliding )
{
std::shared_ptr<DRC_ITEM> drce = DRC_ITEM::Create( DRCE_HOLE_CLEARANCE );
wxString msg = formatMsg( _( "(%s clearance %s; actual %s)" ),
constraint.GetName(),
clearance,
actual );
reportViolation( drce, pos, aLayer );
drce->SetErrorMessage( drce->GetErrorText() + wxS( " " ) + msg );
drce->SetItems( aItem, zone );
drce->SetViolatingRule( constraint.GetParentRule() );
reportViolation( drce, pos, aLayer );
}
}
}
}