diff --git a/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp b/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp index ac1222f9e1..c849725edb 100644 --- a/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp +++ b/3d-viewer/3d_rendering/opengl/render_3d_opengl.cpp @@ -1137,7 +1137,10 @@ void RENDER_3D_OPENGL::renderTransparentModels( const glm::mat4 &aCameraViewMatr [&]( std::pair& a, std::pair& 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 diff --git a/3d-viewer/3d_rendering/raytracing/render_3d_raytrace.cpp b/3d-viewer/3d_rendering/raytracing/render_3d_raytrace.cpp index bb0bba32db..c94a8d8a58 100644 --- a/3d-viewer/3d_rendering/raytracing/render_3d_raytrace.cpp +++ b/3d-viewer/3d_rendering/raytracing/render_3d_raytrace.cpp @@ -1910,9 +1910,19 @@ void RENDER_3D_RAYTRACE::initializeBlockPositions() const SFVEC2UI center( m_realBufferSize.x / 2, m_realBufferSize.y / 2 ); std::sort( m_blockPositions.begin(), m_blockPositions.end(), - [&]( const SFVEC2UI& a, const SFVEC2UI& b ) { + [&]( const SFVEC2UI& a, const SFVEC2UI& b ) + { // 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