From d812babecd8cfa31e6198bdd83d28e2f80fd240f Mon Sep 17 00:00:00 2001 From: Chris Loer Date: Mon, 10 Dec 2018 14:01:25 -0800 Subject: [PATCH] [core] Avoid divide-by-zero when transition duration is 0.. Fixes issue #13506 -- transition duration of 0 would cause symbol flickering. --- src/mbgl/text/placement.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp index 3b2cf20b7ea..a39106a43df 100644 --- a/src/mbgl/text/placement.cpp +++ b/src/mbgl/text/placement.cpp @@ -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(commitTime - prevPlacement.commitTime) / transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION) : 1.0; @@ -405,7 +407,8 @@ void Placement::updateBucketOpacities(SymbolBucket& bucket, std::set& } 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(now - commitTime) / transitionOptions.duration.value_or(util::DEFAULT_TRANSITION_DURATION); } else { return 1.0;