Skip to content

Commit 06e7a0e

Browse files
committed
modify the transform implementation to allow for concurrent animations
The previous implementation of the transform class overrides the current animation with the new one. This new implmentation changes that to allow for concurrent transformations to occur for different types of transfomrations at the same time. For example, you can have two concurrent animations where one modifies the zoom while the other modifies the position of the camera without overriding the other. This change is necessary to allow for concurrent camera animations during navigation.
1 parent 8e3899d commit 06e7a0e

File tree

3 files changed

+312
-172
lines changed

3 files changed

+312
-172
lines changed

include/mbgl/map/camera.hpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,34 @@ struct FreeCameraOptions {
156156
void setPitchBearing(double pitch, double bearing) noexcept;
157157
};
158158

159+
struct PropertyAnimation {
160+
TimePoint start;
161+
Duration duration;
162+
AnimationOptions animation;
163+
bool ran = false, finished = false, done = false;
164+
bool panning = false, scaling = false, rotating = false;
165+
166+
PropertyAnimation(
167+
TimePoint start_, Duration duration_, AnimationOptions animation_, bool panning_, bool scaling_, bool rotating_)
168+
: start(start_),
169+
duration(duration_),
170+
animation(animation_),
171+
panning(panning_),
172+
scaling(scaling_),
173+
rotating(rotating_) {}
174+
175+
double t(TimePoint now) {
176+
bool isAnimated = duration != Duration::zero();
177+
double t = isAnimated ? (std::chrono::duration<double>(now - start) / duration) : 1.0f;
178+
if (t >= 1.0) {
179+
return 1.0;
180+
}
181+
182+
util::UnitBezier ease = animation.easing ? *animation.easing : util::DEFAULT_TRANSITION_EASE;
183+
return ease.solve(t, 0.001);
184+
}
185+
186+
bool isAnimated() const { return duration != Duration::zero(); }
187+
};
188+
159189
} // namespace mbgl

0 commit comments

Comments
 (0)