diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-29 18:13:12 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-31 16:53:07 +0200 |
commit | 38f536049a8ed8f4bdf7706f4afcbbaf06c974c9 (patch) | |
tree | f65bb6ad0ebde1840e523b18d539f122548194ab /src/mbgl/layout | |
parent | a70bfd89108cf1aef75181819ae43e550a69255e (diff) | |
download | qtlocation-mapboxgl-38f536049a8ed8f4bdf7706f4afcbbaf06c974c9.tar.gz |
[core] Moved util::log2 to its own header
- 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)
Diffstat (limited to 'src/mbgl/layout')
-rw-r--r-- | src/mbgl/layout/symbol_layout.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/mbgl/layout/symbol_layout.cpp b/src/mbgl/layout/symbol_layout.cpp index 0bf152e973..06f26b8ffb 100644 --- a/src/mbgl/layout/symbol_layout.cpp +++ b/src/mbgl/layout/symbol_layout.cpp @@ -11,12 +11,12 @@ #include <mbgl/util/constants.hpp> #include <mbgl/util/utf.hpp> #include <mbgl/util/token.hpp> -#include <mbgl/util/math.hpp> #include <mbgl/util/std.hpp> #include <mbgl/util/constants.hpp> #include <mbgl/util/string.hpp> #include <mbgl/math/clamp.hpp> #include <mbgl/math/minmax.hpp> +#include <mbgl/math/log2.hpp> #include <mbgl/platform/platform.hpp> #include <mbgl/platform/log.hpp> @@ -418,8 +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) { - - const float placementZoom = ::fmax(std::log(scale) / std::log(2) + zoom, 0); + const float placementZoom = util::max(util::log2(scale) + zoom, 0.0f); for (const auto& symbol : symbols) { const auto &tl = symbol.tl; @@ -428,9 +427,8 @@ void SymbolLayout::addSymbols(Buffer &buffer, const SymbolQuads &symbols, float const auto &br = symbol.br; const auto &tex = symbol.tex; - float minZoom = - util::max(static_cast<float>(zoom + log(symbol.minScale) / log(2)), placementZoom); - float maxZoom = util::min(static_cast<float>(zoom + log(symbol.maxScale) / log(2)), 25.0f); + float minZoom = util::max(zoom + util::log2(symbol.minScale), placementZoom); + float maxZoom = util::min(zoom + util::log2(symbol.maxScale), util::MAX_ZOOM_F); const auto &anchorPoint = symbol.anchorPoint; // drop upside down versions of glyphs @@ -510,8 +508,8 @@ void SymbolLayout::addToDebugBuffers(CollisionTile& collisionTile, SymbolBucket& bl = util::matrixMultiply(collisionTile.reverseRotationMatrix, bl); br = util::matrixMultiply(collisionTile.reverseRotationMatrix, br); - const float maxZoom = util::clamp(zoom + log(box.maxScale) / log(2), util::MIN_ZOOM, util::MAX_ZOOM); - const float placementZoom = util::clamp(zoom + log(box.placementScale) / log(2), util::MIN_ZOOM, util::MAX_ZOOM); + const float maxZoom = util::clamp(zoom + util::log2(box.maxScale), util::MIN_ZOOM_F, util::MAX_ZOOM_F); + const float placementZoom = util::clamp(zoom + util::log2(box.placementScale), util::MIN_ZOOM_F, util::MAX_ZOOM_F); collisionBox.vertices.emplace_back(anchor.x, anchor.y, tl.x, tl.y, maxZoom, placementZoom); collisionBox.vertices.emplace_back(anchor.x, anchor.y, tr.x, tr.y, maxZoom, placementZoom); |