summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-07-03 11:32:43 -0700
committerChris Loer <chris.loer@mapbox.com>2018-07-05 11:56:38 -0700
commitc9924ae9d5d6e499267eea3bb9b1092bfd18ddf4 (patch)
treed057d6670706abfe2732d1b6e6c1f098a052dc6e
parentaa07dc5461b575abc527dbc25a0059aaa1c184ed (diff)
downloadqtlocation-mapboxgl-c9924ae9d5d6e499267eea3bb9b1092bfd18ddf4.tar.gz
[core] Only update collision debug data if debug mode is on
Fixes issue #12294: unused debug vertices would pile up in buckets over course of tile's lifetime.
-rw-r--r--src/mbgl/text/placement.cpp42
1 files changed, 27 insertions, 15 deletions
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index 33844e6427..fd0710d959 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -301,24 +301,36 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>&
}
auto updateCollisionBox = [&](const auto& feature, const bool placed) {
+ if (feature.alongLine) {
+ return;
+ }
+ auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(placed, false);
+ for (size_t i = 0; i < feature.boxes.size() * 4; i++) {
+ bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex);
+ }
+ };
+
+ auto updateCollisionCircles = [&](const auto& feature, const bool placed) {
+ if (!feature.alongLine) {
+ return;
+ }
for (const CollisionBox& box : feature.boxes) {
- if (feature.alongLine) {
- auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(placed, !box.used);
- bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
- bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
- bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
- bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
- } else {
- auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(placed, false);
- bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex);
- bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex);
- bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex);
- bucket.collisionBox.dynamicVertices.emplace_back(dynamicVertex);
- }
+ auto dynamicVertex = CollisionBoxDynamicAttributes::vertex(placed, !box.used);
+ bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
+ bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
+ bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
+ bucket.collisionCircle.dynamicVertices.emplace_back(dynamicVertex);
}
};
- updateCollisionBox(symbolInstance.textCollisionFeature, opacityState.text.placed);
- updateCollisionBox(symbolInstance.iconCollisionFeature, opacityState.icon.placed);
+
+ if (bucket.hasCollisionBoxData()) {
+ updateCollisionBox(symbolInstance.textCollisionFeature, opacityState.text.placed);
+ updateCollisionBox(symbolInstance.iconCollisionFeature, opacityState.icon.placed);
+ }
+ if (bucket.hasCollisionCircleData()) {
+ updateCollisionCircles(symbolInstance.textCollisionFeature, opacityState.text.placed);
+ updateCollisionCircles(symbolInstance.iconCollisionFeature, opacityState.icon.placed);
+ }
}
bucket.updateOpacity();