bevy/crates
Robert Walter 96f1fd73cb
Add methods to sample curves from IntoIterator types (#14815)
# Objective

Citing @mweatherley 

> As mentioned before, a multi-sampling function in the API which takes
an iterator is probably something we want (e.g. `sample_iter(iter: impl
IntoIterator<Item = f32>) -> impl IntoIterator<Item = T> { //... }`, but
there are some design choices to be made on the details (e.g. does this
filter out points that aren't in the domain? does it do sorting? etc.)

## Solution

I think the most flexible solution for end users is to expose all the
`sample_...` functions with an `iter` equivalent, so we'll have

- `sample_iter`
- `sample_iter_unchecked`
- `sample_iter_clamped`

Answering some questions from the original idea:

> does this filter out points that aren't in the domain?

With the methods the user has the choice to just sample or if they want
to filter out invalid types us `sample_iter` and then apply `filter_map`
to the iterator returned themselves.

> does it do sorting?

I think it's the same thing. If the user wants it, they need to do it
themselves by either collecting and sorting a `Vec` or using
`itertools`. I think there is a legit use case for "please sample me
this collection of points that are unordered" and we would destroy it if
we take away to much agency from users by sorting for them

## Testing

- Added a test which covers all three methods
2024-08-26 18:08:41 +00:00
..
bevy_a11y Add Reflect derive to bevy_a11y::Focus (#14763) 2024-08-15 17:33:20 +00:00
bevy_animation Add AnimationGraph::from_clips and simplify animated_fox example (#14853) 2024-08-25 14:16:04 +00:00
bevy_app Added on_unimplemented Diagnostic for IntoObserverSystem (#14840) 2024-08-25 14:15:49 +00:00
bevy_asset Fix Gizmos warnings and doc errors when a subset of features are selected (#14887) 2024-08-23 16:19:06 +00:00
bevy_audio Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_color Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
bevy_core Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_core_pipeline Ignore PipelineCache ambiguities (#14772) 2024-08-16 23:43:40 +00:00
bevy_derive Remove deprecated bevy_dynamic_plugin (#14534) 2024-07-30 15:31:08 +00:00
bevy_dev_tools Rewrite screenshots. (#14833) 2024-08-25 14:14:32 +00:00
bevy_diagnostic Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
bevy_dylib Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_ecs Implement std::fmt::Debug for ecs::observer::Trigger (#14857) 2024-08-25 16:55:54 +00:00
bevy_encase_derive Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_gilrs Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_gizmos Fix arc_2d Gizmos (#14731) 2024-08-26 17:57:57 +00:00
bevy_gltf Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
bevy_hierarchy Add link to with_children in with_child doc (#14604) 2024-08-04 13:36:52 +00:00
bevy_input Fix common capitalization errors in documentation (#14562) 2024-07-31 21:16:05 +00:00
bevy_internal Add bevy_picking sprite backend (#14757) 2024-08-26 18:01:32 +00:00
bevy_log Fix common capitalization errors in documentation (#14562) 2024-07-31 21:16:05 +00:00
bevy_macro_utils Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_math Add methods to sample curves from IntoIterator types (#14815) 2024-08-26 18:08:41 +00:00
bevy_mikktspace Fix underflow panic in InitTriInfo (#14893) 2024-08-25 14:13:23 +00:00
bevy_pbr Meshlet software raster + start of cleanup (#14623) 2024-08-26 17:54:34 +00:00
bevy_picking Add bevy_picking sprite backend (#14757) 2024-08-26 18:01:32 +00:00
bevy_ptr Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
bevy_reflect bevy_reflect: Add Type type (#14838) 2024-08-25 17:57:07 +00:00
bevy_render ImageSampler::init_descriptor (#11113) 2024-08-26 17:56:37 +00:00
bevy_scene reflect: implement the unique reflect rfc (#7207) 2024-08-12 17:01:41 +00:00
bevy_sprite Add bevy_picking sprite backend (#14757) 2024-08-26 18:01:32 +00:00
bevy_state Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
bevy_tasks Fix common capitalization errors in documentation (#14562) 2024-07-31 21:16:05 +00:00
bevy_text Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
bevy_time Allow ordering variable timesteps around fixed timesteps (#14881) 2024-08-23 16:19:42 +00:00
bevy_transform Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_ui Refactor AsBindGroup to use a associated SystemParam. (#14909) 2024-08-25 20:16:34 +00:00
bevy_utils Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
bevy_window Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
bevy_winit Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00