mirror of
https://github.com/bevyengine/bevy
synced 2024-09-20 06:22:01 +00:00
c8167c1276
## Objective - Provide a way to use `CubicCurve` non-iter methods - Accept a `FnMut` over a `fn` pointer on `iter_samples` - Improve `build_*_cubic_100_points` benchmark by -45% (this means they are twice as fast) ### Solution Previously, the only way to iterate over an evenly spaced set of points on a `CubicCurve` was to use one of the `iter_*` methods. The return value of those methods were bound by `&self` lifetime, making them unusable in certain contexts. Furthermore, other `CubicCurve` methods (`position`, `velocity`, `acceleration`) required normalizing `t` over the `CubicCurve`'s internal segment count. There were no way to access this segment count, making those methods pretty much unusable. The newly added `segment_count` allows accessing the segment count. `iter_samples` used to accept a `fn`, a function pointer. This is surprising and contrary to the rust stdlib APIs, which accept `Fn` traits for `Iterator` combinators. `iter_samples` now accepts a `FnMut`. I don't trust a bit the bevy benchmark suit, but according to it, this doubles (-45%) the performance on the `build_pos_cubic_100_points` and `build_accel_cubic_100_points` benchmarks. --- ## Changelog - Added the `CubicCurve::segments` method to access the underlying segments of a cubic curve - Allow closures as `CubicCurve::iter_samples` `sample_function` argument. |
||
---|---|---|
.. | ||
bevy_a11y | ||
bevy_animation | ||
bevy_app | ||
bevy_asset | ||
bevy_audio | ||
bevy_core | ||
bevy_core_pipeline | ||
bevy_derive | ||
bevy_diagnostic | ||
bevy_dylib | ||
bevy_dynamic_plugin | ||
bevy_ecs | ||
bevy_ecs_compile_fail_tests | ||
bevy_encase_derive | ||
bevy_gilrs | ||
bevy_gizmos | ||
bevy_gltf | ||
bevy_hierarchy | ||
bevy_input | ||
bevy_internal | ||
bevy_log | ||
bevy_macro_utils | ||
bevy_macros_compile_fail_tests | ||
bevy_math | ||
bevy_mikktspace | ||
bevy_pbr | ||
bevy_ptr | ||
bevy_reflect | ||
bevy_reflect_compile_fail_tests | ||
bevy_render | ||
bevy_scene | ||
bevy_sprite | ||
bevy_tasks | ||
bevy_text | ||
bevy_time | ||
bevy_transform | ||
bevy_ui | ||
bevy_utils | ||
bevy_window | ||
bevy_winit |