Repository navigation
Fix broken map on pitch=0 on some systems - #3740
Merged
Merged
Conversation
lucaswoj
reviewed
Dec 5, 2016
| mat4.translate(m, m, [0, 0, -this.altitude]); | ||
|
|
||
| // a hack around https://github.com/mapbox/mapbox-gl-js/issues/2270 | ||
| m[14] = Math.min(m[14], m[15]); |
Contributor
There was a problem hiding this comment.
The rewards of this not-100%-understood fix outweigh the severity of the bug & risks of the fix in my mind.
Out of curiosity, is there any intuitive meaning of elements 14 and 15 in the transformation matrix? Can we anticipate any cases where elements 14 and 15 might end up with very different values? cc @ansis
Member
Author
There was a problem hiding this comment.
There seem to be no intuitive meaning since the perspective projection math is a bit involved, but at this point of position matrix calculation, m[15] always equals the altitude value (1.5), and m[14] represents translation along Z axis (which always seems to be <=1.5).
lucaswoj
approved these changes
Dec 5, 2016
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #2270 by making sure a floating point error does not accumulate into a broken projection matrix.
When pitch = 0, a
Float32Arrayperspective matrix would end up with1.5000001192092896, 1.5as the last values, whileFloat64Arrayproduces correct1.5, 1.5. Empirically, I found that the first value never exceeds the second one with proper precision. When it does (which happens even withFloat64Arrayon some systems), the map disappears. So while I don't fully grasp the math behind this, this hack seems to fix the pitch=0 bug.cc @ansis @jfirebaugh @lucaswoj