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,
(
setup_dissolve_materials
.run_if(
any_component_added::<Handle<StandardMaterial>>()
.or_else(any_component_changed::<Handle<StandardMaterial>>()),
),
.run_if(any_component_added::<Handle<StandardMaterial>>()),
)
)
.add_systems(
@ -1041,7 +1038,7 @@ fn set_animation_speed(
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
@ -1115,12 +1112,9 @@ impl MaterialExtension for DissolveExtension {
/// Sets up all pieces to have an associated "dissolve" material ready for capture
fn setup_dissolve_materials(
// All entities with materials are candidates for this procedure
events: Query<
(Entity, &Handle<StandardMaterial>, Option<&Name>),
Added<Handle<StandardMaterial>>,
>,
events: Query<(Entity, &Handle<StandardMaterial>, &Name), (With<Parent>, Added<Handle<StandardMaterial>>)>,
// 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
parents: Query<&Parent>,
// Used to create DissolveMaterial
@ -1130,19 +1124,16 @@ fn setup_dissolve_materials(
// Used to insert Handle<DissolveMaterial>;
mut commands: Commands,
) {
info!("Setting up dissolve materials...");
events
.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)
.for_each(|(child, std_handle, name)| {
info!("Setting up dissolve material for {:?} {:?}", name, child);
// Get dissolvable data for percentage start
let dissolvable = query
if let Some(dissolvable) = query
.iter_many(parents.iter_ancestors(child))
.next()
.expect("Dissolving data");
.next() {
info!("Setting up dissolve material for {:?} {:?}", name, child);
// Extension we will add to existing gltf-sourced materials
let extension = DissolveExtension {
@ -1164,6 +1155,7 @@ fn setup_dissolve_materials(
.entity(child)
.insert(dis_handle.clone())
.remove::<Handle<StandardMaterial>>();
}
});
}

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

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

Loading…
Cancel
Save