[core] Cleanup in response to review comments
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
namespace mbgl {
|
||||
|
||||
FeatureIndex::FeatureIndex()
|
||||
: grid(util::EXTENT, util::EXTENT, util::EXTENT >> 5) {
|
||||
: grid(util::EXTENT, util::EXTENT, util::EXTENT / 16) { // 16x16 grid -> 32px cell
|
||||
}
|
||||
|
||||
void FeatureIndex::insert(const GeometryCollection& geometries,
|
||||
|
||||
@@ -17,51 +17,48 @@ class SymbolInstance;
|
||||
class RenderSymbolLayer;
|
||||
class SymbolBucket;
|
||||
|
||||
class IndexEntry {
|
||||
Point<float> anchorPoint;
|
||||
|
||||
};
|
||||
|
||||
class IndexedSymbolInstance {
|
||||
public:
|
||||
IndexedSymbolInstance(uint32_t crossTileID_, Point<int64_t> coord_)
|
||||
: crossTileID(crossTileID_), coord(coord_) {};
|
||||
uint32_t crossTileID;
|
||||
Point<int64_t> coord;
|
||||
public:
|
||||
IndexedSymbolInstance(uint32_t crossTileID_, Point<int64_t> coord_)
|
||||
: crossTileID(crossTileID_), coord(coord_)
|
||||
{}
|
||||
|
||||
uint32_t crossTileID;
|
||||
Point<int64_t> coord;
|
||||
};
|
||||
|
||||
class TileLayerIndex {
|
||||
public:
|
||||
TileLayerIndex(OverscaledTileID coord, std::vector<SymbolInstance>&, uint32_t bucketInstanceId);
|
||||
public:
|
||||
TileLayerIndex(OverscaledTileID coord, std::vector<SymbolInstance>&, uint32_t bucketInstanceId);
|
||||
|
||||
Point<int64_t> getScaledCoordinates(SymbolInstance&, const OverscaledTileID&);
|
||||
void findMatches(std::vector<SymbolInstance>&, const OverscaledTileID&);
|
||||
|
||||
OverscaledTileID coord;
|
||||
uint32_t bucketInstanceId;
|
||||
std::map<std::u16string,std::vector<IndexedSymbolInstance>> indexedSymbolInstances;
|
||||
Point<int64_t> getScaledCoordinates(SymbolInstance&, const OverscaledTileID&);
|
||||
void findMatches(std::vector<SymbolInstance>&, const OverscaledTileID&);
|
||||
|
||||
OverscaledTileID coord;
|
||||
uint32_t bucketInstanceId;
|
||||
std::map<std::u16string,std::vector<IndexedSymbolInstance>> indexedSymbolInstances;
|
||||
};
|
||||
|
||||
class CrossTileSymbolLayerIndex {
|
||||
public:
|
||||
CrossTileSymbolLayerIndex();
|
||||
void addBucket(const OverscaledTileID&, SymbolBucket&);
|
||||
bool removeStaleBuckets(const std::unordered_set<uint32_t>& currentIDs);
|
||||
private:
|
||||
std::map<uint8_t,std::map<OverscaledTileID,TileLayerIndex>> indexes;
|
||||
uint32_t maxBucketInstanceId = 0;
|
||||
static uint32_t maxCrossTileID;
|
||||
public:
|
||||
CrossTileSymbolLayerIndex();
|
||||
void addBucket(const OverscaledTileID&, SymbolBucket&);
|
||||
bool removeStaleBuckets(const std::unordered_set<uint32_t>& currentIDs);
|
||||
private:
|
||||
std::map<uint8_t,std::map<OverscaledTileID,TileLayerIndex>> indexes;
|
||||
uint32_t maxBucketInstanceId = 0;
|
||||
static uint32_t maxCrossTileID;
|
||||
};
|
||||
|
||||
class CrossTileSymbolIndex {
|
||||
public:
|
||||
CrossTileSymbolIndex();
|
||||
public:
|
||||
CrossTileSymbolIndex();
|
||||
|
||||
bool addLayer(RenderSymbolLayer&);
|
||||
|
||||
void reset();
|
||||
private:
|
||||
std::map<std::string,CrossTileSymbolLayerIndex> layerIndexes;
|
||||
bool addLayer(RenderSymbolLayer&);
|
||||
|
||||
void reset();
|
||||
private:
|
||||
std::map<std::string, CrossTileSymbolLayerIndex> layerIndexes;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -185,7 +185,7 @@ bool Placement::commit(const Placement& prevPlacement, TimePoint now) {
|
||||
}
|
||||
|
||||
void Placement::updateLayerOpacities(RenderSymbolLayer& symbolLayer) {
|
||||
std::unordered_set<uint32_t> seenCrossTileIDs;
|
||||
std::set<uint32_t> seenCrossTileIDs;
|
||||
for (RenderTile& renderTile : symbolLayer.renderTiles) {
|
||||
if (!renderTile.tile.isRenderable()) {
|
||||
continue;
|
||||
@@ -198,7 +198,7 @@ void Placement::updateLayerOpacities(RenderSymbolLayer& symbolLayer) {
|
||||
}
|
||||
}
|
||||
|
||||
void Placement::updateBucketOpacities(SymbolBucket& bucket, std::unordered_set<uint32_t>& seenCrossTileIDs) {
|
||||
void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>& seenCrossTileIDs) {
|
||||
if (bucket.hasTextData()) bucket.text.opacityVertices.clear();
|
||||
if (bucket.hasIconData()) bucket.icon.opacityVertices.clear();
|
||||
if (bucket.hasCollisionBoxData()) bucket.collisionBox.dynamicVertices.clear();
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace mbgl {
|
||||
const bool showCollisionBoxes,
|
||||
std::unordered_set<uint32_t>& seenCrossTileIDs);
|
||||
|
||||
void updateBucketOpacities(SymbolBucket&, std::unordered_set<uint32_t>&);
|
||||
void updateBucketOpacities(SymbolBucket&, std::set<uint32_t>&);
|
||||
|
||||
CollisionIndex collisionIndex;
|
||||
|
||||
@@ -72,8 +72,8 @@ namespace mbgl {
|
||||
MapMode mapMode;
|
||||
TimePoint commitTime;
|
||||
|
||||
std::unordered_map<uint32_t,PlacementPair> placements;
|
||||
std::unordered_map<uint32_t,JointOpacityState> opacities;
|
||||
std::unordered_map<uint32_t, PlacementPair> placements;
|
||||
std::unordered_map<uint32_t, JointOpacityState> opacities;
|
||||
|
||||
TimePoint recentUntil;
|
||||
bool stale = false;
|
||||
|
||||
@@ -118,8 +118,8 @@ void GeometryTile::setLayers(const std::vector<Immutable<Layer::Impl>>& layers)
|
||||
|
||||
void GeometryTile::setShowCollisionBoxes(const bool showCollisionBoxes_) {
|
||||
if (showCollisionBoxes != showCollisionBoxes_) {
|
||||
showCollisionBoxes = showCollisionBoxes_;
|
||||
++correlationID;
|
||||
showCollisionBoxes = showCollisionBoxes_;
|
||||
++correlationID;
|
||||
worker.invoke(&GeometryTileWorker::setShowCollisionBoxes, showCollisionBoxes, correlationID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,12 +128,12 @@ void GridIndex<T>::query(const BBox& queryBBox, std::function<bool (const T&, co
|
||||
for (auto& element : boxElements) {
|
||||
if (resultFn(element.first, element.second)) {
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
for (auto& element : circleElements) {
|
||||
if (resultFn(element.first, convertToBox(element.second))) {
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -189,16 +189,15 @@ void GridIndex<T>::query(const BCircle& queryBCircle, std::function<bool (const
|
||||
if (noIntersection(queryBBox)) {
|
||||
return;
|
||||
} else if (completeIntersection(queryBBox)) {
|
||||
// TODO: std::for_each?
|
||||
for (auto& element : boxElements) {
|
||||
if (resultFn(element.first, element.second)) {
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
for (auto& element : circleElements) {
|
||||
if (resultFn(element.first, convertToBox(element.second))) {
|
||||
return;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user