From 3275582176b344a3b72154664c1c6c1e9f72dde1 Mon Sep 17 00:00:00 2001 From: "Elijah C. Voigt" Date: Wed, 27 Mar 2024 20:52:41 -0700 Subject: [PATCH] cargo fmt... also maybe fix that shared materials thing --- src/display3d.rs | 127 +++++++++++++++++++++++------------------------ 1 file changed, 63 insertions(+), 64 deletions(-) diff --git a/src/display3d.rs b/src/display3d.rs index 1357947..24053c9 100644 --- a/src/display3d.rs +++ b/src/display3d.rs @@ -222,7 +222,10 @@ fn initialize(mut commands: Commands, board: Res, assets: Res, assets: Res>, // Used to insert Handle; mut commands: Commands, - // Cache dissolve textures that have already been created - mut cache: Local, Handle>>, ) { events .iter() @@ -1202,31 +1206,24 @@ fn setup_dissolve_materials( // Handle this entity (mesh) .for_each(|(child, std_handle)| { info!("Setting up dissolve material for {:?}", child); - let dis_handle = match cache.get(std_handle) { - // We have not seen this material, so create a new dissolve material - None => { - // Extension we will add to existing gltf-sourced materials - let extension = DissolveExtension { percentage: 1.0 }; - // Base material we will extend for the duration of the dissolve effect - let mut base: StandardMaterial = standard_materials - .get(std_handle) - .expect("Resolve material data") - .clone(); - - base.alpha_mode = AlphaMode::Mask(0.5); - base.base_color = Color::NONE.with_a(0.0); - info!("Base material {:#?}", base); - - dissolve_materials.add(ExtendedMaterial { base, extension }) - } - Some(dis_handle) => dis_handle.clone(), - }; - // Insert this handle into the cache (may be redundant) - cache.insert(std_handle.clone(), dis_handle.clone()); + // Extension we will add to existing gltf-sourced materials + let extension = DissolveExtension { percentage: 1.0 }; + // Base material we will extend for the duration of the dissolve effect + let mut base: StandardMaterial = standard_materials + .get(std_handle) + .expect("Resolve material data") + .clone(); + + base.alpha_mode = AlphaMode::Mask(0.5); + base.base_color = Color::NONE.with_a(0.0); + info!("Base material {:#?}", base); + + let dis_handle = dissolve_materials.add(ExtendedMaterial { base, extension }); // Add the dissolve handle as a Backup(T) - commands.entity(child) + commands + .entity(child) .insert(dis_handle.clone()) .remove::>(); }); @@ -1363,52 +1360,54 @@ fn dissolve_animation( children: Query<&Children>, // Used to create Handle mut dissolve_materials: ResMut>, - object_materials: Query<( - Entity, - &Handle, - )>, + object_materials: Query<(Entity, &Handle)>, mut commands: Commands, time: Res