bevy/examples/3d
Jonah Henriksson 38d567d2c5 Make AsBindGroup unsized (#6937)
# Objective

`AsBindGroup` can't be used as a trait object because of the constraint `Sized` and because of the associated function.

This is a problem for [`bevy_atmosphere`](https://github.com/JonahPlusPlus/bevy_atmosphere) because it needs to use a trait that depends on `AsBindGroup` as a trait object, for switching out different shaders at runtime. The current solution it employs is reimplementing the trait and derive macro into that trait, instead of constraining to `AsBindGroup`.

## Solution

Remove the `Sized` constraint from `AsBindGroup` and add the constraint `where Self: Sized` to the associated function `bind_group_layout`. Also change `PreparedBindGroup<T: AsBindGroup>` to `PreparedBindGroup<T>` and use it as `PreparedBindGroup<Self::Data>` instead of `PreparedBindGroup<Self>`.

This weakens the constraints, but increases the flexibility of `AsBindGroup`.
I'm not entirely sure why the `Sized` constraint was there, because it worked fine without it (maybe @cart wasn't aware of use cases for `AsBindGroup` as a trait object or this was just leftover from legacy code?).

---

## Changelog

- `AsBindGroup` can be used as a trait object.
2022-12-16 01:40:15 +00:00
..
3d_scene.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
3d_shapes.rs Add cylinder shape (#6809) 2022-12-11 18:22:05 +00:00
bloom.rs Change From<Icosphere> to TryFrom<Icosphere> (#6484) 2022-11-14 22:34:27 +00:00
fxaa.rs Add FXAA postprocessing (#6393) 2022-11-02 06:51:28 +00:00
lighting.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
lines.rs Allow passing glam vector types as vertex attributes (#6442) 2022-11-04 03:45:17 +00:00
load_gltf.rs Add global time scaling (#5752) 2022-10-22 18:52:29 +00:00
msaa.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
orthographic.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
parenting.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
pbr.rs Change From<Icosphere> to TryFrom<Icosphere> (#6484) 2022-11-14 22:34:27 +00:00
render_to_texture.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
shadow_biases.rs Change From<Icosphere> to TryFrom<Icosphere> (#6484) 2022-11-14 22:34:27 +00:00
shadow_caster_receiver.rs Change From<Icosphere> to TryFrom<Icosphere> (#6484) 2022-11-14 22:34:27 +00:00
skybox.rs Make AsBindGroup unsized (#6937) 2022-12-16 01:40:15 +00:00
spherical_area_lights.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
split_screen.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
spotlight.rs Add global time scaling (#5752) 2022-10-22 18:52:29 +00:00
texture.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
transparency_3d.rs Change From<Icosphere> to TryFrom<Icosphere> (#6484) 2022-11-14 22:34:27 +00:00
two_passes.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
update_gltf_scene.rs Add methods to Query<&Children> and Query<&Parent> to iterate over descendants and ancestors (#6185) 2022-10-31 15:57:50 +00:00
vertex_colors.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
wireframe.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00