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

Fix aabb.fromPoints API #12207

Merged
merged 3 commits into from Sep 1, 2022
Merged

Fix aabb.fromPoints API #12207

merged 3 commits into from Sep 1, 2022

Conversation

karimnaaji
Copy link
Contributor

@karimnaaji karimnaaji commented Aug 31, 2022

Issue discovered while working on #12138. Fixes a regression introduced by 7398fb3 for a function used as part of the tile cover process with globe.

const aabbMin = [Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE];
const aabbMax = [Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE];

uses MIN_VALUE (0) instead of INFINITY, this gives the wrong values when the AABB bounds are negative. e.g., with an AABB with points like that:

[-10, -5, 10, 5]

the bounds gets clamped like this:

[0, 10]

instead of:

[-10, 10]

Launch Checklist

  • briefly describe the changes in this PR
  • write tests for all new functionality
  • post benchmark scores
  • manually test the debug page
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>Fix invalid AABB calculation as part of the globe tile cover</changelog>

Copy link
Contributor

@SnailBones SnailBones left a comment

Choose a reason for hiding this comment

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

Nice work Karim!

One small nit: perhaps it would be better to update the images instead of increasing tolerance, since the subtle change in appearance was introduced by this bug, no?

The lines also look a bit cleaner in the generated image.

image

@karimnaaji
Copy link
Contributor Author

karimnaaji commented Aug 31, 2022

I was worried this change would necessitate a patch release for v2.10.0 as it was already released but this regression did not introduce any measurable performance regression, as benchmarks did not show any difference in top-level rendering metrics with the globe:

v2.10.0 vs v2.9.0:

Screenshot from 2022-08-31 12-46-12

main vs karim/fix-aabb-from-points:

Screenshot from 2022-08-31 12-46-30

```
const aabbMin = [Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE];
const aabbMax = [Number.MIN_VALUE, Number.MIN_VALUE, Number.MIN_VALUE];
```
uses MIN_VALUE (0) instead of INFINITY, this gives the wrong values when the AABB bounds are negative
e.g., with an AABB with points like that:
```
[-10, -5, 10, 5]
```
the bounds gets clamped like this:
```
[0, 10]
```
instead of:
```
[-10, 10]
```
@karimnaaji karimnaaji merged commit 1acc58a into main Sep 1, 2022
@karimnaaji karimnaaji deleted the karim/fix-aabb-from-points branch September 1, 2022 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants