Skip to content

Commit

Permalink
show labels only if they are not hidden later
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrich-ubique committed Jan 22, 2024
1 parent 633e5cf commit 5790949
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 32 deletions.
17 changes: 7 additions & 10 deletions shared/public/CollisionGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,32 +98,29 @@ class CollisionGrid {
}
}
}

bool collision = false;
for (int16_t y = indexRange.yMin; y <= indexRange.yMax; y++) {
for (int16_t x = indexRange.xMin; x <= indexRange.xMax; x++) {
if (!collision) {
for (const auto &rect : gridRects[y][x]) {
if (CollisionUtil::checkRectCollision(projectedRectangle, rect)) {
return 1;
collision = true;
}
}
for (const auto &circle : gridCircles[y][x]) {
if (CollisionUtil::checkRectCircleCollision(projectedRectangle, circle)) {
return 1;
collision = true;
}
}

}
}

// Only insert, when not colliding
for (int16_t y = indexRange.yMin; y <= indexRange.yMax; y++) {
for (int16_t x = indexRange.xMin; x <= indexRange.xMax; x++) {
}
gridRects[y][x].push_back(projectedRectangle);
}
}

if (rectangle.contentHash != 0 && rectangle.symbolSpacing > 0) {
spacedRects[rectangle.contentHash].push_back(projectedRectangle);
}
if (collision) return 1;
return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ class SymbolObjectCollisionWrapper {
}

bool operator<(const SymbolObjectCollisionWrapper &o) const {
if (isColliding != o.isColliding) {
return isColliding;
}
if (symbolObject->smallestVisibleZoom != o.symbolObject->smallestVisibleZoom) {
return symbolObject->smallestVisibleZoom > o.symbolObject->smallestVisibleZoom;
}
if (symbolSortKey == o.symbolSortKey) {
return symbolTileIndex > o.symbolTileIndex;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,22 +627,10 @@ void Tiled2dMapVectorSourceSymbolDataManager::collisionDetection(std::vector<std
const auto objectsIt = symbolGroupsMap.find(layerIdentifier);
if (objectsIt != symbolGroupsMap.end()) {
for (auto &symbolGroup: std::get<1>(objectsIt->second)) {
symbolGroup.syncAccess([&allObjects, zoomIdentifier, persistingPlacement = persistingSymbolPlacement](auto group){
const auto &objects = group->getSymbolObjectsForCollision();
if (persistingPlacement) {
for (auto &object : objects) {
if (object.symbolObject->largestCollisionZoom == -1 || object.symbolObject->largestCollisionZoom < zoomIdentifier) {
allObjects.push_back(object);
}
else {
object.symbolObject->setHideFromCollision(true);
}
}
} else {
for(auto& o : objects) {
allObjects.push_back(o);
}
}
symbolGroup.syncAccess([&allObjects, zoomIdentifier](auto group){
auto objects = group->getSymbolObjectsForCollision();
allObjects.reserve(allObjects.size() + objects.size());
allObjects.insert(allObjects.end(), std::make_move_iterator(objects.begin()), std::make_move_iterator(objects.end()));
});
}
}
Expand Down

0 comments on commit 5790949

Please sign in to comment.