[core] Added special case for atomic flyTo()

startTransition isn’t well-suited to atomic transitions, which are expected to be synchronous and end up at the final state.
This commit is contained in:
Minh Nguyễn
2015-12-17 10:24:58 -08:00
committed by Minh Nguyễn
parent a7e4e6bb1c
commit 986e0ae39e

View File

@@ -373,7 +373,7 @@ void Transform::flyTo(const CameraOptions &options) {
double S = (is_close ? (std::abs(std::log(w1 / w0)) / rho)
: ((r(1) - r0) / rho));
Duration duration = flyOptions.duration ? *flyOptions.duration : Duration::zero();
Duration duration;
if (flyOptions.duration) {
duration = *flyOptions.duration;
} else {
@@ -381,6 +381,11 @@ void Transform::flyTo(const CameraOptions &options) {
duration = std::chrono::duration_cast<std::chrono::steady_clock::duration>(
std::chrono::duration<double, std::chrono::seconds::period>(S / speed));
}
if (duration == Duration::zero()) {
// Atomic transition.
jumpTo(options);
return;
}
startTransition(
[=](double t) {
util::UnitBezier ease = flyOptions.easing ? *flyOptions.easing : util::UnitBezier(0, 0, 0.25, 1);