Also includes going from distance-based neighbor exclusion to angle- based. (Distance doesn't work when very short segments are followed by very long ones.) Fixes https://gitlab.com/kicad/code/kicad/issues/2512
Fixes https://gitlab.com/kicad/code/kicad/issues/6821
Also tries to fix a compile issue on gcc.