Fixed dissolve for pieces crossing canal

main
Elijah C. Voigt 1 year ago
parent 5f3ed207fa
commit 9f3b9151b3

@ -144,10 +144,7 @@ impl Plugin for Display3dPlugin {
Update, Update,
( (
setup_dissolve_materials setup_dissolve_materials
.run_if( .run_if(any_component_added::<Handle<StandardMaterial>>()),
any_component_added::<Handle<StandardMaterial>>()
.or_else(any_component_changed::<Handle<StandardMaterial>>()),
),
) )
) )
.add_systems( .add_systems(
@ -1041,7 +1038,7 @@ fn set_animation_speed(
AnimationSpeed::default() AnimationSpeed::default()
}; };
info!("Animation speed: {:?}", animation_speed.movement); debug!("Animation speed: {:?}", animation_speed.movement);
} }
// When an animation starts, or the animation speed changes, update player speed // When an animation starts, or the animation speed changes, update player speed
@ -1115,12 +1112,9 @@ impl MaterialExtension for DissolveExtension {
/// Sets up all pieces to have an associated "dissolve" material ready for capture /// Sets up all pieces to have an associated "dissolve" material ready for capture
fn setup_dissolve_materials( fn setup_dissolve_materials(
// All entities with materials are candidates for this procedure // All entities with materials are candidates for this procedure
events: Query< events: Query<(Entity, &Handle<StandardMaterial>, &Name), (With<Parent>, Added<Handle<StandardMaterial>>)>,
(Entity, &Handle<StandardMaterial>, Option<&Name>),
Added<Handle<StandardMaterial>>,
>,
// Only process newly created pieces (we do not delete pieces at runtime) // Only process newly created pieces (we do not delete pieces at runtime)
query: Query<&Dissolvable, Added<Children>>, query: Query<&Dissolvable>,
// Children of pieces are the actual meshes that need materials // Children of pieces are the actual meshes that need materials
parents: Query<&Parent>, parents: Query<&Parent>,
// Used to create DissolveMaterial // Used to create DissolveMaterial
@ -1130,19 +1124,16 @@ fn setup_dissolve_materials(
// Used to insert Handle<DissolveMaterial>; // Used to insert Handle<DissolveMaterial>;
mut commands: Commands, mut commands: Commands,
) { ) {
info!("Setting up dissolve materials...");
events events
.iter() .iter()
// Only process if this is a child of a piece
.filter(|(child, _, _)| query.iter_many(parents.iter_ancestors(*child)).count() > 0)
// Handle this entity (mesh) // Handle this entity (mesh)
.for_each(|(child, std_handle, name)| { .for_each(|(child, std_handle, name)| {
info!("Setting up dissolve material for {:?} {:?}", name, child); if let Some(dissolvable) = query
// Get dissolvable data for percentage start
let dissolvable = query
.iter_many(parents.iter_ancestors(child)) .iter_many(parents.iter_ancestors(child))
.next() .next() {
.expect("Dissolving data");
info!("Setting up dissolve material for {:?} {:?}", name, child);
// Extension we will add to existing gltf-sourced materials // Extension we will add to existing gltf-sourced materials
let extension = DissolveExtension { let extension = DissolveExtension {
@ -1164,6 +1155,7 @@ fn setup_dissolve_materials(
.entity(child) .entity(child)
.insert(dis_handle.clone()) .insert(dis_handle.clone())
.remove::<Handle<StandardMaterial>>(); .remove::<Handle<StandardMaterial>>();
}
}); });
} }

@ -371,10 +371,14 @@ impl Board {
fn new() -> Board { fn new() -> Board {
Board::from_ascii( Board::from_ascii(
r#".....dqq // r#".....dqq
dpp..pdq // dpp..pdq
qdp..ppd // qdp..ppd
qqd....."#, // qqd....."#,
r#"....q...
..d.....
....p...
...q...."#,
) )
} }

@ -99,8 +99,8 @@ fn interactive_button(
let mut ts = texts.iter_many_mut(children.iter_descendants(entity)); let mut ts = texts.iter_many_mut(children.iter_descendants(entity));
while let Some((_t, mut s)) = ts.fetch_next() { while let Some((_t, mut s)) = ts.fetch_next() {
s.right = Val::Auto; s.right = Val::Auto;
info!("TODO: Change text color"); debug!("TODO: Change text color");
info!("TODO: Change position"); debug!("TODO: Change position");
} }
} }
Interaction::Hovered => { Interaction::Hovered => {
@ -109,8 +109,8 @@ fn interactive_button(
let mut ts = texts.iter_many_mut(children.iter_descendants(entity)); let mut ts = texts.iter_many_mut(children.iter_descendants(entity));
while let Some((_t, mut s)) = ts.fetch_next() { while let Some((_t, mut s)) = ts.fetch_next() {
s.right = Val::Px(0.0); s.right = Val::Px(0.0);
info!("TODO: Change text color"); debug!("TODO: Change text color");
info!("TODO: Change position"); debug!("TODO: Change position");
} }
} }
Interaction::Pressed => { Interaction::Pressed => {
@ -119,8 +119,8 @@ fn interactive_button(
let mut ts = texts.iter_many_mut(children.iter_descendants(entity)); let mut ts = texts.iter_many_mut(children.iter_descendants(entity));
while let Some((_t, mut s)) = ts.fetch_next() { while let Some((_t, mut s)) = ts.fetch_next() {
s.right = Val::Px(0.0); s.right = Val::Px(0.0);
info!("TODO: Change text color"); debug!("TODO: Change text color");
info!("TODO: Change position"); debug!("TODO: Change position");
} }
} }
}); });

Loading…
Cancel
Save