Repository navigation
[core] Transform{,State} cleanups - #6790
Conversation
|
@brunoabinader, thanks for your PR! By analyzing the history of the files in this pull request, we identified @jfirebaugh, @kkaefer and @ansis to be potential reviewers. |
There was a problem hiding this comment.
Is this correct in the case of overzoomed tiles?
There was a problem hiding this comment.
Good question - I'm not sure. I'll revert this particular change.
There was a problem hiding this comment.
(Same question here BTW.)
There was a problem hiding this comment.
Yes, I guess I didn't account for overscaled zoom on my tests. We can revisit it again with proper unit tests to verify later.
6f3a220 to
acbb073
Compare
cbee3dc to
689c8b1
Compare
|
Took liberty to include a few other refactors and bug fixes related. Rebased after #6468 (/cc @jfirebaugh). |
689c8b1 to
ff9f2fc
Compare
|
|
||
| const float placementZoom = ::fmax(std::log(scale) / std::log(2) + zoom, 0); | ||
| static const uint16_t vertexLength = 4; | ||
| const float placementZoom = util::max(std::log2(scale) + zoom, 0.0f); |
There was a problem hiding this comment.
Oops - forgot to update these, thanks!
| const float a = std::fmod(symbol.anchorAngle + placementAngle + M_PI, M_PI * 2); | ||
| if (keepUpright && placement == style::SymbolPlacementType::Line && | ||
| (a <= M_PI / 2 || a > M_PI * 3 / 2)) { | ||
| (a <= M_PI_2 || a > M_PI_2 * 3)) { |
There was a problem hiding this comment.
Not sure this makes sense for readability. The compiler almost certainly optimizes this anyway.
There was a problem hiding this comment.
Fair enough 👍 From reading http://stackoverflow.com/posts/1610346/revisions it seems that using M_PI_2 actually decreases a bit of precision in favor of pre computation.
| #endif | ||
| } | ||
| template <> float log2(float x); | ||
| template <> double log2(double x); |
There was a problem hiding this comment.
Why are these needed? The implementation is all in the header anyway.
There was a problem hiding this comment.
This accounts for explicit instantiation, which from my understanding instantiates these template specializations to be reused by each compilation unit without duplications.
There was a problem hiding this comment.
Yeah, but they are only needed when you want to force certain instances to exist even if they're not used, or when the template definition is in an implementation file.
| // coordinate in this polygon. | ||
| auto& segment = buffer.segments.back(); | ||
| size_t index = segment.vertexLength; | ||
| uint16_t index = uint16_t(segment.vertexLength); |
There was a problem hiding this comment.
Maybe assert here that it's <= 65535?
|
|
||
| template <typename Buffer> | ||
| void SymbolLayout::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float scale, const bool keepUpright, const style::SymbolPlacementType placement, const float placementAngle) { | ||
| static const uint16_t vertexLength = 4; |
There was a problem hiding this comment.
Sure - btw this accounts for the longest type declaration in our codebase: static constexpr const uint16_t 😄
af691bf to
f1f2840
Compare
- Added util::{MIN,MAX}_ZOOM_F to avoid consecutive conversions from
double to float
- Move util::log2 to its own header (part of mbgl/math)
f1f2840 to
6a756e0
Compare
|
Can you please revert the |
Reuse
TransformState::{zoomScale,scaleZoom,getZoomFraction}andutil::log2whenever possible.