Make sure sorts are deterministic.

This commit is contained in:
Jeff Young 2023-10-04 18:43:36 +01:00
parent 0d51729537
commit 6136c2438d
2 changed files with 16 additions and 3 deletions

View File

@ -1137,7 +1137,10 @@ void RENDER_3D_OPENGL::renderTransparentModels( const glm::mat4 &aCameraViewMatr
[&]( std::pair<const MODELTORENDER *, float>& a, [&]( std::pair<const MODELTORENDER *, float>& a,
std::pair<const MODELTORENDER *, float>& b ) std::pair<const MODELTORENDER *, float>& b )
{ {
return a.second > b.second; if( a.second != b.second )
return a.second > b.second;
return a.first > b.first; // use pointers as a last resort
} ); } );
// Start rendering calls // Start rendering calls

View File

@ -1910,9 +1910,19 @@ void RENDER_3D_RAYTRACE::initializeBlockPositions()
const SFVEC2UI center( m_realBufferSize.x / 2, m_realBufferSize.y / 2 ); const SFVEC2UI center( m_realBufferSize.x / 2, m_realBufferSize.y / 2 );
std::sort( m_blockPositions.begin(), m_blockPositions.end(), std::sort( m_blockPositions.begin(), m_blockPositions.end(),
[&]( const SFVEC2UI& a, const SFVEC2UI& b ) { [&]( const SFVEC2UI& a, const SFVEC2UI& b )
{
// Sort order: inside out. // Sort order: inside out.
return distance( a, center ) < distance( b, center ); float distanceA = distance( a, center );
float distanceB = distance( b, center );
if( distanceA != distanceB )
return distanceA < distanceB;
if( a[0] != b[0] )
return a[0] < b[0];
return a[1] < b[1];
} ); } );
// Create m_shader buffer // Create m_shader buffer