Better handling of vertex sorting

Nominally, the zcode of a vertex is unique.  This is not 100% true,
however, as we must interlace two 32-bit numbers into a single 32-bit
number.  Sorting needs to account for the possibility that the zcode
will be the same while other elements of the vertex are different.  This
commit fixes the broken boolean logic to more clearly handle these cases

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

(cherry picked from commit e7fe69b97f)
This commit is contained in:
Seth Hillbrand 2023-02-13 11:18:04 -08:00
parent 7816652078
commit f56fcb0a14
2 changed files with 20 additions and 5 deletions

View File

@ -210,7 +210,16 @@ private:
std::sort( queue.begin(), queue.end(), []( const Vertex* a, const Vertex* b )
{
if( a->z != b->z )
return a->z < b->z;
if( a->x != b->x )
return a->x < b->x;
if( a->y != b->y )
return a->y < b->y;
return a->i < b->i;
} );
Vertex* prev_elem = nullptr;

View File

@ -252,10 +252,16 @@ private:
std::sort( queue.begin(), queue.end(), []( const Vertex* a, const Vertex* b )
{
return a->z < b->z || ( a->z == b->z
&& ( ( a->x < b->x )
|| ( a->y < b->y )
|| ( a->i < b->i ) ) );
if( a->z != b->z )
return a->z < b->z;
if( a->x != b->x )
return a->x < b->x;
if( a->y != b->y )
return a->y < b->y;
return a->i < b->i;
} );
Vertex* prev_elem = nullptr;