Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
kayhhh committed Sep 26, 2024
1 parent 5da0477 commit 7e1b177
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 352 deletions.
209 changes: 0 additions & 209 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ bevy_mod_xr = { git = "https://github.com/awtterpip/bevy_oxr", optional = true }
bevy_vrm = "0.0.12"
bevy_xr_utils = { git = "https://github.com/awtterpip/bevy_oxr", optional = true }
paste = "1.0.15"
bevy_mod_picking = "0.20.1"
bevy_transform_gizmo = "0.12.0"

[target.'cfg(not(target_family = "wasm"))'.dependencies]
bevy_mod_openxr = { git = "https://github.com/awtterpip/bevy_oxr", optional = true }
Expand Down
3 changes: 0 additions & 3 deletions examples/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ use bevy::prelude::*;
use bevy_vr_controller::{
animation::defaults::default_character_animations, player::PlayerSettings, VrControllerPlugin,
};
use bevy_xr_utils::{
tracking_utils::TrackingUtilitiesPlugin, xr_utils_actions::XRUtilsActionsPlugin,
};

fn main() {
let mut app = App::new();
Expand Down
9 changes: 5 additions & 4 deletions src/animation/load.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use bevy::{gltf::GltfNode, prelude::*, utils::HashMap};
use bevy_vrm::{animations::vrm::VRM_ANIMATION_TARGETS, BoneName};

use super::{
mixamo::{MIXAMO_ANIMATION_TARGETS, MIXAMO_BONE_NAMES},
AnimationName,
};
use crate::ik::RunHumanoidIk;
use bevy::{gltf::GltfNode, prelude::*, utils::HashMap};
use bevy_vrm::{animations::vrm::VRM_ANIMATION_TARGETS, BoneName};

#[derive(Component, Clone)]
pub struct AvatarAnimationClips(pub HashMap<AnimationName, AvatarAnimation>);
Expand All @@ -25,7 +25,7 @@ pub(crate) fn load_animation_nodes(
mut gltfs: ResMut<Assets<Gltf>>,
mut graphs: ResMut<Assets<AnimationGraph>>,
nodes: Res<Assets<GltfNode>>,
run_humanoid_ik: Res<RunHumanoidIk>,
#[cfg(feature = "xr")] run_humanoid_ik: Res<crate::ik::RunHumanoidIk>,
) {
for (entity, animations) in avatars.iter() {
let mut graph = AnimationGraph::default();
Expand Down Expand Up @@ -58,6 +58,7 @@ pub(crate) fn load_animation_nodes(
continue;
}

#[cfg(feature = "xr")]
if run_humanoid_ik.0 {
match name {
BoneName::LeftShoulder
Expand Down
1 change: 0 additions & 1 deletion src/animation/weights.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use bevy::{animation::ActiveAnimation, prelude::*, utils::HashMap};

use super::{AnimationName, AvatarAnimationNodes};
use crate::ik::RunHumanoidIk;
use crate::{
player::{PlayerAvatar, PlayerBody},
velocity::AverageVelocity,
Expand Down
29 changes: 29 additions & 0 deletions src/ik/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use bevy::{prelude::*, transform::systems::propagate_transforms};

mod systems;

pub struct HumanoidIKPlugin;

impl Plugin for HumanoidIKPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<RunHumanoidIk>().add_systems(
Update,
(
systems::setup_ik_system,
systems::modify_ik_state,
(
propagate_transforms,
systems::reset_rotations,
propagate_transforms,
systems::humanoid_ik_system,
)
.chain()
.after(crate::animation::weights::play_avatar_animations)
.run_if(resource_equals::<RunHumanoidIk>(RunHumanoidIk(true))),
),
);
}
}

#[derive(Resource, Default, PartialEq, Eq)]
pub struct RunHumanoidIk(pub bool);
Loading

0 comments on commit 7e1b177

Please sign in to comment.