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

Conversation

dvdkon
Copy link
Contributor

@dvdkon dvdkon commented Feb 19, 2025

Description

This PR comprises two changes to the 3D view:

  • Decoupling entity visibility from the currently set near/far planes: Currently, which entities are visible depends on the near/far planes. However, adding/removing entities will likely change the near/far planes that are used as input. Currently, we just re-run the scene update once, but to do this properly we'd need to loop until the planes stabilise.

    I instead propose not caring about the planes when selecting entities (by just choosing small/large enough constants), which is where the current process would converge to after enough frames anyway. This way, we get rid of the second (expensive) updateScene() call per frame, almost doubling frame rate, and reduce complexity as a bonus.

  • Early culling in QgsVirtualPointCloudEntity: On each scene update, the VPC entity iterates over its constituent point clouds and calls their handleSceneUpdate() method. That will eventually do frustum culling somewhere in QgsChunkedEntity, but we can get a significant speedup if we do the frustum culling on whole point clouds already in the VPC entity.

Done by adding frustum culling early in the loop, results in a ~10x
speedup in one project.
@github-actions github-actions bot added this to the 3.42.0 milestone Feb 19, 2025
Copy link

github-actions bot commented Feb 20, 2025

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit a50d2b9)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit a50d2b9)

Copy link

Tests failed for Qt 6

One or more tests failed using the build from commit a50d2b9

shaded_terrain_no_layers (testTerrainShading)

shaded_terrain_no_layers

Test failed at testTerrainShading at tests/src/3d/testqgs3drendering.cpp:406

Rendered image did not match tests/testdata/control_images/3d/expected_shaded_terrain_no_layers/expected_shaded_terrain_no_layers.png (found 211503 pixels different)

terrain_theme (testMapTheme)

terrain_theme

Test failed at testMapTheme at tests/src/3d/testqgs3drendering.cpp:1387

flat_terrain_filtered_1 (testFilteredFlatTerrain)

flat_terrain_filtered_1

Test failed at testFilteredFlatTerrain at tests/src/3d/testqgs3drendering.cpp:1870

dem_terrain_filtered_1 (testFilteredDemTerrain)

dem_terrain_filtered_1

Test failed at testFilteredDemTerrain at tests/src/3d/testqgs3drendering.cpp:1917

Rendered image did not match tests/testdata/control_images/3d/expected_dem_terrain_filtered_1/expected_dem_terrain_filtered_1.png (found 52451 pixels different)

pointcloud_3d_singlecolor (testPointCloudSingleColor)

pointcloud_3d_singlecolor

Test failed at testPointCloudSingleColor at tests/src/3d/testqgspointcloud3drendering.cpp:280

pointcloud_3d_singlecolor_clipping (testPointCloudSingleColorClipping)

pointcloud_3d_singlecolor_clipping

Test failed at testPointCloudSingleColorClipping at tests/src/3d/testqgspointcloud3drendering.cpp:322

pointcloud_3d_colorramp (testPointCloudAttributeByRamp)

pointcloud_3d_colorramp

Test failed at testPointCloudAttributeByRamp at tests/src/3d/testqgspointcloud3drendering.cpp:371

pointcloud_3d_classification (testPointCloudClassification)

pointcloud_3d_classification

Test failed at testPointCloudClassification at tests/src/3d/testqgspointcloud3drendering.cpp:408

pointcloud_3d_classification_pointsizes (testPointCloudClassificationOverridePointSizes)

pointcloud_3d_classification_pointsizes

Test failed at testPointCloudClassificationOverridePointSizes at tests/src/3d/testqgspointcloud3drendering.cpp:447

pointcloud_3d_filtered_classification (testPointCloudFilteredClassification)

pointcloud_3d_filtered_classification

Test failed at testPointCloudFilteredClassification at tests/src/3d/testqgspointcloud3drendering.cpp:487

pointcloud_3d_filtered_scene_extent (testPointCloudFilteredSceneExtent)

pointcloud_3d_filtered_scene_extent

Test failed at testPointCloudFilteredSceneExtent at tests/src/3d/testqgspointcloud3drendering.cpp:526

virtual_pointcloud_3d_overview (testPointCloud3DOverview)

virtual_pointcloud_3d_overview

Test failed at testPointCloud3DOverview at tests/src/3d/testqgspointcloud3drendering.cpp:603

The full test report (included comparison of rendered vs expected images) can be found here.

Further documentation on the QGIS test infrastructure can be found in the Developer's Guide.

Copy link

Tests failed for Qt 5

One or more tests failed using the build from commit a50d2b9

shaded_terrain_no_layers (testTerrainShading)

shaded_terrain_no_layers

Test failed at testTerrainShading at tests/src/3d/testqgs3drendering.cpp:406

Rendered image did not match tests/testdata/control_images/3d/expected_shaded_terrain_no_layers/expected_shaded_terrain_no_layers.png (found 211503 pixels different)

flat_terrain_filtered_1 (testFilteredFlatTerrain)

flat_terrain_filtered_1

Test failed at testFilteredFlatTerrain at tests/src/3d/testqgs3drendering.cpp:1870

dem_terrain_filtered_1 (testFilteredDemTerrain)

dem_terrain_filtered_1

Test failed at testFilteredDemTerrain at tests/src/3d/testqgs3drendering.cpp:1917

Rendered image did not match tests/testdata/control_images/3d/expected_dem_terrain_filtered_1/expected_dem_terrain_filtered_1.png (found 52451 pixels different)

pointcloud_3d_singlecolor (testPointCloudSingleColor)

pointcloud_3d_singlecolor

Test failed at testPointCloudSingleColor at tests/src/3d/testqgspointcloud3drendering.cpp:280

pointcloud_3d_singlecolor_clipping (testPointCloudSingleColorClipping)

pointcloud_3d_singlecolor_clipping

Test failed at testPointCloudSingleColorClipping at tests/src/3d/testqgspointcloud3drendering.cpp:322

pointcloud_3d_colorramp (testPointCloudAttributeByRamp)

pointcloud_3d_colorramp

Test failed at testPointCloudAttributeByRamp at tests/src/3d/testqgspointcloud3drendering.cpp:371

pointcloud_3d_classification (testPointCloudClassification)

pointcloud_3d_classification

Test failed at testPointCloudClassification at tests/src/3d/testqgspointcloud3drendering.cpp:408

pointcloud_3d_classification_pointsizes (testPointCloudClassificationOverridePointSizes)

pointcloud_3d_classification_pointsizes

Test failed at testPointCloudClassificationOverridePointSizes at tests/src/3d/testqgspointcloud3drendering.cpp:447

pointcloud_3d_filtered_classification (testPointCloudFilteredClassification)

pointcloud_3d_filtered_classification

Test failed at testPointCloudFilteredClassification at tests/src/3d/testqgspointcloud3drendering.cpp:487

pointcloud_3d_filtered_scene_extent (testPointCloudFilteredSceneExtent)

pointcloud_3d_filtered_scene_extent

Test failed at testPointCloudFilteredSceneExtent at tests/src/3d/testqgspointcloud3drendering.cpp:526

virtual_pointcloud_3d_overview (testPointCloud3DOverview)

virtual_pointcloud_3d_overview

Test failed at testPointCloud3DOverview at tests/src/3d/testqgspointcloud3drendering.cpp:603

The full test report (included comparison of rendered vs expected images) can be found here.

Further documentation on the QGIS test infrastructure can be found in the Developer's Guide.

@nyalldawson
Copy link
Collaborator

@dvdkon i'm not sure if it's related to the previous set of optimisations, but on current master there's a regression in 3d movement when using the mouse wheel to zoom in -- if a small zoom is performed quickly, the map will zoom in a HUGE amount. The same amount of movement zooming out works correctly.

@nyalldawson nyalldawson added the Frozen Feature freeze - Do not merge! label Feb 20, 2025
@uclaros
Copy link
Contributor

uclaros commented Feb 21, 2025

I can confirm that without #60246 zooming in works as usual

@nyalldawson
Copy link
Collaborator

@uclaros should we revert #60246 before today's release? It's an optimisation only, and causes a regression

@uclaros
Copy link
Contributor

uclaros commented Feb 21, 2025

Yes, I think we should. We can reintroduce it later with a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Frozen Feature freeze - Do not merge!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants