-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animation Primitives #49
base: main
Are you sure you want to change the base?
Conversation
Ping @lassade; I'm very curious on your opinions on this if you have the time and interest. |
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I'm very impressed. These are good abstractions that are powerful, flexible and build on each other.
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
a few notes
|
In the storage domain you should include how streamed data will be handled and at mention available animation formats namely ACL (https://github.com/nfrechette/acl) in the prior art. |
Almost completely revised the RFC end to end:
Still quite a few TODOs, namely discussing a strategy for implementing To respond to @lassade's comments (next time please leave them inline so I can address them 1-by-1 instead of a giant block like this).
Good point, retracted that idea after discussing this with you on Discord and reading your
I'm tentatively addressing this by trying to use a newtype and implement
This can be addressed by the newtype pattern that I mentioned above. Though I'm curious why we wouldn't want to use slerp other than performance.
Right, and that's sort of an implementation detail that we need to address, and is sort of separate from the design detailed here. I'm well aware this is an issue, but it's something we need to resolve in general, not just for animation.
I added a section on this, though I'm not 100% sold on it. After reading your implementation, I get the distinct impression that this very heavily complicates the implementation as the cursor must be mutably saved somewhere, and you might have the same curve/clip being sampled in different locations by multiple entities (or even within the same entity). That's not to say I think we should definitely not add it in, but it does seem like an optimization we can add in after we deliver a MVP on this.
Great point! Added that a mention of ACL in. I need to rewrite that section to mention the other efforts in the Rust community and other public literature about the approaches to this. |
# Objective - Add a basic animation player - Single track - Not generic, can only animate `Transform`s - With plenty of possible optimisations available - Close-ish to bevyengine/rfcs#49 - https://discord.com/channels/691052431525675048/774027865020039209/958820063148929064 ## Solution - Can play animations - looping or not - Can pause animations - Can seek in animation - Can alter speed of animation - I also removed the previous gltf animation example https://user-images.githubusercontent.com/8672791/161051887-e79283f0-9803-448a-93d0-5f7a62acb02d.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me this looks like flexible and powerful primitives to build on top of. I particularly like how this would build animation in bevy from the ground up to be able to animate anything and not just skeletal animation.
- Obvious outstanding TODOs
- Don't feel I have enough experience to give feedback on the suggested technical implementation details
- It is clearly and concisely written, so even with limited technical knowledge it is easy to read and understand
Overall this is great work, thank you!
Looking at the curve system as explained in the RFC, it reminds me of how Godot does animations, specifically how Godot lets you animate literally everything including UI all using the same UI graph. I'm wondering, will the Curve syntax work for everything, or only for certain things like skeletal animation? |
# Objective - Add a basic animation player - Single track - Not generic, can only animate `Transform`s - With plenty of possible optimisations available - Close-ish to bevyengine/rfcs#49 - https://discord.com/channels/691052431525675048/774027865020039209/958820063148929064 ## Solution - Can play animations - looping or not - Can pause animations - Can seek in animation - Can alter speed of animation - I also removed the previous gltf animation example https://user-images.githubusercontent.com/8672791/161051887-e79283f0-9803-448a-93d0-5f7a62acb02d.mp4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the concept, I'm going to think about it for a bit but here are a couple of nitpick-y grammar/etc.
A curve always covers the time range of `[0, duration]`, but must return valid | ||
values when sampled at any non-negative time. What a curve does beyond this range | ||
is implementation specifc. This typically will just return the value that would | ||
be sampled at time 0 or `duration`, whichever is closer, but it doesn't have to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it can only be sampled with non-negative time then wouldn't it only be clamped to duration
here?
buffer like `Vec<T>`. However, it stores the exact keyframe times in a parallel | ||
`Vec<T>`, allowing for the time between keyframes to be variable. This comes at a | ||
cost: sampling the curve requires performing a binary search to find the | ||
surroudning keyframe before sampling a value from the curve itself. This can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
surroudning keyframe before sampling a value from the curve itself. This can | |
surrounding keyframe before sampling a value from the curve itself. This can |
rfcs/49-animation-primitives.md
Outdated
of keyframes and the representation of said keyframes, and a typical game with | ||
multiple character animations may several hundreds or thousands of curves to | ||
sample from. To both help cut down on memory usage and minimize cache misses, | ||
it's useful to compress the most usecases seen by a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's useful to compress the most usecases seen by a | |
it's useful to compress the usecases most likely to be seen by a user. |
A rough outline of how such a `PropertyPath` struct might look like: | ||
|
||
```rust | ||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, ParitialOrd)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, ParitialOrd)] | |
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)] |
parts: Box<[Name]>, | ||
} | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, ParitialOrd)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, ParitialOrd)] | |
#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)] |
PropertyPaths are written out as raw strings, and parsed on deserialization. | ||
|
||
### `AnimationClip` | ||
A `AnimationClip` is a serializable asset type that encompasses a mapping of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A `AnimationClip` is a serializable asset type that encompasses a mapping of | |
An `AnimationClip` is a serializable asset type that encompasses a mapping of |
Bevy absolutely needs some form of a first-party animation system, no modern game | ||
engine can be called production ready without one. Having this exist solely as a | ||
third-party ecosystem crate is unacceptable as it would promote a | ||
facturing of the ecosystem with multiple incompatible baseline animation system |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
facturing of the ecosystem with multiple incompatible baseline animation system | |
fracturing of the ecosystem with multiple incompatible baseline animation system |
|
||
## Unresolved questions | ||
- Can we safely interleave multiple curves together so that we do not incur | ||
mulitple cache misses when sampling from animation clips? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mulitple cache misses when sampling from animation clips? | |
multiple cache misses when sampling from animation clips? |
# Objective - Fixes #6338 This PR allows for smooth transitions between different animations. ## Solution - This PR uses very simple linear blending of animations. - When starting a new animation, you can give it a duration, and throughout that duration, the previous and the new animation are being linearly blended, until only the new animation is running. - I'm aware of bevyengine/rfcs#49 and bevyengine/rfcs#51, which are more complete solutions to this problem, but they seem still far from being implemented. Until they're ready, this PR allows for the most basic use case of blending, i.e. smoothly transitioning between different animations. ## Migration Guide - no bc breaking changes
# Objective - Fixes bevyengine#6338 This PR allows for smooth transitions between different animations. ## Solution - This PR uses very simple linear blending of animations. - When starting a new animation, you can give it a duration, and throughout that duration, the previous and the new animation are being linearly blended, until only the new animation is running. - I'm aware of bevyengine/rfcs#49 and bevyengine/rfcs#51, which are more complete solutions to this problem, but they seem still far from being implemented. Until they're ready, this PR allows for the most basic use case of blending, i.e. smoothly transitioning between different animations. ## Migration Guide - no bc breaking changes
# Objective - Fixes bevyengine#6338 This PR allows for smooth transitions between different animations. ## Solution - This PR uses very simple linear blending of animations. - When starting a new animation, you can give it a duration, and throughout that duration, the previous and the new animation are being linearly blended, until only the new animation is running. - I'm aware of bevyengine/rfcs#49 and bevyengine/rfcs#51, which are more complete solutions to this problem, but they seem still far from being implemented. Until they're ready, this PR allows for the most basic use case of blending, i.e. smoothly transitioning between different animations. ## Migration Guide - no bc breaking changes
# Objective - Fixes bevyengine#6338 This PR allows for smooth transitions between different animations. ## Solution - This PR uses very simple linear blending of animations. - When starting a new animation, you can give it a duration, and throughout that duration, the previous and the new animation are being linearly blended, until only the new animation is running. - I'm aware of bevyengine/rfcs#49 and bevyengine/rfcs#51, which are more complete solutions to this problem, but they seem still far from being implemented. Until they're ready, this PR allows for the most basic use case of blending, i.e. smoothly transitioning between different animations. ## Migration Guide - no bc breaking changes
# Objective - Add a basic animation player - Single track - Not generic, can only animate `Transform`s - With plenty of possible optimisations available - Close-ish to bevyengine/rfcs#49 - https://discord.com/channels/691052431525675048/774027865020039209/958820063148929064 ## Solution - Can play animations - looping or not - Can pause animations - Can seek in animation - Can alter speed of animation - I also removed the previous gltf animation example https://user-images.githubusercontent.com/8672791/161051887-e79283f0-9803-448a-93d0-5f7a62acb02d.mp4
I might be a couple years late to the party here, but I have some thoughts on In investigating matters related to, e.g. mesh generation by curve extrusion, I have also come up against curve sampling and similar questions related to what appear here as
Notably, for curves constructed by splines, (1) is available algebraically (hence for arbitrary parameter values with no interpolation necessary), while (2) and (3) must generally be constructed by sampling (although for some simple classes of curves they could also be algebraic). Here are what I see as the main differences:
I think the good news is that these differences are mostly easy to accommodate. For the first, it is not really much of a rift, as long as the For the third, I see this mostly as creating difficulties when serializing and deserializing. For example, something like type erasing the underlying algebraic structure, if necessary, could require passage from exact information to discrete samples; luckily, if we come to that bridge, the other kinds of data that we need are still "compatible" in the sense that they could be recomputed from discrete data anyway (that is to say that RMF, for instance, really only needs a The second is where I wanted to raise a minor point. I am against the exact definition of
I think that this would provide a solid common baseline (at least at the level of API) for the distinct areas. (By the way, thank you for writing this, and sorry if I am verbose.) |
# Objective - Add a basic animation player - Single track - Not generic, can only animate `Transform`s - With plenty of possible optimisations available - Close-ish to bevyengine/rfcs#49 - https://discord.com/channels/691052431525675048/774027865020039209/958820063148929064 ## Solution - Can play animations - looping or not - Can pause animations - Can seek in animation - Can alter speed of animation - I also removed the previous gltf animation example https://user-images.githubusercontent.com/8672791/161051887-e79283f0-9803-448a-93d0-5f7a62acb02d.mp4
RENDERED
This RFC details the absolute bare minimum viable API for setting up a flexible and extendable property based animation system in Bevy... or at least part of it. This gets probably about 1/3 of the way there.