Skip to content

Commit e10f36c

Browse files
authored
Update Bevy to v0.16 (#52)
* refactor: ⬆️ Update Bevy to v0.16 * fix: 🐛 Fix crash due to the UI side panel being updated in the wrong schedule * refactor: ♻️ Re-add `#[must_use]` on `FrameExt` trait method definitions * fix: 🐛 Fix panic on window close * fix: 🐛 Fix Peak Alloc panic * docs: 📝 Add development information to the readme
1 parent 8c0bc7b commit e10f36c

File tree

18 files changed

+775
-634
lines changed

18 files changed

+775
-634
lines changed

Cargo.lock

Lines changed: 691 additions & 585 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[workspace]
22
resolver = "2"
3-
members = ["crates/*", ]
3+
members = ["crates/*"]
44

55
[workspace.package]
66
version = "0.1.0"
@@ -9,9 +9,10 @@ license = "MIT OR Apache-2.0"
99
repository = "https://github.com/nixon-voxell/bevy_motion_matching"
1010

1111
[workspace.dependencies]
12-
bevy = { version = "0.15", features = ["asset_processor"] }
13-
bevy_gltf = "0.15"
14-
bevy_egui = "0.33"
12+
bevy = { version = "0.16", features = ["asset_processor"] }
13+
bevy_gltf = "0.16"
14+
bevy_egui = "0.34"
15+
bevy_platform = "0.16"
1516
serde_json = "1.0"
1617
serde = "1.0"
1718
bvh_anim = "0.4"
@@ -43,23 +44,24 @@ bevy_bvh_anim = { path = "crates/bevy_bvh_anim" }
4344
bevy = { workspace = true }
4445
bevy_gltf = { workspace = true }
4546
bevy_egui = { workspace = true }
47+
bevy_platform = { workspace = true }
4648
serde = { workspace = true }
4749
serde_json = { workspace = true }
4850
thiserror = { workspace = true }
4951

5052
egui_extras = "0.31.1"
51-
egui_plot = "0.31.0"
52-
leafwing-input-manager = "0.16.0"
53+
egui_plot = "0.32.1"
54+
leafwing-input-manager = "0.17"
5355

5456
# Debug editor (run with debug feature to enable it)
55-
bevy-inspector-egui = { version = "0.29", optional = true }
57+
bevy-inspector-egui = { version = "0.31", optional = true }
5658
kdtree = "0.7.0"
57-
peak_alloc = "0.2.1"
59+
peak_alloc = { git = "https://github.com/Steveplays28/peak_alloc", branch = "fix-usize-overflow" }
5860
clustering = "0.2.1"
5961
csv = "1.3.0"
6062

6163
[dev-dependencies]
62-
bevy-inspector-egui = { version = "0.29" }
64+
bevy-inspector-egui = { version = "0.31" }
6365

6466
[lints]
6567
workspace = true

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
Motion matching enables characters to smoothly transition between animations by finding the best matching pose and trajectory from an extensive database, without the need to create state machines.
99
Gameplay logic can be embedded side by side with motion matching by querying animations with the desired attributes.
1010

11+
## Showcase
12+
1113
### Configuration
1214

1315
![config](./.github/assets/config.png)
@@ -16,6 +18,29 @@ Gameplay logic can be embedded side by side with motion matching by querying ani
1618

1719
![play-mode](./.github/assets/play-mode.png)
1820

21+
## Development
22+
23+
### Prerequisites
24+
25+
- Rust
26+
- MSRV: v1.85.0
27+
- Cargo
28+
- Linux: [Bevy dependencies](https://github.com/bevyengine/bevy/blob/main/docs/linux_dependencies.md)
29+
- Optional, for the Visual Studio Code `start` task: `cargo-watch`
30+
- `cargo install cargo-watch` or `cargo binstall cargo-watch`
31+
32+
### Building
33+
34+
```bash
35+
cargo build
36+
```
37+
38+
### Running
39+
40+
```bash
41+
cargo run --features bevy/dynamic_linking
42+
```
43+
1944
## Reference
2045

2146
- [Learned Motion Matching](https://static-wordpress.ubisoft.com/montreal.ubisoft.com/wp-content/uploads/2020/07/09154101/Learned_Motion_Matching.pdf)

crates/bevy_bvh_anim/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ pub mod joint_matrices;
1818
pub mod joint_traits;
1919

2020
pub trait FrameExt {
21+
#[must_use]
2122
fn get_pos_rot(&self, joint_data: &JointData) -> (Vec3, Quat);
2223

24+
#[must_use]
2325
fn get_pos(&self, joint_data: &JointData) -> Vec3;
2426

27+
#[must_use]
2528
fn get_rot(&self, joint_data: &JointData) -> Quat;
2629
}
2730

2831
impl FrameExt for Frame {
29-
#[must_use]
3032
fn get_pos_rot(&self, joint_data: &JointData) -> (Vec3, Quat) {
3133
let mut pos = Vec3::ZERO;
3234
let mut euler = Vec3::ZERO;
@@ -52,7 +54,6 @@ impl FrameExt for Frame {
5254
)
5355
}
5456

55-
#[must_use]
5657
fn get_pos(&self, joint_data: &JointData) -> Vec3 {
5758
let mut pos = Vec3::ZERO;
5859

@@ -72,7 +73,6 @@ impl FrameExt for Frame {
7273
pos
7374
}
7475

75-
#[must_use]
7676
fn get_rot(&self, joint_data: &JointData) -> Quat {
7777
let mut euler = Vec3::ZERO;
7878

src/bvh_manager/bvh_gizmos.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ fn armature_gizmos(
7272
}
7373

7474
if let Ok(children) = q_children.get(parent) {
75-
for &child in children.iter() {
75+
for child in children.iter() {
7676
if let Ok(transform) = q_transforms.get(child) {
7777
let child_translation = transform.translation();
7878

@@ -99,7 +99,7 @@ fn armature_gizmos(
9999
}
100100
}
101101

102-
if let Ok((entity, transform)) = q_character.get_single() {
102+
if let Ok((entity, transform)) = q_character.single() {
103103
recursive_draw(
104104
0,
105105
entity,

src/bvh_manager/bvh_library.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use std::{fs, path::PathBuf, str::FromStr};
22

3-
use bevy::{prelude::*, utils::HashSet};
3+
use bevy::prelude::*;
44
use bevy_bvh_anim::prelude::*;
5+
use bevy_platform::collections::HashSet;
56

67
pub const BVH_FOLDER: &str = "bvh";
78
pub const BVH_MAP_FOLDER: &str = "bvh_map";

src/bvh_manager/bvh_player.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use bevy::{
22
asset::{DependencyLoadState, LoadState, RecursiveDependencyLoadState},
3+
platform::collections::HashMap,
34
prelude::*,
4-
utils::hashbrown::HashMap,
55
};
66
use bevy_bvh_anim::{bvh_anim::ChannelType, prelude::*};
77

@@ -35,7 +35,7 @@ fn generate_bone_map(
3535
server: Res<AssetServer>,
3636
mut asset_loaded: Local<bool>,
3737
) {
38-
let Ok((entity, scene_root)) = q_character.get_single() else {
38+
let Ok((entity, scene_root)) = q_character.single() else {
3939
return;
4040
};
4141

@@ -64,7 +64,7 @@ fn generate_bone_map(
6464
q_transforms: &Query<&Transform>,
6565
) {
6666
if let Ok(children) = q_children.get(parent) {
67-
for &child in children.iter() {
67+
for child in children.iter() {
6868
for _ in 0..indent {
6969
print!("| ");
7070
}

src/camera.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ fn pan_orbit_camera(
188188
{
189189
if is_focus {
190190
camera_focus.clear();
191-
} else if let Ok(entity) = q_main_scene.get_single() {
191+
} else if let Ok(entity) = q_main_scene.single() {
192192
camera_focus.set(entity);
193193
}
194194
}

src/motion/motion_player.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ fn _test(
7373

7474
// if input.just_pressed(KeyCode::Space) {
7575
// for entity in q_entities.iter() {
76-
// jump_evw.send(JumpToPose {
76+
// jump_evw.write(JumpToPose {
7777
// motion_pose: MotionPose {
7878
// chunk_index: 0,
7979
// time: 3.0,

src/motion_matching.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn flow(
9191
let index = motion_player.target_pair_index();
9292
let Some(traj_pose) = &traj_pose_pair[index] else {
9393
// Find a new animation to play.
94-
traj_match_evw.send(TrajectoryMatch(entity));
94+
traj_match_evw.write(TrajectoryMatch(entity));
9595
continue;
9696
};
9797

@@ -101,7 +101,7 @@ fn flow(
101101
continue;
102102
}
103103
false => {
104-
pred_match_evw.send(PredictionMatch {
104+
pred_match_evw.write(PredictionMatch {
105105
motion_pose: *traj_pose.motion_pose(),
106106
entity,
107107
});
@@ -154,7 +154,7 @@ fn prediction_match(
154154
trajectory_data.get_chunk(pred_match.chunk_index),
155155
pose_data.is_chunk_loopable(pred_match.chunk_index),
156156
) else {
157-
traj_match_evw.send(TrajectoryMatch(pred_match.entity));
157+
traj_match_evw.write(TrajectoryMatch(pred_match.entity));
158158
continue;
159159
};
160160

@@ -163,7 +163,7 @@ fn prediction_match(
163163
match loopable {
164164
true => chunk_offset = 0,
165165
false => {
166-
traj_match_evw.send(TrajectoryMatch(pred_match.entity));
166+
traj_match_evw.write(TrajectoryMatch(pred_match.entity));
167167
continue;
168168
}
169169
}
@@ -186,7 +186,7 @@ fn prediction_match(
186186
.collect::<Vec<_>>();
187187

188188
if traj.distance(&data_traj) > match_config.pred_match_threshold {
189-
traj_match_evw.send(TrajectoryMatch(pred_match.entity));
189+
traj_match_evw.write(TrajectoryMatch(pred_match.entity));
190190
}
191191
}
192192
}
@@ -301,7 +301,7 @@ fn trajectory_match(
301301
/ runs as f64;
302302
motion_matching_result.matching_result.runs = runs;
303303

304-
nearest_trajectories_evw.send(NearestTrajectories {
304+
nearest_trajectories_evw.write(NearestTrajectories {
305305
trajectories: nearest_trajs,
306306
entity,
307307
});
@@ -378,7 +378,7 @@ fn pose_match(
378378
motion_matching_result.selected_trajectory = best_traj_index;
379379

380380
let best_traj = &trajs[best_traj_index];
381-
jump_evw.send(JumpToPose {
381+
jump_evw.write(JumpToPose {
382382
motion_pose: MotionPose {
383383
chunk_index: best_traj.chunk_index,
384384
time: motion_asset

0 commit comments

Comments
 (0)