From 923dad6ca8abe62e4f1b8d6f096360c855649add Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 16 Jan 2020 19:54:51 -0800 Subject: [PATCH] PNS: Modify MarkObstacles logic to select shorter When routing where we hit multiple obstacles, we choose the shortest path to allow overlapping hits to choose the shorter path, thus giving a better chance of returning true for the DRC-compliant path. Fixes #3773 | https://gitlab.com/kicad/code/kicad/issues/3773 (cherry picked from commit 38f13ef481cd2e5cf560b921bcaabf9cdc7d00fb) --- pcbnew/router/pns_line_placer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pcbnew/router/pns_line_placer.cpp b/pcbnew/router/pns_line_placer.cpp index 85e6a5d7c7..2245d17a62 100644 --- a/pcbnew/router/pns_line_placer.cpp +++ b/pcbnew/router/pns_line_placer.cpp @@ -2,7 +2,7 @@ * KiRouter - a push-and-(sometimes-)shove PCB router * * Copyright (C) 2013-2017 CERN - * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors. * Author: Tomasz Wlostowski * * This program is free software: you can redistribute it and/or modify it @@ -450,7 +450,10 @@ bool LINE_PLACER::rhMarkObstacles( const VECTOR2I& aP, LINE& aNewHead ) if( ( nearest - aP ).EuclideanNorm() < newHead.Width() + cl ) { buildInitialLine( nearest, newHead ); - if ( newHead.CLine().Length() > bestHead.CLine().Length() ) + + // We want the shortest line here to ensure we don't break a clearance + // rule on larger, overlapping items (e.g. vias) + if( newHead.CLine().Length() < bestHead.CLine().Length() ) { bestHead = newHead; hasBest = true;