-
Jerome Humbert authored
Ensure change detection on components and assets is only triggered when an animator effectively modifies said component or asset, and not invariably just by the simple fact of the animator ticking each frame. This change modifies the signature of the `component_animator_system()` and `asset_animator_system()` public functions to directly consume a `ResMut<Events<TweenCompleted>>` instead of an `EventWriter<TweenCompleted>`, to work around some internal limitations. It also publicly exposes a new `Targetable` trait used to work around the impossibility to retrieve a `Mut<T>` from a `Mut<Assets<T>>`. Instead, the trait provides an "target dereferencing" method `target_mut()` which dereferences the target component or asset, and triggers its change detection. The trait is implemented for all components via the `ComponentTarget` object, and for all assets via the `AssetTarget` object. The 3 types described here are publicly exposed to workaround some Bevy limitations, and because the trait appears in the public `Tweenable<T>` API. However users are discouraged from taking strong dependencies on those, as they will be removed once Bevy provides a way to achieve this conditionaly dereferencing without this workaround. Fixes #33
Unverifieda3fecb10
- Changelog
- [Unreleased]
- Added
- Changed
- Removed
- Fixed
- [0.5.0] - 2022-08-04
- Added
- Changed
- [0.4.0] - 2022-04-16
- Changed
- [0.3.3] - 2022-03-05
- Added
- [0.3.2] - 2022-02-24
- Added
- Changed
- Removed
- Fixed
- [0.3.1] - 2022-02-12
- Added
- Changed
- Removed
- Fixed
- [0.3.0] - 2022-01-28
- Added
- Fixed
- [0.2.0] - 2022-01-09
- Changed
- Added
- [0.1.0] - 2021-12-24
CHANGELOG.md 9.63 KiB
Changelog
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased]
Added
- Added
RepeatCount
andRepeatStrategy
for more granular control over animation looping. - Added
with_repeat_count()
andwith_repeat_strategy()
builder methods toTween<T>
. - Added a
speed()
getter onAnimator<T>
andAssetAnimator<T>
. - Added
set_elapsed(Duration)
andelapsed() -> Duration
to theTweenable<T>
trait. Those methods are preferable overset_progress()
andprogress()
as they avoid the conversion to floating-point values and any rounding errors. - Added a new
bevy_text
feature forText
-related built-in lenses. - Added
Targetable
,ComponentTarget
, andAssetTarget
, which should be considered private even though they appear in the public API. They are a workaround for Bevy 0.8 and will likely be removed in the future once the related Bevy limitation is lifted.
Changed
- Removed the
tweening_type
parameter from the signature ofTween<T>::new()
; usewith_repeat_count()
andwith_repeat_strategy()
instead. - Animators now always have a tween (instead of it being optional). This means the default animator implementation was removed.
-
Delay::new()
now panics if theduration
is zero. This prevents creating no-opDelay
objects, and avoids an internal edge case producing wrong results. - Tweens moving to
TweenState::Completed
are now guaranteed to freeze their state. In particular, this means that their direction will not flip at the end of the last loop if their repeat strategy isRepeatStrategy::MirroredRepeat
. - Moved the
TextColorLens
lens from thebevy_ui
feature to the newbevy_text
one, to allow using it without the Bevy UI crate. - Changed the signature of the
component_animator_system()
andasset_animator_system()
public functions to directly consume aResMut<Events<TweenCompleted>>
instead of anEventWriter<TweenCompleted>
, to work around some internal limitations.
Removed
- Removed
Tweenable::is_looping()
, which was not implemented for most tweenables. - Removed
TweeningType
in favor ofRepeatCount
andRepeatStrategy
.
Fixed
- Fixed the animator speed feature, which got broken in #44.
- Fixed change detection triggering unconditionally when
component_animator_system()
orasset_animator_system()
are ticked, even when the animator did not mutate its target component or asset. (#33)
[0.5.0] - 2022-08-04
Added
- Added
is_forward()
andis_backward()
convenience helpers toTweeningDirection
. - Added
Tween::set_direction()
andTween::with_direction()
which allow configuring the playback direction of a tween, allowing to play it backward from end to start. - Added support for dynamically changing an animation's speed with
Animator::set_speed
. - Added
AnimationSystem
label to tweening tick systems. - Added a
BoxedTweenable
trait to make working withBox<dyn Tweenable + ...>
easier.
Changed
- Compatible with Bevy 0.8
- Double boxing in
Sequence
andTracks
was fixed. As a result, any custom tweenables should implementFrom
forBoxedTweenable
to make those APIs easier to use.
[0.4.0] - 2022-04-16
Changed
- Compatible with Bevy 0.7
- Better dependencies: Introduced features
bevy_sprite
andbevy_ui
taking a dependency on the same-named crates of Bevy, and removed the forced dependency onbevy/render
. The new features are enabled by default, for discoverability, and only impact the prebuilt lenses. The library now builds without any Bevy optional feature.
[0.3.3] - 2022-03-05
Added
- Added new built-in rotation lenses based on angle interpolation, to allow rotation animations larger than a half turn:
TransformRotateXLens
TransformRotateYLens
TransformRotateZLens
TransformRotateAxisLens
[0.3.2] - 2022-02-24
Added
- Implemented
Default
forTweeningType
(=Once
),EaseMethod
(=Linear
),TweeningDirection
(=Forward
). - Added
Tweenable::is_looping()
,Tweenable::set_progress()
,Tweenable::times_completed()
, andTweenable::rewind()
. - Added
Animator::set_progress()
,Animator::progress()
,Animator::stop()
, andAnimator::rewind()
. - Added
AssetAnimator::set_progress()
,AssetAnimator::progress()
,AssetAnimator::stop()
, andAssetAnimator::rewind()
. - Added the
TweenCompleted
event, raised when aTween<T>
completed its animation if that feature was previously activated withset_completed_event()
orwith_completed_event()
.
Changed
-
TweenState
now contains only two states:Active
andCompleted
. Looping animations are always active, and non-looping ones are completed once they reach their end point. - Merged the
started
andended
callbacks into acompleted
one (Tween::set_completed()
andTween::clear_completed()
), which is invoked when the tween completes a single iteration. That is, for non-looping animations, whenTweenState::Completed
is reached. And for looping animations, once per iteration (going from start -> end, or from end -> start).
Removed
- Removed
Tweenable::stop()
. Tweenables do not have a "stop" state anymore, they are only either active or completed. The playback state is only relevant on theAnimator
orAssetAnimator
which controls them.
Fixed
- Fixed a bug with the alpha value of colored lenses being too large (
TextColorLens
,SpriteColorLens
,ColorMaterialColorLens
).
[0.3.1] - 2022-02-12
Added
- Add user callbacks on tween started (
Tween::set_started
) and ended (Tween::set_ended
). - Implement
Default
forAnimatorState
asAnimatorState::Playing
. - Added
Animator::with_state()
andAssetAnimator::with_state()
, builder-like functions to override the defaultAnimatorState
. - Added
Tween::is_looping()
returning true for all butTweeningType::Once
. - Added the
Tweenable<T>
trait, implemented by theTween<T>
andDelay<T>
animation, and by theTracks<T>
andSequence<T>
animation collections. - Added
IntoBoxDynTweenable<T>
, a trait to convert aTweenable<T>
trait object into a boxed variant. - Publicly exposed
Sequence<T>
, a sequence ofTweenable<T>
running one after the other. - Publicly exposed
Tracks<T>
, a collection ofTweenable<T>
running in parallel. - Publicly exposed
TweenState
, the playback state of a singleTweenable<T>
item. - Added
Tween<T>::then()
andSequence<T>::then()
to append aTweenable<T>
to a sequence (creating a new sequence in the case ofTween<T>::then()
). - Added
tweenable()
andtweenable_mut()
on theAnimator<T>
andAssetAnimator<T>
to access their top-levelTweenable<T>
. - Implemented
Default
forAnimator<T>
andAssetAnimator<T>
, creating an animator without any tweenable item (no-op). - Added
Delay
tweenable for a time delay between other tweens. - Added a new
menu
example demonstrating in particular theDelay
tweenable.
Changed
- Moved tween duration out of the
TweeningType
enum, which combined with the removal of the "pause" feature in loops makes it a C-like enum. - The
Sequence<T>
progress now reports the progress of the total sequence. Individual sub-tweenables cannot be accessed. - Updated the
sequence
example to add some text showing the current sequence progress. - Modified the signature of
new()
forAnimator<T>
andAssetAnimator<T>
to take a singleTweenable<T>
instead of trying to build aTween<T>
internally. This allows passing anyTweenable<T>
as the top-level animatable item of an animator, and avoids the overhead of maintaining aTracks<T>
internally in each animator when the most common use case is likely to use a singleTween<T>
or aSequence<T>
without parallelism.
Removed
- Removed the "pause" feature in-between loops of
TweeningType::Loop
andTweeningType::PingPong
, which can be replaced if needed by a sequence including aDelay
tweenable. RemovedTween::is_paused()
. - Removed
new_single()
andnew_seq()
on theAnimator<T>
andAssetAnimator<T>
. Users should explicitly create aTween<T>
orSequence<T>
instead, and usenew()
.
Fixed
- Fix missing public export of
component_animator_system()
andasset_animator_system()
preventing the animation of all but the built-in items.
[0.3.0] - 2022-01-28
Added
- Add
Tween<T>
describing a single tween animation, independently of its target (asset or component). - Add
Tween<T>::is_paused()
to query when a tweening animation is in its pause phase, if any. - Add
Tween<T>::direction()
to query the playback direction of a tweening animation (forward or backward). - Add
Tween<T>::progress()
to query the progres ratio in [0:1] of a tweening animation. - Enable multiple lenses per animator via "tracks", the ability to add multiple tween animations running in parallel on the same component.
- Enable sequences of tween animations running serially, one after the other, for each track of an animator, allowing to create more complex animations.
Fixed
- Perform spherical linear interpolation (slerp) for
Quat
rotation ofTransform
animation viaTransformRotationLens
, instead of mere linear interpolation leaving the quaternion non-normalized.
[0.2.0] - 2022-01-09
Changed
- Update to Bevy 0.6
- Update to rust edition 2021
- Force Cargo resolver v2
Added
- Added built-in lens
SpriteColorLens
, since the color of aSprite
is now an intrinsic property of the component in Bevy 0.6, and does not useColorMaterial
anymore.
[0.1.0] - 2021-12-24
Initial version for Bevy 0.5