-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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. |
@@ -256,8 +256,7 @@ void Painter::renderSymbol(PaintParameters& parameters, | |||
auto& collisionBoxShader = shaders->collisionBox; | |||
context.program = collisionBoxShader.getID(); | |||
collisionBoxShader.u_matrix = tile.matrix; | |||
// TODO: This was the overscaled z instead of the canonical z. | |||
collisionBoxShader.u_scale = std::pow(2, state.getZoom() - tile.id.canonical.z); | |||
collisionBoxShader.u_scale = state.zoomScale(state.getZoomFraction()); |
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.
Is this correct in the case of overzoomed tiles?
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.
Good question - I'm not sure. I'll revert this particular change.
@@ -139,7 +139,7 @@ void GeometryTile::queryRenderedFeatures( | |||
queryGeometry, | |||
transformState.getAngle(), | |||
util::tileSize * id.overscaleFactor(), | |||
std::pow(2, transformState.getZoom() - id.overscaledZ), | |||
transformState.zoomScale(transformState.getZoomFraction()), |
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.
(Same question here BTW.)
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not using util::log2
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.
Oops - forgot to update these, thanks!
const auto &anchorPoint = symbol.anchorPoint; | ||
|
||
// drop upside down versions of glyphs | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure this makes sense for readability. The compiler almost certainly optimizes this anyway.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these needed? The implementation is all in the header anyway.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
buffer.segments.emplace_back(buffer.vertices.size(), buffer.triangles.size()); | ||
} | ||
|
||
// We're generating triangle fans, so we always start with the first | ||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe assert here that it's <= 65535
?
@@ -418,6 +418,7 @@ std::unique_ptr<SymbolBucket> SymbolLayout::place(CollisionTile& collisionTile) | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be constexpr
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.
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::log2
whenever possible.