diff --git a/src/mbgl/map/live_tile_data.cpp b/src/mbgl/map/live_tile_data.cpp index 59f7b4de3..54b394890 100644 --- a/src/mbgl/map/live_tile_data.cpp +++ b/src/mbgl/map/live_tile_data.cpp @@ -16,9 +16,10 @@ LiveTileData::LiveTileData(const TileID& id_, GlyphStore& glyphStore_, SpriteAtlas& spriteAtlas_, util::ptr sprite_, - const SourceInfo& source_) + const SourceInfo& source_, + float angle_) : VectorTileData::VectorTileData(id_, mapMaxZoom, style_, glyphAtlas_, glyphStore_, - spriteAtlas_, sprite_, source_), + spriteAtlas_, sprite_, source_, angle_), annotationManager(annotationManager_) { // live features are always ready setState(State::loaded); @@ -53,5 +54,6 @@ void LiveTileData::parse() { if (getState() != State::obsolete) { setState(State::parsed); + redoPlacement(); } } diff --git a/src/mbgl/map/live_tile_data.hpp b/src/mbgl/map/live_tile_data.hpp index e56a7bf7e..c237cddc9 100644 --- a/src/mbgl/map/live_tile_data.hpp +++ b/src/mbgl/map/live_tile_data.hpp @@ -17,7 +17,8 @@ public: GlyphStore&, SpriteAtlas&, util::ptr, - const SourceInfo&); + const SourceInfo&, + float); ~LiveTileData(); void parse() override; diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index 7ab089460..01057103e 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -288,7 +288,7 @@ TileData::State Source::addTile(MapData& data, if (info.type == SourceType::Vector) { new_tile.data = std::make_shared(normalized_id, data.transform.getMaxZoom(), style, glyphAtlas, - glyphStore, spriteAtlas, sprite, info); + glyphStore, spriteAtlas, sprite, info, transformState.getAngle()); new_tile.data->request(style.workers, transformState.getPixelRatio(), callback); } else if (info.type == SourceType::Raster) { new_tile.data = std::make_shared(normalized_id, texturePool, info); @@ -296,7 +296,7 @@ TileData::State Source::addTile(MapData& data, } else if (info.type == SourceType::Annotations) { new_tile.data = std::make_shared(normalized_id, data.annotationManager, data.transform.getMaxZoom(), style, glyphAtlas, - glyphStore, spriteAtlas, sprite, info); + glyphStore, spriteAtlas, sprite, info, transformState.getAngle()); new_tile.data->reparse(style.workers, callback); } else { throw std::runtime_error("source type not implemented"); diff --git a/src/mbgl/map/vector_tile_data.cpp b/src/mbgl/map/vector_tile_data.cpp index f8a928024..312dde7f5 100644 --- a/src/mbgl/map/vector_tile_data.cpp +++ b/src/mbgl/map/vector_tile_data.cpp @@ -21,7 +21,8 @@ VectorTileData::VectorTileData(const TileID& id_, GlyphStore& glyphStore_, SpriteAtlas& spriteAtlas_, util::ptr sprite_, - const SourceInfo& source_) + const SourceInfo& source_, + float angle) : TileData(id_, source_), depth(id_.z >= source_.max_zoom ? mapMaxZoom - id_.z : 1), glyphAtlas(glyphAtlas_), @@ -29,7 +30,9 @@ VectorTileData::VectorTileData(const TileID& id_, spriteAtlas(spriteAtlas_), sprite(sprite_), style(style_), - collision(util::make_unique(id_.z, 4096, source_.tile_size)) { + collision(util::make_unique(id_.z, 4096, source_.tile_size, angle)), + lastAngle(angle), + currentAngle(angle) { } VectorTileData::~VectorTileData() { @@ -61,6 +64,7 @@ void VectorTileData::parse() { setState(State::partial); } else { setState(State::parsed); + redoPlacement(); } } catch (const std::exception& ex) { Log::Error(Event::ParseTile, "Parsing [%d/%d/%d] failed: %s", id.z, id.x, id.y, ex.what()); @@ -111,14 +115,15 @@ void VectorTileData::setState(const State& state_) { } } +void VectorTileData::redoPlacement() { + redoPlacement(lastAngle); +} + void VectorTileData::redoPlacement(float angle) { if (angle != currentAngle) { lastAngle = angle; - if (getState() != State::parsed || redoingPlacement) { - redoWhenDone = true; - return; - } + if (getState() != State::parsed || redoingPlacement) return; redoingPlacement = true; currentAngle = angle; @@ -147,8 +152,5 @@ void VectorTileData::endRedoPlacement() { } } redoingPlacement = false; - if (redoWhenDone) { - redoPlacement(lastAngle); - redoWhenDone = false; - } + redoPlacement(); } diff --git a/src/mbgl/map/vector_tile_data.hpp b/src/mbgl/map/vector_tile_data.hpp index 2cf419079..eea353bd9 100644 --- a/src/mbgl/map/vector_tile_data.hpp +++ b/src/mbgl/map/vector_tile_data.hpp @@ -39,7 +39,8 @@ public: GlyphStore&, SpriteAtlas&, util::ptr, - const SourceInfo&); + const SourceInfo&, + float); ~VectorTileData(); void parse() override; @@ -58,6 +59,8 @@ public: const float depth; protected: + void redoPlacement(); + // Holds the actual geometries in this tile. FillVertexBuffer fillVertexBuffer; LineVertexBuffer lineVertexBuffer; @@ -84,9 +87,8 @@ private: std::unique_ptr collision; float lastAngle = 0; - float currentAngle = 0; + float currentAngle; bool redoingPlacement = false; - bool redoWhenDone = false; void endRedoPlacement(); void workerRedoPlacement(float angle); }; diff --git a/src/mbgl/text/collision_tile.hpp b/src/mbgl/text/collision_tile.hpp index a3f524ca9..d010353fb 100644 --- a/src/mbgl/text/collision_tile.hpp +++ b/src/mbgl/text/collision_tile.hpp @@ -34,8 +34,8 @@ namespace mbgl { class CollisionTile { public: - inline explicit CollisionTile(float _zoom, float tileExtent, float tileSize) : - zoom(_zoom), tilePixelRatio(tileExtent / tileSize) { reset(0, 0); } + inline explicit CollisionTile(float _zoom, float tileExtent, float tileSize, float angle_) : + zoom(_zoom), tilePixelRatio(tileExtent / tileSize) { reset(angle_, 0); } void reset(const float angle, const float pitch); float placeFeature(const CollisionFeature &feature);