mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Adds Xtilt to BirdLarge skeleton
This commit is contained in:
@ -7,7 +7,7 @@ use core::f32::consts::PI;
|
|||||||
pub struct RunAnimation;
|
pub struct RunAnimation;
|
||||||
|
|
||||||
impl Animation for RunAnimation {
|
impl Animation for RunAnimation {
|
||||||
type Dependency<'a> = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f32);
|
type Dependency<'a> = (Vec3<f32>, Vec3<f32>, Vec3<f32>, Vec3<f32>, f32);
|
||||||
type Skeleton = BirdLargeSkeleton;
|
type Skeleton = BirdLargeSkeleton;
|
||||||
|
|
||||||
#[cfg(feature = "use-dyn-lib")]
|
#[cfg(feature = "use-dyn-lib")]
|
||||||
@ -16,7 +16,7 @@ impl Animation for RunAnimation {
|
|||||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_run")]
|
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_run")]
|
||||||
fn update_skeleton_inner<'a>(
|
fn update_skeleton_inner<'a>(
|
||||||
skeleton: &Self::Skeleton,
|
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,
|
anim_time: f32,
|
||||||
rate: &mut f32,
|
rate: &mut f32,
|
||||||
s_a: &SkeletonAttr,
|
s_a: &SkeletonAttr,
|
||||||
@ -64,6 +64,7 @@ impl Animation for RunAnimation {
|
|||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
} * 1.3;
|
} * 1.3;
|
||||||
|
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()) * speednorm;
|
||||||
|
|
||||||
next.head.scale = Vec3::one() * 0.99;
|
next.head.scale = Vec3::one() * 0.99;
|
||||||
next.neck.scale = Vec3::one() * 1.01;
|
next.neck.scale = Vec3::one() * 1.01;
|
||||||
@ -110,9 +111,9 @@ impl Animation for RunAnimation {
|
|||||||
next.chest.position = Vec3::new(
|
next.chest.position = Vec3::new(
|
||||||
0.0,
|
0.0,
|
||||||
s_a.chest.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;
|
) * 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_y(tilt * 0.8)
|
||||||
* Quaternion::rotation_z(shortalt * 0.10);
|
* Quaternion::rotation_z(shortalt * 0.10);
|
||||||
|
|
||||||
@ -177,9 +178,9 @@ impl Animation for RunAnimation {
|
|||||||
next.chest.position = Vec3::new(
|
next.chest.position = Vec3::new(
|
||||||
0.0,
|
0.0,
|
||||||
s_a.chest.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;
|
) * 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_y(tilt * 0.8)
|
||||||
* Quaternion::rotation_z(shortalt * 0.10);
|
* Quaternion::rotation_z(shortalt * 0.10);
|
||||||
|
|
||||||
|
@ -3336,6 +3336,9 @@ impl FigureMgr {
|
|||||||
FigureState::new(renderer, BirdLargeSkeleton::default(), body)
|
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) {
|
let (character, last_character) = match (character, last_character) {
|
||||||
(Some(c), Some(l)) => (c, l),
|
(Some(c), Some(l)) => (c, l),
|
||||||
_ => continue,
|
_ => continue,
|
||||||
@ -3366,6 +3369,7 @@ impl FigureMgr {
|
|||||||
// TODO: Update to use the quaternion.
|
// TODO: Update to use the quaternion.
|
||||||
ori * anim::vek::Vec3::<f32>::unit_y(),
|
ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||||
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
|
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||||
|
rel_avg_vel,
|
||||||
state.acc_vel,
|
state.acc_vel,
|
||||||
),
|
),
|
||||||
state.state_time,
|
state.state_time,
|
||||||
|
Reference in New Issue
Block a user