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] correctly compute near/far planes when a scene is reloaded #55632

Merged
merged 3 commits into from
Jan 22, 2024

Conversation

ptitjano
Copy link
Collaborator

@ptitjano ptitjano commented Dec 15, 2023

From the main commit:

The near/far planes are computed in `Qgs3DMapScene` when the camera
parameters have changed. Their values depend on the bounding boxes of
the visible entities. However, the near and far planes are not
recomputed when a new entity is added.
This can be problematic for entities from a vector layer because their
vertical extent is unknown when the associated bounding boxes are
created.

This issue is fixed by calling
`Qgs3DMapscene::updateCameraNearFarPlanes` when a new scene entity is
created. Indeed, on a new scene entity, the exact exact bounding box
has been computed by the loader of the chunked entity.

Description

Current behavior : the far plane is not correct when the scene is reloaded

near_far.webm

Fixed behavior with this PR: far plane computation is correct

near_far_after.webm

cc @benoitdm-oslandia @wonder-sk @uclaros

@github-actions github-actions bot added this to the 3.36.0 milestone Dec 15, 2023
@ptitjano ptitjano force-pushed the mapscene-near-far-ready branch 2 times, most recently from 99d04df to 7424be3 Compare December 15, 2023 11:23
Copy link

github-actions bot commented Dec 15, 2023

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit 44bb58d)

@ptitjano ptitjano force-pushed the mapscene-near-far-ready branch from 7424be3 to 4d3f699 Compare December 15, 2023 14:26
Copy link

github-actions bot commented Dec 15, 2023

Tests failed for Qt 6

One or more tests failed using the build from commit ffd4bd2

polygon3d_extrusion_opacity (testExtrudedPolygons)

polygon3d_extrusion_opacity

Test failed at testExtrudedPolygons at tests/src/3d/testqgs3drendering.cpp:453

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

polygon3d_extrusion_data_defined (testExtrudedPolygonsDataDefined)

polygon3d_extrusion_data_defined

Test failed at testExtrudedPolygonsDataDefined at tests/src/3d/testqgs3drendering.cpp:556

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

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 Dec 15, 2023

Tests failed for Qt 5

One or more tests failed using the build from commit ffd4bd2

polygon3d_extrusion_opacity (testExtrudedPolygons)

polygon3d_extrusion_opacity

Test failed at testExtrudedPolygons at tests/src/3d/testqgs3drendering.cpp:453

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

polygon3d_extrusion_data_defined (testExtrudedPolygonsDataDefined)

polygon3d_extrusion_data_defined

Test failed at testExtrudedPolygonsDataDefined at tests/src/3d/testqgs3drendering.cpp:556

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

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

Off topic, but do you notice the light intensity increase which happens when the settings are changed? I've tried to track this down and have had no luck... I suspect it's a qt3d internal bug. 😢

Copy link

github-actions bot commented Jan 3, 2024

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@github-actions github-actions bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jan 3, 2024
@Djedouas Djedouas removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jan 3, 2024
@ptitjano ptitjano force-pushed the mapscene-near-far-ready branch 2 times, most recently from d271022 to ffd4bd2 Compare January 16, 2024 19:45
@nyalldawson
Copy link
Collaborator

@ptitjano can you use test mask updates for the test images instead of replacing the reference image? There's only a handful of pixels different, so the mask should be used instead.

@ptitjano ptitjano force-pushed the mapscene-near-far-ready branch 2 times, most recently from f76a863 to 520b1a9 Compare January 17, 2024 11:39
@ptitjano
Copy link
Collaborator Author

@ptitjano can you use test mask updates for the test images instead of replacing the reference image? There's only a handful of pixels different, so the mask should be used instead.

Done

@wonder-sk
Copy link
Member

@ptitjano please rebase...

@ptitjano ptitjano force-pushed the mapscene-near-far-ready branch from 520b1a9 to 5ba923b Compare January 22, 2024 09:17
`Qgs3DNavigationWidget` is updated when the camera parameters are
updated by `QgsCameraController`. However, the near far planes of the
camera can be updated from the `Qgs3DMapScene`. In that case, the
`Qgs3DNavigationWidget` also neeeds to be updated.

This issue is fixed by listening to the near/far plane changes from
the scene camera in `Qgs3DMapCanvas`.
The near/far planes are computed in `Qgs3DMapScene` when the camera
parameters have changed. Their values depend on the bounding boxes of
the visible entities. However, the near and far planes are not
recomputed when a new entity is added.
This can be problematic for entities from a vector layer because their
vertical extent is unknown when the associated bounding boxes are
created.

This issue is fixed by calling
`Qgs3DMapscene::updateCameraNearFarPlanes` when a new scene entity is
created. Indeed, on a new scene entity, the exact exact bounding box
has been computed by the loader of the chunked entity.
@ptitjano ptitjano force-pushed the mapscene-near-far-ready branch from 5ba923b to 44bb58d Compare January 22, 2024 10:38
@ptitjano
Copy link
Collaborator Author

@ptitjano please rebase...

Done

@wonder-sk wonder-sk enabled auto-merge (squash) January 22, 2024 11:05
@ptitjano ptitjano disabled auto-merge January 22, 2024 11:37
@lbartoletti lbartoletti enabled auto-merge (squash) January 22, 2024 13:06
@lbartoletti lbartoletti merged commit 2e7c0e6 into qgis:master Jan 22, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants