Allow for rounding error in connection width checker

We perform checks using squared distance but this loses the integer
rounding in the standard norm.  To correct for this, we allow a single
IU in the restriction, allowing fractionally smaller connection widths
before calculating the squared limit

Fixes https://gitlab.com/kicad/code/kicad/issues/14130

Fixes https://gitlab.com/kicad/code/kicad/issues/14131
This commit is contained in:
Seth Hillbrand 2023-02-28 15:24:14 -08:00
parent 4a761179d0
commit a0f99ea8ba
1 changed files with 6 additions and 1 deletions

View File

@ -523,7 +523,12 @@ private:
// z-order range for the current point ± limit bounding box
const int32_t maxZ = zOrder( aPt->x + m_limit, aPt->y + m_limit );
const int32_t minZ = zOrder( aPt->x - m_limit, aPt->y - m_limit );
const SEG::ecoord limit2 = SEG::Square( m_limit );
// Subtract 1 to account for rounding inaccuracies in SquaredEuclideanNorm()
// below. We would usually test for rounding in the final value but since we
// are working in squared integers here, we allow the 1nm slop rather than
// force a separate calculation
const SEG::ecoord limit2 = SEG::Square( m_limit - 1 );
// first look for points in increasing z-order
Vertex* p = aPt->nextZ;