Skip to content

Commit

Permalink
Speed up QgsCameraController::sampleDepthBuffer() averaging
Browse files Browse the repository at this point in the history
  • Loading branch information
dvdkon committed Feb 13, 2025
1 parent cc3a09b commit 7e074a0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/3d/qgscameracontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,14 @@ double QgsCameraController::sampleDepthBuffer( int px, int py )
// Returns the average of depth values that are not 1 (void area)
depth = 0;
int samplesCount = 0;
for ( int x = 0; x < mDepthBufferImage.width(); ++x )
// Make sure we can do the cast
Q_ASSERT( mDepthBufferImage.format() == QImage::Format_RGB32 );
for ( int y = 0; y < mDepthBufferImage.height(); ++y )
{
for ( int y = 0; y < mDepthBufferImage.height(); ++y )
const QRgb *line = reinterpret_cast<const QRgb *>( mDepthBufferImage.scanLine( y ) );
for ( int x = 0; x < mDepthBufferImage.width(); ++x )
{
double d = Qgs3DUtils::decodeDepth( mDepthBufferImage.pixel( x, y ) );
double d = Qgs3DUtils::decodeDepth( line[x] );
if ( d < 1 )
{
depth += d;
Expand Down

0 comments on commit 7e074a0

Please sign in to comment.