diff options
Diffstat (limited to 'src/mbgl/text/placement.cpp')
-rw-r--r-- | src/mbgl/text/placement.cpp | 42 |
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(); |