Skip to content

Commit ef7bafa

Browse files
authored
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
1 parent 11afe16 commit ef7bafa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

crates/bevy_pbr/src/extended_material.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,19 @@ pub struct ExtendedMaterial<B: Material, E: MaterialExtension> {
128128
pub extension: E,
129129
}
130130

131+
impl<B, E> Default for ExtendedMaterial<B, E>
132+
where
133+
B: Material + Default,
134+
E: MaterialExtension + Default,
135+
{
136+
fn default() -> Self {
137+
Self {
138+
base: B::default(),
139+
extension: E::default(),
140+
}
141+
}
142+
}
143+
131144
// We don't use the `TypePath` derive here due to a bug where `#[reflect(type_path = false)]`
132145
// causes the `TypePath` derive to not generate an implementation.
133146
impl_type_path!((in bevy_pbr::extended_material) ExtendedMaterial<B: Material, E: MaterialExtension>);

0 commit comments

Comments
 (0)