From 3c2de422db8b0fe8355330a265118d621c00d380 Mon Sep 17 00:00:00 2001 From: Snowram Date: Tue, 21 Sep 2021 01:19:34 +0200 Subject: [PATCH] Adds Xtilt to BirdLarge skeleton --- voxygen/anim/src/bird_large/run.rs | 13 +++++++------ voxygen/src/scene/figure/mod.rs | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/voxygen/anim/src/bird_large/run.rs b/voxygen/anim/src/bird_large/run.rs index 2e9e7fbb98..b2909c201d 100644 --- a/voxygen/anim/src/bird_large/run.rs +++ b/voxygen/anim/src/bird_large/run.rs @@ -7,7 +7,7 @@ use core::f32::consts::PI; pub struct RunAnimation; impl Animation for RunAnimation { - type Dependency<'a> = (Vec3, Vec3, Vec3, f32); + type Dependency<'a> = (Vec3, Vec3, Vec3, Vec3, f32); type Skeleton = BirdLargeSkeleton; #[cfg(feature = "use-dyn-lib")] @@ -16,7 +16,7 @@ impl Animation for RunAnimation { #[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_run")] fn update_skeleton_inner<'a>( skeleton: &Self::Skeleton, - (velocity, orientation, last_ori, acc_vel): Self::Dependency<'a>, + (velocity, orientation, last_ori, avg_vel, acc_vel): Self::Dependency<'a>, anim_time: f32, rate: &mut f32, s_a: &SkeletonAttr, @@ -64,6 +64,7 @@ impl Animation for RunAnimation { } else { 0.0 } * 1.3; + let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()) * speednorm; next.head.scale = Vec3::one() * 0.99; next.neck.scale = Vec3::one() * 1.01; @@ -110,9 +111,9 @@ impl Animation for RunAnimation { next.chest.position = Vec3::new( 0.0, s_a.chest.0, - s_a.chest.1 + short * 0.5 + speednorm * -2.0, + s_a.chest.1 + short * 0.5 + x_tilt * 10.0 + speednorm * -2.0, ) * s_a.scaler; - next.chest.orientation = Quaternion::rotation_x(-0.1 + short * 0.07) + next.chest.orientation = Quaternion::rotation_x(-0.1 + short * 0.07 + x_tilt) * Quaternion::rotation_y(tilt * 0.8) * Quaternion::rotation_z(shortalt * 0.10); @@ -177,9 +178,9 @@ impl Animation for RunAnimation { next.chest.position = Vec3::new( 0.0, s_a.chest.0, - s_a.chest.1 + short * 0.5 + 0.5 * speednorm, + s_a.chest.1 + short * 0.5 + x_tilt * 10.0 + 0.5 * speednorm, ) * s_a.scaler; - next.chest.orientation = Quaternion::rotation_x(short * 0.07) + next.chest.orientation = Quaternion::rotation_x(short * 0.07 + x_tilt) * Quaternion::rotation_y(tilt * 0.8) * Quaternion::rotation_z(shortalt * 0.10); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 97bc171988..e0d87e8fc0 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -3336,6 +3336,9 @@ impl FigureMgr { FigureState::new(renderer, BirdLargeSkeleton::default(), body) }); + // Average velocity relative to the current ground + let rel_avg_vel = state.avg_vel - physics.ground_vel; + let (character, last_character) = match (character, last_character) { (Some(c), Some(l)) => (c, l), _ => continue, @@ -3366,6 +3369,7 @@ impl FigureMgr { // TODO: Update to use the quaternion. ori * anim::vek::Vec3::::unit_y(), state.last_ori * anim::vek::Vec3::::unit_y(), + rel_avg_vel, state.acc_vel, ), state.state_time,