mbrea-c / bevy_animation_graph

Animation graphs in Bevy!
Apache License 2.0
97 stars 5 forks source link

Sample curves eagerly #41

Closed mbrea-c closed 6 months ago

mbrea-c commented 6 months ago

Since the start, I have been using lazy/delayed sampling for the animation graph. This means that the pose data passed around the graph was in the form of curve segments (ValueFrame types), and we sample them only when needed. While this allowed a couple of cool things (e.g. extremely flexible animation chaining), the complexity introduced in many parts of the codebase was getting out of hand.

The industry standard way of doing this is to sample animations as early as possible, and only worked with pose values throughout the graph. This PR switches to that approach.

This is part of an effort to clean up technical debt from the codebase, and make development faster and more approachable.

Breaking changes

There are changes in how chaining and looping works that required a new parameter being introduced. Chain and loop nodes now have a interpolation_period f32 parameter that determines how long should be spent blending back to the starting pose (for looping) or blending to the second animation (for chaining). You should manually edit graphs files to change the Loop and Chain nodes to a struct (change Loop to Loop() and Chain to Chain()), and when opening the editor the nodes should be loaded with default values. See the updated examples for how for how to do similar tasks in the new system.

Follow-up work