[core] Placement::commit() handles absence of previuos placement

This commit is contained in:
Mikhail Pozdnyakov
2019-12-05 18:01:10 +02:00
parent ffd378c68e
commit 1829fb5e40
3 changed files with 14 additions and 5 deletions

View File

@@ -427,8 +427,7 @@ std::unique_ptr<RenderTree> RenderOrchestrator::createRenderTree(const UpdatePar
Mutable<Placement> placement = makeMutable<Placement>(updateParameters.transformState,
updateParameters.mode,
updateParameters.transitionOptions,
updateParameters.crossSourceCollisions,
placementController.getPlacement());
updateParameters.crossSourceCollisions);
for (auto it = layersNeedPlacement.crbegin(); it != layersNeedPlacement.crend(); ++it) {
const RenderLayer& layer = *it;
crossTileSymbolIndex.addLayer(layer, updateParameters.transformState.getLatLng().longitude());

View File

@@ -101,6 +101,7 @@ Placement::Placement(const TransformState& state_,
placementZoom(state_.getZoom()),
collisionGroups(crossSourceCollisions),
prevPlacement(std::move(prevPlacement_)) {
assert(prevPlacement || mapMode != MapMode::Continuous);
if (prevPlacement) {
prevPlacement->get()->prevPlacement = nullopt; // Only hold on to one placement back
}
@@ -533,13 +534,22 @@ void Placement::placeBucket(
}
void Placement::commit(TimePoint now, const double zoom) {
assert(getPrevPlacement());
commitTime = now;
if (!getPrevPlacement()) {
assert(mapMode != MapMode::Continuous);
fadeStartTime = commitTime;
for (auto& jointPlacement : placements) {
opacities.emplace(
jointPlacement.first,
JointOpacityState(
jointPlacement.second.text, jointPlacement.second.icon, jointPlacement.second.skipFade));
}
return;
}
bool placementChanged = false;
prevZoomAdjustment = getPrevPlacement()->zoomAdjustment(zoom);
float increment = getPrevPlacement()->symbolFadeChange(commitTime);
// add the opacities from the current placement, and copy their current values from the previous placement

View File

@@ -116,7 +116,7 @@ public:
MapMode,
style::TransitionOptions,
const bool crossSourceCollisions,
optional<Immutable<Placement>> prevPlacement);
optional<Immutable<Placement>> prevPlacement = nullopt);
void placeLayer(const RenderLayer&, const mat4&, bool showCollisionBoxes);
void commit(TimePoint, const double zoom);
void updateLayerBuckets(const RenderLayer&, const TransformState&, bool updateOpacities) const;