Skip to content

Commit

Permalink
Speed up QgsVirtualPointCloudEntity::handleSceneUpdate
Browse files Browse the repository at this point in the history
Done by adding frustum culling early in the loop, results in a ~10x
speedup in one project.
  • Loading branch information
dvdkon committed Feb 25, 2025
1 parent 5d9d82a commit f702cb4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/3d/qgsvirtualpointcloudentity_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,18 @@ void QgsVirtualPointCloudEntity::handleSceneUpdate( const SceneContext &sceneCon
const QVector<QgsPointCloudSubIndex> subIndexes = provider()->subIndexes();
for ( int i = 0; i < subIndexes.size(); ++i )
{
// If the chunked entity needs an update, do it even if it's occluded,
// since otherwise we'd return needsUpdate() == true until it comes into
// view again.
bool needsUpdate = mChunkedEntitiesMap.contains( i ) && mChunkedEntitiesMap[i]->needsUpdate();

const QgsBox3D &box3D = mBboxes.at( i );

if ( box3D.isEmpty() )
if ( !needsUpdate && box3D.isEmpty() )
continue;

QgsAABB aabb = QgsAABB::fromBox3D( box3D, mBboxesEntity->vertexDataOrigin() );
if ( !needsUpdate && Qgs3DUtils::isCullable( aabb, sceneContext.viewProjectionMatrix ) )
continue;

// magic number 256 is the common span value for a COPC root node
Expand Down

0 comments on commit f702cb4

Please sign in to comment.