From 4bf35cbed83cd5a0558d258952cd1577fb58eee3 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 29 Mar 2024 12:53:15 -0700 Subject: [PATCH] Remove duplicated clearanceEpsilon We already get clearance epsilon in the clearance resolver. Don't subtract it twice or we end up getting DRC errors Fixes https://gitlab.com/kicad/code/kicad/-/issues/16879 (cherry picked from commit 10c1072479b668d3b453d4bda288569ae94ea467) --- pcbnew/router/pns_item.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pcbnew/router/pns_item.cpp b/pcbnew/router/pns_item.cpp index 042fe0e497..486739fbd8 100644 --- a/pcbnew/router/pns_item.cpp +++ b/pcbnew/router/pns_item.cpp @@ -103,7 +103,6 @@ bool ITEM::collideSimple( const ITEM* aHead, const NODE* aNode, const SHAPE* shapeH = aHead->Shape(); const HOLE* holeH = aHead->Hole(); int lineWidthH = 0; - int clearanceEpsilon = aNode->GetRuleResolver()->ClearanceEpsilon(); bool collisionsFound = false; if( this == aHead ) // we cannot be self-colliding @@ -212,8 +211,10 @@ bool ITEM::collideSimple( const ITEM* aHead, const NODE* aNode, int actual; VECTOR2I pos; - if( shapeH->Collide( shapeI, clearance + lineWidthH + lineWidthI - clearanceEpsilon, - &actual, &pos ) ) + // The extra "1" here is to account for the fact that the hulls are built to exactly + // the clearance distance, so we need to allow for no collision when exactly at the + // clearance distance. + if( shapeH->Collide( shapeI, clearance + lineWidthH + lineWidthI - 1, &actual, &pos ) ) { if( checkCastellation && aNode->QueryEdgeExclusions( pos ) ) return false; @@ -241,7 +242,10 @@ bool ITEM::collideSimple( const ITEM* aHead, const NODE* aNode, else { // Fast method - if( shapeH->Collide( shapeI, clearance + lineWidthH + lineWidthI - clearanceEpsilon ) ) + // The extra "1" here is to account for the fact that the hulls are built to exactly + // the clearance distance, so we need to allow for no collision when exactly at the + // clearance distance. + if( shapeH->Collide( shapeI, clearance + lineWidthH + lineWidthI - 1 ) ) { if( aCtx ) {