Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[core] Avoid divide-by-zero when transition duration is 0..
Browse files Browse the repository at this point in the history
Fixes issue #13506 -- transition duration of 0 would cause symbol flickering.
  • Loading branch information
ChrisLoer committed Dec 11, 2018
1 parent 662a495 commit d812bab
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mbgl/text/placement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ void Placement::commit(const Placement& prevPlacement, TimePoint now) {

bool placementChanged = false;

float increment = mapMode == MapMode::Continuous && transitionOptions.enablePlacementTransitions ?
float increment = mapMode == MapMode::Continuous &&
transitionOptions.enablePlacementTransitions &&
transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION) > Milliseconds(0) ?
std::chrono::duration<float>(commitTime - prevPlacement.commitTime) / transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION) :
1.0;

Expand Down Expand Up @@ -405,7 +407,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set<uint32_t>&
}

float Placement::symbolFadeChange(TimePoint now) const {
if (mapMode == MapMode::Continuous && transitionOptions.enablePlacementTransitions) {
if (mapMode == MapMode::Continuous && transitionOptions.enablePlacementTransitions &&
transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION) > Milliseconds(0)) {
return std::chrono::duration<float>(now - commitTime) / transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION);
} else {
return 1.0;
Expand Down

0 comments on commit d812bab

Please sign in to comment.