Add missing Default impl to ExtendedMaterial. (#13008)

# Objective

When trying to be generic over `Material + Default`, the lack of a
`Default` impl for `ExtendedMaterial`, even when both of its components
implement `Default`, is problematic. I think was probably just
overlooked.

## Solution

Impl `Default` if the material and extension both impl `Default`.

---

## Changelog

## Migration Guide
This commit is contained in:
charlotte 2024-04-18 05:57:14 -07:00 committed by GitHub
parent 11afe16079
commit ef7bafa68e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -128,6 +128,19 @@ pub struct ExtendedMaterial<B: Material, E: MaterialExtension> {
pub extension: E,
}
impl<B, E> Default for ExtendedMaterial<B, E>
where
B: Material + Default,
E: MaterialExtension + Default,
{
fn default() -> Self {
Self {
base: B::default(),
extension: E::default(),
}
}
}
// We don't use the `TypePath` derive here due to a bug where `#[reflect(type_path = false)]`
// causes the `TypePath` derive to not generate an implementation.
impl_type_path!((in bevy_pbr::extended_material) ExtendedMaterial<B: Material, E: MaterialExtension>);