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

Merged
merged 8 commits into from
Mar 11, 2025

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 15606c0)

🪟 Windows Qt6 builds

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

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
@wonder-sk wonder-sk closed this Mar 10, 2025
@wonder-sk wonder-sk reopened this Mar 10, 2025
@qgis qgis deleted a comment from github-actions bot Mar 11, 2025
@qgis qgis deleted a comment from github-actions bot Mar 11, 2025
@nyalldawson
Copy link
Collaborator

Looks fantastic -- great work @wonder-sk !!

@wonder-sk wonder-sk merged commit eb62404 into qgis:master Mar 11, 2025
29 of 31 checks passed
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.

3 participants