Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further improve 3D Map View performance #60672

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/3d/qgs3dmapscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,7 @@ void Qgs3DMapScene::onCameraChanged()
}

updateScene( true );
bool changedCameraPlanes = updateCameraNearFarPlanes();

if ( changedCameraPlanes )
{
// repeat update of entities - because we have updated camera's near/far planes,
// the active nodes may have changed as well
updateScene( true );
updateCameraNearFarPlanes();
}
updateCameraNearFarPlanes();

onShadowSettingsChanged();

Expand All @@ -342,6 +334,14 @@ void Qgs3DMapScene::updateScene( bool forceUpdate )
sceneContext.cameraPos = camera->position();
const QSize size = mEngine->size();
sceneContext.screenSizePx = std::max( size.width(), size.height() ); // TODO: is this correct?

// Make our own projection matrix so that frustum culling done by the
// entities isn't dependent on the current near/far planes, which would then
// require multiple steps to stabilize.
QMatrix4x4 projMatrix;
projMatrix.setToIdentity();
// Just use some high values for the far plane so we don't have to custom-make the matrix.
projMatrix.perspective( camera->fieldOfView(), camera->aspectRatio(), 1, 10'000'000 );
sceneContext.viewProjectionMatrix = camera->projectionMatrix() * camera->viewMatrix();


Expand Down
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
Loading