Compute much better axis-aligned bounding boxes for tiles, for use by Unreal Engine #823
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
After: