-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Quadtree performance #12907
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
Open
mzschwartz5
wants to merge
5
commits into
main
Choose a base branch
from
quadtree-performance
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+94
−75
Open
Quadtree performance #12907
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4b7dd01
Improves performance of quadtree customdata
mzschwartz5 327a3e6
Changes quadtree tile customdata from array to set
mzschwartz5 7a98a4d
CHANGES.md for quadtree
mzschwartz5 7de48c2
Changes customData to set in GlobeSurfaceTile
mzschwartz5 6febd2b
Removes rectangle check from quadtree tile for performance
mzschwartz5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments / questions on this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mzschwartz5 I'm responding here belatedly after you pinged me about this on Teams...
I don't think the IDL should be an issue, because I don't think our quadtree tiles can ever cross it?
But I think there's a bigger problem here.
First, consider a quadtree with a Web Mercator tiling scheme. The four child tiles aren't subdivided at the center latitude at all in that case (they're divided in the center in Web Mercator coordinates, which do not map linearly to latitude), so this check is very wrong.
Even in the Geographic projection, where this seems correct, it might still cause subtle problems. It's a floating point thing, and a bit hard to explain, so bear with me...
If we want to know the coordinates of a particular tile given its Level / X / Y quadtree coordinates, there are two ways we can do that. One is that we can repeatedly subdivide the appropriate tile until we reach the one we care about. Level zero spans -90 to 90 degrees latitude, let's say, so we can divide that level 0 tile at 0 degrees latitude, pick the appropriate level 1 tile from among the four, and then divide that to get our level 2 tiles, and so on. Mathematically, it's repeated division, right?
Or, the other way to do it is to divide the entire coordinate space by the number of tiles in the level, giving us a tile width/height, and then multiply that by the tile coordinate. One division, one multiplication.
Mathematically, they're identical. In floating point land, they're not. The repeated divisions in the first approach can lead to accumulation of rounding errors. After drilling down 20+ levels, those tiny errors get magnified to really actually matter. The "dividing line" of a tile computed with the two approaches can be a significant tile width away. We've seen this happen.
So, as a policy, in the name of both performance and precision, CesiumJS always uses the second approach to compute tile coordinates. The subtle problem is that the code above is effectively determining tile boundaries using the first approach. If there's any possibility of this operation happening repeatedly, and thus of errors accumulating, then it could lead to wrong results.
You should be able to solve both problems (the Web Mercator one, and this subtle one) by letting the tiling scheme compute the center point rather than averaging the coordinates.