mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
a09104b62c
# Objective Make `StableInterpolate` "just work" on tuples whose parts are each `StableInterpolate` types. These types arise notably through `Curve::zip` (or just through explicit mapping of a similar form). It would otherwise be kind of frustrating to stumble upon such a thing and then realize that, e.g., automatic resampling just doesn't work, even though there is a very "obvious" way to do it. ## Solution Infer `StableInterpolate` on tuples of up to size 11. I can make that number bigger, if desired. Unfortunately, I don't think that our standard "fake variadics" tools actually work for this; the anonymous field accessors of tuples are `:tt` for purposes of macro expansion, which means that you can't simplify away the identifiers by doing something clever like using recursion (which would work if they were `:expr`). Maybe someone who knows some incredibly dark magic could chime in with a better solution. The expanded impls look like this: ```rust impl< T0: StableInterpolate, T1: StableInterpolate, T2: StableInterpolate, T3: StableInterpolate, T4: StableInterpolate, > StableInterpolate for (T0, T1, T2, T3, T4) { fn interpolate_stable(&self, other: &Self, t: f32) -> Self { ( <T0 as StableInterpolate>::interpolate_stable(&self.0, &other.0, t), <T1 as StableInterpolate>::interpolate_stable(&self.1, &other.1, t), <T2 as StableInterpolate>::interpolate_stable(&self.2, &other.2, t), <T3 as StableInterpolate>::interpolate_stable(&self.3, &other.3, t), <T4 as StableInterpolate>::interpolate_stable(&self.4, &other.4, t), ) } } ``` ## Testing Expanded macros; it compiles. ## Future Make a version of the fake variadics workflow that supports this kind of thing. |
||
---|---|---|
.. | ||
bevy_a11y | ||
bevy_animation | ||
bevy_app | ||
bevy_asset | ||
bevy_audio | ||
bevy_color | ||
bevy_core | ||
bevy_core_pipeline | ||
bevy_derive | ||
bevy_dev_tools | ||
bevy_diagnostic | ||
bevy_dylib | ||
bevy_ecs | ||
bevy_encase_derive | ||
bevy_gilrs | ||
bevy_gizmos | ||
bevy_gltf | ||
bevy_hierarchy | ||
bevy_image | ||
bevy_input | ||
bevy_internal | ||
bevy_log | ||
bevy_macro_utils | ||
bevy_math | ||
bevy_mesh | ||
bevy_mikktspace | ||
bevy_pbr | ||
bevy_picking | ||
bevy_ptr | ||
bevy_reflect | ||
bevy_remote | ||
bevy_render | ||
bevy_scene | ||
bevy_sprite | ||
bevy_state | ||
bevy_tasks | ||
bevy_text | ||
bevy_time | ||
bevy_transform | ||
bevy_ui | ||
bevy_utils | ||
bevy_window | ||
bevy_winit |