bevy/crates
Aevyrie 2ea0061018 Add generic cubic splines to bevy_math (#7683)
# Objective

- Make cubic splines more flexible and more performant
- Remove the existing spline implementation that is generic over many degrees
  - This is a potential performance footgun and adds type complexity for negligible gain.
- Add implementations of:
  - Bezier splines
  - Cardinal splines (inc. Catmull-Rom)
  - B-Splines
  - Hermite splines

https://user-images.githubusercontent.com/2632925/221780519-495d1b20-ab46-45b4-92a3-32c46da66034.mp4


https://user-images.githubusercontent.com/2632925/221780524-2b154016-699f-404f-9c18-02092f589b04.mp4


https://user-images.githubusercontent.com/2632925/221780525-f934f99d-9ad4-4999-bae2-75d675f5644f.mp4


## Solution

- Implements the concept that splines are curve generators (e.g. https://youtu.be/jvPPXbo87ds?t=3488) via the `CubicGenerator` trait.
- Common splines are bespoke data types that implement this trait. This gives us flexibility to add custom spline-specific methods on these types, while ultimately all generating a `CubicCurve`.
- All splines generate `CubicCurve`s, which are a chain of precomputed polynomial coefficients. This means that all splines have the same evaluation cost, as the calculations for determining position, velocity, and acceleration are all identical. In addition, `CubicCurve`s are simply a list of `CubicSegment`s, which are evaluated from t=0 to t=1. This also means cubic splines of different type can be chained together, as ultimately they all are simply a collection of `CubicSegment`s.
- Because easing is an operation on a singe segment of a Bezier curve, we can simply implement easing on `Beziers` that use the `Vec2` type for points. Higher level crates such as `bevy_ui` can wrap this in a more ergonomic interface as needed.

### Performance
Measured on a desktop i5 8600K (6-year-old CPU):
- easing: 2.7x faster (19ns)
- cubic vec2 position sample: 1.5x faster (1.8ns)
- cubic vec3 position sample: 1.5x faster (2.6ns)
- cubic vec3a position sample: 1.9x faster (1.4ns)

On a laptop i7 11800H:
- easing: 16ns
- cubic vec2 position sample: 1.6ns
- cubic vec3 position sample: 2.3ns
- cubic vec3a position sample: 1.2ns

---

## Changelog

- Added a generic cubic curve trait, and implementation for Cardinal splines (including Catmull-Rom), B-Splines, Beziers, and Hermite Splines. 2D cubic curve segments also implement easing functionality for animation.
2023-03-03 22:06:42 +00:00
..
bevy_a11y Integrate AccessKit (#6874) 2023-03-01 22:45:04 +00:00
bevy_animation Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_app Add marker traits to distinguish base sets from regular system sets (#7863) 2023-03-02 13:22:58 +00:00
bevy_asset Fix hot reloading for read_asset_bytes (#6797) 2023-03-02 02:51:06 +00:00
bevy_audio Remove redundant symphonia-mp3 feature (#7852) 2023-03-01 03:22:46 +00:00
bevy_core Fix some typos (#7763) 2023-02-20 22:56:57 +00:00
bevy_core_pipeline Camera Output Modes, MSAA Writeback, and BlitPipeline (#7671) 2023-03-01 20:35:13 +00:00
bevy_derive update winit to 0.28 (#7480) 2023-02-03 16:41:39 +00:00
bevy_diagnostic Update sysinfo and improve its use a bit (#7826) 2023-02-27 01:05:58 +00:00
bevy_dylib Rename dynamic feature (#7340) 2023-01-23 14:28:00 +00:00
bevy_dynamic_plugin Adapt path type of dynamically_load_plugin (#6734) 2022-12-05 23:39:43 +00:00
bevy_ecs Revise docs for system set marker traits (#7882) 2023-03-03 14:43:54 +00:00
bevy_ecs_compile_fail_tests EntityMut: rename remove_intersection to remove and remove to take (#7810) 2023-02-26 00:09:19 +00:00
bevy_encase_derive add helper for macro to get either bevy::x or bevy_x depending on how it was imported (#7164) 2023-01-11 21:12:02 +00:00
bevy_gilrs Make StartupSet a base set (#7574) 2023-02-19 03:10:06 +00:00
bevy_gltf Add extras field to GltfNode (#6973) 2023-02-13 17:56:36 +00:00
bevy_hierarchy EntityMut: rename remove_intersection to remove and remove to take (#7810) 2023-02-26 00:09:19 +00:00
bevy_input add common run conditions to bevy_input (#7806) 2023-02-25 22:08:13 +00:00
bevy_internal Integrate AccessKit (#6874) 2023-03-01 22:45:04 +00:00
bevy_log Fix suppression of all console logs when trace_tracy is enabled (#6955) 2022-12-20 23:45:43 +00:00
bevy_macro_utils Update toml_edit to 0.19 (#7834) 2023-02-27 23:59:06 +00:00
bevy_math Add generic cubic splines to bevy_math (#7683) 2023-03-03 22:06:42 +00:00
bevy_mikktspace Release 0.9.0 (#6568) 2022-11-12 20:01:29 +00:00
bevy_pbr Fix dependency of shadow mapping on the optional PrepassPlugin (#7878) 2023-03-03 15:08:54 +00:00
bevy_ptr Fix minor typos in code and docs (#7378) 2023-01-27 12:12:53 +00:00
bevy_reflect impl Reflect for std::collections::HashMap instead of only bevy::utils::HashMap (#7739) (#7782) 2023-02-27 21:37:36 +00:00
bevy_reflect_compile_fail_tests Enable deriving Reflect on structs with generic types (#7364) 2023-01-28 00:12:06 +00:00
bevy_render Camera Output Modes, MSAA Writeback, and BlitPipeline (#7671) 2023-03-01 20:35:13 +00:00
bevy_scene Base Sets (#7466) 2023-02-06 03:10:08 +00:00
bevy_sprite Doc bevy sprite (#7858) 2023-03-03 18:14:40 +00:00
bevy_tasks Fix asset_debug_server hang. There should be at most one ThreadExecut… (#7825) 2023-03-02 08:40:25 +00:00
bevy_text fix whitespaces in comment (#7853) 2023-03-01 10:20:56 +00:00
bevy_time Add timer-based common run conditions (on_timer and on_fixed_timer) (#7866) 2023-03-02 12:53:54 +00:00
bevy_transform single parent set for transform propagate (#7869) 2023-03-02 20:04:03 +00:00
bevy_ui Fix bevy_ui compile error without bevy_text (#7877) 2023-03-02 22:44:12 +00:00
bevy_utils Fix some typos (#7763) 2023-02-20 22:56:57 +00:00
bevy_window Remove mention of Windows 11 from Window::transparent's docs (#7832) 2023-02-27 21:10:52 +00:00
bevy_winit Integrate AccessKit (#6874) 2023-03-01 22:45:04 +00:00