From 9fbaa238a2348879f222802efe3ef4ea5013fee2 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 17 Jun 2023 16:04:07 +0100 Subject: [PATCH] Don't create 22.5-degree gateways if we're not cardinal or diagonal. Fixes https://gitlab.com/kicad/code/kicad/-/issues/14984 --- pcbnew/router/pns_diff_pair.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pcbnew/router/pns_diff_pair.cpp b/pcbnew/router/pns_diff_pair.cpp index 7cd8b4aa34..36d6172bec 100644 --- a/pcbnew/router/pns_diff_pair.cpp +++ b/pcbnew/router/pns_diff_pair.cpp @@ -609,8 +609,11 @@ void DP_GATEWAYS::buildDpContinuation( const DP_PRIMITIVE_PAIR& aPair, bool aIsD if( !aPair.Directional() ) return; - // Add gateways that angle the anchor points by 22.5 degrees for connection to tracks which - // are at +/- 45 degrees from the existing direction. + // If we're at a "normal" angle (cardinal or 45-degree-diagonal), then add gateways that angle + // the anchor points by 22.5-degrees for connection to tracks which are at +/- 45 degrees from + // the existing direction. + + int epsilon = 5; // 0.005um auto addAngledGateways = [&]( int length, int priority ) @@ -632,11 +635,16 @@ void DP_GATEWAYS::buildDpContinuation( const DP_PRIMITIVE_PAIR& aPair, bool aIsD m_gateways.push_back( gwExtendN ); }; - addAngledGateways( KiROUND( (double) m_gap * 0.38268 ), 20 ); + VECTOR2I delta = aPair.AnchorP() - aPair.AnchorN(); - // fixme; sin(22.5) doesn't always work, so we also add some lower priority ones with a bit - // of wiggle room. See https://gitlab.com/kicad/code/kicad/-/issues/12459. - addAngledGateways( KiROUND( (double) m_gap * 0.4 ), 5 ); + if( abs( delta.x ) < epsilon || abs( delta.y ) < epsilon || abs( delta.x - delta.y ) < epsilon ) + { + addAngledGateways( KiROUND( (double) m_gap * 0.38268 ), 20 ); + + // fixme; sin(22.5) doesn't always work, so we also add some lower priority ones with a + // bit of wiggle room. See https://gitlab.com/kicad/code/kicad/-/issues/12459. + addAngledGateways( KiROUND( (double) m_gap * 0.4 ), 5 ); + } }