Getting things mostly fixed up with the 0.12 update

Problems with animations, regressions IMO. Not sure how to fix w/
correctness in mind.

Waiting on sam to make some updates to the assets file before fixing
animations then can produce a build.
main
Elijah C. Voigt 2 years ago
parent a1a0814673
commit 3d5d1dd42a

10
Cargo.lock generated

@ -2062,9 +2062,12 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad2dcfb6dd7a66f9eb3d181a29dcfb22d146b0bcdc2e1ed1713cbf03939a88ea" checksum = "ad2dcfb6dd7a66f9eb3d181a29dcfb22d146b0bcdc2e1ed1713cbf03939a88ea"
dependencies = [ dependencies = [
"base64 0.13.1",
"byteorder", "byteorder",
"gltf-json", "gltf-json",
"image",
"lazy_static", "lazy_static",
"urlencoding",
] ]
[[package]] [[package]]
@ -2542,6 +2545,7 @@ dependencies = [
"anyhow", "anyhow",
"bevy", "bevy",
"bevy_fmod", "bevy_fmod",
"gltf",
"serde", "serde",
"thiserror", "thiserror",
"toml", "toml",
@ -3684,6 +3688,12 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "urlencoding"
version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]] [[package]]
name = "uuid" name = "uuid"
version = "1.6.1" version = "1.6.1"

@ -12,5 +12,7 @@ toml = { version = "0.8", features = ["parse"] }
anyhow = "*" anyhow = "*"
thiserror = "*" thiserror = "*"
gltf = "*"
[profile.dev] [profile.dev]
opt-level = 3 opt-level = 3

@ -70,9 +70,20 @@ intro_a = "GameCamIntro1"
intro_b = "GameCamIntro2" intro_b = "GameCamIntro2"
turn_a = "GameCamSide2>1" turn_a = "GameCamSide2>1"
turn_b = "GameCamSide1>2" turn_b = "GameCamSide1>2"
pick_up = "PiecePickup" [display3d.models.animations.pick_up]
put_down = "PiecePutDown" pawn = "PiecePickup"
idle = "PieceIdle" drone = "PiecePickup"
queen = "PiecePickup"
[display3d.models.animations.put_down]
pawn = "PiecePutDown"
drone = "PiecePutDown"
queen = "PiecePutDown"
[display3d.models.animations.idle]
pawn = "PieceIdle"
drone = "PieceIdle"
queen = "PieceIdle"
[display3d.models.materials] [display3d.models.materials]
queen_red = "Queen" queen_red = "Queen"
@ -107,7 +118,7 @@ Rgba = { red = 1.0, green = 1.0, blue = 1.0, alpha = 0.0 }
# https://docs.rs/bevy/0.11.3/bevy/pbr/enum.FogFalloff.html # https://docs.rs/bevy/0.11.3/bevy/pbr/enum.FogFalloff.html
### ###
[display3d.fog.falloff] [display3d.fog.falloff]
Exponential = { density = 0.005 } Exponential = { density = 0.000 }
# Examples: # Examples:
# * Linear = { start = 1.0, end = 10.0 } # * Linear = { start = 1.0, end = 10.0 }
# * Exponential = { density = 1.0 } # * Exponential = { density = 1.0 }

BIN
assets/models/Martian Chess.glb (Stored with Git LFS)

Binary file not shown.

@ -0,0 +1,11 @@
use gltf::*;
fn main() -> gltf::Result<()> {
let g = Gltf::open("assets/models/Martian Chess.glb")?;
g.animations()
.into_iter()
.for_each(|x| {
println!("{:?}", x.name());
});
Ok(())
}

@ -0,0 +1,24 @@
# Debugging animations not working?
OK so seems like this:
https://github.com/bevyengine/bevy/blob/22e39c4abf6e2fdf99ba0820b3c35db73be71347/crates/bevy_animation/src/lib.rs#L119C12-L122
Printed as this:
```
paths: {
EntityPath {
parts: [
"Queen",
],
}: 0,
},
```
Means the only entity that this will play for is one called "Queen".
Now there are a few hacks we can do.
We can add the `Name("Queen")` to all of our entities but that's BS.
They aren't Queens they are Pawns and Drones.
So why does Bevy think the animation is only associated with Queen and not other entities?

@ -27,6 +27,7 @@ impl Plugin for DebugPlugin {
display_diagnostics.run_if(resource_exists::<DebugEnabled>()), display_diagnostics.run_if(resource_exists::<DebugEnabled>()),
toggle_debug_ui.run_if(resource_changed_or_removed::<DebugEnabled>()), toggle_debug_ui.run_if(resource_changed_or_removed::<DebugEnabled>()),
camera_info.run_if(resource_exists::<DebugEnabled>()), camera_info.run_if(resource_exists::<DebugEnabled>()),
// gltf_info.run_if(on_event::<AssetEvent<Gltf>>()),
), ),
); );
} }
@ -139,3 +140,11 @@ fn camera_info(mut debug_infos: ResMut<DebugInfo>, cameras: Query<(&Camera, &Nam
.collect::<String>(); .collect::<String>();
debug_infos.set("Cameras".into(), camera_names); debug_infos.set("Cameras".into(), camera_names);
} }
fn gltf_info(
gltfs: Res<Assets<Gltf>>,
) {
gltfs.iter().for_each(|(_, gltf)| {
info!("Named animations: {:#?}", gltf.named_animations);
});
}

@ -203,6 +203,7 @@ fn hydrate_camera(
let skybox_handle = tweak let skybox_handle = tweak
.get_handle::<Image>("display3d_models_skybox_file") .get_handle::<Image>("display3d_models_skybox_file")
.unwrap(); .unwrap();
info!("Hydrating camera {:?}", entity);
// Populate the components for the camera // Populate the components for the camera
commands.entity(entity).insert(( commands.entity(entity).insert((
Display3d, Display3d,
@ -434,18 +435,6 @@ fn set_board_model(
.expect("Game board model") .expect("Game board model")
.clone(); .clone();
}); });
// TODO: Get rid of this -- upstream asset has merged tiles back into gameboard scene
let assets_handle = tweak
.get_handle::<Gltf>("display3d_models_assets_file")
.unwrap();
tiles.iter_mut().for_each(|mut handle| {
let gltf = gltfs.get(assets_handle.clone()).expect("Load GLTF content");
*handle = gltf
.named_scenes
.get("Tiles")
.expect("Game tiles model")
.clone();
});
} }
/// Sets a piece location given it's board index /// Sets a piece location given it's board index
@ -867,7 +856,8 @@ fn pick_up(
>, >,
gltfs: Res<Assets<Gltf>>, gltfs: Res<Assets<Gltf>>,
children: Query<&Children>, children: Query<&Children>,
mut players: Query<&mut AnimationPlayer>, mut players: Query<(&Name, &mut AnimationPlayer)>,
clips: Res<Assets<AnimationClip>>,
tweaks: Res<Assets<Tweaks>>, tweaks: Res<Assets<Tweaks>>,
tweaks_file: Res<tweak::GameTweaks>, tweaks_file: Res<tweak::GameTweaks>,
) { ) {
@ -879,31 +869,40 @@ fn pick_up(
.get_handle::<Gltf>("display3d_models_assets_file") .get_handle::<Gltf>("display3d_models_assets_file")
.unwrap(); .unwrap();
let gltf = gltfs.get(assets_handle).expect("Load GLTF content"); let gltf = gltfs.get(assets_handle).expect("Load GLTF content");
info!("Pickup animation for {:?}", entity);
children.iter_descendants(entity).for_each(|child| { children.iter_descendants(entity).for_each(|child| {
if let Ok(mut player) = players.get_mut(child) { info!(" Child: {:?}", child);
info!("Picking up {:?} {:?}", entity, piece); if let Ok((name, mut player)) = players.get_mut(child) {
let animation = gltf.named_animations.get( info!("Picking up {:?} ({:?}) {:?}", name, entity, piece);
let pickup_handle = gltf.named_animations.get(
tweak tweak
.get::<String>("display3d_models_animations_pick_up") .get::<String>("display3d_models_animations_pick_up_queen")
.unwrap() .unwrap()
.as_str(), .as_str(),
); ).expect("Pickup Animation");
let idle = gltf.named_animations.get( let idle_handle = gltf.named_animations.get(
tweak tweak
.get::<String>("display3d_models_animations_idle") .get::<String>("display3d_models_animations_idle_queen")
.unwrap() .unwrap()
.as_str(), .as_str(),
); ).expect("Idle animation");
player if let Some(pickup_clip) = clips.get(pickup_handle) {
.start_with_transition( info!("Animation clip: {:#?}", pickup_clip);
animation.expect("Pickup Animation").clone(), if let Some(idle_clip) = clips.get(idle_handle) {
Duration::from_secs_f32(0.75), if pickup_clip.compatible_with(name) && idle_clip.compatible_with(name) {
) player
.start_with_transition( .start_with_transition(
idle.expect("Idle animation").clone(), pickup_handle.clone(),
Duration::from_secs_f32(1.5), Duration::from_secs_f32(0.75),
) )
.set_repeat(RepeatAnimation::Forever); .start_with_transition(
idle_handle.clone(),
Duration::from_secs_f32(1.5),
)
.set_repeat(RepeatAnimation::Forever);
}
};
}
} }
}) })
}); });
@ -914,7 +913,8 @@ fn put_down(
mut query: Query<&game::Piece, (With<game::Piece>, With<game::Selectable>, With<Display3d>)>, mut query: Query<&game::Piece, (With<game::Piece>, With<game::Selectable>, With<Display3d>)>,
gltfs: Res<Assets<Gltf>>, gltfs: Res<Assets<Gltf>>,
children: Query<&Children>, children: Query<&Children>,
mut players: Query<&mut AnimationPlayer>, mut players: Query<(&Name, &mut AnimationPlayer)>,
clips: Res<Assets<AnimationClip>>,
tweaks: Res<Assets<Tweaks>>, tweaks: Res<Assets<Tweaks>>,
tweaks_file: Res<tweak::GameTweaks>, tweaks_file: Res<tweak::GameTweaks>,
) { ) {
@ -922,26 +922,30 @@ fn put_down(
.get(&tweaks_file.handle.clone()) .get(&tweaks_file.handle.clone())
.expect("Load tweakfile"); .expect("Load tweakfile");
events.read().for_each(|entity| { events.read().for_each(|entity| {
if let Ok(_piece) = query.get_mut(entity) { if let Ok(piece) = query.get_mut(entity) {
let assets_handle = tweak let assets_handle = tweak
.get_handle::<Gltf>("display3d_models_assets_file") .get_handle::<Gltf>("display3d_models_assets_file")
.unwrap(); .unwrap();
let gltf = gltfs.get(assets_handle).expect("Load GLTF content"); let gltf = gltfs.get(assets_handle).expect("Load GLTF content");
children.iter_descendants(entity).for_each(|child| { children.iter_descendants(entity).for_each(|child| {
if let Ok(mut player) = players.get_mut(child) { if let Ok((name, mut player)) = players.get_mut(child) {
info!("Putting down {:?}", entity); info!("Putting down {:?}", entity);
let animation = gltf.named_animations.get( let putdown_handle = gltf.named_animations.get(
tweak tweak
.get::<String>("display3d_models_animations_put_down") .get::<String>("display3d_models_animations_put_down_queen")
.unwrap() .unwrap()
.as_str(), .as_str(),
); ).expect("PutDown Animation");
player if let Some(putdown_clip) = clips.get(putdown_handle) {
.start_with_transition( if putdown_clip.compatible_with(name) {
animation.expect("PutDown Animation").clone(), player
Duration::from_secs_f32(0.75), .start_with_transition(
) putdown_handle.clone(),
.set_repeat(RepeatAnimation::Never); Duration::from_secs_f32(0.75),
)
.set_repeat(RepeatAnimation::Never);
}
}
} }
}) })
} }

Loading…
Cancel
Save