From dede3f5709d363498931b46642397c372252b3a4 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 29 Nov 2021 15:04:36 +0000 Subject: [PATCH] Implement an EPSILON for library/schematic/board checking. This is mainly to not get caught out when format changes result in different values being stored vs. calculated (such as for arcs). --- common/eda_shape.cpp | 4 +++- common/eda_text.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/common/eda_shape.cpp b/common/eda_shape.cpp index 2b5015a1da..e96e5cb540 100644 --- a/common/eda_shape.cpp +++ b/common/eda_shape.cpp @@ -1423,7 +1423,9 @@ void EDA_SHAPE::SwapShape( EDA_SHAPE* aImage ) int EDA_SHAPE::Compare( const EDA_SHAPE* aOther ) const { -#define TEST( a, b ) { if( a != b ) return a - b; } +#define EPSILON 2 // Should be enough for rounding errors on calculated items + +#define TEST( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; } #define TEST_PT( a, b ) { TEST( a.x, b.x ); TEST( a.y, b.y ); } TEST_PT( m_start, aOther->m_start ); diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 2df5f8e913..5447d9325b 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -655,7 +655,9 @@ std::shared_ptr EDA_TEXT::GetEffectiveTextShape( ) const int EDA_TEXT::Compare( const EDA_TEXT* aOther ) const { -#define TEST( a, b ) { if( a != b ) return a - b; } +#define EPSILON 2 // Should be enough for rounding errors on calculated items + +#define TEST( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; } #define TEST_PT( a, b ) { TEST( a.x, b.x ); TEST( a.y, b.y ); } TEST_PT( m_e.pos, aOther->m_e.pos );