From ef7bafa68efbeee233c5a8d3bb5e266ed888f8c4 Mon Sep 17 00:00:00 2001 From: charlotte Date: Thu, 18 Apr 2024 05:57:14 -0700 Subject: [PATCH] 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 --- crates/bevy_pbr/src/extended_material.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/bevy_pbr/src/extended_material.rs b/crates/bevy_pbr/src/extended_material.rs index 70f9ec34cc..aa77b51c62 100644 --- a/crates/bevy_pbr/src/extended_material.rs +++ b/crates/bevy_pbr/src/extended_material.rs @@ -128,6 +128,19 @@ pub struct ExtendedMaterial { pub extension: E, } +impl Default for ExtendedMaterial +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);