Don't create 22.5-degree gateways if we're not cardinal or diagonal.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14984
This commit is contained in:
Jeff Young 2023-06-17 16:04:07 +01:00
parent cf4f0723f8
commit 9fbaa238a2
1 changed files with 14 additions and 6 deletions

View File

@ -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 );
}
}