From 30ecc997ea66b922736de82847b19437dbca48da Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 14 Oct 2023 15:06:08 +0100 Subject: [PATCH] Factor tool back animation code out --- voxygen/anim/src/character/idle.rs | 63 +-------------------- voxygen/anim/src/character/jump.rs | 86 +---------------------------- voxygen/anim/src/character/mod.rs | 78 +++++++++++++++++++++++++- voxygen/anim/src/character/mount.rs | 53 +----------------- voxygen/anim/src/character/roll.rs | 30 +--------- voxygen/anim/src/character/run.rs | 84 +--------------------------- voxygen/anim/src/character/stand.rs | 64 +-------------------- voxygen/anim/src/character/swim.rs | 83 +--------------------------- 8 files changed, 86 insertions(+), 455 deletions(-) diff --git a/voxygen/anim/src/character/idle.rs b/voxygen/anim/src/character/idle.rs index d010bce292..0322d63551 100644 --- a/voxygen/anim/src/character/idle.rs +++ b/voxygen/anim/src/character/idle.rs @@ -86,75 +86,14 @@ impl Animation for IdleAnimation { next.glider.position = Vec3::new(0.0, 0.0, 10.0); next.glider.scale = Vec3::one() * 0.0; next.hold.position = Vec3::new(0.4, -0.3, -5.8); - match hands { - (Some(Hands::Two), _) | (None, Some(Hands::Two)) => match active_tool_kind { - Some(ToolKind::Bow) => { - next.main.position = Vec3::new(0.0, -5.0 - skeleton.back_carry_offset, 6.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { - next.main.position = Vec3::new(2.0, -5.0 - skeleton.back_carry_offset, -1.0); - next.main.orientation = - Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); - }, - _ => { - next.main.position = Vec3::new(-7.0, -5. - skeleton.back_carry_offset, 15.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - }, - (_, _) => {}, - }; - match hands { - (Some(Hands::One), _) => match active_tool_kind { - Some(ToolKind::Dagger) => { - next.main.position = Vec3::new(5.0, 1.0 - skeleton.back_carry_offset, 2.0); - next.main.orientation = - Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); - }, - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.main.position = Vec3::new(-4.0, -4.0 - skeleton.back_carry_offset, 10.0); - next.main.orientation = - Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0); - }, - - _ => {}, - }, - (_, _) => {}, - }; - match hands { - (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { - Some(ToolKind::Dagger) => { - next.second.position = Vec3::new(-5.0, 1.0 - skeleton.back_carry_offset, 2.0); - next.second.orientation = - Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); - }, - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.second.position = Vec3::new(4.0, -5.0 - skeleton.back_carry_offset, 10.0); - next.second.orientation = - Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); - }, - _ => {}, - }, - (_, _) => {}, - }; + next.do_tools_on_back(hands, active_tool_kind, second_tool_kind); next.lantern.position = Vec3::new(s_a.lantern.0, s_a.lantern.1, s_a.lantern.2); next.lantern.orientation = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1); next.torso.position = Vec3::new(0.0, 0.0, 0.0); - next.second.scale = match hands { - (Some(Hands::One), Some(Hands::One)) => Vec3::one(), - (_, _) => Vec3::zero(), - }; - - if let (None, Some(Hands::Two)) = hands { - next.second = next.main; - } - next } } diff --git a/voxygen/anim/src/character/jump.rs b/voxygen/anim/src/character/jump.rs index b57c1bdd8d..72da2b8a78 100644 --- a/voxygen/anim/src/character/jump.rs +++ b/voxygen/anim/src/character/jump.rs @@ -3,7 +3,6 @@ use super::{ CharacterSkeleton, SkeletonAttr, }; use common::comp::item::{Hands, ToolKind}; -use core::f32::consts::PI; pub struct JumpAnimation; impl Animation for JumpAnimation { @@ -136,58 +135,7 @@ impl Animation for JumpAnimation { next.glider.position = Vec3::new(0.0, 0.0, 10.0); next.glider.scale = Vec3::one() * 0.0; - let main_tool = if let (None, Some(Hands::Two)) = hands { - second_tool_kind - } else { - active_tool_kind - }; - - match main_tool { - Some(ToolKind::Dagger) => { - next.main.position = Vec3::new(5.0, 1.0 - skeleton.back_carry_offset, 2.0); - next.main.orientation = - Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); - }, - Some(ToolKind::Shield) => { - next.main.position = Vec3::new(-0.0, -5.0 - skeleton.back_carry_offset, 3.0); - next.main.orientation = - Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); - }, - Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { - next.main.position = Vec3::new(2.0, -5.0 - skeleton.back_carry_offset, -1.0); - next.main.orientation = - Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); - }, - Some(ToolKind::Bow) => { - next.main.position = Vec3::new(0.0, -5.0 - skeleton.back_carry_offset, 6.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - _ => { - next.main.position = Vec3::new(-7.0, -5.0 - skeleton.back_carry_offset, 15.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - } - - match second_tool_kind { - Some(ToolKind::Dagger) => { - next.second.position = Vec3::new(-5.0, 1.0 - skeleton.back_carry_offset, 2.0); - next.second.orientation = - Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); - }, - Some(ToolKind::Shield) => { - next.second.position = Vec3::new(0.0, -4.5 - skeleton.back_carry_offset, 3.0); - next.second.orientation = - Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); - }, - - _ => { - next.second.position = Vec3::new(-7.0, -5.0 - skeleton.back_carry_offset, 15.0); - next.second.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - } + next.do_tools_on_back(hands, active_tool_kind, second_tool_kind); next.lantern.position = Vec3::new(s_a.lantern.0, s_a.lantern.1, s_a.lantern.2); next.lantern.orientation = Quaternion::rotation_x(1.0 * switch + slow * 0.3 * switch) @@ -208,38 +156,6 @@ impl Animation for JumpAnimation { next.torso.position = Vec3::new(0.0, 0.0, 0.0); next.torso.orientation = Quaternion::rotation_x(0.0); - match hands { - (Some(Hands::One), _) => match active_tool_kind { - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.main.position = Vec3::new(-4.0, -5.0 - skeleton.back_carry_offset, 10.0); - next.main.orientation = - Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0); - }, - - _ => {}, - }, - (_, _) => {}, - }; - match hands { - (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.second.position = Vec3::new(4.0, -6.0 - skeleton.back_carry_offset, 10.0); - next.second.orientation = - Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); - }, - _ => {}, - }, - (_, _) => {}, - }; - next.second.scale = match hands { - (Some(Hands::One) | None, Some(Hands::One)) => Vec3::one(), - (_, _) => Vec3::zero(), - }; - - if let (None, Some(Hands::Two)) = hands { - next.second = next.main; - } - next } } diff --git a/voxygen/anim/src/character/mod.rs b/voxygen/anim/src/character/mod.rs index c5cf136a64..4d3e1c5b66 100644 --- a/voxygen/anim/src/character/mod.rs +++ b/voxygen/anim/src/character/mod.rs @@ -58,7 +58,10 @@ pub use self::{ wallrun::WallrunAnimation, wield::WieldAnimation, }; use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton, TrailSource}; -use common::comp; +use common::comp::{ + self, + tool::{Hands, ToolKind}, +}; use core::{convert::TryFrom, f32::consts::PI}; pub type Body = comp::humanoid::Body; @@ -333,3 +336,76 @@ impl<'a> From<&'a Body> for SkeletonAttr { } } } + +impl CharacterSkeleton { + pub fn do_tools_on_back( + &mut self, + hands: (Option, Option), + active_tool_kind: Option, + second_tool_kind: Option, + ) { + match (hands, active_tool_kind, second_tool_kind) { + ((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => match tool { + Some(ToolKind::Bow) => { + self.main.position = Vec3::new(0.0, -5.0 - self.back_carry_offset, 6.0); + self.main.orientation = + Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); + }, + Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { + self.main.position = Vec3::new(2.0, -5.0 - self.back_carry_offset, -1.0); + self.main.orientation = + Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); + }, + _ => { + self.main.position = Vec3::new(-7.0, -5.0 - self.back_carry_offset, 15.0); + self.main.orientation = + Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); + }, + }, + ((_, _), _, _) => {}, + } + + match hands { + (Some(Hands::One), _) => match active_tool_kind { + Some(ToolKind::Dagger) => { + self.main.position = Vec3::new(5.0, 1.0 - self.back_carry_offset, 2.0); + self.main.orientation = + Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); + }, + Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { + self.main.position = Vec3::new(-4.0, -4.5 - self.back_carry_offset, 10.0); + self.main.orientation = + Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); + }, + Some(ToolKind::Shield) => { + self.main.position = Vec3::new(-0.0, -4.0 - self.back_carry_offset, 3.0); + self.main.orientation = + Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); + }, + _ => {}, + }, + (_, _) => {}, + } + match hands { + (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { + Some(ToolKind::Dagger) => { + self.second.position = Vec3::new(-5.0, 1.0 - self.back_carry_offset, 2.0); + self.second.orientation = + Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); + }, + Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { + self.second.position = Vec3::new(4.0, -5.0 - self.back_carry_offset, 10.0); + self.second.orientation = + Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); + }, + Some(ToolKind::Shield) => { + self.second.position = Vec3::new(0.0, -4.0 - self.back_carry_offset, 3.0); + self.second.orientation = + Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); + }, + _ => {}, + }, + (_, _) => {}, + } + } +} diff --git a/voxygen/anim/src/character/mount.rs b/voxygen/anim/src/character/mount.rs index 4769c02b4d..5e70b074f4 100644 --- a/voxygen/anim/src/character/mount.rs +++ b/voxygen/anim/src/character/mount.rs @@ -155,59 +155,8 @@ impl Animation for MountAnimation { next.glider.position = Vec3::new(0.0, 0.0, 10.0); next.glider.scale = Vec3::one() * 0.0; next.hold.position = Vec3::new(0.4, -0.3, -5.8); - match hands { - (Some(Hands::Two), _) | (None, Some(Hands::Two)) => match active_tool_kind { - Some(ToolKind::Bow) => { - next.main.position = Vec3::new(0.0, -5.0, 6.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); - }, - Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { - next.main.position = Vec3::new(2.0, -5.0, -1.0); - next.main.orientation = - Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(1.57); - }, - _ => { - next.main.position = Vec3::new(-7.0, -5.0, 15.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57); - }, - }, - (_, _) => {}, - }; - match hands { - (Some(Hands::One), _) => match active_tool_kind { - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.main.position = Vec3::new(-4.0, -5.0, 10.0); - next.main.orientation = - Quaternion::rotation_y(2.35) * Quaternion::rotation_z(1.57); - }, - - _ => {}, - }, - (_, _) => {}, - }; - match hands { - (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.second.position = Vec3::new(4.0, -6.0, 10.0); - next.second.orientation = - Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-1.57); - }, - _ => {}, - }, - (_, _) => {}, - }; - - next.second.scale = match hands { - (Some(Hands::One), Some(Hands::One)) => Vec3::one(), - (_, _) => Vec3::zero(), - }; - - if let (None, Some(Hands::Two)) = hands { - next.second = next.main; - } + next.do_tools_on_back(hands, active_tool_kind, second_tool_kind); next } diff --git a/voxygen/anim/src/character/roll.rs b/voxygen/anim/src/character/roll.rs index f250c915cd..764861fbca 100644 --- a/voxygen/anim/src/character/roll.rs +++ b/voxygen/anim/src/character/roll.rs @@ -36,7 +36,7 @@ impl Animation for RollAnimation { skeleton: &Self::Skeleton, ( active_tool_kind, - _second_tool_kind, + second_tool_kind, hands, wield_status, orientation, @@ -206,32 +206,8 @@ impl Animation for RollAnimation { (_, _) => {}, } } else { - next.hand_l.position = Vec3::new( - -s_a.hand.0, - s_a.hand.1 + 1.0 * movement1, - s_a.hand.2 + 2.0 * movement1, - ); - next.hand_l.orientation = Quaternion::rotation_x(0.6 * movement1); - - next.hand_r.position = if prev_aimed_dir.is_some() { - Vec3::new( - -1.0 * movement1 + s_a.hand.0, - s_a.hand.1 + 1.0 * movement1, - s_a.hand.2 + 2.0 * movement1, - ) - } else { - Vec3::new( - -1.0 * movement1 + s_a.hand.0 + 3.0, - s_a.hand.1 + 1.0 * movement1, - s_a.hand.2 + 2.0 * movement1 + 8.0, - ) - }; - next.hand_r.orientation = if prev_aimed_dir.is_some() { - Quaternion::rotation_x(0.6 * movement1) - } else { - Quaternion::rotation_y(-1.0) - }; - }; + next.do_tools_on_back(hands, active_tool_kind, second_tool_kind); + } next.head.position = Vec3::new( 0.0, s_a.head.0 + 1.5 * movement1, diff --git a/voxygen/anim/src/character/run.rs b/voxygen/anim/src/character/run.rs index 7d3d1eec72..9cb0096405 100644 --- a/voxygen/anim/src/character/run.rs +++ b/voxygen/anim/src/character/run.rs @@ -230,57 +230,7 @@ impl Animation for RunAnimation { next.glider.position = Vec3::new(0.0, 0.0, 10.0); next.glider.scale = Vec3::one() * 0.0; - let main_tool = if let (None, Some(Hands::Two)) = hands { - second_tool_kind - } else { - active_tool_kind - }; - - match main_tool { - Some(ToolKind::Dagger) => { - next.main.position = Vec3::new(5.0, 1.0 - skeleton.back_carry_offset, 2.0); - next.main.orientation = - Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); - }, - Some(ToolKind::Shield) => { - next.main.position = Vec3::new(-0.0, -5.0 - skeleton.back_carry_offset, 3.0); - next.main.orientation = - Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); - }, - Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { - next.main.position = Vec3::new(2.0, -5.0 - skeleton.back_carry_offset, -1.0); - next.main.orientation = - Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); - }, - Some(ToolKind::Bow) => { - next.main.position = Vec3::new(0.0, -5.0 - skeleton.back_carry_offset, 6.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - _ => { - next.main.position = Vec3::new(-7.0, -5.0 - skeleton.back_carry_offset, 15.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0 + shorte * -0.2); - }, - } - - match second_tool_kind { - Some(ToolKind::Dagger) => { - next.second.position = Vec3::new(-5.0, 1.0 - skeleton.back_carry_offset, 2.0); - next.second.orientation = - Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); - }, - Some(ToolKind::Shield) => { - next.second.position = Vec3::new(0.0, -4.5 - skeleton.back_carry_offset, 3.0); - next.second.orientation = - Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); - }, - _ => { - next.second.position = Vec3::new(-7.0, -5.0 - skeleton.back_carry_offset, 15.0); - next.second.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - } + next.do_tools_on_back(hands, active_tool_kind, second_tool_kind); next.lantern.position = Vec3::new(s_a.lantern.0, s_a.lantern.1, s_a.lantern.2); next.lantern.orientation = @@ -308,38 +258,6 @@ impl Animation for RunAnimation { next.torso.position = Vec3::new(0.0, 0.0, 0.0); - match hands { - (Some(Hands::One), _) => match active_tool_kind { - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.main.position = Vec3::new(-4.0, -4.5 - skeleton.back_carry_offset, 10.0); - next.main.orientation = - Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0); - }, - - _ => {}, - }, - (_, _) => {}, - }; - match hands { - (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.second.position = Vec3::new(4.0, -5.0 - skeleton.back_carry_offset, 10.0); - next.second.orientation = - Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); - }, - _ => {}, - }, - (_, _) => {}, - }; - - next.second.scale = match hands { - (Some(Hands::One) | None, Some(Hands::One)) => Vec3::one(), - (_, _) => Vec3::zero(), - }; - - if let (None, Some(Hands::Two)) = hands { - next.second = next.main; - } if wall.map_or(false, |e| e.y > 0.5) { let push = (1.0 - orientation.x.abs()).powi(2); let right_sub = -(orientation.x).min(0.0); diff --git a/voxygen/anim/src/character/stand.rs b/voxygen/anim/src/character/stand.rs index 24f70e64d3..02c9cf96ef 100644 --- a/voxygen/anim/src/character/stand.rs +++ b/voxygen/anim/src/character/stand.rs @@ -3,7 +3,6 @@ use super::{ CharacterSkeleton, SkeletonAttr, }; use common::comp::item::{Hands, ToolKind}; -use core::f32::consts::PI; use std::ops::Mul; pub struct StandAnimation; @@ -108,69 +107,8 @@ impl Animation for StandAnimation { next.glider.position = Vec3::new(0.0, 0.0, 10.0); next.glider.scale = Vec3::one() * 0.0; next.hold.position = Vec3::new(0.4, -0.3, -5.8); - match (hands, active_tool_kind, second_tool_kind) { - ((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => match tool { - Some(ToolKind::Bow) => { - next.main.position = Vec3::new(0.0, -5.0 - skeleton.back_carry_offset, 6.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { - next.main.position = Vec3::new(2.0, -5.0 - skeleton.back_carry_offset, -1.0); - next.main.orientation = - Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); - }, - _ => { - next.main.position = Vec3::new(-7.0, -5.0 - skeleton.back_carry_offset, 15.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - }, - ((_, _), _, _) => {}, - }; - match hands { - (Some(Hands::One), _) => match active_tool_kind { - Some(ToolKind::Dagger) => { - next.main.position = Vec3::new(5.0, 1.0 - skeleton.back_carry_offset, 2.0); - next.main.orientation = - Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); - }, - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.main.position = Vec3::new(-4.0, -4.5 - skeleton.back_carry_offset, 10.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - Some(ToolKind::Shield) => { - next.main.position = Vec3::new(-0.0, -4.0 - skeleton.back_carry_offset, 3.0); - next.main.orientation = - Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); - }, - _ => {}, - }, - (_, _) => {}, - }; - match hands { - (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { - Some(ToolKind::Dagger) => { - next.second.position = Vec3::new(-5.0, 1.0 - skeleton.back_carry_offset, 2.0); - next.second.orientation = - Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); - }, - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.second.position = Vec3::new(4.0, -5.0 - skeleton.back_carry_offset, 10.0); - next.second.orientation = - Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); - }, - Some(ToolKind::Shield) => { - next.second.position = Vec3::new(0.0, -4.0 - skeleton.back_carry_offset, 3.0); - next.second.orientation = - Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); - }, - _ => {}, - }, - (_, _) => {}, - }; + next.do_tools_on_back(hands, active_tool_kind, second_tool_kind); next.lantern.position = Vec3::new(s_a.lantern.0, s_a.lantern.1, s_a.lantern.2); next.lantern.orientation = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1); diff --git a/voxygen/anim/src/character/swim.rs b/voxygen/anim/src/character/swim.rs index dd5df42c72..1923f0e8fe 100644 --- a/voxygen/anim/src/character/swim.rs +++ b/voxygen/anim/src/character/swim.rs @@ -171,57 +171,7 @@ impl Animation for SwimAnimation { next.glider.position = Vec3::new(0.0, 0.0, 10.0); next.glider.scale = Vec3::one() * 0.0; - let main_tool = if let (None, Some(Hands::Two)) = hands { - second_tool_kind - } else { - active_tool_kind - }; - - match main_tool { - Some(ToolKind::Dagger) => { - next.main.position = Vec3::new(5.0, 1.0, 2.0); - next.main.orientation = - Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(2.0 * PI); - }, - Some(ToolKind::Shield) => { - next.main.position = Vec3::new(-0.0, -5.0, 3.0); - next.main.orientation = - Quaternion::rotation_y(0.25 * PI) * Quaternion::rotation_z(-1.5 * PI); - }, - Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => { - next.main.position = Vec3::new(2.0, -5.0, -1.0); - next.main.orientation = - Quaternion::rotation_y(-0.5) * Quaternion::rotation_z(PI / 2.0); - }, - Some(ToolKind::Bow) => { - next.main.position = Vec3::new(0.0, -5.0, 6.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - _ => { - next.main.position = Vec3::new(-7.0, -5.0, 15.0); - next.main.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - } - - match second_tool_kind { - Some(ToolKind::Dagger) => { - next.second.position = Vec3::new(-5.0, 1.0, 2.0); - next.second.orientation = - Quaternion::rotation_x(-1.35 * PI) * Quaternion::rotation_z(-2.0 * PI); - }, - Some(ToolKind::Shield) => { - next.second.position = Vec3::new(0.0, -4.0, 3.0); - next.second.orientation = - Quaternion::rotation_y(-0.25 * PI) * Quaternion::rotation_z(1.5 * PI); - }, - _ => { - next.second.position = Vec3::new(-7.0, -5.0, 15.0); - next.second.orientation = - Quaternion::rotation_y(2.5) * Quaternion::rotation_z(PI / 2.0); - }, - } + next.do_tools_on_back(hands, active_tool_kind, second_tool_kind); next.lantern.position = Vec3::new(s_a.lantern.0, s_a.lantern.1, s_a.lantern.2); next.lantern.scale = Vec3::one() * 0.65; @@ -238,37 +188,6 @@ impl Animation for SwimAnimation { + avgspeed * avg_vel.z * -0.003, ) * Quaternion::rotation_y(tilt * 2.0) * Quaternion::rotation_z(tilt * 3.0); - match hands { - (Some(Hands::One), _) => match active_tool_kind { - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.main.position = Vec3::new(-4.0, -5.0, 10.0); - next.main.orientation = - Quaternion::rotation_y(2.35) * Quaternion::rotation_z(PI / 2.0); - }, - - _ => {}, - }, - (_, _) => {}, - }; - match hands { - (None | Some(Hands::One), Some(Hands::One)) => match second_tool_kind { - Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => { - next.second.position = Vec3::new(4.0, -6.0, 10.0); - next.second.orientation = - Quaternion::rotation_y(-2.5) * Quaternion::rotation_z(-PI / 2.0); - }, - _ => {}, - }, - (_, _) => {}, - }; - next.second.scale = match hands { - (Some(Hands::One), Some(Hands::One)) => Vec3::one(), - (_, _) => Vec3::zero(), - }; - - if let (None, Some(Hands::Two)) = hands { - next.second = next.main; - } next }