From 691607f3987f106b00caebd9c0a49684f24bc7bd Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sat, 1 Aug 2020 22:59:22 -0400 Subject: [PATCH 1/8] swimming changes --- voxygen/src/anim/Cargo.toml | 2 +- voxygen/src/anim/src/character/climb.rs | 489 ++++++++++++++++++------ voxygen/src/anim/src/character/run.rs | 12 +- voxygen/src/anim/src/character/swim.rs | 85 ++-- voxygen/src/scene/figure/mod.rs | 1 + voxygen/src/session.rs | 7 +- voxygen/src/settings.rs | 12 +- voxygen/src/window.rs | 11 +- 8 files changed, 451 insertions(+), 168 deletions(-) diff --git a/voxygen/src/anim/Cargo.toml b/voxygen/src/anim/Cargo.toml index ab4d0e2bfe..92ce71acb0 100644 --- a/voxygen/src/anim/Cargo.toml +++ b/voxygen/src/anim/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" name = "voxygen_anim" # Uncomment to use animation hot reloading # Note: this breaks `cargo test` -# crate-type = ["lib", "cdylib"] +crate-type = ["lib", "cdylib"] [features] use-dyn-lib = ["libloading", "notify", "lazy_static", "tracing", "find_folder"] diff --git a/voxygen/src/anim/src/character/climb.rs b/voxygen/src/anim/src/character/climb.rs index 47257ed641..adcb48b5c4 100644 --- a/voxygen/src/anim/src/character/climb.rs +++ b/voxygen/src/anim/src/character/climb.rs @@ -1,6 +1,7 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; use common::comp::item::{Hands, ToolKind}; -use std::f32::consts::PI; +use std::{f32::consts::PI, ops::Mul}; + use vek::*; pub struct ClimbAnimation; @@ -21,19 +22,20 @@ impl Animation for ClimbAnimation { #[cfg_attr(feature = "be-dyn-lib", export_name = "character_climb")] fn update_skeleton_inner( skeleton: &Self::Skeleton, - (active_tool_kind, second_tool_kind, velocity, _orientation, _global_time): Self::Dependency, + (active_tool_kind, second_tool_kind, velocity, _orientation, global_time): Self::Dependency, anim_time: f64, rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let speed = velocity.magnitude(); + let speed = velocity.z; *rate = speed; - let constant = 1.0; let smooth = (anim_time as f32 * constant as f32 * 1.5).sin(); let smootha = (anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin(); + let drop = (anim_time as f32 * constant as f32 * 4.0 + PI / 2.0).sin(); + let dropa = (anim_time as f32 * constant as f32 * 4.0).sin(); let quick = (((5.0) / (0.6 + 4.0 * ((anim_time as f32 * constant as f32 * 1.5).sin()).powf(2.0 as f32))) @@ -46,145 +48,386 @@ impl Animation for ClimbAnimation { .powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * constant as f32 * 1.5 + PI / 2.0).sin()); - - next.head.offset = Vec3::new( - 0.0, - -4.0 + skeleton_attr.head.0, - skeleton_attr.head.1 + smootha * 0.2, + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 2.0) + .floor() + .mul(7331.0) + .sin() + * 0.3, + ((global_time + anim_time) as f32 / 2.0) + .floor() + .mul(1337.0) + .sin() + * 0.15, ); - next.head.ori = Quaternion::rotation_z(smooth * 0.1) - * Quaternion::rotation_x(0.6) - * Quaternion::rotation_y(quick * 0.1); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; + if speed > 0.7 { + next.head.offset = Vec3::new( + 0.0, + -4.0 + skeleton_attr.head.0, + skeleton_attr.head.1 + smootha * 0.2, + ); + next.head.ori = Quaternion::rotation_z(smooth * 0.1) + * Quaternion::rotation_x(0.6) + * Quaternion::rotation_y(quick * 0.1); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new( - 0.0, - skeleton_attr.chest.0 + 1.0, - skeleton_attr.chest.1 + smootha * 1.1, - ); - next.chest.ori = Quaternion::rotation_z(quick * 0.25) - * Quaternion::rotation_x(-0.15) - * Quaternion::rotation_y(quick * -0.12); - next.chest.scale = Vec3::one(); + next.chest.offset = Vec3::new( + 0.0, + skeleton_attr.chest.0, + skeleton_attr.chest.1 + smootha * 1.1, + ); + next.chest.ori = Quaternion::rotation_z(quick * 0.25) + * Quaternion::rotation_x(-0.15) + * Quaternion::rotation_y(quick * -0.12); + next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 1.0, skeleton_attr.belt.1); - next.belt.ori = Quaternion::rotation_z(quick * 0.0) * Quaternion::rotation_x(0.0); - next.belt.scale = Vec3::one(); + next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 1.0, skeleton_attr.belt.1); + next.belt.ori = Quaternion::rotation_z(quick * 0.0) * Quaternion::rotation_x(0.0); + next.belt.scale = Vec3::one(); - next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); - next.back.ori = Quaternion::rotation_x(-0.2); - next.back.scale = Vec3::one() * 1.02; + next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); + next.back.ori = Quaternion::rotation_x(-0.2); + next.back.scale = Vec3::one() * 1.02; - next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1); - next.shorts.ori = Quaternion::rotation_z(quick * 0.0) - * Quaternion::rotation_x(0.1) - * Quaternion::rotation_y(quick * 0.10); - next.shorts.scale = Vec3::one(); + next.shorts.offset = + Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1); + next.shorts.ori = Quaternion::rotation_z(quick * 0.0) + * Quaternion::rotation_x(0.1) + * Quaternion::rotation_y(quick * 0.10); + next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new( - -skeleton_attr.hand.0, - skeleton_attr.hand.1 + quicka * 1.5, - 5.0 + skeleton_attr.hand.2 - quick * 4.0, - ); - next.l_hand.ori = Quaternion::rotation_x(2.2 + quicka * 0.5); - next.l_hand.scale = Vec3::one(); + next.l_hand.offset = Vec3::new( + -skeleton_attr.hand.0, + 4.0 + skeleton_attr.hand.1 + quicka * 1.5, + 5.0 + skeleton_attr.hand.2 - quick * 4.0, + ); + next.l_hand.ori = Quaternion::rotation_x(2.2 + quicka * 0.5); + next.l_hand.scale = Vec3::one(); - next.r_hand.offset = Vec3::new( - skeleton_attr.hand.0, - skeleton_attr.hand.1 - quicka * 1.5, - 5.0 + skeleton_attr.hand.2 + quick * 4.0, - ); - next.r_hand.ori = Quaternion::rotation_x(2.2 - quicka * 0.5); - next.r_hand.scale = Vec3::one(); + next.r_hand.offset = Vec3::new( + skeleton_attr.hand.0, + 5.0 + skeleton_attr.hand.1 - quicka * 1.5, + 5.0 + skeleton_attr.hand.2 + quick * 4.0, + ); + next.r_hand.ori = Quaternion::rotation_x(2.2 - quicka * 0.5); + next.r_hand.scale = Vec3::one(); - next.l_foot.offset = Vec3::new( - -skeleton_attr.foot.0, - 1.0 + skeleton_attr.foot.1, - skeleton_attr.foot.2 + quick * 2.5, - ); - next.l_foot.ori = Quaternion::rotation_x(0.2 - quicka * 0.5); - next.l_foot.scale = Vec3::one(); + match active_tool_kind { + Some(ToolKind::Dagger(_)) => { + next.main.offset = Vec3::new(-4.0, -5.0, 7.0); + next.main.ori = + Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI); + }, + Some(ToolKind::Shield(_)) => { + next.main.offset = Vec3::new(-0.0, -5.0, 3.0); + next.main.ori = + Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); + }, + _ => { + next.main.offset = Vec3::new(-7.0, -5.0, 15.0); + next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); + }, + } + next.main.scale = Vec3::one(); - next.r_foot.offset = Vec3::new( - skeleton_attr.foot.0, - 1.0 + skeleton_attr.foot.1, - skeleton_attr.foot.2 - quick * 2.5, - ); - next.r_foot.ori = Quaternion::rotation_x(0.2 + quicka * 0.5); - next.r_foot.scale = Vec3::one(); + match second_tool_kind { + Some(ToolKind::Dagger(_)) => { + next.second.offset = Vec3::new(4.0, -6.0, 7.0); + next.second.ori = + Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); + }, + Some(ToolKind::Shield(_)) => { + next.second.offset = Vec3::new(0.0, -4.0, 3.0); + next.second.ori = + Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); + }, + _ => { + next.second.offset = Vec3::new(-7.0, -5.0, 15.0); + next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); + }, + } + next.second.scale = Vec3::one(); + next.l_foot.offset = Vec3::new( + -skeleton_attr.foot.0, + 5.0 + skeleton_attr.foot.1, + skeleton_attr.foot.2 + quick * 2.5, + ); + next.l_foot.ori = Quaternion::rotation_x(0.2 - quicka * 0.5); + next.l_foot.scale = Vec3::one(); - next.l_shoulder.offset = Vec3::new( - -skeleton_attr.shoulder.0, - skeleton_attr.shoulder.1, - skeleton_attr.shoulder.2, - ); - next.l_shoulder.ori = Quaternion::rotation_x(smootha * 0.15); - next.l_shoulder.scale = Vec3::one() * 1.1; + next.r_foot.offset = Vec3::new( + skeleton_attr.foot.0, + 4.0 + skeleton_attr.foot.1, + skeleton_attr.foot.2 - quick * 2.5, + ); + next.r_foot.ori = Quaternion::rotation_x(0.2 + quicka * 0.5); + next.r_foot.scale = Vec3::one(); - next.r_shoulder.offset = Vec3::new( - skeleton_attr.shoulder.0, - skeleton_attr.shoulder.1, - skeleton_attr.shoulder.2, - ); - next.r_shoulder.ori = Quaternion::rotation_x(smooth * 0.15); - next.r_shoulder.scale = Vec3::one() * 1.1; + next.l_shoulder.offset = Vec3::new( + -skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.l_shoulder.ori = Quaternion::rotation_x(smootha * 0.15); + next.l_shoulder.scale = Vec3::one() * 1.1; - next.glider.offset = Vec3::new(0.0, 0.0, 10.0); - next.glider.scale = Vec3::one() * 0.0; + next.r_shoulder.offset = Vec3::new( + skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.r_shoulder.ori = Quaternion::rotation_x(smooth * 0.15); + next.r_shoulder.scale = Vec3::one() * 1.1; - match active_tool_kind { - Some(ToolKind::Dagger(_)) => { - next.main.offset = Vec3::new(-4.0, -5.0, 7.0); - next.main.ori = - Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(1.5 * PI); - }, - Some(ToolKind::Shield(_)) => { - next.main.offset = Vec3::new(-0.0, -5.0, 3.0); - next.main.ori = - Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); - }, - _ => { - next.main.offset = Vec3::new(-7.0, -5.0, 15.0); + next.glider.offset = Vec3::new(0.0, 0.0, 10.0); + next.glider.scale = Vec3::one() * 0.0; + + next.main.offset = Vec3::new(-7.0, -5.0, 18.0); + next.main.ori = + Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57 + smootha * 0.25); + next.main.scale = Vec3::one(); + + next.second.offset = Vec3::new(0.0, 0.0, 0.0); + next.second.ori = Quaternion::rotation_y(0.0); + next.second.scale = Vec3::one() * 0.0; + + next.lantern.offset = Vec3::new( + skeleton_attr.lantern.0, + skeleton_attr.lantern.1, + skeleton_attr.lantern.2, + ); + next.lantern.ori = + Quaternion::rotation_x(smooth * -0.3) * Quaternion::rotation_y(smooth * -0.3); + next.lantern.scale = Vec3::one() * 0.65; + + next.torso.offset = Vec3::new(0.0, -0.2 + smooth * -0.08, 0.4) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.control.scale = Vec3::one(); + + next.l_control.scale = Vec3::one(); + + next.r_control.scale = Vec3::one(); + } else { + if speed > -0.7 { + next.head.offset = + Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); + next.head.ori = Quaternion::rotation_x(2.0 * head_look.y.abs()) + * Quaternion::rotation_z(3.5 * head_look.x.abs()); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new( + 0.0, + -2.0 + skeleton_attr.chest.0 + 3.0, + skeleton_attr.chest.1, + ); + next.chest.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.3) + * Quaternion::rotation_z(0.6); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 0.5, skeleton_attr.belt.1); + next.belt.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.1); + next.belt.scale = Vec3::one(); + + next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); + next.back.ori = Quaternion::rotation_x(-0.2); + next.back.scale = Vec3::one() * 1.02; + + next.shorts.offset = + Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1); + next.shorts.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.1) + * Quaternion::rotation_y(0.0); + next.shorts.scale = Vec3::one(); + + next.l_hand.offset = Vec3::new( + -skeleton_attr.hand.0, + 2.0 + skeleton_attr.hand.1, + skeleton_attr.hand.2, + ); + next.l_hand.ori = Quaternion::rotation_x(0.8); + next.l_hand.scale = Vec3::one(); + + next.r_hand.offset = Vec3::new( + skeleton_attr.hand.0, + 5.5 + skeleton_attr.hand.1, + 5.0 + skeleton_attr.hand.2, + ); + next.r_hand.ori = Quaternion::rotation_x(2.2) * Quaternion::rotation_y(-0.5); + next.r_hand.scale = Vec3::one(); + + next.l_foot.offset = Vec3::new( + -skeleton_attr.foot.0, + 5.0 + skeleton_attr.foot.1, + 1.0 + skeleton_attr.foot.2, + ); + next.l_foot.ori = Quaternion::rotation_x(0.55); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new( + skeleton_attr.foot.0, + 5.0 + skeleton_attr.foot.1, + -2.0 + skeleton_attr.foot.2, + ); + next.r_foot.ori = Quaternion::rotation_x(0.2); + next.r_foot.scale = Vec3::one(); + + next.l_shoulder.offset = Vec3::new( + -skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.1; + + next.r_shoulder.offset = Vec3::new( + skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.1; + + next.glider.offset = Vec3::new(0.0, 0.0, 10.0); + next.glider.scale = Vec3::one() * 0.0; + + next.main.offset = Vec3::new(-7.0, -5.0, 18.0); next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); - }, - } - next.main.scale = Vec3::one(); + next.main.scale = Vec3::one(); - match second_tool_kind { - Some(ToolKind::Dagger(_)) => { - next.second.offset = Vec3::new(4.0, -6.0, 7.0); - next.second.ori = - Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); - }, - Some(ToolKind::Shield(_)) => { - next.second.offset = Vec3::new(0.0, -4.0, 3.0); - next.second.ori = - Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); - }, - _ => { - next.second.offset = Vec3::new(-7.0, -5.0, 15.0); - next.second.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); - }, - } - next.second.scale = Vec3::one(); + next.second.offset = Vec3::new(0.0, 0.0, 0.0); + next.second.ori = Quaternion::rotation_y(0.0); + next.second.scale = Vec3::one() * 0.0; - next.lantern.offset = Vec3::new( - skeleton_attr.lantern.0, - skeleton_attr.lantern.1, - skeleton_attr.lantern.2, - ); - next.lantern.ori = - Quaternion::rotation_x(smooth * -0.3) * Quaternion::rotation_y(smooth * -0.3); - next.lantern.scale = Vec3::one() * 0.65; + next.lantern.offset = Vec3::new( + skeleton_attr.lantern.0, + skeleton_attr.lantern.1, + skeleton_attr.lantern.2, + ); + next.lantern.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.lantern.scale = Vec3::one() * 0.65; - next.torso.offset = Vec3::new(0.0, -0.2 + smooth * -0.08, 0.4) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + next.torso.offset = Vec3::new(0.0, -0.2, 0.4) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - next.control.scale = Vec3::one(); + next.control.scale = Vec3::one(); - next.l_control.scale = Vec3::one(); + next.l_control.scale = Vec3::one(); + next.r_control.scale = Vec3::one(); + } else { + next.head.offset = + Vec3::new(0.0, -1.0 + skeleton_attr.head.0, skeleton_attr.head.1); + next.head.ori = Quaternion::rotation_x(-0.25) * Quaternion::rotation_z(0.0); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new( + 0.0, + -2.0 + skeleton_attr.chest.0 + 3.0, + skeleton_attr.chest.1, + ); + next.chest.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.2 + drop * 0.05) + * Quaternion::rotation_z(0.0); + next.chest.scale = Vec3::one(); + + next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 0.5, skeleton_attr.belt.1); + next.belt.ori = + Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.1 + dropa * 0.1); + next.belt.scale = Vec3::one(); + + next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); + next.back.ori = Quaternion::rotation_x(-0.15); + next.back.scale = Vec3::one() * 1.02; + + next.shorts.offset = + Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1); + next.shorts.ori = Quaternion::rotation_z(0.0) + * Quaternion::rotation_x(0.1 + dropa * 0.12) + * Quaternion::rotation_y(0.0); + next.shorts.scale = Vec3::one(); + + next.l_hand.offset = Vec3::new( + -skeleton_attr.hand.0, + 7.5 + skeleton_attr.hand.1, + 7.0 + skeleton_attr.hand.2 + dropa * -1.0, + ); + next.l_hand.ori = + Quaternion::rotation_x(2.2) * Quaternion::rotation_y(0.3 + dropa * 0.1); + next.l_hand.scale = Vec3::one(); + + next.r_hand.offset = Vec3::new( + skeleton_attr.hand.0, + 7.5 + skeleton_attr.hand.1, + 5.0 + skeleton_attr.hand.2 + drop * -1.0, + ); + next.r_hand.ori = + Quaternion::rotation_x(2.2) * Quaternion::rotation_y(-0.3 + drop * 0.1); + next.r_hand.scale = Vec3::one(); + + next.l_foot.offset = Vec3::new( + -skeleton_attr.foot.0, + 4.0 + skeleton_attr.foot.1, + 1.0 + skeleton_attr.foot.2 + drop * -2.0, + ); + next.l_foot.ori = Quaternion::rotation_x(0.55 + drop * 0.1); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new( + skeleton_attr.foot.0, + 2.0 + skeleton_attr.foot.1, + -2.0 + skeleton_attr.foot.2 + smooth * 1.0, + ); + next.r_foot.ori = Quaternion::rotation_x(0.2 + smooth * 0.15); + next.r_foot.scale = Vec3::one(); + + next.l_shoulder.offset = Vec3::new( + -skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.1; + + next.r_shoulder.offset = Vec3::new( + skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.1; + + next.glider.offset = Vec3::new(0.0, 0.0, 10.0); + next.glider.scale = Vec3::one() * 0.0; + + next.main.offset = Vec3::new(-7.0, -5.0, 18.0); + next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); + next.main.scale = Vec3::one(); + + next.second.offset = Vec3::new(0.0, 0.0, 0.0); + next.second.ori = Quaternion::rotation_y(0.0); + next.second.scale = Vec3::one() * 0.0; + + next.lantern.offset = Vec3::new( + skeleton_attr.lantern.0, + skeleton_attr.lantern.1, + skeleton_attr.lantern.2, + ); + next.lantern.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.lantern.scale = Vec3::one() * 0.65; + + next.torso.offset = Vec3::new(0.0, -0.2, 0.4) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.control.scale = Vec3::one(); + + next.l_control.scale = Vec3::one(); + } + }; next.r_control.scale = Vec3::one(); next.second.scale = match ( diff --git a/voxygen/src/anim/src/character/run.rs b/voxygen/src/anim/src/character/run.rs index f85f1ca477..d821576b11 100644 --- a/voxygen/src/anim/src/character/run.rs +++ b/voxygen/src/anim/src/character/run.rs @@ -48,17 +48,17 @@ impl Animation for RunAnimation { let footvertl = (anim_time as f32 * 16.0 * walk * lab as f32).sin(); let footvertr = (anim_time as f32 * 16.0 * walk * lab as f32 + PI).sin(); - let footrotl = (((5.0) - / (2.5 - + (2.5) + let footrotl = (((1.0) + / (0.5 + + (0.5) * ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 1.4).sin()) .powf(2.0 as f32))) .sqrt()) * ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 1.4).sin()); - let footrotr = (((5.0) - / (1.0 - + (4.0) + let footrotr = (((1.0) + / (0.5 + + (0.5) * ((anim_time as f32 * 16.0 * walk * lab as f32 + PI * 0.4).sin()) .powf(2.0 as f32))) .sqrt()) diff --git a/voxygen/src/anim/src/character/swim.rs b/voxygen/src/anim/src/character/swim.rs index e7e23023ae..e505c83198 100644 --- a/voxygen/src/anim/src/character/swim.rs +++ b/voxygen/src/anim/src/character/swim.rs @@ -12,6 +12,7 @@ type SwimAnimationDependency = ( Vec3, Vec3, f64, + Vec3, ); impl Animation for SwimAnimation { @@ -25,17 +26,19 @@ impl Animation for SwimAnimation { fn update_skeleton_inner( skeleton: &Self::Skeleton, - (active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency, + (active_tool_kind, second_tool_kind, velocity, orientation, last_ori, global_time, avg_vel): Self::Dependency, anim_time: f64, rate: &mut f32, skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - let speed = Vec2::::from(velocity).magnitude(); + let speed = Vec3::::from(velocity).magnitude(); *rate = 1.0; + let tempo = if speed > 0.5 { 1.0 } else { 0.7 }; + let intensity = if speed > 0.5 { 1.0 } else { 0.3 }; - let lab = 1.0; + let lab = 1.0 * tempo; let short = (anim_time as f32 * lab as f32 * 6.0).sin(); @@ -45,13 +48,29 @@ impl Animation for SwimAnimation { let wave_stop = (anim_time as f32 * 9.0).min(PI / 2.0 / 2.0).sin(); + let footrotl = (((1.0) + / (0.2 + + (0.8) + * ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()); + + let footrotr = (((1.0) + / (0.2 + + (0.8) + * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()); + + let foothoril = (anim_time as f32 * 6.0 * lab as f32 + PI * 1.45).sin(); + let foothorir = (anim_time as f32 * 6.0 * lab as f32 + PI * (0.45)).sin(); let head_look = Vec2::new( - ((global_time + anim_time) as f32 / 18.0) + ((global_time + anim_time) as f32 / 4.0 * (1.0 / tempo)) .floor() .mul(7331.0) .sin() * 0.2, - ((global_time + anim_time) as f32 / 18.0) + ((global_time + anim_time) as f32 / 4.0 * (1.0 / tempo)) .floor() .mul(1337.0) .sin() @@ -70,25 +89,32 @@ impl Animation for SwimAnimation { } else { 0.0 } * 1.3; + + let adjust = if speed > 0.5 { -1.57 } else { -3.14 * speed }; next.head.offset = Vec3::new( 0.0, -3.0 + skeleton_attr.head.0, skeleton_attr.head.1 - 1.0 + short * 0.3, ); - next.head.ori = Quaternion::rotation_z(head_look.x - short * 0.4) - * Quaternion::rotation_x(head_look.y + 0.35 + speed * 0.045); + next.head.ori = Quaternion::rotation_z(head_look.x + short * -0.6 * intensity) + * Quaternion::rotation_x( + (0.6 * head_look.y * (1.0 / intensity)).abs() + + 0.45 * intensity + + velocity.z * 0.02, + ); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new( 0.0, skeleton_attr.chest.0, - skeleton_attr.chest.1 + short * 1.3, + -13.0 + skeleton_attr.chest.1 + short * 1.3 * intensity, ); - next.chest.ori = Quaternion::rotation_z(short * 0.4); + next.chest.ori = Quaternion::rotation_z(short * 0.4 * intensity); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); - next.belt.ori = Quaternion::rotation_z(short * 0.30); + next.belt.ori = Quaternion::rotation_x(velocity.z * 0.01) + * Quaternion::rotation_z(short * 0.2 * intensity); next.belt.scale = Vec3::one(); next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); @@ -96,39 +122,42 @@ impl Animation for SwimAnimation { next.back.scale = Vec3::one() * 1.02; next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); - next.shorts.ori = Quaternion::rotation_z(short * 0.5); + next.shorts.ori = Quaternion::rotation_x(velocity.z * 0.02) + * Quaternion::rotation_z(short * 0.3 * intensity); next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new( -skeleton_attr.hand.0, - 1.5 + skeleton_attr.hand.1 - foot * 1.2, - 2.0 + skeleton_attr.hand.2 + foot * -3.0, + 1.5 + skeleton_attr.hand.1 - foot * 1.2 * intensity, + 2.0 + skeleton_attr.hand.2 + foot * -3.0 * intensity, ); - next.l_hand.ori = Quaternion::rotation_x(0.8 + foot * -0.6) * Quaternion::rotation_y(0.2); + next.l_hand.ori = + Quaternion::rotation_x(0.8 + foot * -0.6 * intensity) * Quaternion::rotation_y(0.2); next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new( skeleton_attr.hand.0, - 1.5 + skeleton_attr.hand.1 + foot * 1.2, - 2.0 + skeleton_attr.hand.2 + foot * 3.0, + 1.5 + skeleton_attr.hand.1 + foot * 1.2 * intensity, + 2.0 + skeleton_attr.hand.2 + foot * 3.0 * intensity, ); - next.r_hand.ori = Quaternion::rotation_x(0.8 + foot * 0.6) * Quaternion::rotation_y(-0.2); + next.r_hand.ori = + Quaternion::rotation_x(0.8 + foot * 0.6 * intensity) * Quaternion::rotation_y(-0.2); next.r_hand.scale = Vec3::one(); next.l_foot.offset = Vec3::new( -skeleton_attr.foot.0, - skeleton_attr.foot.1 + foot * 1.2, - -3.0 + skeleton_attr.foot.2 + foot * 3.5, + skeleton_attr.foot.1 + foothorir * 1.5 * intensity, + -15.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity, ); - next.l_foot.ori = Quaternion::rotation_x(-1.1 + foot * 0.6); + next.l_foot.ori = Quaternion::rotation_x(-0.8 + footrotl * 0.4 * intensity); next.l_foot.scale = Vec3::one(); next.r_foot.offset = Vec3::new( skeleton_attr.foot.0, - skeleton_attr.foot.1 - foot * 1.2, - -3.0 + skeleton_attr.foot.2 + foot * -3.5, + skeleton_attr.foot.1 + foothorir * 1.5 * intensity, + -15.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity, ); - next.r_foot.ori = Quaternion::rotation_x(-1.1 + foot * -0.6); + next.r_foot.ori = Quaternion::rotation_x(-0.8 + footrotr * 0.4 * intensity); next.r_foot.scale = Vec3::one(); next.l_shoulder.offset = Vec3::new( @@ -136,7 +165,7 @@ impl Animation for SwimAnimation { skeleton_attr.shoulder.1, skeleton_attr.shoulder.2, ); - next.l_shoulder.ori = Quaternion::rotation_x(short * 0.15); + next.l_shoulder.ori = Quaternion::rotation_x(short * 0.15 * intensity); next.l_shoulder.scale = Vec3::one() * 1.1; next.r_shoulder.offset = Vec3::new( @@ -144,7 +173,7 @@ impl Animation for SwimAnimation { skeleton_attr.shoulder.1, skeleton_attr.shoulder.2, ); - next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15); + next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15 * intensity); next.r_shoulder.scale = Vec3::one() * 1.1; next.glider.offset = Vec3::new(0.0, 0.0, 10.0); @@ -194,9 +223,9 @@ impl Animation for SwimAnimation { next.lantern.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); next.lantern.scale = Vec3::one() * 0.65; - next.torso.offset = Vec3::new(0.0, -1.2 + shortalt * -0.065, 0.4) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(speed * -0.190 * wave_stop * 1.05) - * Quaternion::rotation_z(tilt * 12.0); + next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(adjust + avg_vel.z * 0.12) + * Quaternion::rotation_z(tilt * 12.0 + short * 0.4 * intensity); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.control.scale = Vec3::one(); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 980433f024..68cb4cd7b6 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -636,6 +636,7 @@ impl FigureMgr { ori, state.last_ori, time, + state.avg_vel, ), state.state_time, &mut state_animation_rate, diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index 3c5f266164..d59c543277 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -322,8 +322,11 @@ impl PlayState for SessionState { Event::InputUpdate(GameInput::Jump, state) => { self.inputs.jump.set_state(state); }, - Event::InputUpdate(GameInput::Swim, state) => { - self.inputs.swim.set_state(state); + Event::InputUpdate(GameInput::SwimUp, state) => { + self.inputs.swimup.set_state(state); + }, + Event::InputUpdate(GameInput::SwimDown, state) => { + self.inputs.swimdown.set_state(state); }, Event::InputUpdate(GameInput::Sit, state) if state != self.key_state.toggle_sit => diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 441108bdb7..4011998185 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -134,7 +134,8 @@ impl ControlSettings { GameInput::Glide => KeyMouse::Key(VirtualKeyCode::LShift), GameInput::Climb => KeyMouse::Key(VirtualKeyCode::Space), GameInput::ClimbDown => KeyMouse::Key(VirtualKeyCode::LControl), - GameInput::Swim => KeyMouse::Key(VirtualKeyCode::Space), + GameInput::SwimUp => KeyMouse::Key(VirtualKeyCode::Space), + GameInput::SwimDown => KeyMouse::Key(VirtualKeyCode::LShift), //GameInput::WallLeap => MIDDLE_CLICK_KEY, GameInput::ToggleLantern => KeyMouse::Key(VirtualKeyCode::G), GameInput::Mount => KeyMouse::Key(VirtualKeyCode::F), @@ -199,7 +200,8 @@ impl Default for ControlSettings { GameInput::Glide, GameInput::Climb, GameInput::ClimbDown, - GameInput::Swim, + GameInput::SwimUp, + GameInput::SwimDown, //GameInput::WallLeap, GameInput::ToggleLantern, GameInput::Mount, @@ -308,7 +310,8 @@ pub mod con_settings { pub glide: Button, pub climb: Button, pub climb_down: Button, - pub swim: Button, + pub swimup: Button, + pub swimdown: Button, //pub wall_leap: Button, pub toggle_lantern: Button, pub mount: Button, @@ -398,7 +401,8 @@ pub mod con_settings { glide: Button::Simple(GilButton::LeftTrigger), climb: Button::Simple(GilButton::South), climb_down: Button::Simple(GilButton::Unknown), - swim: Button::Simple(GilButton::South), + swimup: Button::Simple(GilButton::South), + swimdown: Button::Simple(GilButton::Unknown), //wall_leap: Button::Simple(GilButton::Unknown), toggle_lantern: Button::Simple(GilButton::East), mount: Button::Simple(GilButton::North), diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index b8bf69c08b..efa4702f4c 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -39,7 +39,8 @@ pub enum GameInput { Glide, Climb, ClimbDown, - Swim, + SwimUp, + SwimDown, //WallLeap, ToggleLantern, Mount, @@ -88,7 +89,8 @@ impl GameInput { GameInput::Glide => "gameinput.glide", GameInput::Climb => "gameinput.climb", GameInput::ClimbDown => "gameinput.climbdown", - GameInput::Swim => "gameinput.swim", + GameInput::SwimUp => "gameinput.swimup", + GameInput::SwimDown => "gameinput.swimdown", //GameInput::WallLeap => "gameinput.wallleap", GameInput::ToggleLantern => "gameinput.togglelantern", GameInput::Mount => "gameinput.mount", @@ -147,7 +149,8 @@ impl GameInput { GameInput::Glide, GameInput::Climb, GameInput::ClimbDown, - GameInput::Swim, + GameInput::SwimUp, + GameInput::SwimDown, GameInput::ToggleLantern, GameInput::Mount, GameInput::Enter, @@ -201,7 +204,7 @@ impl GameInput { match self { GameInput::Jump => GameInput::Jump, GameInput::Climb => GameInput::Jump, - GameInput::Swim => GameInput::Jump, + GameInput::SwimUp => GameInput::Jump, GameInput::Respawn => GameInput::Jump, GameInput::FreeLook => GameInput::FreeLook, From 9ff5c23cf04583e78f48a09b87c0ec60fb82c5bb Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sun, 2 Aug 2020 01:09:11 -0400 Subject: [PATCH 2/8] readd sneak --- client/src/lib.rs | 15 + common/src/comp/character_state.rs | 1 + common/src/comp/controller.rs | 13 +- common/src/states/climb.rs | 7 +- common/src/states/glide_wield.rs | 11 +- common/src/states/idle.rs | 6 + common/src/states/mod.rs | 1 + common/src/states/sneak.rs | 56 ++++ common/src/states/utils.rs | 15 +- common/src/states/wielding.rs | 6 + common/src/sys/character_behavior.rs | 6 + common/src/sys/phys.rs | 2 +- common/src/sys/stats.rs | 1 + voxygen/src/anim/src/character/mod.rs | 6 +- voxygen/src/anim/src/character/sneak.rs | 319 +++++++++++++++++++ voxygen/src/anim/src/character/swim.rs | 6 +- voxygen/src/anim/src/quadruped_low/mod.rs | 2 +- voxygen/src/anim/src/quadruped_medium/mod.rs | 2 +- voxygen/src/key_state.rs | 2 + voxygen/src/scene/figure/mod.rs | 9 + voxygen/src/session.rs | 9 + voxygen/src/settings.rs | 4 + voxygen/src/window.rs | 3 + 23 files changed, 482 insertions(+), 20 deletions(-) create mode 100644 common/src/states/sneak.rs create mode 100644 voxygen/src/anim/src/character/sneak.rs diff --git a/client/src/lib.rs b/client/src/lib.rs index 404c2a1686..f4a864b2de 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -594,6 +594,21 @@ impl Client { } } + pub fn toggle_sneak(&mut self) { + let is_sneaking = self + .state + .ecs() + .read_storage::() + .get(self.entity) + .map(|cs| matches!(cs, comp::CharacterState::Sneak)); + + match is_sneaking { + Some(true) => self.control_action(ControlAction::Stand), + Some(false) => self.control_action(ControlAction::Sneak), + None => warn!("Can't toggle sneak, client entity doesn't have a `CharacterState`"), + } + } + pub fn toggle_glide(&mut self) { let is_gliding = self .state diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index a77263578d..af1d1fac4c 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -41,6 +41,7 @@ pub enum CharacterState { Climb, Sit, Dance, + Sneak, Glide, GlideWield, /// A basic blocking state diff --git a/common/src/comp/controller.rs b/common/src/comp/controller.rs index 3c2c6c8828..ff00ac4b49 100644 --- a/common/src/comp/controller.rs +++ b/common/src/comp/controller.rs @@ -46,6 +46,7 @@ pub enum ControlAction { Unwield, Sit, Dance, + Sneak, Stand, } @@ -170,7 +171,8 @@ pub struct ControllerInputs { pub wall_leap: Input, pub charge: Input, pub climb: Option, - pub swim: Input, + pub swimup: Input, + pub swimdown: Input, pub move_dir: Vec2, pub look_dir: Dir, } @@ -194,7 +196,8 @@ impl ControllerInputs { self.glide.tick(dt); self.wall_leap.tick(dt); self.charge.tick(dt); - self.swim.tick(dt); + self.swimup.tick(dt); + self.swimdown.tick(dt); } pub fn tick_freshness(&mut self) { @@ -206,7 +209,8 @@ impl ControllerInputs { self.glide.tick_freshness(); self.wall_leap.tick_freshness(); self.charge.tick_freshness(); - self.swim.tick_freshness(); + self.swimup.tick_freshness(); + self.swimdown.tick_freshness(); } /// Updates Controller inputs with new version received from the client @@ -220,7 +224,8 @@ impl ControllerInputs { self.wall_leap.update_with_new(new.wall_leap); self.charge.update_with_new(new.charge); self.climb = new.climb; - self.swim.update_with_new(new.swim); + self.swimup.update_with_new(new.swimup); + self.swimdown.update_with_new(new.swimdown); self.move_dir = new.move_dir; self.look_dir = new.look_dir; } diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 3a5ca7093e..44642ec656 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -52,7 +52,8 @@ impl CharacterBehavior for Data { // Expend energy if climbing let energy_use = match climb { - Climb::Up | Climb::Down => 8, + Climb::Up => 5, + Climb::Down => 1, Climb::Hold => 1, }; @@ -79,14 +80,14 @@ impl CharacterBehavior for Data { match climb { Climb::Down => { update.vel.0 -= - data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 6.0); + data.dt.0 * update.vel.0.map(|e| e.abs().powf(1.5) * e.signum() * 1.0); }, Climb::Up => { update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.25).min(CLIMB_SPEED); }, Climb::Hold => { // Antigrav - update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.5).min(CLIMB_SPEED); + update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.1).min(CLIMB_SPEED); update.vel.0 = Lerp::lerp( update.vel.0, Vec3::zero(), diff --git a/common/src/states/glide_wield.rs b/common/src/states/glide_wield.rs index e385a3d3a0..0cc4d826e0 100644 --- a/common/src/states/glide_wield.rs +++ b/common/src/states/glide_wield.rs @@ -16,9 +16,12 @@ impl CharacterBehavior for Data { handle_wield(data, &mut update); // If not on the ground while wielding glider enter gliding state - if !data.physics.on_ground && !data.physics.in_fluid { + if !data.physics.on_ground { update.character = CharacterState::Glide; } + if data.physics.in_fluid { + update.character = CharacterState::Idle; + } update } @@ -35,6 +38,12 @@ impl CharacterBehavior for Data { update } + fn sneak(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_sneak(data, &mut update); + update + } + fn unwield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); update.character = CharacterState::Idle; diff --git a/common/src/states/idle.rs b/common/src/states/idle.rs index e86c1bd77c..fdc2dc1ef1 100644 --- a/common/src/states/idle.rs +++ b/common/src/states/idle.rs @@ -37,6 +37,12 @@ impl CharacterBehavior for Data { update } + fn sneak(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_sneak(data, &mut update); + update + } + fn glide_wield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); attempt_glide_wield(data, &mut update); diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index b88bfe7514..5c620b8c6b 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -13,6 +13,7 @@ pub mod idle; pub mod leap_melee; pub mod roll; pub mod sit; +pub mod sneak; pub mod spin_melee; pub mod triple_strike; pub mod utils; diff --git a/common/src/states/sneak.rs b/common/src/states/sneak.rs new file mode 100644 index 0000000000..9efbdadb2b --- /dev/null +++ b/common/src/states/sneak.rs @@ -0,0 +1,56 @@ +use super::utils::*; +use crate::{ + comp::{CharacterState, StateUpdate}, + sys::character_behavior::{CharacterBehavior, JoinData}, +}; + +pub struct Data; + +impl CharacterBehavior for Data { + fn behavior(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + + handle_move(data, &mut update, 0.4); + handle_jump(data, &mut update); + handle_wield(data, &mut update); + handle_climb(data, &mut update); + handle_dodge_input(data, &mut update); + + // Try to Fall/Stand up/Move + if !data.physics.on_ground { + update.character = CharacterState::Idle; + } + + update + } + + fn wield(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_wield(data, &mut update); + update + } + + fn sit(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_sit(data, &mut update); + update + } + + fn dance(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_dance(data, &mut update); + update + } + + fn glide_wield(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_glide_wield(data, &mut update); + update + } + + fn swap_loadout(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_swap_loadout(data, &mut update); + update + } +} diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index ee20892e6c..7a2b4f19a1 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -118,9 +118,14 @@ fn swim_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) { handle_orientation(data, update, if data.physics.on_ground { 9.0 } else { 2.0 }); // Swim - if data.inputs.swim.is_pressed() { + if data.inputs.swimup.is_pressed() { update.vel.0.z = - (update.vel.0.z + data.dt.0 * GRAVITY * 2.25).min(BASE_HUMANOID_WATER_SPEED); + (update.vel.0.z + data.dt.0 * GRAVITY * 4.0).min(BASE_HUMANOID_WATER_SPEED); + } + // Swim + if data.inputs.swimdown.is_pressed() { + update.vel.0.z = + (update.vel.0.z + data.dt.0 * GRAVITY * -3.5).min(BASE_HUMANOID_WATER_SPEED); } } @@ -159,6 +164,12 @@ pub fn attempt_dance(data: &JoinData, update: &mut StateUpdate) { } } +pub fn attempt_sneak(data: &JoinData, update: &mut StateUpdate) { + if data.physics.on_ground && data.body.is_humanoid() { + update.character = CharacterState::Sneak; + } +} + /// Checks that player can `Climb` and updates `CharacterState` if so pub fn handle_climb(data: &JoinData, update: &mut StateUpdate) { if data.inputs.climb.is_some() diff --git a/common/src/states/wielding.rs b/common/src/states/wielding.rs index aa723fce2c..f64ae9c77f 100644 --- a/common/src/states/wielding.rs +++ b/common/src/states/wielding.rs @@ -33,6 +33,12 @@ impl CharacterBehavior for Data { update } + fn sneak(&self, data: &JoinData) -> StateUpdate { + let mut update = StateUpdate::from(data); + attempt_sneak(data, &mut update); + update + } + fn unwield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); update.character = CharacterState::Idle; diff --git a/common/src/sys/character_behavior.rs b/common/src/sys/character_behavior.rs index e79d31aa29..eccf237433 100644 --- a/common/src/sys/character_behavior.rs +++ b/common/src/sys/character_behavior.rs @@ -27,6 +27,7 @@ pub trait CharacterBehavior { fn unwield(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } fn sit(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } fn dance(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } + fn sneak(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } fn stand(&self, data: &JoinData) -> StateUpdate { StateUpdate::from(data) } fn handle_event(&self, data: &JoinData, event: ControlAction) -> StateUpdate { match event { @@ -36,6 +37,7 @@ pub trait CharacterBehavior { ControlAction::Unwield => self.unwield(data), ControlAction::Sit => self.sit(data), ControlAction::Dance => self.dance(data), + ControlAction::Sneak => self.sneak(data), ControlAction::Stand => self.stand(data), } } @@ -232,6 +234,9 @@ impl<'a> System<'a> for Sys { CharacterState::Dance => { states::dance::Data::handle_event(&states::dance::Data, &j, action) }, + CharacterState::Sneak => { + states::sneak::Data::handle_event(&states::sneak::Data, &j, action) + }, CharacterState::BasicBlock => { states::basic_block::Data.handle_event(&j, action) }, @@ -261,6 +266,7 @@ impl<'a> System<'a> for Sys { CharacterState::GlideWield => states::glide_wield::Data.behavior(&j), CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, &j), CharacterState::Dance => states::dance::Data::behavior(&states::dance::Data, &j), + CharacterState::Sneak => states::sneak::Data::behavior(&states::sneak::Data, &j), CharacterState::BasicBlock => states::basic_block::Data.behavior(&j), CharacterState::Roll(data) => data.behavior(&j), CharacterState::Wielding => states::wielding::Data.behavior(&j), diff --git a/common/src/sys/phys.rs b/common/src/sys/phys.rs index ffec0df1b4..0df848919c 100644 --- a/common/src/sys/phys.rs +++ b/common/src/sys/phys.rs @@ -15,7 +15,7 @@ use specs::{ use vek::*; pub const GRAVITY: f32 = 9.81 * 5.0; -const BOUYANCY: f32 = 0.0; +const BOUYANCY: f32 = 1.0; // Friction values used for linear damping. They are unitless quantities. The // value of these quantities must be between zero and one. They represent the // amount an object will slow down within 1/60th of a second. Eg. if the frction diff --git a/common/src/sys/stats.rs b/common/src/sys/stats.rs index 3c83d45bb9..100cd4170b 100644 --- a/common/src/sys/stats.rs +++ b/common/src/sys/stats.rs @@ -77,6 +77,7 @@ impl<'a> System<'a> for Sys { CharacterState::Idle { .. } | CharacterState::Sit { .. } | CharacterState::Dance { .. } + | CharacterState::Sneak { .. } | CharacterState::Glide { .. } | CharacterState::GlideWield { .. } | CharacterState::Wielding { .. } diff --git a/voxygen/src/anim/src/character/mod.rs b/voxygen/src/anim/src/character/mod.rs index f3440fa3ed..e0f1b635ce 100644 --- a/voxygen/src/anim/src/character/mod.rs +++ b/voxygen/src/anim/src/character/mod.rs @@ -16,6 +16,7 @@ pub mod roll; pub mod run; pub mod shoot; pub mod sit; +pub mod sneak; pub mod spin; pub mod spinmelee; pub mod stand; @@ -29,8 +30,9 @@ pub use self::{ dance::DanceAnimation, dash::DashAnimation, equip::EquipAnimation, glidewield::GlideWieldAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, leapmelee::LeapAnimation, roll::RollAnimation, run::RunAnimation, - shoot::ShootAnimation, sit::SitAnimation, spin::SpinAnimation, spinmelee::SpinMeleeAnimation, - stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation, + shoot::ShootAnimation, sit::SitAnimation, sneak::SneakAnimation, spin::SpinAnimation, + spinmelee::SpinMeleeAnimation, stand::StandAnimation, swim::SwimAnimation, + wield::WieldAnimation, }; use super::{Bone, FigureBoneData, Skeleton}; diff --git a/voxygen/src/anim/src/character/sneak.rs b/voxygen/src/anim/src/character/sneak.rs new file mode 100644 index 0000000000..281607f259 --- /dev/null +++ b/voxygen/src/anim/src/character/sneak.rs @@ -0,0 +1,319 @@ +use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; +use common::comp::item::ToolKind; +use std::{f32::consts::PI, ops::Mul}; +use vek::*; + +pub struct SneakAnimation; + +impl Animation for SneakAnimation { + type Dependency = (Option, Vec3, Vec3, Vec3, f64); + type Skeleton = CharacterSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"character_sneak\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "character_sneak")] + #[allow(clippy::identity_conversion)] // TODO: Pending review in #587 + + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + (_active_tool_kind, velocity, orientation, last_ori, global_time): Self::Dependency, + anim_time: f64, + rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + let speed = Vec2::::from(velocity).magnitude(); + *rate = 1.0; + let slow = (anim_time as f32 * 3.0).sin(); + let breathe = ((anim_time as f32 * 0.5).sin()).abs(); + let walkintensity = if speed > 5.0 { 1.0 } else { 0.45 }; + let lower = if speed > 5.0 { 0.0 } else { 1.0 }; + let _snapfoot = if speed > 5.0 { 1.1 } else { 2.0 }; + let lab = 1.0; + let foothoril = (anim_time as f32 * 7.0 * lab as f32 + PI * 1.45).sin(); + let foothorir = (anim_time as f32 * 7.0 * lab as f32 + PI * (0.45)).sin(); + + let footvertl = (anim_time as f32 * 7.0 * lab as f32).sin(); + let footvertr = (anim_time as f32 * 7.0 * lab as f32 + PI).sin(); + + let footrotl = (((5.0) + / (2.5 + + (2.5) + * ((anim_time as f32 * 7.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * 7.0 * lab as f32 + PI * 1.4).sin()); + + let footrotr = (((5.0) + / (1.0 + + (4.0) + * ((anim_time as f32 * 7.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * 7.0 * lab as f32 + PI * 0.4).sin()); + + let short = (anim_time as f32 * lab as f32 * 7.0).sin(); + let noisea = (anim_time as f32 * 11.0 + PI / 6.0).sin(); + let noiseb = (anim_time as f32 * 19.0 + PI / 4.0).sin(); + + let shorte = (((5.0) + / (4.0 + 1.0 * ((anim_time as f32 * lab as f32 * 7.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 7.0).sin()); + + let shortalt = (anim_time as f32 * lab as f32 * 7.0 + PI / 2.0).sin(); + + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 18.0) + .floor() + .mul(7331.0) + .sin() + * 0.2, + ((global_time + anim_time) as f32 / 18.0) + .floor() + .mul(1337.0) + .sin() + * 0.1, + ); + + let ori = Vec2::from(orientation); + let last_ori = Vec2::from(last_ori); + let tilt = if Vec2::new(ori, last_ori) + .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|m| m > 0.001 && m.is_finite()) + .reduce_and() + && ori.angle_between(last_ori).is_finite() + { + ori.angle_between(last_ori).min(0.2) + * last_ori.determine_side(Vec2::zero(), ori).signum() + } else { + 0.0 + } * 1.3; + + if speed > 0.5 { + next.l_hand.offset = Vec3::new( + 1.0 - skeleton_attr.hand.0, + 4.0 + skeleton_attr.hand.1, + 1.0 + skeleton_attr.hand.2, + ); + next.l_hand.ori = Quaternion::rotation_x(1.0); + next.l_hand.scale = Vec3::one(); + + next.r_hand.offset = Vec3::new( + -1.0 + skeleton_attr.hand.0, + -1.0 + skeleton_attr.hand.1, + skeleton_attr.hand.2, + ); + next.r_hand.ori = Quaternion::rotation_x(0.4); + next.r_hand.scale = Vec3::one(); + next.head.offset = Vec3::new( + 0.0, + -4.0 + skeleton_attr.head.0, + -1.0 + skeleton_attr.head.1 + short * 0.06, + ); + next.head.ori = Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.06) + * Quaternion::rotation_x(head_look.y + 0.45); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new( + 0.0, + skeleton_attr.chest.0, + -1.0 + skeleton_attr.chest.1 + shortalt * -0.5, + ); + next.chest.ori = Quaternion::rotation_z(0.3 + short * 0.08 + tilt * -0.2) + * Quaternion::rotation_y(tilt * 0.8) + * Quaternion::rotation_x(-0.5); + next.chest.scale = Vec3::one(); + + next.belt.offset = + Vec3::new(0.0, 0.5 + skeleton_attr.belt.0, 0.7 + skeleton_attr.belt.1); + next.belt.ori = Quaternion::rotation_z(short * 0.1 + tilt * -1.1) + * Quaternion::rotation_y(tilt * 0.5) + * Quaternion::rotation_x(0.2); + next.belt.scale = Vec3::one(); + + next.glider.ori = Quaternion::rotation_x(0.0); + next.glider.offset = Vec3::new(0.0, 0.0, 10.0); + next.glider.scale = Vec3::one() * 0.0; + + next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); + next.back.ori = + Quaternion::rotation_x(-0.25 + short * 0.1 + noisea * 0.1 + noiseb * 0.1); + next.back.scale = Vec3::one() * 1.02; + + next.shorts.offset = Vec3::new( + 0.0, + 1.0 + skeleton_attr.shorts.0, + 1.0 + skeleton_attr.shorts.1, + ); + next.shorts.ori = Quaternion::rotation_z(short * 0.16 + tilt * -1.5) + * Quaternion::rotation_y(tilt * 0.7) + * Quaternion::rotation_x(0.3); + next.shorts.scale = Vec3::one(); + + next.l_foot.offset = Vec3::new( + -skeleton_attr.foot.0, + skeleton_attr.foot.1 + foothoril * -10.5 * walkintensity - lower * 1.0, + 1.0 + skeleton_attr.foot.2 + ((footvertl * -1.7).max(-1.0)) * walkintensity, + ); + next.l_foot.ori = Quaternion::rotation_x(-0.2 + footrotl * -0.8 * walkintensity) + * Quaternion::rotation_y(tilt * 1.8); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new( + skeleton_attr.foot.0, + skeleton_attr.foot.1 + foothorir * -10.5 * walkintensity - lower * 1.0, + 1.0 + skeleton_attr.foot.2 + ((footvertr * -1.7).max(-1.0)) * walkintensity, + ); + next.r_foot.ori = Quaternion::rotation_x(-0.2 + footrotr * -0.8 * walkintensity) + * Quaternion::rotation_y(tilt * 1.8); + next.r_foot.scale = Vec3::one(); + + next.l_shoulder.offset = Vec3::new( + -skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.l_shoulder.ori = Quaternion::rotation_x(short * 0.15 * walkintensity); + next.l_shoulder.scale = Vec3::one() * 1.1; + + next.r_shoulder.offset = Vec3::new( + skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.r_shoulder.ori = Quaternion::rotation_x(short * -0.15 * walkintensity); + next.r_shoulder.scale = Vec3::one() * 1.1; + + next.main.offset = Vec3::new(-7.0, -6.5, 15.0); + next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); + next.main.scale = Vec3::one(); + + next.second.scale = Vec3::one() * 0.0; + + next.lantern.offset = Vec3::new( + skeleton_attr.lantern.0, + skeleton_attr.lantern.1, + skeleton_attr.lantern.2, + ); + next.lantern.ori = + Quaternion::rotation_x(shorte * 0.2 + 0.4) * Quaternion::rotation_y(shorte * 0.1); + next.lantern.scale = Vec3::one() * 0.65; + + next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_y(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.control.offset = Vec3::new(0.0, 0.0, 0.0); + next.control.ori = Quaternion::rotation_x(0.0); + next.control.scale = Vec3::one(); + + next.l_control.scale = Vec3::one(); + + next.r_control.scale = Vec3::one(); + } else { + next.head.offset = Vec3::new( + 0.0, + -4.0 + skeleton_attr.head.0, + -2.0 + skeleton_attr.head.1 + slow * 0.1 + breathe * -0.05, + ); + next.head.ori = Quaternion::rotation_z(head_look.x) + * Quaternion::rotation_x(0.6 + head_look.y.abs()); + next.head.scale = Vec3::one() * skeleton_attr.head_scale + breathe * -0.05; + + next.chest.offset = Vec3::new( + 0.0, + skeleton_attr.chest.0, + -3.0 + skeleton_attr.chest.1 + slow * 0.1, + ); + next.chest.ori = Quaternion::rotation_x(-0.7); + next.chest.scale = Vec3::one() * 1.01 + breathe * 0.03; + + next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); + next.belt.ori = Quaternion::rotation_z(0.3 + head_look.x * -0.1); + next.belt.scale = Vec3::one() + breathe * -0.03; + + next.l_hand.offset = Vec3::new( + 1.0 - skeleton_attr.hand.0, + 5.0 + skeleton_attr.hand.1, + 0.0 + skeleton_attr.hand.2, + ); + next.l_hand.ori = Quaternion::rotation_x(1.35); + next.l_hand.scale = Vec3::one(); + + next.r_hand.offset = Vec3::new( + -1.0 + skeleton_attr.hand.0, + skeleton_attr.hand.1, + skeleton_attr.hand.2, + ); + next.r_hand.ori = Quaternion::rotation_x(0.4); + next.r_hand.scale = Vec3::one(); + + next.glider.ori = Quaternion::rotation_x(0.35); + next.glider.offset = Vec3::new(0.0, 0.0, 10.0); + next.glider.scale = Vec3::one() * 0.0; + + next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); + next.back.scale = Vec3::one() * 1.02; + + next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); + next.shorts.ori = Quaternion::rotation_z(0.6 + head_look.x * -0.2); + next.shorts.scale = Vec3::one() + breathe * -0.03; + + next.l_foot.offset = Vec3::new( + -skeleton_attr.foot.0, + -6.0 + skeleton_attr.foot.1, + 1.0 + skeleton_attr.foot.2, + ); + next.l_foot.ori = Quaternion::rotation_x(-0.5); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new( + skeleton_attr.foot.0, + 4.0 + skeleton_attr.foot.1, + skeleton_attr.foot.2, + ); + next.r_foot.ori = Quaternion::rotation_x(0.0); + next.r_foot.scale = Vec3::one(); + + next.l_shoulder.offset = Vec3::new( + -skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.l_shoulder.scale = (Vec3::one() + breathe * -0.05) * 1.15; + + next.r_shoulder.offset = Vec3::new( + skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.r_shoulder.scale = (Vec3::one() + breathe * -0.05) * 1.15; + + next.main.offset = Vec3::new(-7.0, -5.0, 15.0); + next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); + next.main.scale = Vec3::one(); + + next.second.offset = Vec3::new(0.0, 0.0, 0.0); + next.second.scale = Vec3::one() * 0.0; + + next.lantern.offset = Vec3::new( + skeleton_attr.lantern.0, + skeleton_attr.lantern.1, + skeleton_attr.lantern.2, + ); + next.lantern.ori = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1); + next.lantern.scale = Vec3::one() * 0.65; + + next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.control.scale = Vec3::one(); + + next.l_control.scale = Vec3::one(); + + next.r_control.scale = Vec3::one(); + } + next + } +} diff --git a/voxygen/src/anim/src/character/swim.rs b/voxygen/src/anim/src/character/swim.rs index e505c83198..56369cac2b 100644 --- a/voxygen/src/anim/src/character/swim.rs +++ b/voxygen/src/anim/src/character/swim.rs @@ -42,12 +42,8 @@ impl Animation for SwimAnimation { let short = (anim_time as f32 * lab as f32 * 6.0).sin(); - let shortalt = (anim_time as f32 * lab as f32 * 6.0 + PI / 2.0).sin(); - let foot = (anim_time as f32 * lab as f32 * 6.0).sin(); - let wave_stop = (anim_time as f32 * 9.0).min(PI / 2.0 / 2.0).sin(); - let footrotl = (((1.0) / (0.2 + (0.8) @@ -146,7 +142,7 @@ impl Animation for SwimAnimation { next.l_foot.offset = Vec3::new( -skeleton_attr.foot.0, - skeleton_attr.foot.1 + foothorir * 1.5 * intensity, + skeleton_attr.foot.1 + foothoril * 1.5 * intensity, -15.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity, ); next.l_foot.ori = Quaternion::rotation_x(-0.8 + footrotl * 0.4 * intensity); diff --git a/voxygen/src/anim/src/quadruped_low/mod.rs b/voxygen/src/anim/src/quadruped_low/mod.rs index 577ce0acac..cc621e6667 100644 --- a/voxygen/src/anim/src/quadruped_low/mod.rs +++ b/voxygen/src/anim/src/quadruped_low/mod.rs @@ -142,7 +142,7 @@ impl<'a> From<&'a comp::quadruped_low::Body> for SkeletonAttr { (Tortoise, _) => (5.0, 1.0), (Rocksnapper, _) => (6.0, 0.5), (Pangolin, _) => (-0.5, 8.0), - (Maneater, _) => (6.0, 9.5), + (Maneater, _) => (7.0, 11.5), }, head_lower: match (body.species, body.body_type) { (Crocodile, _) => (8.0, 0.0), diff --git a/voxygen/src/anim/src/quadruped_medium/mod.rs b/voxygen/src/anim/src/quadruped_medium/mod.rs index d78069b986..4a1fefe2bf 100644 --- a/voxygen/src/anim/src/quadruped_medium/mod.rs +++ b/voxygen/src/anim/src/quadruped_medium/mod.rs @@ -209,7 +209,7 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr { (Wolf, _) => (5.0, -3.0), (Frostfang, _) => (4.0, -3.0), (Mouflon, _) => (10.5, -4.0), - (Catoblepas, _) => (1.0, -6.0), + (Catoblepas, _) => (1.0, -4.0), (Bonerattler, _) => (3.0, -3.0), }, tail: match (body.species, body.body_type) { diff --git a/voxygen/src/key_state.rs b/voxygen/src/key_state.rs index 84992bc8d6..5d12a95888 100644 --- a/voxygen/src/key_state.rs +++ b/voxygen/src/key_state.rs @@ -10,6 +10,7 @@ pub struct KeyState { pub toggle_wield: bool, pub toggle_glide: bool, pub toggle_sit: bool, + pub toggle_sneak: bool, pub toggle_dance: bool, pub auto_walk: bool, pub swap_loadout: bool, @@ -30,6 +31,7 @@ impl Default for KeyState { toggle_wield: false, toggle_glide: false, toggle_sit: false, + toggle_sneak: false, toggle_dance: false, auto_walk: false, swap_loadout: false, diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 68cb4cd7b6..916e007a74 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -720,6 +720,15 @@ impl FigureMgr { ) } }, + CharacterState::Sneak { .. } => { + anim::character::SneakAnimation::update_skeleton( + &CharacterSkeleton::new(), + (active_tool_kind, vel.0, ori, state.last_ori, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + }, CharacterState::Boost(_) => { anim::character::AlphaAnimation::update_skeleton( &target_base, diff --git a/voxygen/src/session.rs b/voxygen/src/session.rs index d59c543277..2f5cf8df9e 100644 --- a/voxygen/src/session.rs +++ b/voxygen/src/session.rs @@ -347,6 +347,15 @@ impl PlayState for SessionState { self.client.borrow_mut().toggle_dance(); } } + Event::InputUpdate(GameInput::Sneak, state) + if state != self.key_state.toggle_sneak => + { + self.key_state.toggle_sneak = state; + if state { + self.stop_auto_walk(); + self.client.borrow_mut().toggle_sneak(); + } + } Event::InputUpdate(GameInput::MoveForward, state) => { if state && global_state.settings.gameplay.stop_auto_walk_on_input { self.stop_auto_walk(); diff --git a/voxygen/src/settings.rs b/voxygen/src/settings.rs index 4011998185..e8ef4c38a3 100644 --- a/voxygen/src/settings.rs +++ b/voxygen/src/settings.rs @@ -136,6 +136,7 @@ impl ControlSettings { GameInput::ClimbDown => KeyMouse::Key(VirtualKeyCode::LControl), GameInput::SwimUp => KeyMouse::Key(VirtualKeyCode::Space), GameInput::SwimDown => KeyMouse::Key(VirtualKeyCode::LShift), + GameInput::Sneak => KeyMouse::Key(VirtualKeyCode::LControl), //GameInput::WallLeap => MIDDLE_CLICK_KEY, GameInput::ToggleLantern => KeyMouse::Key(VirtualKeyCode::G), GameInput::Mount => KeyMouse::Key(VirtualKeyCode::F), @@ -202,6 +203,7 @@ impl Default for ControlSettings { GameInput::ClimbDown, GameInput::SwimUp, GameInput::SwimDown, + GameInput::Sneak, //GameInput::WallLeap, GameInput::ToggleLantern, GameInput::Mount, @@ -312,6 +314,7 @@ pub mod con_settings { pub climb_down: Button, pub swimup: Button, pub swimdown: Button, + pub sneak: Button, //pub wall_leap: Button, pub toggle_lantern: Button, pub mount: Button, @@ -403,6 +406,7 @@ pub mod con_settings { climb_down: Button::Simple(GilButton::Unknown), swimup: Button::Simple(GilButton::South), swimdown: Button::Simple(GilButton::Unknown), + sneak: Button::Simple(GilButton::Unknown), //wall_leap: Button::Simple(GilButton::Unknown), toggle_lantern: Button::Simple(GilButton::East), mount: Button::Simple(GilButton::North), diff --git a/voxygen/src/window.rs b/voxygen/src/window.rs index efa4702f4c..b8a6f913c4 100644 --- a/voxygen/src/window.rs +++ b/voxygen/src/window.rs @@ -41,6 +41,7 @@ pub enum GameInput { ClimbDown, SwimUp, SwimDown, + Sneak, //WallLeap, ToggleLantern, Mount, @@ -91,6 +92,7 @@ impl GameInput { GameInput::ClimbDown => "gameinput.climbdown", GameInput::SwimUp => "gameinput.swimup", GameInput::SwimDown => "gameinput.swimdown", + GameInput::Sneak => "gameinput.sneak", //GameInput::WallLeap => "gameinput.wallleap", GameInput::ToggleLantern => "gameinput.togglelantern", GameInput::Mount => "gameinput.mount", @@ -151,6 +153,7 @@ impl GameInput { GameInput::ClimbDown, GameInput::SwimUp, GameInput::SwimDown, + GameInput::Sneak, GameInput::ToggleLantern, GameInput::Mount, GameInput::Enter, From 316546af222e463e220bccc2c2c62b5e48928842 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Fri, 7 Aug 2020 01:45:01 -0400 Subject: [PATCH 3/8] bandaid fix for swim wield --- voxygen/src/anim/src/character/mod.rs | 3 +- voxygen/src/anim/src/character/swim.rs | 28 +- voxygen/src/anim/src/character/swimwield.rs | 426 ++++++++++++++++++++ voxygen/src/scene/figure/mod.rs | 18 +- 4 files changed, 457 insertions(+), 18 deletions(-) create mode 100644 voxygen/src/anim/src/character/swimwield.rs diff --git a/voxygen/src/anim/src/character/mod.rs b/voxygen/src/anim/src/character/mod.rs index e0f1b635ce..0e3d677e32 100644 --- a/voxygen/src/anim/src/character/mod.rs +++ b/voxygen/src/anim/src/character/mod.rs @@ -21,6 +21,7 @@ pub mod spin; pub mod spinmelee; pub mod stand; pub mod swim; +pub mod swimwield; pub mod wield; // Reexports @@ -31,7 +32,7 @@ pub use self::{ glidewield::GlideWieldAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, leapmelee::LeapAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, sneak::SneakAnimation, spin::SpinAnimation, - spinmelee::SpinMeleeAnimation, stand::StandAnimation, swim::SwimAnimation, + spinmelee::SpinMeleeAnimation, stand::StandAnimation, swim::SwimAnimation, swimwield::SwimWieldAnimation, wield::WieldAnimation, }; diff --git a/voxygen/src/anim/src/character/swim.rs b/voxygen/src/anim/src/character/swim.rs index 56369cac2b..7f0bc32e47 100644 --- a/voxygen/src/anim/src/character/swim.rs +++ b/voxygen/src/anim/src/character/swim.rs @@ -40,7 +40,7 @@ impl Animation for SwimAnimation { let lab = 1.0 * tempo; - let short = (anim_time as f32 * lab as f32 * 6.0).sin(); + let short = (anim_time as f32 * lab as f32 * 6.0+ PI/2.0).sin(); let foot = (anim_time as f32 * lab as f32 * 6.0).sin(); @@ -80,7 +80,7 @@ impl Animation for SwimAnimation { .reduce_and() && ori.angle_between(last_ori).is_finite() { - ori.angle_between(last_ori).min(0.2) + ori.angle_between(last_ori).min(0.8) * last_ori.determine_side(Vec2::zero(), ori).signum() } else { 0.0 @@ -92,9 +92,9 @@ impl Animation for SwimAnimation { -3.0 + skeleton_attr.head.0, skeleton_attr.head.1 - 1.0 + short * 0.3, ); - next.head.ori = Quaternion::rotation_z(head_look.x + short * -0.6 * intensity) + next.head.ori = Quaternion::rotation_z(head_look.x*0.5 + short * -0.2 * intensity) * Quaternion::rotation_x( - (0.6 * head_look.y * (1.0 / intensity)).abs() + (0.4 * head_look.y * (1.0 / intensity)).abs() + 0.45 * intensity + velocity.z * 0.02, ); @@ -105,7 +105,7 @@ impl Animation for SwimAnimation { skeleton_attr.chest.0, -13.0 + skeleton_attr.chest.1 + short * 1.3 * intensity, ); - next.chest.ori = Quaternion::rotation_z(short * 0.4 * intensity); + next.chest.ori = Quaternion::rotation_z(short * 0.1 * intensity); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); @@ -123,21 +123,21 @@ impl Animation for SwimAnimation { next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new( - -skeleton_attr.hand.0, - 1.5 + skeleton_attr.hand.1 - foot * 1.2 * intensity, - 2.0 + skeleton_attr.hand.2 + foot * -3.0 * intensity, + -1.0-skeleton_attr.hand.0, + 1.5 + skeleton_attr.hand.1 - foot * 2.0 * intensity, + 5.0 + skeleton_attr.hand.2 + foot * -5.0 * intensity, ); next.l_hand.ori = - Quaternion::rotation_x(0.8 + foot * -0.6 * intensity) * Quaternion::rotation_y(0.2); + Quaternion::rotation_x(1.5 + foot * -1.2 * intensity) * Quaternion::rotation_y(0.4+foot*-0.35); next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new( - skeleton_attr.hand.0, - 1.5 + skeleton_attr.hand.1 + foot * 1.2 * intensity, - 2.0 + skeleton_attr.hand.2 + foot * 3.0 * intensity, + 1.0+skeleton_attr.hand.0, + 1.5 + skeleton_attr.hand.1 + foot * 2.0 * intensity, + 5.0 + skeleton_attr.hand.2 + foot * 5.0 * intensity, ); next.r_hand.ori = - Quaternion::rotation_x(0.8 + foot * 0.6 * intensity) * Quaternion::rotation_y(-0.2); + Quaternion::rotation_x(1.5 + foot * 1.2 * intensity) * Quaternion::rotation_y(-0.4+foot*-0.35); next.r_hand.scale = Vec3::one(); next.l_foot.offset = Vec3::new( @@ -221,7 +221,7 @@ impl Animation for SwimAnimation { next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(adjust + avg_vel.z * 0.12) - * Quaternion::rotation_z(tilt * 12.0 + short * 0.4 * intensity); + * Quaternion::rotation_z(tilt * 12.0 + short * 0.0 * intensity); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.control.scale = Vec3::one(); diff --git a/voxygen/src/anim/src/character/swimwield.rs b/voxygen/src/anim/src/character/swimwield.rs new file mode 100644 index 0000000000..a9000a7e2e --- /dev/null +++ b/voxygen/src/anim/src/character/swimwield.rs @@ -0,0 +1,426 @@ +use super::{super::Animation, CharacterSkeleton, SkeletonAttr}; +use common::comp::item::{Hands, ToolKind}; +use std::{f32::consts::PI, ops::Mul}; +use vek::*; + +pub struct SwimWieldAnimation; + +impl Animation for SwimWieldAnimation { + type Dependency = (Option, Option, f32, f64); + type Skeleton = CharacterSkeleton; + + #[cfg(feature = "use-dyn-lib")] + const UPDATE_FN: &'static [u8] = b"character_swimwield\0"; + + #[cfg_attr(feature = "be-dyn-lib", export_name = "character_swimwield")] + #[allow(clippy::approx_constant)] // TODO: Pending review in #587 + fn update_skeleton_inner( + skeleton: &Self::Skeleton, + (active_tool_kind, second_tool_kind, velocity, global_time): Self::Dependency, + anim_time: f64, + rate: &mut f32, + skeleton_attr: &SkeletonAttr, + ) -> Self::Skeleton { + let mut next = (*skeleton).clone(); + *rate = 1.0; + let lab = 1.0; + let speed = Vec3::::from(velocity).magnitude(); + *rate = 1.0; + let intensity = if speed > 0.5 { 1.0 } else { 0.3 }; + let footrotl = (((1.0) + / (0.2 + + (0.8) + * ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin()); + + let footrotr = (((1.0) + / (0.2 + + (0.8) + * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()); + + let head_look = Vec2::new( + ((global_time + anim_time) as f32 / 3.0) + .floor() + .mul(7331.0) + .sin() + * 0.2, + ((global_time + anim_time) as f32 / 3.0) + .floor() + .mul(1337.0) + .sin() + * 0.1, + ); + + let slowalt = (anim_time as f32 * 6.0 + PI).cos(); + let u_slow = (anim_time as f32 * 1.0 + PI).sin(); + let slow = (anim_time as f32 * 3.0 + PI).sin(); + let foothoril = (anim_time as f32 * 6.0 * lab as f32 + PI * 1.45).sin(); + let foothorir = (anim_time as f32 * 6.0 * lab as f32 + PI * (0.45)).sin(); + let u_slowalt = (anim_time as f32 * 3.0 + PI).cos(); + let short = (((5.0) + / (1.5 + 3.5 * ((anim_time as f32 * lab as f32 * 16.0).sin()).powf(2.0 as f32))) + .sqrt()) + * ((anim_time as f32 * lab as f32 * 16.0).sin()); + let noisea = (anim_time as f32 * 11.0 + PI / 6.0).sin(); + let noiseb = (anim_time as f32 * 19.0 + PI / 4.0).sin(); + + next.l_foot.offset = Vec3::new( + -skeleton_attr.foot.0, + skeleton_attr.foot.1 + foothoril * 1.5 * intensity, + -15.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity, + ); + next.l_foot.ori = Quaternion::rotation_x(-0.8 + footrotl * 0.4 * intensity); + next.l_foot.scale = Vec3::one(); + + next.r_foot.offset = Vec3::new( + skeleton_attr.foot.0, + skeleton_attr.foot.1 + foothorir * 1.5 * intensity, + -15.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity, + ); + next.r_foot.ori = Quaternion::rotation_x(-0.8 + footrotr * 0.4 * intensity); + next.r_foot.scale = Vec3::one(); + if velocity > 0.1 { + next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(velocity * -0.05); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); + next.back.ori = Quaternion::rotation_x( + (-0.5 + short * 0.3 + noisea * 0.3 + noiseb * 0.3).min(-0.1), + ); + next.back.scale = Vec3::one() * 1.02; + } else { + next.head.offset = Vec3::new( + 0.0, + -2.0 + skeleton_attr.head.0, + skeleton_attr.head.1 + u_slow * 0.1, + ); + next.head.ori = + Quaternion::rotation_z(head_look.x) * Quaternion::rotation_x(head_look.y.abs()); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + + next.chest.offset = Vec3::new( + 0.0 + slowalt * 0.5, + skeleton_attr.chest.0, + skeleton_attr.chest.1 + u_slow * 0.5, + ); + next.torso.offset = Vec3::new(0.0, 0.0, 0.0) * skeleton_attr.scaler; + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; + + next.l_foot.offset = Vec3::new( + -skeleton_attr.foot.0, + -2.0 + skeleton_attr.foot.1, + skeleton_attr.foot.2, + ); + + next.r_foot.offset = Vec3::new( + skeleton_attr.foot.0, + 2.0 + skeleton_attr.foot.1, + skeleton_attr.foot.2, + ); + + next.chest.ori = + Quaternion::rotation_y(u_slowalt * 0.04) * Quaternion::rotation_z(0.15); + + next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); + next.belt.ori = Quaternion::rotation_y(u_slowalt * 0.03) * Quaternion::rotation_z(0.22); + next.belt.scale = Vec3::one() * 1.02; + + next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); + next.back.ori = Quaternion::rotation_x(-0.2); + next.back.scale = Vec3::one() * 1.02; + next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); + next.shorts.ori = Quaternion::rotation_z(0.3); + } + match active_tool_kind { + //TODO: Inventory + Some(ToolKind::Sword(_)) => { + next.l_hand.offset = Vec3::new(-0.75, -1.0, -2.5); + next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.2); + next.l_hand.scale = Vec3::one() * 1.04; + next.r_hand.offset = Vec3::new(0.75, -1.5, -5.5); + next.r_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(0.0, 0.0, -3.0); + next.main.ori = Quaternion::rotation_x(-0.1) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = Quaternion::rotation_x(u_slow * 0.15) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(u_slowalt * 0.08); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Dagger(_)) => { + // hands should be larger when holding a dagger grip, + // also reduce flicker with overlapping polygons + let hand_scale = 1.12; + + next.control.offset = Vec3::new(0.0, 0.0, 0.0); + //next.control.ori = Quaternion::rotation_x(slow * 1.0); + // * Quaternion::rotation_y(0.0) + // * Quaternion::rotation_z(u_slowalt * 0.08); + // next.control.scale = Vec3::one(); + + next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(0.0 * PI) + * Quaternion::rotation_y(0.0 * PI) + * Quaternion::rotation_z(0.0 * PI); + next.l_hand.scale = Vec3::one() * hand_scale; + + next.main.offset = Vec3::new(0.0, 0.0, 0.0); + next.main.ori = Quaternion::rotation_x(0.0 * PI) + * Quaternion::rotation_y(0.0 * PI) + * Quaternion::rotation_z(0.0 * PI); + + next.l_control.offset = Vec3::new(-7.0, 0.0, 0.0); + // next.l_control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0) + // * Quaternion::rotation_y(0.0) + // * Quaternion::rotation_z(u_slowalt * 0.08); + // next.l_control.scale = Vec3::one(); + + next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(0.0 * PI) + * Quaternion::rotation_y(0.0 * PI) + * Quaternion::rotation_z(0.0 * PI); + next.r_hand.scale = Vec3::one() * hand_scale; + + next.second.offset = Vec3::new(0.0, 0.0, 0.0); + next.second.ori = Quaternion::rotation_x(0.0 * PI) + * Quaternion::rotation_y(0.0 * PI) + * Quaternion::rotation_z(0.0 * PI); + next.second.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(7.0, 0.0, 0.0); + // next.r_control.ori = Quaternion::rotation_x(0.0 * PI) + // * Quaternion::rotation_y(0.0 * PI) + // * Quaternion::rotation_z(0.0 * PI); + // next.r_control.scale = Vec3::one(); + }, + Some(ToolKind::Axe(_)) => { + if velocity < 0.5 { + next.head.offset = Vec3::new( + 0.0, + -3.5 + skeleton_attr.head.0, + skeleton_attr.head.1 + u_slow * 0.1, + ); + next.head.ori = Quaternion::rotation_z(head_look.x) + * Quaternion::rotation_x(0.35 + head_look.y.abs()); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + next.chest.ori = Quaternion::rotation_x(-0.35) + * Quaternion::rotation_y(u_slowalt * 0.04) + * Quaternion::rotation_z(0.15); + next.belt.offset = + Vec3::new(0.0, 1.0 + skeleton_attr.belt.0, skeleton_attr.belt.1); + next.belt.ori = Quaternion::rotation_x(0.15) + * Quaternion::rotation_y(u_slowalt * 0.03) + * Quaternion::rotation_z(0.15); + next.shorts.offset = + Vec3::new(0.0, 1.0 + skeleton_attr.shorts.0, skeleton_attr.shorts.1); + next.shorts.ori = Quaternion::rotation_x(0.15) * Quaternion::rotation_z(0.25); + next.control.ori = Quaternion::rotation_x(1.8) + * Quaternion::rotation_y(-0.5) + * Quaternion::rotation_z(PI - 0.2); + next.control.scale = Vec3::one(); + } else { + next.control.ori = Quaternion::rotation_x(2.1) + * Quaternion::rotation_y(-0.4) + * Quaternion::rotation_z(PI - 0.2); + next.control.scale = Vec3::one(); + } + next.l_hand.offset = Vec3::new(-0.5, 0.0, 4.0); + next.l_hand.ori = Quaternion::rotation_x(PI / 2.0) + * Quaternion::rotation_z(0.0) + * Quaternion::rotation_y(0.0); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(0.5, 0.0, -2.5); + next.r_hand.ori = Quaternion::rotation_x(PI / 2.0) + * Quaternion::rotation_z(0.0) + * Quaternion::rotation_y(0.0); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(-0.0, -2.0, -1.0); + next.main.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + + next.control.offset = Vec3::new(-3.0, 11.0, 3.0); + }, + Some(ToolKind::Hammer(_)) => { + next.l_hand.offset = Vec3::new(-12.0, 0.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(-0.0) * Quaternion::rotation_y(0.0); + next.l_hand.scale = Vec3::one() * 1.08; + next.r_hand.offset = Vec3::new(2.0, 0.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); + next.r_hand.scale = Vec3::one() * 1.06; + next.main.offset = Vec3::new(0.0, 0.0, 0.0); + next.main.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(-1.57) + * Quaternion::rotation_z(1.57); + + next.control.offset = Vec3::new(6.0, 7.0, 1.0); + next.control.ori = Quaternion::rotation_x(0.3 + u_slow * 0.15) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(u_slowalt * 0.08); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Staff(_)) => { + next.l_hand.offset = Vec3::new(1.5, 0.5, -4.0); + next.l_hand.ori = Quaternion::rotation_x(1.47) * Quaternion::rotation_y(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(8.0, 4.0, 2.0); + next.r_hand.ori = Quaternion::rotation_x(1.8) + * Quaternion::rotation_y(0.5) + * Quaternion::rotation_z(-0.27); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(12.0, 8.4, 13.2); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(3.14 + 0.3) + * Quaternion::rotation_z(0.9); + + next.control.offset = Vec3::new(-14.0, 1.8, 3.0); + next.control.ori = Quaternion::rotation_x(u_slow * 0.2) + * Quaternion::rotation_y(-0.2) + * Quaternion::rotation_z(u_slowalt * 0.1); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Shield(_)) => { + // hands should be larger when holding a dagger grip, + // also reduce flicker with overlapping polygons + let hand_scale = 1.12; + + next.control.offset = Vec3::new(0.0, 0.0, 0.0); + // next.control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0) + // * Quaternion::rotation_y(0.0) + // * Quaternion::rotation_z(u_slowalt * 0.08); + // next.control.scale = Vec3::one(); + + next.l_hand.offset = Vec3::new(0.0, 0.0, 0.0); + next.l_hand.ori = Quaternion::rotation_x(0.0 * PI) + * Quaternion::rotation_y(0.0 * PI) + * Quaternion::rotation_z(0.0 * PI); + next.l_hand.scale = Vec3::one() * hand_scale; + + next.main.offset = Vec3::new(0.0, 0.0, 0.0); + next.main.ori = Quaternion::rotation_x(0.0 * PI) + * Quaternion::rotation_y(0.0 * PI) + * Quaternion::rotation_z(0.0 * PI); + + next.l_control.offset = Vec3::new(-7.0, 0.0, 0.0); + // next.l_control.ori = Quaternion::rotation_x(u_slow * 0.15 + 1.0) + // * Quaternion::rotation_y(0.0) + // * Quaternion::rotation_z(u_slowalt * 0.08); + // next.l_control.scale = Vec3::one(); + + next.r_hand.offset = Vec3::new(0.0, 0.0, 0.0); + next.r_hand.ori = Quaternion::rotation_x(0.0 * PI) + * Quaternion::rotation_y(0.0 * PI) + * Quaternion::rotation_z(0.0 * PI); + next.r_hand.scale = Vec3::one() * hand_scale; + + next.second.offset = Vec3::new(0.0, 0.0, 0.0); + next.second.ori = Quaternion::rotation_x(0.0 * PI) + * Quaternion::rotation_y(0.0 * PI) + * Quaternion::rotation_z(0.0 * PI); + next.second.scale = Vec3::one(); + + next.r_control.offset = Vec3::new(7.0, 0.0, 0.0); + // next.r_control.ori = Quaternion::rotation_x(0.0 * PI) + // * Quaternion::rotation_y(0.0 * PI) + // * Quaternion::rotation_z(0.0 * PI); + // next.r_control.scale = Vec3::one(); + }, + Some(ToolKind::Bow(_)) => { + next.l_hand.offset = Vec3::new(2.0, 1.5, 0.0); + next.l_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(5.9, 4.5, -5.0); + next.r_hand.ori = Quaternion::rotation_x(1.20) + * Quaternion::rotation_y(-0.6) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(3.0, 2.0, -13.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(0.3) + * Quaternion::rotation_z(-0.6); + + next.hold.offset = Vec3::new(1.2, -1.0, -5.2); + next.hold.ori = Quaternion::rotation_x(-1.7) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(-0.1); + next.hold.scale = Vec3::one() * 1.0; + + next.control.offset = Vec3::new(-7.0, 6.0, 6.0); + next.control.ori = + Quaternion::rotation_x(u_slow * 0.2) * Quaternion::rotation_z(u_slowalt * 0.1); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Debug(_)) => { + next.l_hand.offset = Vec3::new(-7.0, 4.0, 3.0); + next.l_hand.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.l_hand.scale = Vec3::one() * 1.01; + next.r_hand.offset = Vec3::new(7.0, 2.5, -1.25); + next.r_hand.ori = Quaternion::rotation_x(1.27) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(-0.3); + next.r_hand.scale = Vec3::one() * 1.01; + next.main.offset = Vec3::new(5.0, 8.75, -2.0); + next.main.ori = Quaternion::rotation_x(-0.3) + * Quaternion::rotation_y(-1.27) + * Quaternion::rotation_z(0.0); + next.main.scale = Vec3::one(); + next.control.offset = Vec3::new(0.0, 6.0, 6.0); + next.control.ori = + Quaternion::rotation_x(u_slow * 0.2) * Quaternion::rotation_z(u_slowalt * 0.1); + next.control.scale = Vec3::one(); + }, + Some(ToolKind::Farming(_)) => { + if velocity < 0.5 { + next.head.ori = Quaternion::rotation_z(head_look.x) + * Quaternion::rotation_x(-0.2 + head_look.y.abs()); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; + } + next.l_hand.offset = Vec3::new(9.0, 1.0, 1.0); + next.l_hand.ori = Quaternion::rotation_x(1.57) * Quaternion::rotation_y(0.0); + next.l_hand.scale = Vec3::one() * 1.05; + next.r_hand.offset = Vec3::new(9.0, 1.0, 11.0); + next.r_hand.ori = Quaternion::rotation_x(1.57) + * Quaternion::rotation_y(0.0) + * Quaternion::rotation_z(0.0); + next.r_hand.scale = Vec3::one() * 1.05; + next.main.offset = Vec3::new(7.5, 7.5, 13.2); + next.main.ori = Quaternion::rotation_x(0.0) + * Quaternion::rotation_y(3.14) + * Quaternion::rotation_z(0.0); + + next.control.offset = Vec3::new(-11.0 + slow * 2.0, 1.8, 4.0); + next.control.ori = Quaternion::rotation_x(u_slow * 0.1) + * Quaternion::rotation_y(0.6 + u_slow * 0.1) + * Quaternion::rotation_z(u_slowalt * 0.1); + next.control.scale = Vec3::one(); + }, + _ => {}, + } + + next.l_control.scale = Vec3::one(); + + next.r_control.scale = Vec3::one(); + + next.second.scale = match ( + active_tool_kind.map(|tk| tk.hands()), + second_tool_kind.map(|tk| tk.hands()), + ) { + (Some(Hands::OneHand), Some(Hands::OneHand)) => Vec3::one(), + (_, _) => Vec3::zero(), + }; + + next + } +} diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 916e007a74..541d88b19f 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -597,7 +597,7 @@ impl FigureMgr { skeleton_attr, ), // Running - (true, true, _) => anim::character::RunAnimation::update_skeleton( + (true, true, false) => anim::character::RunAnimation::update_skeleton( &CharacterSkeleton::new(), ( active_tool_kind.clone(), @@ -627,7 +627,7 @@ impl FigureMgr { skeleton_attr, ), // Swim - (false, _, true) => anim::character::SwimAnimation::update_skeleton( + (_, _, true) => anim::character::SwimAnimation::update_skeleton( &CharacterSkeleton::new(), ( active_tool_kind.clone(), @@ -823,13 +823,25 @@ impl FigureMgr { ) }, CharacterState::Wielding { .. } => { + if physics.in_fluid { + anim::character::SwimWieldAnimation::update_skeleton( + &target_base, + (active_tool_kind, second_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } + else{ anim::character::WieldAnimation::update_skeleton( &target_base, (active_tool_kind, second_tool_kind, vel.0.magnitude(), time), state.state_time, &mut state_animation_rate, skeleton_attr, - ) +) + } + }, CharacterState::Glide { .. } => { anim::character::GlidingAnimation::update_skeleton( From 854361cdaa42eee6f3bbca223c53caae05429f5d Mon Sep 17 00:00:00 2001 From: jshipsey Date: Fri, 7 Aug 2020 01:51:50 -0400 Subject: [PATCH 4/8] changelog --- voxygen/src/anim/Cargo.toml | 2 +- voxygen/src/anim/src/character/mod.rs | 4 ++-- voxygen/src/anim/src/character/swim.rs | 16 ++++++------- voxygen/src/scene/figure/mod.rs | 32 ++++++++++++-------------- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/voxygen/src/anim/Cargo.toml b/voxygen/src/anim/Cargo.toml index 92ce71acb0..ab4d0e2bfe 100644 --- a/voxygen/src/anim/Cargo.toml +++ b/voxygen/src/anim/Cargo.toml @@ -8,7 +8,7 @@ edition = "2018" name = "voxygen_anim" # Uncomment to use animation hot reloading # Note: this breaks `cargo test` -crate-type = ["lib", "cdylib"] +# crate-type = ["lib", "cdylib"] [features] use-dyn-lib = ["libloading", "notify", "lazy_static", "tracing", "find_folder"] diff --git a/voxygen/src/anim/src/character/mod.rs b/voxygen/src/anim/src/character/mod.rs index 0e3d677e32..7f2ef17a49 100644 --- a/voxygen/src/anim/src/character/mod.rs +++ b/voxygen/src/anim/src/character/mod.rs @@ -32,8 +32,8 @@ pub use self::{ glidewield::GlideWieldAnimation, gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, leapmelee::LeapAnimation, roll::RollAnimation, run::RunAnimation, shoot::ShootAnimation, sit::SitAnimation, sneak::SneakAnimation, spin::SpinAnimation, - spinmelee::SpinMeleeAnimation, stand::StandAnimation, swim::SwimAnimation, swimwield::SwimWieldAnimation, - wield::WieldAnimation, + spinmelee::SpinMeleeAnimation, stand::StandAnimation, swim::SwimAnimation, + swimwield::SwimWieldAnimation, wield::WieldAnimation, }; use super::{Bone, FigureBoneData, Skeleton}; diff --git a/voxygen/src/anim/src/character/swim.rs b/voxygen/src/anim/src/character/swim.rs index 7f0bc32e47..75ea32dfa2 100644 --- a/voxygen/src/anim/src/character/swim.rs +++ b/voxygen/src/anim/src/character/swim.rs @@ -40,7 +40,7 @@ impl Animation for SwimAnimation { let lab = 1.0 * tempo; - let short = (anim_time as f32 * lab as f32 * 6.0+ PI/2.0).sin(); + let short = (anim_time as f32 * lab as f32 * 6.0 + PI / 2.0).sin(); let foot = (anim_time as f32 * lab as f32 * 6.0).sin(); @@ -92,7 +92,7 @@ impl Animation for SwimAnimation { -3.0 + skeleton_attr.head.0, skeleton_attr.head.1 - 1.0 + short * 0.3, ); - next.head.ori = Quaternion::rotation_z(head_look.x*0.5 + short * -0.2 * intensity) + next.head.ori = Quaternion::rotation_z(head_look.x * 0.5 + short * -0.2 * intensity) * Quaternion::rotation_x( (0.4 * head_look.y * (1.0 / intensity)).abs() + 0.45 * intensity @@ -123,21 +123,21 @@ impl Animation for SwimAnimation { next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new( - -1.0-skeleton_attr.hand.0, + -1.0 - skeleton_attr.hand.0, 1.5 + skeleton_attr.hand.1 - foot * 2.0 * intensity, 5.0 + skeleton_attr.hand.2 + foot * -5.0 * intensity, ); - next.l_hand.ori = - Quaternion::rotation_x(1.5 + foot * -1.2 * intensity) * Quaternion::rotation_y(0.4+foot*-0.35); + next.l_hand.ori = Quaternion::rotation_x(1.5 + foot * -1.2 * intensity) + * Quaternion::rotation_y(0.4 + foot * -0.35); next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new( - 1.0+skeleton_attr.hand.0, + 1.0 + skeleton_attr.hand.0, 1.5 + skeleton_attr.hand.1 + foot * 2.0 * intensity, 5.0 + skeleton_attr.hand.2 + foot * 5.0 * intensity, ); - next.r_hand.ori = - Quaternion::rotation_x(1.5 + foot * 1.2 * intensity) * Quaternion::rotation_y(-0.4+foot*-0.35); + next.r_hand.ori = Quaternion::rotation_x(1.5 + foot * 1.2 * intensity) + * Quaternion::rotation_y(-0.4 + foot * -0.35); next.r_hand.scale = Vec3::one(); next.l_foot.offset = Vec3::new( diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 541d88b19f..68c0861f2b 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -824,24 +824,22 @@ impl FigureMgr { }, CharacterState::Wielding { .. } => { if physics.in_fluid { - anim::character::SwimWieldAnimation::update_skeleton( - &target_base, - (active_tool_kind, second_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) + anim::character::SwimWieldAnimation::update_skeleton( + &target_base, + (active_tool_kind, second_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) + } else { + anim::character::WieldAnimation::update_skeleton( + &target_base, + (active_tool_kind, second_tool_kind, vel.0.magnitude(), time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ) } - else{ - anim::character::WieldAnimation::update_skeleton( - &target_base, - (active_tool_kind, second_tool_kind, vel.0.magnitude(), time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, -) - } - }, CharacterState::Glide { .. } => { anim::character::GlidingAnimation::update_skeleton( From be3ed4b238ee33dfb0874d7255bb2f781063de04 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Fri, 7 Aug 2020 02:01:34 -0400 Subject: [PATCH 5/8] minor anim tweak --- voxygen/src/anim/src/character/swim.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/voxygen/src/anim/src/character/swim.rs b/voxygen/src/anim/src/character/swim.rs index 75ea32dfa2..d7a1a832a2 100644 --- a/voxygen/src/anim/src/character/swim.rs +++ b/voxygen/src/anim/src/character/swim.rs @@ -125,7 +125,7 @@ impl Animation for SwimAnimation { next.l_hand.offset = Vec3::new( -1.0 - skeleton_attr.hand.0, 1.5 + skeleton_attr.hand.1 - foot * 2.0 * intensity, - 5.0 + skeleton_attr.hand.2 + foot * -5.0 * intensity, + intensity * 5.0 + skeleton_attr.hand.2 + foot * -5.0 * intensity, ); next.l_hand.ori = Quaternion::rotation_x(1.5 + foot * -1.2 * intensity) * Quaternion::rotation_y(0.4 + foot * -0.35); @@ -134,7 +134,7 @@ impl Animation for SwimAnimation { next.r_hand.offset = Vec3::new( 1.0 + skeleton_attr.hand.0, 1.5 + skeleton_attr.hand.1 + foot * 2.0 * intensity, - 5.0 + skeleton_attr.hand.2 + foot * 5.0 * intensity, + intensity * 5.0 + skeleton_attr.hand.2 + foot * 5.0 * intensity, ); next.r_hand.ori = Quaternion::rotation_x(1.5 + foot * 1.2 * intensity) * Quaternion::rotation_y(-0.4 + foot * -0.35); From d7b3e84153818a4b927a36a1578e7b700afe1ca3 Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sat, 8 Aug 2020 13:47:17 -0400 Subject: [PATCH 6/8] swim alterations to condense the body on strong turns --- voxygen/src/anim/src/character/swim.rs | 79 ++++++++++++--------- voxygen/src/anim/src/character/swimwield.rs | 8 +-- voxygen/src/scene/figure/mod.rs | 2 +- 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/voxygen/src/anim/src/character/swim.rs b/voxygen/src/anim/src/character/swim.rs index d7a1a832a2..939eda7fd4 100644 --- a/voxygen/src/anim/src/character/swim.rs +++ b/voxygen/src/anim/src/character/swim.rs @@ -32,17 +32,19 @@ impl Animation for SwimAnimation { skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); + let avgspeed = Vec2::::from(avg_vel).magnitude(); + let avgtotal = Vec3::::from(avg_vel).magnitude(); let speed = Vec3::::from(velocity).magnitude(); *rate = 1.0; - let tempo = if speed > 0.5 { 1.0 } else { 0.7 }; + let tempo = if speed > 0.5 { 1.5 } else { 0.7 }; let intensity = if speed > 0.5 { 1.0 } else { 0.3 }; let lab = 1.0 * tempo; - let short = (anim_time as f32 * lab as f32 * 6.0 + PI / 2.0).sin(); + let short = (anim_time as f32 * lab as f32 * 6.0 + PI * 0.9).sin(); - let foot = (anim_time as f32 * lab as f32 * 6.0).sin(); + let foot = (anim_time as f32 * lab as f32 * 6.0 + PI * -0.1).sin(); let footrotl = (((1.0) / (0.2 @@ -58,8 +60,8 @@ impl Animation for SwimAnimation { .sqrt()) * ((anim_time as f32 * 6.0 * lab as f32 + PI * 0.4).sin()); - let foothoril = (anim_time as f32 * 6.0 * lab as f32 + PI * 1.45).sin(); - let foothorir = (anim_time as f32 * 6.0 * lab as f32 + PI * (0.45)).sin(); + let foothoril = (anim_time as f32 * 6.0 * lab as f32 + PI * 1.4).sin(); + let foothorir = (anim_time as f32 * 6.0 * lab as f32 + PI * (0.4)).sin(); let head_look = Vec2::new( ((global_time + anim_time) as f32 / 4.0 * (1.0 / tempo)) .floor() @@ -85,32 +87,35 @@ impl Animation for SwimAnimation { } else { 0.0 } * 1.3; + let abstilt = tilt.abs(); - let adjust = if speed > 0.5 { -1.57 } else { -3.14 * speed }; + let squash = if abstilt > 0.2 { 0.35 } else { 1.0 }; //condenses the body at strong turns next.head.offset = Vec3::new( 0.0, -3.0 + skeleton_attr.head.0, skeleton_attr.head.1 - 1.0 + short * 0.3, ); - next.head.ori = Quaternion::rotation_z(head_look.x * 0.5 + short * -0.2 * intensity) - * Quaternion::rotation_x( - (0.4 * head_look.y * (1.0 / intensity)).abs() - + 0.45 * intensity - + velocity.z * 0.02, - ); + next.head.ori = + Quaternion::rotation_z(head_look.x * 0.5 + short * -0.2 * intensity + tilt * 3.0) + * Quaternion::rotation_x( + (0.4 * head_look.y * (1.0 / intensity)).abs() + + 0.45 * intensity + + velocity.z * 0.03 + - (abstilt * 1.8), + ); next.head.scale = Vec3::one() * skeleton_attr.head_scale; next.chest.offset = Vec3::new( 0.0, skeleton_attr.chest.0, - -13.0 + skeleton_attr.chest.1 + short * 1.3 * intensity, + -10.0 + skeleton_attr.chest.1 + short * 0.3 * intensity, ); next.chest.ori = Quaternion::rotation_z(short * 0.1 * intensity); next.chest.scale = Vec3::one(); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); - next.belt.ori = Quaternion::rotation_x(velocity.z * 0.01) - * Quaternion::rotation_z(short * 0.2 * intensity); + next.belt.ori = Quaternion::rotation_x(velocity.z.abs() * -0.005 + abstilt * 1.0) + * Quaternion::rotation_z(short * -0.2 * intensity); next.belt.scale = Vec3::one(); next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); @@ -118,42 +123,44 @@ impl Animation for SwimAnimation { next.back.scale = Vec3::one() * 1.02; next.shorts.offset = Vec3::new(0.0, skeleton_attr.shorts.0, skeleton_attr.shorts.1); - next.shorts.ori = Quaternion::rotation_x(velocity.z * 0.02) - * Quaternion::rotation_z(short * 0.3 * intensity); + next.shorts.ori = Quaternion::rotation_x(velocity.z.abs() * -0.005 + abstilt * 1.0) + * Quaternion::rotation_z(short * -0.3 * intensity); next.shorts.scale = Vec3::one(); next.l_hand.offset = Vec3::new( -1.0 - skeleton_attr.hand.0, - 1.5 + skeleton_attr.hand.1 - foot * 2.0 * intensity, - intensity * 5.0 + skeleton_attr.hand.2 + foot * -5.0 * intensity, + 1.5 + skeleton_attr.hand.1 - foot * 2.0 * intensity * squash, + intensity * 5.0 + skeleton_attr.hand.2 + foot * -5.0 * intensity * squash, ); - next.l_hand.ori = Quaternion::rotation_x(1.5 + foot * -1.2 * intensity) + next.l_hand.ori = Quaternion::rotation_x(1.5 + foot * -1.2 * intensity * squash) * Quaternion::rotation_y(0.4 + foot * -0.35); next.l_hand.scale = Vec3::one(); next.r_hand.offset = Vec3::new( 1.0 + skeleton_attr.hand.0, - 1.5 + skeleton_attr.hand.1 + foot * 2.0 * intensity, - intensity * 5.0 + skeleton_attr.hand.2 + foot * 5.0 * intensity, + 1.5 + skeleton_attr.hand.1 + foot * 2.0 * intensity * squash, + intensity * 5.0 + skeleton_attr.hand.2 + foot * 5.0 * intensity * squash, ); - next.r_hand.ori = Quaternion::rotation_x(1.5 + foot * 1.2 * intensity) + next.r_hand.ori = Quaternion::rotation_x(1.5 + foot * 1.2 * intensity * squash) * Quaternion::rotation_y(-0.4 + foot * -0.35); next.r_hand.scale = Vec3::one(); next.l_foot.offset = Vec3::new( -skeleton_attr.foot.0, - skeleton_attr.foot.1 + foothoril * 1.5 * intensity, - -15.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity, + skeleton_attr.foot.1 + foothoril * 1.5 * intensity * squash, + -10.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity * squash, ); - next.l_foot.ori = Quaternion::rotation_x(-0.8 + footrotl * 0.4 * intensity); + next.l_foot.ori = + Quaternion::rotation_x(-0.8 * squash + footrotl * 0.4 * intensity * squash); next.l_foot.scale = Vec3::one(); next.r_foot.offset = Vec3::new( skeleton_attr.foot.0, - skeleton_attr.foot.1 + foothorir * 1.5 * intensity, - -15.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity, + skeleton_attr.foot.1 + foothorir * 1.5 * intensity * squash, + -10.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity * squash, ); - next.r_foot.ori = Quaternion::rotation_x(-0.8 + footrotr * 0.4 * intensity); + next.r_foot.ori = + Quaternion::rotation_x(-0.8 * squash + footrotr * 0.4 * intensity * squash); next.r_foot.scale = Vec3::one(); next.l_shoulder.offset = Vec3::new( @@ -218,13 +225,19 @@ impl Animation for SwimAnimation { ); next.lantern.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); next.lantern.scale = Vec3::one() * 0.65; - + let switch = if avg_vel.z > 0.0 && avgspeed < 0.5 { + avgtotal.min(0.5) + } else { + avgtotal + }; next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(adjust + avg_vel.z * 0.12) - * Quaternion::rotation_z(tilt * 12.0 + short * 0.0 * intensity); + next.torso.ori = Quaternion::rotation_x( + (((1.0 / switch) * PI / 2.0 + avg_vel.z * 0.12).min(1.57) - PI / 2.0) + + avgspeed * avg_vel.z * -0.003, + ) * Quaternion::rotation_z(tilt * 8.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - next.control.scale = Vec3::one(); + next.control.scale = Vec3::one(); //avgspeed*-0.14*reverse + next.l_control.scale = Vec3::one(); diff --git a/voxygen/src/anim/src/character/swimwield.rs b/voxygen/src/anim/src/character/swimwield.rs index a9000a7e2e..3554ffa5e5 100644 --- a/voxygen/src/anim/src/character/swimwield.rs +++ b/voxygen/src/anim/src/character/swimwield.rs @@ -70,7 +70,7 @@ impl Animation for SwimWieldAnimation { next.l_foot.offset = Vec3::new( -skeleton_attr.foot.0, skeleton_attr.foot.1 + foothoril * 1.5 * intensity, - -15.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity, + -10.0 + skeleton_attr.foot.2 + footrotl * 3.0 * intensity, ); next.l_foot.ori = Quaternion::rotation_x(-0.8 + footrotl * 0.4 * intensity); next.l_foot.scale = Vec3::one(); @@ -78,11 +78,11 @@ impl Animation for SwimWieldAnimation { next.r_foot.offset = Vec3::new( skeleton_attr.foot.0, skeleton_attr.foot.1 + foothorir * 1.5 * intensity, - -15.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity, + -10.0 + skeleton_attr.foot.2 + footrotr * 3.0 * intensity, ); next.r_foot.ori = Quaternion::rotation_x(-0.8 + footrotr * 0.4 * intensity); next.r_foot.scale = Vec3::one(); - if velocity > 0.1 { + if velocity > 0.01 { next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(velocity * -0.05); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; @@ -123,7 +123,7 @@ impl Animation for SwimWieldAnimation { ); next.chest.ori = - Quaternion::rotation_y(u_slowalt * 0.04) * Quaternion::rotation_z(0.15); + Quaternion::rotation_y(u_slowalt * 0.04) * Quaternion::rotation_z(0.25); next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0, skeleton_attr.belt.1); next.belt.ori = Quaternion::rotation_y(u_slowalt * 0.03) * Quaternion::rotation_z(0.22); diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 68c0861f2b..f825ac585b 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -584,7 +584,7 @@ impl FigureMgr { physics.in_fluid, // In water ) { // Standing - (true, false, _) => anim::character::StandAnimation::update_skeleton( + (true, false, false) => anim::character::StandAnimation::update_skeleton( &CharacterSkeleton::new(), ( active_tool_kind.clone(), From 37c733a06760e23abcfa0d5515ccaf6b527f7caa Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sat, 8 Aug 2020 17:04:50 -0400 Subject: [PATCH 7/8] clippy, consdensed climb, corrected some swim bugs --- voxygen/src/anim/src/character/climb.rs | 302 ++++++++---------------- voxygen/src/anim/src/character/sneak.rs | 5 +- voxygen/src/anim/src/character/swim.rs | 14 +- 3 files changed, 102 insertions(+), 219 deletions(-) diff --git a/voxygen/src/anim/src/character/climb.rs b/voxygen/src/anim/src/character/climb.rs index adcb48b5c4..aee0be362b 100644 --- a/voxygen/src/anim/src/character/climb.rs +++ b/voxygen/src/anim/src/character/climb.rs @@ -28,7 +28,7 @@ impl Animation for ClimbAnimation { skeleton_attr: &SkeletonAttr, ) -> Self::Skeleton { let mut next = (*skeleton).clone(); - + let lateral = Vec2::::from(velocity).magnitude(); let speed = velocity.z; *rate = speed; let constant = 1.0; @@ -60,7 +60,8 @@ impl Animation for ClimbAnimation { .sin() * 0.15, ); - if speed > 0.7 { + let stagnant = if speed > -0.7 { 1.0 } else { 0.0 }; //sets static position when there is no movement + if speed > 0.7 || lateral > 0.1 { next.head.offset = Vec3::new( 0.0, -4.0 + skeleton_attr.head.0, @@ -203,232 +204,113 @@ impl Animation for ClimbAnimation { next.torso.offset = Vec3::new(0.0, -0.2 + smooth * -0.08, 0.4) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - - next.control.scale = Vec3::one(); - - next.l_control.scale = Vec3::one(); - - next.r_control.scale = Vec3::one(); } else { - if speed > -0.7 { - next.head.offset = - Vec3::new(0.0, -2.0 + skeleton_attr.head.0, skeleton_attr.head.1); - next.head.ori = Quaternion::rotation_x(2.0 * head_look.y.abs()) - * Quaternion::rotation_z(3.5 * head_look.x.abs()); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; + next.head.offset = Vec3::new( + 0.0, + -1.0 - stagnant + skeleton_attr.head.0, + skeleton_attr.head.1, + ); + next.head.ori = Quaternion::rotation_x( + -0.25 * (1.0 - stagnant) + stagnant * 2.0 * head_look.x.abs(), + ) * Quaternion::rotation_z(stagnant * 3.5 * head_look.x.abs()); + next.head.scale = Vec3::one() * skeleton_attr.head_scale; - next.chest.offset = Vec3::new( - 0.0, - -2.0 + skeleton_attr.chest.0 + 3.0, - skeleton_attr.chest.1, - ); - next.chest.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.3) - * Quaternion::rotation_z(0.6); - next.chest.scale = Vec3::one(); + next.chest.offset = Vec3::new(0.0, 1.0 + skeleton_attr.chest.0, skeleton_attr.chest.1); + next.chest.ori = Quaternion::rotation_z(0.6 * stagnant) + * Quaternion::rotation_x((0.2 + drop * 0.05) * (1.0 - stagnant)); + next.chest.scale = Vec3::one(); - next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 0.5, skeleton_attr.belt.1); - next.belt.ori = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.1); - next.belt.scale = Vec3::one(); + next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 0.5, skeleton_attr.belt.1); + next.belt.ori = Quaternion::rotation_x(0.1 + dropa * 0.1); + next.belt.scale = Vec3::one(); - next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); - next.back.ori = Quaternion::rotation_x(-0.2); - next.back.scale = Vec3::one() * 1.02; + next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); + next.back.ori = Quaternion::rotation_x( + -0.2 + dropa * 0.1 - 0.15 * (1.0 - stagnant) + stagnant * 0.1, + ); + next.back.scale = Vec3::one() * 1.02; - next.shorts.offset = - Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1); - next.shorts.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.1) - * Quaternion::rotation_y(0.0); - next.shorts.scale = Vec3::one(); + next.shorts.offset = + Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1); + next.shorts.ori = Quaternion::rotation_x(0.1 + dropa * 0.12 * (1.0 - stagnant)); + next.shorts.scale = Vec3::one(); - next.l_hand.offset = Vec3::new( - -skeleton_attr.hand.0, - 2.0 + skeleton_attr.hand.1, - skeleton_attr.hand.2, - ); - next.l_hand.ori = Quaternion::rotation_x(0.8); - next.l_hand.scale = Vec3::one(); + next.l_hand.offset = Vec3::new( + -skeleton_attr.hand.0, + 7.5 + stagnant * -5.0 + skeleton_attr.hand.1, + 7.0 + stagnant * -7.0 + skeleton_attr.hand.2 + dropa * -1.0 * (1.0 - stagnant), + ); + next.l_hand.ori = Quaternion::rotation_x(2.2 + stagnant * -1.4) + * Quaternion::rotation_y((0.3 + dropa * 0.1) * (1.0 - stagnant)); + next.l_hand.scale = Vec3::one(); - next.r_hand.offset = Vec3::new( - skeleton_attr.hand.0, - 5.5 + skeleton_attr.hand.1, - 5.0 + skeleton_attr.hand.2, - ); - next.r_hand.ori = Quaternion::rotation_x(2.2) * Quaternion::rotation_y(-0.5); - next.r_hand.scale = Vec3::one(); + next.r_hand.offset = Vec3::new( + skeleton_attr.hand.0, + 7.5 + stagnant * -2.5 + skeleton_attr.hand.1, + 5.0 + skeleton_attr.hand.2 + drop * -1.0 * (1.0 - stagnant), + ); + next.r_hand.ori = Quaternion::rotation_x(2.2) + * Quaternion::rotation_y(-0.3 + drop * 0.1 * (1.0 - stagnant)); + next.r_hand.scale = Vec3::one(); - next.l_foot.offset = Vec3::new( - -skeleton_attr.foot.0, - 5.0 + skeleton_attr.foot.1, - 1.0 + skeleton_attr.foot.2, - ); - next.l_foot.ori = Quaternion::rotation_x(0.55); - next.l_foot.scale = Vec3::one(); + next.l_foot.offset = Vec3::new( + -skeleton_attr.foot.0, + 4.0 + stagnant * 3.0 + skeleton_attr.foot.1, + 1.0 + skeleton_attr.foot.2 + drop * -2.0 * (1.0 - stagnant), + ); + next.l_foot.ori = Quaternion::rotation_x(0.55 + drop * 0.1 * (1.0 - stagnant)); + next.l_foot.scale = Vec3::one(); - next.r_foot.offset = Vec3::new( - skeleton_attr.foot.0, - 5.0 + skeleton_attr.foot.1, - -2.0 + skeleton_attr.foot.2, - ); - next.r_foot.ori = Quaternion::rotation_x(0.2); - next.r_foot.scale = Vec3::one(); + next.r_foot.offset = Vec3::new( + skeleton_attr.foot.0, + 2.0 + stagnant * 4.0 + skeleton_attr.foot.1, + -2.0 + skeleton_attr.foot.2 + smooth * 1.0 * (1.0 - stagnant), + ); + next.r_foot.ori = Quaternion::rotation_x(0.2 + smooth * 0.15 * (1.0 - stagnant)); + next.r_foot.scale = Vec3::one(); - next.l_shoulder.offset = Vec3::new( - -skeleton_attr.shoulder.0, - skeleton_attr.shoulder.1, - skeleton_attr.shoulder.2, - ); - next.l_shoulder.ori = Quaternion::rotation_x(0.0); - next.l_shoulder.scale = Vec3::one() * 1.1; + next.l_shoulder.offset = Vec3::new( + -skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.l_shoulder.ori = Quaternion::rotation_x(0.0); + next.l_shoulder.scale = Vec3::one() * 1.1; - next.r_shoulder.offset = Vec3::new( - skeleton_attr.shoulder.0, - skeleton_attr.shoulder.1, - skeleton_attr.shoulder.2, - ); - next.r_shoulder.ori = Quaternion::rotation_x(0.0); - next.r_shoulder.scale = Vec3::one() * 1.1; + next.r_shoulder.offset = Vec3::new( + skeleton_attr.shoulder.0, + skeleton_attr.shoulder.1, + skeleton_attr.shoulder.2, + ); + next.r_shoulder.ori = Quaternion::rotation_x(0.0); + next.r_shoulder.scale = Vec3::one() * 1.1; - next.glider.offset = Vec3::new(0.0, 0.0, 10.0); - next.glider.scale = Vec3::one() * 0.0; + next.glider.offset = Vec3::new(0.0, 0.0, 10.0); + next.glider.scale = Vec3::one() * 0.0; - next.main.offset = Vec3::new(-7.0, -5.0, 18.0); - next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); - next.main.scale = Vec3::one(); + next.main.offset = Vec3::new(-7.0, -5.0, 18.0); + next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); + next.main.scale = Vec3::one(); - next.second.offset = Vec3::new(0.0, 0.0, 0.0); - next.second.ori = Quaternion::rotation_y(0.0); - next.second.scale = Vec3::one() * 0.0; + next.second.offset = Vec3::new(0.0, 0.0, 0.0); + next.second.ori = Quaternion::rotation_y(0.0); + next.second.scale = Vec3::one() * 0.0; - next.lantern.offset = Vec3::new( - skeleton_attr.lantern.0, - skeleton_attr.lantern.1, - skeleton_attr.lantern.2, - ); - next.lantern.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); - next.lantern.scale = Vec3::one() * 0.65; + next.lantern.offset = Vec3::new( + skeleton_attr.lantern.0, + skeleton_attr.lantern.1, + skeleton_attr.lantern.2, + ); + next.lantern.ori = Quaternion::rotation_x(0.0); + next.lantern.scale = Vec3::one() * 0.65; - next.torso.offset = Vec3::new(0.0, -0.2, 0.4) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - - next.control.scale = Vec3::one(); - - next.l_control.scale = Vec3::one(); - - next.r_control.scale = Vec3::one(); - } else { - next.head.offset = - Vec3::new(0.0, -1.0 + skeleton_attr.head.0, skeleton_attr.head.1); - next.head.ori = Quaternion::rotation_x(-0.25) * Quaternion::rotation_z(0.0); - next.head.scale = Vec3::one() * skeleton_attr.head_scale; - - next.chest.offset = Vec3::new( - 0.0, - -2.0 + skeleton_attr.chest.0 + 3.0, - skeleton_attr.chest.1, - ); - next.chest.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.2 + drop * 0.05) - * Quaternion::rotation_z(0.0); - next.chest.scale = Vec3::one(); - - next.belt.offset = Vec3::new(0.0, skeleton_attr.belt.0 + 0.5, skeleton_attr.belt.1); - next.belt.ori = - Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.1 + dropa * 0.1); - next.belt.scale = Vec3::one(); - - next.back.offset = Vec3::new(0.0, skeleton_attr.back.0, skeleton_attr.back.1); - next.back.ori = Quaternion::rotation_x(-0.15); - next.back.scale = Vec3::one() * 1.02; - - next.shorts.offset = - Vec3::new(0.0, skeleton_attr.shorts.0 + 1.0, skeleton_attr.shorts.1); - next.shorts.ori = Quaternion::rotation_z(0.0) - * Quaternion::rotation_x(0.1 + dropa * 0.12) - * Quaternion::rotation_y(0.0); - next.shorts.scale = Vec3::one(); - - next.l_hand.offset = Vec3::new( - -skeleton_attr.hand.0, - 7.5 + skeleton_attr.hand.1, - 7.0 + skeleton_attr.hand.2 + dropa * -1.0, - ); - next.l_hand.ori = - Quaternion::rotation_x(2.2) * Quaternion::rotation_y(0.3 + dropa * 0.1); - next.l_hand.scale = Vec3::one(); - - next.r_hand.offset = Vec3::new( - skeleton_attr.hand.0, - 7.5 + skeleton_attr.hand.1, - 5.0 + skeleton_attr.hand.2 + drop * -1.0, - ); - next.r_hand.ori = - Quaternion::rotation_x(2.2) * Quaternion::rotation_y(-0.3 + drop * 0.1); - next.r_hand.scale = Vec3::one(); - - next.l_foot.offset = Vec3::new( - -skeleton_attr.foot.0, - 4.0 + skeleton_attr.foot.1, - 1.0 + skeleton_attr.foot.2 + drop * -2.0, - ); - next.l_foot.ori = Quaternion::rotation_x(0.55 + drop * 0.1); - next.l_foot.scale = Vec3::one(); - - next.r_foot.offset = Vec3::new( - skeleton_attr.foot.0, - 2.0 + skeleton_attr.foot.1, - -2.0 + skeleton_attr.foot.2 + smooth * 1.0, - ); - next.r_foot.ori = Quaternion::rotation_x(0.2 + smooth * 0.15); - next.r_foot.scale = Vec3::one(); - - next.l_shoulder.offset = Vec3::new( - -skeleton_attr.shoulder.0, - skeleton_attr.shoulder.1, - skeleton_attr.shoulder.2, - ); - next.l_shoulder.ori = Quaternion::rotation_x(0.0); - next.l_shoulder.scale = Vec3::one() * 1.1; - - next.r_shoulder.offset = Vec3::new( - skeleton_attr.shoulder.0, - skeleton_attr.shoulder.1, - skeleton_attr.shoulder.2, - ); - next.r_shoulder.ori = Quaternion::rotation_x(0.0); - next.r_shoulder.scale = Vec3::one() * 1.1; - - next.glider.offset = Vec3::new(0.0, 0.0, 10.0); - next.glider.scale = Vec3::one() * 0.0; - - next.main.offset = Vec3::new(-7.0, -5.0, 18.0); - next.main.ori = Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); - next.main.scale = Vec3::one(); - - next.second.offset = Vec3::new(0.0, 0.0, 0.0); - next.second.ori = Quaternion::rotation_y(0.0); - next.second.scale = Vec3::one() * 0.0; - - next.lantern.offset = Vec3::new( - skeleton_attr.lantern.0, - skeleton_attr.lantern.1, - skeleton_attr.lantern.2, - ); - next.lantern.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); - next.lantern.scale = Vec3::one() * 0.65; - - next.torso.offset = Vec3::new(0.0, -0.2, 0.4) * skeleton_attr.scaler; - next.torso.ori = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0); - next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; - - next.control.scale = Vec3::one(); - - next.l_control.scale = Vec3::one(); - } + next.torso.offset = Vec3::new(0.0, -0.2, 0.4) * skeleton_attr.scaler; + next.torso.ori = Quaternion::rotation_x(0.0); + next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; }; + next.control.scale = Vec3::one(); next.r_control.scale = Vec3::one(); + next.l_control.scale = Vec3::one(); next.second.scale = match ( active_tool_kind.map(|tk| tk.hands()), diff --git a/voxygen/src/anim/src/character/sneak.rs b/voxygen/src/anim/src/character/sneak.rs index 281607f259..52563090a1 100644 --- a/voxygen/src/anim/src/character/sneak.rs +++ b/voxygen/src/anim/src/character/sneak.rs @@ -13,7 +13,6 @@ impl Animation for SneakAnimation { const UPDATE_FN: &'static [u8] = b"character_sneak\0"; #[cfg_attr(feature = "be-dyn-lib", export_name = "character_sneak")] - #[allow(clippy::identity_conversion)] // TODO: Pending review in #587 fn update_skeleton_inner( skeleton: &Self::Skeleton, @@ -75,10 +74,10 @@ impl Animation for SneakAnimation { * 0.1, ); - let ori = Vec2::from(orientation); + let ori: Vec2 = Vec2::from(orientation); let last_ori = Vec2::from(last_ori); let tilt = if Vec2::new(ori, last_ori) - .map(|o| Vec2::::from(o).magnitude_squared()) + .map(|o| o.magnitude_squared()) .map(|m| m > 0.001 && m.is_finite()) .reduce_and() && ori.angle_between(last_ori).is_finite() diff --git a/voxygen/src/anim/src/character/swim.rs b/voxygen/src/anim/src/character/swim.rs index 939eda7fd4..b0c2c33d32 100644 --- a/voxygen/src/anim/src/character/swim.rs +++ b/voxygen/src/anim/src/character/swim.rs @@ -33,9 +33,10 @@ impl Animation for SwimAnimation { ) -> Self::Skeleton { let mut next = (*skeleton).clone(); let avgspeed = Vec2::::from(avg_vel).magnitude(); - let avgtotal = Vec3::::from(avg_vel).magnitude(); - let speed = Vec3::::from(velocity).magnitude(); + let avgtotal = avg_vel.magnitude(); + + let speed = velocity.magnitude(); *rate = 1.0; let tempo = if speed > 0.5 { 1.5 } else { 0.7 }; let intensity = if speed > 0.5 { 1.0 } else { 0.3 }; @@ -96,12 +97,12 @@ impl Animation for SwimAnimation { skeleton_attr.head.1 - 1.0 + short * 0.3, ); next.head.ori = - Quaternion::rotation_z(head_look.x * 0.5 + short * -0.2 * intensity + tilt * 3.0) + Quaternion::rotation_z(head_look.x * 0.3 + short * -0.2 * intensity + tilt * 3.0) * Quaternion::rotation_x( (0.4 * head_look.y * (1.0 / intensity)).abs() + 0.45 * intensity + velocity.z * 0.03 - - (abstilt * 1.8), + - (abstilt * 1.8).min(0.0), ); next.head.scale = Vec3::one() * skeleton_attr.head_scale; @@ -230,11 +231,12 @@ impl Animation for SwimAnimation { } else { avgtotal }; - next.torso.offset = Vec3::new(0.0, 0.0, 1.0) * skeleton_attr.scaler; + next.torso.offset = Vec3::new(0.0, 0.0, 1.0 - avgspeed * 0.05) * skeleton_attr.scaler; next.torso.ori = Quaternion::rotation_x( (((1.0 / switch) * PI / 2.0 + avg_vel.z * 0.12).min(1.57) - PI / 2.0) + avgspeed * avg_vel.z * -0.003, - ) * Quaternion::rotation_z(tilt * 8.0); + ) * Quaternion::rotation_y(tilt * 8.0) + * Quaternion::rotation_z(tilt * 8.0); next.torso.scale = Vec3::one() / 11.0 * skeleton_attr.scaler; next.control.scale = Vec3::one(); //avgspeed*-0.14*reverse + From 45971fa4033e351900ff851aa10db86ca7d07b3b Mon Sep 17 00:00:00 2001 From: jshipsey Date: Sat, 8 Aug 2020 17:05:48 -0400 Subject: [PATCH 8/8] state corrections --- common/src/states/climb.rs | 3 ++- common/src/states/glide.rs | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/common/src/states/climb.rs b/common/src/states/climb.rs index 44642ec656..4bf3cf71b2 100644 --- a/common/src/states/climb.rs +++ b/common/src/states/climb.rs @@ -87,7 +87,8 @@ impl CharacterBehavior for Data { }, Climb::Hold => { // Antigrav - update.vel.0.z = (update.vel.0.z + data.dt.0 * GRAVITY * 1.1).min(CLIMB_SPEED); + update.vel.0.z = + (update.vel.0.z + data.dt.0 * GRAVITY * 1.075).min(CLIMB_SPEED); update.vel.0 = Lerp::lerp( update.vel.0, Vec3::zero(), diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index c8c06b68be..93449a2ad3 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -24,7 +24,9 @@ impl CharacterBehavior for Data { update.character = CharacterState::GlideWield; return update; } - + if data.physics.in_fluid { + update.character = CharacterState::Idle; + } // If there is a wall in front of character and they are trying to climb go to // climb handle_climb(&data, &mut update);