Open cart opened 2 days ago
I'd like to land this in 0.15 as it:
There are a few things that I would do differently here.
First, I would define a getter and setter rather than returning a mutable field. This would allow the property being animated to be a simplified abstraction of the underlying property. So for example, I could animate rotation_x as an angle instead of having to deal with a quat - the conversion from angle to quat could be done in the AnimatableProperty impl. Similarly, I could animate scale as a scalar affecting all dimensions instead of separate scale_x, scale_y, scale_z.
See also the discussion in #15725 - there's a difference between "keyframe" curves and "transition" curves (my terms, perhaps there's a better way of describing this), in that the animation target can change in mid-animation (like a button which inflates when hovered, but the mouse quickly enters and leaves, giving no time for the animation to complete). In thee cases, you want to avoid an ugly jump from resetting the animation back to start, and instead start the animation from whatever the current state is.
Objective
Animating component properties requires too much boilerplate at the moment:
Solution
This adds
AnimatedProperty
andAnimatedPropertyOptional
, enabling the following:This required reworking the internals a bit, namely stripping out a lot of the
Reflect
usage, as that implementation was fundamentally incompatible with theAnimatedProperty
pattern.Reflect
was being used in this context just to downcast traits. But we can get downcasting behavior without theReflect
requirement by implementingDowncast
forAnimationCurveEvaluator
.