From c1bea4fb30328970aa8f6e81163b95131c3781b7 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Fri, 21 Feb 2025 11:04:35 +1000 Subject: [PATCH] Revert "Speed up QgsCameraController::sampleDepthBuffer() averaging" This reverts commit 1c2a0d56283910aa77959b405e3a0cfb3d6e1ef9. --- src/3d/qgscameracontroller.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/3d/qgscameracontroller.cpp b/src/3d/qgscameracontroller.cpp index 13e650f515b..1871bfb46a5 100644 --- a/src/3d/qgscameracontroller.cpp +++ b/src/3d/qgscameracontroller.cpp @@ -266,14 +266,11 @@ double QgsCameraController::sampleDepthBuffer( int px, int py ) // Returns the average of depth values that are not 1 (void area) depth = 0; int samplesCount = 0; - // Make sure we can do the cast - Q_ASSERT( mDepthBufferImage.format() == QImage::Format_RGB32 ); - for ( int y = 0; y < mDepthBufferImage.height(); ++y ) + for ( int x = 0; x < mDepthBufferImage.width(); ++x ) { - const QRgb *line = reinterpret_cast( mDepthBufferImage.constScanLine( y ) ); - for ( int x = 0; x < mDepthBufferImage.width(); ++x ) + for ( int y = 0; y < mDepthBufferImage.height(); ++y ) { - double d = Qgs3DUtils::decodeDepth( line[x] ); + double d = Qgs3DUtils::decodeDepth( mDepthBufferImage.pixel( x, y ) ); if ( d < 1 ) { depth += d;