place symbols with correct angle on initial load
This commit is contained in:
@@ -16,9 +16,10 @@ LiveTileData::LiveTileData(const TileID& id_,
|
||||
GlyphStore& glyphStore_,
|
||||
SpriteAtlas& spriteAtlas_,
|
||||
util::ptr<Sprite> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ public:
|
||||
GlyphStore&,
|
||||
SpriteAtlas&,
|
||||
util::ptr<Sprite>,
|
||||
const SourceInfo&);
|
||||
const SourceInfo&,
|
||||
float);
|
||||
~LiveTileData();
|
||||
|
||||
void parse() override;
|
||||
|
||||
@@ -288,7 +288,7 @@ TileData::State Source::addTile(MapData& data,
|
||||
if (info.type == SourceType::Vector) {
|
||||
new_tile.data =
|
||||
std::make_shared<VectorTileData>(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<RasterTileData>(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<LiveTileData>(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");
|
||||
|
||||
@@ -21,7 +21,8 @@ VectorTileData::VectorTileData(const TileID& id_,
|
||||
GlyphStore& glyphStore_,
|
||||
SpriteAtlas& spriteAtlas_,
|
||||
util::ptr<Sprite> 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<CollisionTile>(id_.z, 4096, source_.tile_size)) {
|
||||
collision(util::make_unique<CollisionTile>(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();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,8 @@ public:
|
||||
GlyphStore&,
|
||||
SpriteAtlas&,
|
||||
util::ptr<Sprite>,
|
||||
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<CollisionTile> collision;
|
||||
|
||||
float lastAngle = 0;
|
||||
float currentAngle = 0;
|
||||
float currentAngle;
|
||||
bool redoingPlacement = false;
|
||||
bool redoWhenDone = false;
|
||||
void endRedoPlacement();
|
||||
void workerRedoPlacement(float angle);
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user