
370 IV Performance
if ( isEqual (v1.x,v2.x))
{
// Can t sort on this criterion , try another
if ( isEqual (v1.y,v2.y))
{
if ( isEqual (v1.z,v2.z))
{
// Same for UVs , normals , ...
// Vertices are equal
return false;
}
else
{
return v1.z > v2.z;
}
}
else
{
return v1.y > v2.y; // Can t sort on x, but y is ok
}
}
else
{
return v1.x > v2.x; // x is already discriminant , sort on this axis
}
Listing 26.2. Comparison function 1.
26.4.2 memcmp() Version
If the vertices are packed and we only want to weld vertices w ith perfectly equal co-
ordinates, this function can be greatly simplified by using memcmp instead, as shown
in Listing 26.3.
return memcmp ((void*) this ,(void *) &that ...