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

Compute much better axis-aligned bounding boxes for tiles, for use by Unreal Engine #823

Merged
merged 4 commits into from
Apr 29, 2022

Conversation

kring
Copy link
Member

@kring kring commented Apr 20, 2022

When we create a static mesh, we must provide an AABB and bounding sphere. These bounding volumes aren't used for culling or tile selection in cesium-native, because it has its own (more accurate) bounding volumes, but Unreal Engine uses them for its own frustum and occlusion culling and possibly other things.

The AABB is provided in model coordinates, and then it's transformed into world coordinates as the static mesh component's transformation changes. The problem is that our tile models are often expressed in ECEF (minus a translation), and so they're really poorly aligned with the axes. Therefore, our AABBs, when expressed in model coordinates, are big and cube-like. Once they're rotated into world coordinates, the CesiumGeoreference guarantees that tiles near the origin are much more axis-aligned. But Unreal Engine doesn't have enough information to produce better world-space AABBs, so it still uses the big cube-like ones, only rotated to a different orientation.

Fortunately Unreal Engine provides a virtual method on UPrimitiveComponent, CalcBounds, that allows us to calculate a new world-space AABB according to a new transformation in a much more accurate way. Specifically, we use our accurate oriented bounding box, bounding region, etc. to produce a much more accurate world-space AABB. This results in much smaller world-space AABBs in many cases, which should make rendering more efficient.

In the screenshots below, look at the blue lines, which are the outlines of the AABBs, and notice how much smaller the volumes are in the "after" screenshot.

Before:
image

After:
image

@cesium-concierge
Copy link

Thanks for the pull request @kring!

  • ✔️ Signed CLA found.

Reviewers, don't forget to make sure that:

@joseph-kaile joseph-kaile self-assigned this Apr 29, 2022
Copy link
Collaborator

@joseph-kaile joseph-kaile left a comment

Choose a reason for hiding this comment

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

Looks very good. Works well.

@joseph-kaile joseph-kaile merged commit ea40636 into ue4-main Apr 29, 2022
@joseph-kaile joseph-kaile deleted the better-ue-bounding-volumes branch April 29, 2022 21:21
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.

None yet

3 participants