veloren_voxygen_anim/quadruped_low/
jump.rs

1use common::comp::body::parts::HeadState;
2
3use super::{
4    super::{Animation, vek::*},
5    QuadrupedLowSkeleton, SkeletonAttr,
6};
7
8pub struct JumpAnimation;
9
10impl Animation for JumpAnimation {
11    type Dependency<'a> = (f32, f32, &'a [HeadState]);
12    type Skeleton = QuadrupedLowSkeleton;
13
14    #[cfg(feature = "use-dyn-lib")]
15    const UPDATE_FN: &'static [u8] = b"quadruped_low_jump\0";
16
17    #[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_jump")]
18    fn update_skeleton_inner(
19        skeleton: &Self::Skeleton,
20        (_global_time, _, head_states): Self::Dependency<'_>,
21        _anim_time: f32,
22        _rate: &mut f32,
23        s_a: &SkeletonAttr,
24    ) -> Self::Skeleton {
25        let mut next = (*skeleton).clone();
26
27        next.tail_front.scale = Vec3::one() * 0.98;
28        next.tail_rear.scale = Vec3::one() * 0.98;
29
30        // Central head
31        next.head_c_upper.position = Vec3::new(0.0, s_a.head_upper.0, s_a.head_upper.1);
32
33        next.head_c_lower.position = Vec3::new(0.0, s_a.head_lower.0, s_a.head_lower.1);
34        next.head_c_lower.scale = Vec3::one() * (head_states[1].is_attached() as i32 as f32);
35
36        next.jaw_c.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
37
38        // Left head
39        next.jaw_l.scale = Vec3::one() * 0.98;
40        next.head_l_upper.position = Vec3::new(
41            -s_a.side_head_upper.0,
42            s_a.side_head_upper.1,
43            s_a.side_head_upper.2,
44        );
45
46        next.head_l_lower.position = Vec3::new(
47            -s_a.side_head_lower.0,
48            s_a.side_head_lower.1,
49            s_a.side_head_lower.2,
50        );
51        next.head_l_lower.scale = Vec3::one() * (head_states[0].is_attached() as i32 as f32);
52
53        next.jaw_l.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
54
55        // Right head
56        next.jaw_r.scale = Vec3::one() * 0.98;
57        next.head_r_upper.position = Vec3::new(
58            s_a.side_head_upper.0,
59            s_a.side_head_upper.1,
60            s_a.side_head_upper.2,
61        );
62
63        next.head_r_lower.position = Vec3::new(
64            s_a.side_head_lower.0,
65            s_a.side_head_lower.1,
66            s_a.side_head_lower.2,
67        );
68        next.head_r_lower.scale = Vec3::one() * (head_states[2].is_attached() as i32 as f32);
69
70        next.jaw_r.position = Vec3::new(0.0, s_a.jaw.0, s_a.jaw.1);
71
72        next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1);
73        if s_a.tongue_for_tail {
74            next.tail_front.scale = Vec3::one() * 0.1;
75            next.tail_rear.scale = Vec3::one() * 0.1;
76        } else {
77            next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
78
79            next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
80        }
81        next.foot_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2);
82
83        next.foot_fr.position = Vec3::new(s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2);
84
85        next.foot_bl.position = Vec3::new(-s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2);
86
87        next.foot_br.position = Vec3::new(s_a.feet_b.0, s_a.feet_b.1, s_a.feet_b.2);
88
89        next
90    }
91}