diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-20 00:51:33 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2016-10-25 08:12:31 +0300 |
commit | 679bfbfb32d6371d6eb405b5e465353c53298c41 (patch) | |
tree | 262d7f27a10790571fdfcca32d0afaaee7d61cc2 /src | |
parent | 846e57de586355c80ff488fc7fd4f7b9462b465d (diff) | |
download | qtlocation-mapboxgl-679bfbfb32d6371d6eb405b5e465353c53298c41.tar.gz |
[core] Simplify CollisionTile::findPlacementScale
Improve findPlacementScale semantics by moving the check if the
placement scale result is bigger than minimum scale out of the function
scope.
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/text/collision_tile.cpp | 12 | ||||
-rw-r--r-- | src/mbgl/text/collision_tile.hpp | 2 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/mbgl/text/collision_tile.cpp b/src/mbgl/text/collision_tile.cpp index aa83cbae44..2fea819aaa 100644 --- a/src/mbgl/text/collision_tile.cpp +++ b/src/mbgl/text/collision_tile.cpp @@ -27,9 +27,8 @@ CollisionTile::CollisionTile(PlacementConfig config_) : config(std::move(config_ } -float CollisionTile::findPlacementScale(float minPlacementScale, const Point<float>& anchor, - const CollisionBox& box, const Point<float>& blockingAnchor, const CollisionBox& blocking) { - +float CollisionTile::findPlacementScale(const Point<float>& anchor, const CollisionBox& box, const Point<float>& blockingAnchor, const CollisionBox& blocking) { + float minPlacementScale = minScale; // Find the lowest scale at which the two boxes can fit side by side without overlapping. // Original algorithm: @@ -90,7 +89,7 @@ float CollisionTile::placeFeature(const CollisionFeature& feature, bool allowOve const CollisionBox& blocking = std::get<1>(*it); Point<float> blockingAnchor = util::matrixMultiply(rotationMatrix, blocking.anchor); - minPlacementScale = findPlacementScale(minPlacementScale, anchor, box, blockingAnchor, blocking); + minPlacementScale = util::max(minPlacementScale, findPlacementScale(anchor, box, blockingAnchor, blocking)); if (minPlacementScale >= maxScale) return minPlacementScale; } } @@ -108,8 +107,7 @@ float CollisionTile::placeFeature(const CollisionFeature& feature, bool allowOve box.maxScale); for (auto& blocking : edges) { - minPlacementScale = findPlacementScale(minPlacementScale, box.anchor, rotatedBox, blocking.anchor, blocking); - + minPlacementScale = util::max(minPlacementScale, findPlacementScale(box.anchor, rotatedBox, blocking.anchor, blocking)); if (minPlacementScale >= maxScale) return minPlacementScale; } } @@ -179,7 +177,7 @@ std::vector<IndexedSubfeature> CollisionTile::queryRenderedSymbols(const Geometr result.push_back(indexedFeature); } else { auto blockingAnchor = util::matrixMultiply(rotationMatrix, blocking.anchor); - float minPlacementScale = findPlacementScale(minScale, anchor, queryBox, blockingAnchor, blocking); + float minPlacementScale = findPlacementScale(anchor, queryBox, blockingAnchor, blocking); if (minPlacementScale >= scale) { seenFeatures.insert(indexedFeature.index); result.push_back(indexedFeature); diff --git a/src/mbgl/text/collision_tile.hpp b/src/mbgl/text/collision_tile.hpp index a2c5220fce..186cd19d28 100644 --- a/src/mbgl/text/collision_tile.hpp +++ b/src/mbgl/text/collision_tile.hpp @@ -54,7 +54,7 @@ public: std::array<float, 4> reverseRotationMatrix; private: - float findPlacementScale(float minPlacementScale, + float findPlacementScale( const Point<float>& anchor, const CollisionBox& box, const Point<float>& blockingAnchor, const CollisionBox& blocking); Box getTreeBox(const Point<float>& anchor, const CollisionBox& box, const float scale = 1.0); |