Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/motion_data/motion_data.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions imported_assets/Default/bvh/Walk/Left Turn 90.bvh.meta
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(
meta_format_version: "1.0",
processed_info: Some((
hash: (246, 57, 126, 66, 58, 43, 30, 97, 20, 187, 0, 234, 143, 248, 238, 108, 254, 107, 13, 133, 129, 57, 174, 6, 173, 94, 193, 228, 76, 156, 100, 47),
full_hash: (246, 57, 126, 66, 58, 43, 30, 97, 20, 187, 0, 234, 143, 248, 238, 108, 254, 107, 13, 133, 129, 57, 174, 6, 173, 94, 193, 228, 76, 156, 100, 47),
hash: (207, 155, 50, 168, 216, 31, 7, 214, 250, 95, 84, 17, 207, 154, 3, 40, 195, 110, 145, 97, 12, 228, 43, 194, 65, 183, 98, 46, 94, 50, 70, 64),
full_hash: (207, 155, 50, 168, 216, 31, 7, 214, 250, 95, 84, 17, 207, 154, 3, 40, 195, 110, 145, 97, 12, 228, 43, 194, 65, 183, 98, 46, 94, 50, 70, 64),
process_dependencies: [],
)),
asset: Load(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(
meta_format_version: "1.0",
processed_info: Some((
hash: (99, 59, 244, 128, 200, 129, 10, 123, 151, 0, 90, 89, 124, 132, 29, 226, 248, 81, 50, 187, 9, 29, 185, 61, 249, 213, 128, 196, 167, 104, 156, 119),
full_hash: (99, 59, 244, 128, 200, 129, 10, 123, 151, 0, 90, 89, 124, 132, 29, 226, 248, 81, 50, 187, 9, 29, 185, 61, 249, 213, 128, 196, 167, 104, 156, 119),
hash: (70, 84, 121, 229, 145, 241, 139, 14, 67, 178, 120, 44, 70, 109, 219, 104, 56, 171, 0, 188, 160, 100, 3, 174, 235, 120, 36, 52, 82, 93, 253, 162),
full_hash: (70, 84, 121, 229, 145, 241, 139, 14, 67, 178, 120, 44, 70, 109, 219, 104, 56, 171, 0, 188, 160, 100, 3, 174, 235, 120, 36, 52, 82, 93, 253, 162),
process_dependencies: [],
)),
asset: Load(
Expand Down
4 changes: 2 additions & 2 deletions imported_assets/Default/bvh/Walk/Right Turn 90.bvh.meta
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(
meta_format_version: "1.0",
processed_info: Some((
hash: (179, 24, 113, 213, 229, 71, 28, 160, 10, 127, 132, 95, 11, 222, 35, 85, 206, 136, 174, 215, 100, 228, 149, 25, 132, 251, 96, 190, 227, 24, 104, 71),
full_hash: (179, 24, 113, 213, 229, 71, 28, 160, 10, 127, 132, 95, 11, 222, 35, 85, 206, 136, 174, 215, 100, 228, 149, 25, 132, 251, 96, 190, 227, 24, 104, 71),
hash: (183, 180, 140, 111, 168, 74, 96, 16, 242, 238, 135, 15, 19, 147, 139, 98, 55, 201, 160, 52, 216, 220, 185, 38, 104, 217, 200, 74, 218, 107, 110, 251),
full_hash: (183, 180, 140, 111, 168, 74, 96, 16, 242, 238, 135, 15, 19, 147, 139, 98, 55, 201, 160, 52, 216, 220, 185, 38, 104, 217, 200, 74, 218, 107, 110, 251),
process_dependencies: [],
)),
asset: Load(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(
meta_format_version: "1.0",
processed_info: Some((
hash: (105, 102, 118, 147, 146, 72, 79, 20, 200, 75, 2, 136, 237, 111, 21, 198, 63, 130, 222, 149, 134, 39, 152, 50, 233, 255, 50, 144, 161, 126, 198, 117),
full_hash: (105, 102, 118, 147, 146, 72, 79, 20, 200, 75, 2, 136, 237, 111, 21, 198, 63, 130, 222, 149, 134, 39, 152, 50, 233, 255, 50, 144, 161, 126, 198, 117),
hash: (199, 239, 224, 42, 64, 127, 164, 162, 229, 137, 106, 60, 80, 220, 135, 91, 189, 57, 165, 100, 110, 60, 235, 32, 62, 41, 158, 130, 0, 41, 196, 104),
full_hash: (199, 239, 224, 42, 64, 127, 164, 162, 229, 137, 106, 60, 80, 220, 135, 91, 189, 57, 165, 100, 110, 60, 235, 32, 62, 41, 158, 130, 0, 41, 196, 104),
process_dependencies: [],
)),
asset: Load(
Expand Down
4 changes: 2 additions & 2 deletions imported_assets/Default/bvh/Walk/Walk Backwards.bvh.meta
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(
meta_format_version: "1.0",
processed_info: Some((
hash: (188, 212, 6, 169, 125, 104, 181, 112, 106, 110, 6, 94, 234, 90, 22, 22, 230, 116, 162, 42, 106, 131, 133, 123, 164, 234, 26, 116, 33, 198, 210, 203),
full_hash: (188, 212, 6, 169, 125, 104, 181, 112, 106, 110, 6, 94, 234, 90, 22, 22, 230, 116, 162, 42, 106, 131, 133, 123, 164, 234, 26, 116, 33, 198, 210, 203),
hash: (81, 185, 118, 210, 112, 168, 160, 177, 171, 40, 196, 198, 63, 73, 229, 94, 174, 251, 170, 240, 229, 143, 144, 231, 83, 105, 122, 6, 249, 60, 183, 42),
full_hash: (81, 185, 118, 210, 112, 168, 160, 177, 171, 40, 196, 198, 63, 73, 229, 94, 174, 251, 170, 240, 229, 143, 144, 231, 83, 105, 122, 6, 249, 60, 183, 42),
process_dependencies: [],
)),
asset: Load(
Expand Down
2 changes: 1 addition & 1 deletion imported_assets/Default/motion_data/motion_data.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions imported_assets/Default/motion_data/motion_data.json.meta
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(
meta_format_version: "1.0",
processed_info: Some((
hash: (17, 242, 183, 142, 147, 160, 233, 76, 28, 247, 180, 200, 176, 153, 225, 113, 11, 215, 214, 181, 7, 154, 60, 3, 162, 184, 17, 3, 119, 180, 169, 186),
full_hash: (17, 242, 183, 142, 147, 160, 233, 76, 28, 247, 180, 200, 176, 153, 225, 113, 11, 215, 214, 181, 7, 154, 60, 3, 162, 184, 17, 3, 119, 180, 169, 186),
hash: (152, 243, 17, 201, 12, 250, 250, 10, 180, 251, 244, 73, 166, 182, 191, 91, 169, 217, 15, 236, 104, 235, 184, 31, 50, 113, 58, 226, 62, 8, 19, 117),
full_hash: (152, 243, 17, 201, 12, 250, 250, 10, 180, 251, 244, 73, 166, 182, 191, 91, 169, 217, 15, 236, 104, 235, 184, 31, 50, 113, 58, 226, 62, 8, 19, 117),
process_dependencies: [],
)),
asset: Load(
Expand Down
63 changes: 62 additions & 1 deletion src/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use crate::action::PlayerAction;
use crate::draw_axes::{ColorPalette, DrawAxes};
use crate::trajectory::MovementDirection;
use crate::transform2d::Transform2d;
use crate::ui::play_mode::RunPresetDirection;
use crate::MainSet;

pub struct PlayerPlugin;
Expand All @@ -18,20 +19,80 @@ impl Plugin for PlayerPlugin {
})
.add_systems(
Update,
(movement_direction, draw_player_direction)
(
preset_movement_direction,
movement_direction,
draw_player_direction,
)
.chain()
.in_set(MainSet::Action),
);
}
}

fn preset_movement_direction(
mut q_movement_directions: Query<&mut MovementDirection>,
time: Res<Time>,
movement_config: Res<MovementConfig>,
mut state: Local<(usize, f32)>,
run_preset_direction: Res<RunPresetDirection>,
) {
if **run_preset_direction == false {
return;
}

let directions = [
// Up
Vec2::new(0.0, 1.0),
// Right
Vec2::new(1.0, 0.0),
// Down
Vec2::new(0.0, -1.0),
// Left
Vec2::new(-1.0, 0.0),
];

let direction_durations = [6.0, 5.0, 5.0, 5.0];

let (current_direction, elapsed_time) = *state;

let new_elapsed_time = elapsed_time + time.delta_seconds();

let current_direction_duration = direction_durations[current_direction];

let mut new_direction = current_direction;
let mut reset_time = new_elapsed_time;

if new_elapsed_time >= current_direction_duration {
new_direction = (current_direction + 1) % directions.len();
reset_time = 0.0;
}

*state = (new_direction, reset_time);

let direction = directions[new_direction];
for mut movement_direction in q_movement_directions.iter_mut() {
// **movement_direction = direction;

**movement_direction = Vec2::lerp(
**movement_direction,
direction,
f32::min(1.0, movement_config.lerp_factor * time.delta_seconds()),
);
}
}

fn movement_direction(
mut q_movement_directions: Query<&mut MovementDirection>,
movement_config: Res<MovementConfig>,
action: Res<ActionState<PlayerAction>>,
time: Res<Time>,
q_camera: Query<&Transform, With<Camera>>,
run_preset_direction: Res<RunPresetDirection>,
) {
if **run_preset_direction {
return;
}
let camera_transform = q_camera.single();
let mut action_axis = action
.clamped_axis_pair(&PlayerAction::Walk)
Expand Down
1 change: 1 addition & 0 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl Plugin for UiPlugin {
.init_resource::<config::DrawMainArmature>()
.init_resource::<play_mode::DrawNearestTrajectory>()
.init_resource::<play_mode::DrawNearestPoseArmature>()
.init_resource::<play_mode::RunPresetDirection>()
.init_resource::<config::DrawTrajectory>()
.init_resource::<builder::BuildConfigs>()
.init_resource::<play_mode::MotionMatchingResult>()
Expand Down
15 changes: 15 additions & 0 deletions src/ui/play_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub fn play_mode_panel(ui: &mut egui::Ui, world: &mut World) {
data_inspector(ui, world);
draw_nearest_pose_armature_checkbox(ui, world);
draw_nearest_trajectory_checkbox(ui, world);
run_preset_direction(ui, world);
motion_matching_method(ui, world);
trajectory_matching_visualization(ui, world);
motion_matching_result(ui, world);
Expand Down Expand Up @@ -86,6 +87,11 @@ fn draw_nearest_pose_armature_checkbox(ui: &mut egui::Ui, world: &mut World) {
fn draw_nearest_trajectory_checkbox(ui: &mut egui::Ui, world: &mut World) {
let mut draw_trajectory = world.resource_mut::<DrawNearestTrajectory>();
ui.checkbox(&mut draw_trajectory, "Show Nearest Trajectory Arrows");
}

fn run_preset_direction(ui: &mut egui::Ui, world: &mut World) {
let mut run_preset_movement = world.resource_mut::<RunPresetDirection>();
ui.checkbox(&mut run_preset_movement, "Run Preset Movement");
ui.add_space(10.0);
}

Expand Down Expand Up @@ -317,6 +323,15 @@ impl Default for DrawNearestTrajectory {
}
}

#[derive(Resource, Deref, DerefMut)]
pub struct RunPresetDirection(bool);

impl Default for RunPresetDirection {
fn default() -> Self {
Self(true)
}
}

#[derive(Default, Resource)]
pub struct MotionMatchingResult {
/// Match trajectories and pose distances.
Expand Down