Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
respect scene's 2d clipping extent
  • Loading branch information
uclaros authored and wonder-sk committed May 11, 2023
1 parent 6452004 commit 0276a33
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/3d/qgsvirtualpointcloudentity_p.cpp
Expand Up @@ -43,13 +43,16 @@ QgsVirtualPointCloudEntity::QgsVirtualPointCloudEntity( QgsPointCloudLayer *laye
{
mSymbol.reset( symbol );
mBboxesEntity = new QgsChunkBoundsEntity( this );
const QgsRectangle mapExtent = Qgs3DUtils::tryReprojectExtent2D( mMap.extent(), mMap.crs(), layer->crs(), mMap.transformContext() );
const QVector<QgsPointCloudSubIndex> subIndexes = provider()->subIndexes();
for ( int i = 0; i < subIndexes.size(); ++i )
{
const QgsPointCloudSubIndex &si = subIndexes.at( i );
mBboxes << Qgs3DUtils::mapToWorldExtent( si.extent(), si.zRange().lower(), si.zRange().upper(), mMap.origin() );
const QgsRectangle intersection = si.extent().intersect( mapExtent );

if ( !si.index() )
mBboxes << Qgs3DUtils::mapToWorldExtent( intersection, si.zRange().lower(), si.zRange().upper(), mMap.origin() );

if ( !si.index() || intersection.isEmpty() )
continue;

QgsPointCloudLayerChunkedEntity *entity = new QgsPointCloudLayerChunkedEntity( si.index(),
Expand Down Expand Up @@ -111,6 +114,10 @@ void QgsVirtualPointCloudEntity::handleSceneUpdate( const QgsChunkedEntity::Scen
for ( int i = 0; i < subIndexes.size(); ++i )
{
const QgsAABB &bbox = mBboxes.at( i );

if ( bbox.isEmpty() )
continue;

// magic number 256 is the common span value for a COPC root node
constexpr int SPAN = 256;
const float epsilon = std::min( bbox.xExtent(), bbox.yExtent() ) / SPAN;
Expand Down Expand Up @@ -175,6 +182,9 @@ void QgsVirtualPointCloudEntity::updateBboxEntity()
if ( mChunkedEntitiesMap.contains( i ) && mChunkedEntitiesMap[i]->isEnabled() )
continue;

if ( mBboxes.at( i ).isEmpty() )
continue;

bboxes << mBboxes.at( i );
}

Expand Down

0 comments on commit 0276a33

Please sign in to comment.