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

[3d] Large scene support: shift scene's origin if the camera got too far #60869

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

wonder-sk
Copy link
Member

This "origin rebasing" or "origin shifting" technique is commonly used in various 3D engines when dealing with large scenes (where objects need double precision coordinates). It should greatly improve our capability to handle large scenes (e.g. more than 50km across)

For now, I have used a simple rule that when camera gets 10 km away from the world's origin, the origin is shifted (and camera is placed at the origin). The origin shift has a bit of a cost (we're updating 4x4 transform matrices of all active nodes), so we prefer not to do it on every camera change, but only when necessary. That said, I have not seen slowdowns when origin gets shifted.

Also add a checkbox to the debug panel to allow devs temporarily turn it off.

A related philosophical question from Futurama:

image

Before:

simplescreenrecorder-2025-03-05_15.31.36.mp4

After:

simplescreenrecorder-2025-03-05_15.34.44.mp4

@wonder-sk wonder-sk added the 3D Relates to QGIS' 3D engine or rendering label Mar 5, 2025
@github-actions github-actions bot added this to the 3.44.0 milestone Mar 5, 2025
Copy link

github-actions bot commented Mar 5, 2025

🪟 Windows builds

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

🪟 Windows Qt6 builds

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

Copy link

github-actions bot commented Mar 5, 2025

Tests failed for Qt 5

One or more tests failed using the build from commit cb82929

4978_line_rendering_2 (testEpsg4978LineRendering)

4978_line_rendering_2

Test failed at testEpsg4978LineRendering at tests/src/3d/testqgs3drendering.cpp:1838

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

github-actions bot commented Mar 5, 2025

Tests failed for Qt 6

One or more tests failed using the build from commit 966441b

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

rubberband_3d_point (testRubberBandPoint)

rubberband_3d_point

Test failed at testRubberBandPoint at tests/src/3d/testqgsrubberband3drendering.cpp:115

rubberband_3d_line (testRubberBandLine)

rubberband_3d_line

Test failed at testRubberBandLine at tests/src/3d/testqgsrubberband3drendering.cpp:145

rubberband_3d_polygon (testRubberBandPolygon)

rubberband_3d_polygon

Test failed at testRubberBandPolygon at tests/src/3d/testqgsrubberband3drendering.cpp:175

rubberband_3d_hidden_marker (testRubberBandHiddenMarker)

rubberband_3d_hidden_marker

Test failed at testRubberBandHiddenMarker at tests/src/3d/testqgsrubberband3drendering.cpp:208

rubberband_3d_hidden_last_marker (testRubberBandHiddenLastMarker)

rubberband_3d_hidden_last_marker

Test failed at testRubberBandHiddenLastMarker at tests/src/3d/testqgsrubberband3drendering.cpp:239

rubberband_3d_hidden_edges (testRubberBandHiddenEdges)

rubberband_3d_hidden_edges

Test failed at testRubberBandHiddenEdges at tests/src/3d/testqgsrubberband3drendering.cpp:272

rubberband_3d_hidden_fill (testRubberBandHiddenPolygonFill)

rubberband_3d_hidden_fill

Test failed at testRubberBandHiddenPolygonFill at tests/src/3d/testqgsrubberband3drendering.cpp:305

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
Contributor

@uclaros uclaros left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So nice!
All the underlying work finally getting enabled!

This should greatly improve our capability to handle large scenes (e.g. more than 50km across)

Also add a checkbox to the debug panel to allow devs temporarily turn it off.
@wonder-sk wonder-sk force-pushed the auto-shift-origin branch from cb82929 to e447b59 Compare March 6, 2025 12:42
pre-commit-ci bot and others added 5 commits March 6, 2025 12:44
Relax the assumption that origin is always in the center of the scene
Origin may get updated in Qgs3DMapScene constructor, so let's set
ours once the Qgs3DMapScene is constructed
@wonder-sk wonder-sk closed this Mar 7, 2025
@wonder-sk wonder-sk reopened this Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3D Relates to QGIS' 3D engine or rendering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants