Fix stupid coding error.

(Don't use epsilon on non-coordinate values, and in particular,
definitely not on polygon vertex count.)
This commit is contained in:
Jeff Young 2021-11-29 19:33:32 +00:00
parent a0f1d77eaa
commit 7ccf658379
2 changed files with 8 additions and 6 deletions

View File

@ -1425,8 +1425,9 @@ int EDA_SHAPE::Compare( const EDA_SHAPE* aOther ) const
{
#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 ); }
#define TEST( a, b ) { if( a != b ) return a - b; }
#define TEST_E( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; }
#define TEST_PT( a, b ) { TEST_E( a.x, b.x ); TEST_E( a.y, b.y ); }
TEST_PT( m_start, aOther->m_start );
TEST_PT( m_end, aOther->m_end );
@ -1450,7 +1451,7 @@ int EDA_SHAPE::Compare( const EDA_SHAPE* aOther ) const
TEST_PT( m_poly.CVertex( ii ), aOther->m_poly.CVertex( ii ) );
}
TEST( m_width, aOther->m_width );
TEST_E( m_width, aOther->m_width );
TEST( (int) m_fill, (int) aOther->m_fill );
return 0;

View File

@ -657,13 +657,14 @@ int EDA_TEXT::Compare( const EDA_TEXT* aOther ) const
{
#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 ); }
#define TEST( a, b ) { if( a != b ) return a - b; }
#define TEST_E( a, b ) { if( abs( a - b ) > EPSILON ) return a - b; }
#define TEST_PT( a, b ) { TEST_E( a.x, b.x ); TEST_E( a.y, b.y ); }
TEST_PT( m_e.pos, aOther->m_e.pos );
TEST_PT( m_e.size, aOther->m_e.size );
TEST( m_e.penwidth, aOther->m_e.penwidth );
TEST_E( m_e.penwidth, aOther->m_e.penwidth );
TEST( m_e.angle, aOther->m_e.angle );
TEST( m_e.hjustify, aOther->m_e.hjustify );