Merge branch 'sam/2h-offhand-anim-fixes' into 'master'

2 Hand Offhand Animation Fixes

See merge request veloren/veloren!2129
This commit is contained in:
Justin Shipsey 2021-04-15 01:21:52 +00:00
commit f7f2eb4b9b
23 changed files with 399 additions and 241 deletions

View File

@ -2,7 +2,7 @@ ItemDef(
name: "Orichalcum Mace",
description: "Forged with orichalcum.",
kind: Tool((
kind: Axe,
kind: Hammer,
hands: One,
stats: Direct((
equip_time_secs: 0.4,

View File

@ -689,14 +689,10 @@ impl AbilityInfo {
} else {
unwrap_tool_data(data, EquipSlot::Mainhand)
};
let (tool, hand) = if from_offhand {
(tool_data.map(|t| t.kind), Some(HandInfo::OffHand))
} else {
(
tool_data.map(|t| t.kind),
tool_data.map(|t| HandInfo::from_main_tool(t)),
)
};
let (tool, hand) = (
tool_data.map(|t| t.kind),
tool_data.map(|t| HandInfo::from_main_tool(t, from_offhand)),
);
Self {
tool,
@ -715,10 +711,16 @@ pub enum HandInfo {
}
impl HandInfo {
pub fn from_main_tool(tool: &Tool) -> Self {
pub fn from_main_tool(tool: &Tool, from_offhand: bool) -> Self {
match tool.hands {
Hands::Two => Self::TwoHanded,
Hands::One => Self::MainHand,
Hands::One => {
if from_offhand {
Self::OffHand
} else {
Self::MainHand
}
},
}
}
}

View File

@ -106,7 +106,9 @@ impl Animation for AlphaAnimation {
}
match hands {
(Some(Hands::Two), _) => match ability_info.and_then(|a| a.tool) {
(Some(Hands::Two), _) | (None, Some(Hands::Two)) => match ability_info
.and_then(|a| a.tool)
{
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
@ -283,6 +285,11 @@ impl Animation for AlphaAnimation {
},
(_, _) => {},
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -2,15 +2,19 @@ use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::{comp::item::ToolKind, states::utils::StageSection};
use common::{
comp::item::{Hands, ToolKind},
states::utils::{AbilityInfo, StageSection},
};
use std::f32::consts::PI;
pub struct BeamAnimation;
impl Animation for BeamAnimation {
#[allow(clippy::type_complexity)]
type Dependency = (
Option<ToolKind>,
Option<ToolKind>,
Option<AbilityInfo>,
(Option<Hands>, Option<Hands>),
f32,
f32,
Option<StageSection>,
@ -24,7 +28,7 @@ impl Animation for BeamAnimation {
#[allow(clippy::single_match)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(active_tool_kind, _second_tool_kind, _global_time, velocity, stage_section): Self::Dependency,
(ability_info, hands, _global_time, velocity, stage_section): Self::Dependency,
anim_time: f32,
rate: &mut f32,
s_a: &SkeletonAttr,
@ -53,7 +57,7 @@ impl Animation for BeamAnimation {
* Quaternion::rotation_y(0.15)
* Quaternion::rotation_z(0.0);
match active_tool_kind {
match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
next.control.position = Vec3::new(
s_a.stc.0 + (move1 * 16.0) * (1.0 - move3),
@ -109,6 +113,10 @@ impl Animation for BeamAnimation {
_ => {},
}
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -52,7 +52,9 @@ impl Animation for BetaAnimation {
next.head.orientation = Quaternion::rotation_z(-0.4 + move1 * -1.0 + move2 * 1.5);
}
match hands {
(Some(Hands::Two), _) => match ability_info.and_then(|a| a.tool) {
(Some(Hands::Two), _) | (None, Some(Hands::Two)) => match ability_info
.and_then(|a| a.tool)
{
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
@ -125,6 +127,10 @@ impl Animation for BetaAnimation {
(_, _) => {},
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -81,7 +81,9 @@ impl Animation for ChargeswingAnimation {
}
match hands {
(Some(Hands::Two), _) => match ability_info.and_then(|a| a.tool) {
(Some(Hands::Two), _) | (None, Some(Hands::Two)) => match ability_info
.and_then(|a| a.tool)
{
Some(ToolKind::Hammer) | Some(ToolKind::HammerSimple) => {
next.hand_l.position =
Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2 + (move2 * -8.0));
@ -127,6 +129,7 @@ impl Animation for ChargeswingAnimation {
},
(_, _) => {},
};
match hands {
(None | Some(Hands::One), Some(Hands::One)) => {
match ability_info.and_then(|a| a.tool) {
@ -165,6 +168,10 @@ impl Animation for ChargeswingAnimation {
(_, _) => {},
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -91,25 +91,27 @@ impl Animation for DashAnimation {
* Quaternion::rotation_y(slow(anim_time) * 0.4);
match hands {
(Some(Hands::Two), _) => match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
(Some(Hands::Two), _) | (None, Some(Hands::Two)) => {
match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
next.control.position = Vec3::new(
s_a.sc.0 + (move1 * -5.0 + move3 * -2.0),
s_a.sc.1 + (move2.min(1.0) * -2.0),
s_a.sc.2 + (move2.min(1.0) * 2.0),
);
next.control.orientation =
Quaternion::rotation_x(s_a.sc.3 + (move1 * -1.0 + move3 * -0.5))
* Quaternion::rotation_y(s_a.sc.4 + (move1 * 1.5 + move3 * -2.5));
},
_ => {},
next.control.position = Vec3::new(
s_a.sc.0 + (move1 * -5.0 + move3 * -2.0),
s_a.sc.1 + (move2.min(1.0) * -2.0),
s_a.sc.2 + (move2.min(1.0) * 2.0),
);
next.control.orientation =
Quaternion::rotation_x(s_a.sc.3 + (move1 * -1.0 + move3 * -0.5))
* Quaternion::rotation_y(s_a.sc.4 + (move1 * 1.5 + move3 * -2.5));
},
_ => {},
}
},
(_, _) => {},
};
@ -169,6 +171,10 @@ impl Animation for DashAnimation {
(_, _) => {},
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -88,7 +88,7 @@ impl Animation for IdleAnimation {
next.glider.scale = Vec3::one() * 0.0;
next.hold.position = Vec3::new(0.4, -0.3, -5.8);
match hands {
(Some(Hands::Two), _) => match active_tool_kind {
(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 =
@ -142,6 +142,10 @@ impl Animation for IdleAnimation {
(_, _) => Vec3::zero(),
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -136,7 +136,13 @@ impl Animation for JumpAnimation {
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
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(-4.0, -5.0, 7.0);
next.main.orientation =
@ -217,6 +223,11 @@ impl Animation for JumpAnimation {
(Some(Hands::One) | None, Some(Hands::One)) => Vec3::one(),
(_, _) => Vec3::zero(),
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -115,44 +115,46 @@ impl Animation for LeapAnimation {
}
match hands {
(Some(Hands::Two), _) => match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Hammer) => {
next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3);
next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3);
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation =
Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(
s_a.hc.0 + move2 * -10.0 + move3 * 10.0,
s_a.hc.1 + move2 * 5.0 + move3 * 7.0,
s_a.hc.2 + move2 * 5.0 + move3 * -10.0,
);
next.control.orientation =
Quaternion::rotation_x(s_a.hc.3 + move2 * 1.57 + move3 * -2.3)
* Quaternion::rotation_y(s_a.hc.4 + move2 * 1.3)
* Quaternion::rotation_z(s_a.hc.5 + move2 * -1.0 + move3 * 0.5);
},
Some(ToolKind::Axe) => {
next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.ahl.3);
next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.ahr.3);
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation =
Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
(Some(Hands::Two), _) | (None, Some(Hands::Two)) => {
match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Hammer) => {
next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3);
next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3);
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation =
Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(
s_a.hc.0 + move2 * -10.0 + move3 * 10.0,
s_a.hc.1 + move2 * 5.0 + move3 * 7.0,
s_a.hc.2 + move2 * 5.0 + move3 * -10.0,
);
next.control.orientation =
Quaternion::rotation_x(s_a.hc.3 + move2 * 1.57 + move3 * -2.3)
* Quaternion::rotation_y(s_a.hc.4 + move2 * 1.3)
* Quaternion::rotation_z(s_a.hc.5 + move2 * -1.0 + move3 * 0.5);
},
Some(ToolKind::Axe) => {
next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.ahl.3);
next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.ahr.3);
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation =
Quaternion::rotation_y(0.0) * Quaternion::rotation_z(0.0);
next.control.position = Vec3::new(
s_a.ac.0 + move2 * 8.0 + move3 * 15.0,
s_a.ac.1 + move3 * -10.0,
s_a.ac.2 + move3 * 4.0,
);
next.control.orientation = Quaternion::rotation_x(s_a.ac.3)
* Quaternion::rotation_y(s_a.ac.4 + move2 * -0.8 + move3 * -4.0)
* Quaternion::rotation_z(s_a.ac.5 + move2 * -0.6 + move3 * -1.6);
},
_ => {},
next.control.position = Vec3::new(
s_a.ac.0 + move2 * 8.0 + move3 * 15.0,
s_a.ac.1 + move3 * -10.0,
s_a.ac.2 + move3 * 4.0,
);
next.control.orientation = Quaternion::rotation_x(s_a.ac.3)
* Quaternion::rotation_y(s_a.ac.4 + move2 * -0.8 + move3 * -4.0)
* Quaternion::rotation_z(s_a.ac.5 + move2 * -0.6 + move3 * -1.6);
},
_ => {},
}
},
(_, _) => {},
};
@ -232,6 +234,11 @@ impl Animation for LeapAnimation {
},
(_, _) => {},
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -2,13 +2,17 @@ use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::{comp::item::ToolKind, states::utils::StageSection};
use common::{
comp::item::{Hands, ToolKind},
states::utils::{AbilityInfo, StageSection},
};
pub struct RepeaterAnimation;
impl Animation for RepeaterAnimation {
#[allow(clippy::type_complexity)]
type Dependency = (
Option<ToolKind>,
Option<ToolKind>,
Option<AbilityInfo>,
(Option<Hands>, Option<Hands>),
Vec3<f32>,
f32,
Option<StageSection>,
@ -22,7 +26,7 @@ impl Animation for RepeaterAnimation {
#[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, stage_section): Self::Dependency,
(ability_info, hands, _velocity, _global_time, stage_section): Self::Dependency,
anim_time: f32,
rate: &mut f32,
s_a: &SkeletonAttr,
@ -42,7 +46,7 @@ impl Animation for RepeaterAnimation {
fn fire(x: f32) -> f32 { (x * 18.0).sin() }
if let Some(ToolKind::Bow) = active_tool_kind {
if let Some(ToolKind::Bow) = ability_info.and_then(|a| a.tool) {
next.hand_l.position = Vec3::new(s_a.bhl.0, s_a.bhl.1, s_a.bhl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.bhl.3);
next.hand_r.position = Vec3::new(s_a.bhr.0, s_a.bhr.1, s_a.bhr.2);
@ -96,6 +100,10 @@ impl Animation for RepeaterAnimation {
* Quaternion::rotation_z(-0.3);
}
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -200,7 +200,13 @@ impl Animation for RunAnimation {
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
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(-4.0, -5.0, 7.0);
next.main.orientation =
@ -281,6 +287,11 @@ impl Animation for RunAnimation {
(Some(Hands::One) | None, Some(Hands::One)) => Vec3::one(),
(_, _) => Vec3::zero(),
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -2,7 +2,10 @@ use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::{comp::item::ToolKind, states::utils::StageSection};
use common::{
comp::item::Hands,
states::utils::{AbilityInfo, StageSection},
};
pub struct Input {
pub attack: bool,
@ -10,9 +13,10 @@ pub struct Input {
pub struct ShockwaveAnimation;
impl Animation for ShockwaveAnimation {
#[allow(clippy::type_complexity)]
type Dependency = (
Option<ToolKind>,
Option<ToolKind>,
Option<AbilityInfo>,
(Option<Hands>, Option<Hands>),
f32,
f32,
Option<StageSection>,
@ -26,7 +30,7 @@ impl Animation for ShockwaveAnimation {
#[allow(clippy::single_match)] // TODO: Pending review in #587
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_active_tool_kind, _second_tool_kind, _global_time, velocity, stage_section): Self::Dependency,
(_ability_info, hands, _global_time, velocity, stage_section): Self::Dependency,
anim_time: f32,
rate: &mut f32,
s_a: &SkeletonAttr,
@ -104,6 +108,11 @@ impl Animation for ShockwaveAnimation {
next.foot_r.orientation = Quaternion::rotation_y(move1 * -0.3 + move2 * 0.3)
* Quaternion::rotation_z(move1 * 0.4 + move2 * -0.4);
}
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -2,14 +2,18 @@ use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::{comp::item::ToolKind, states::utils::StageSection, util::Dir};
use common::{
comp::item::{Hands, ToolKind},
states::utils::{AbilityInfo, StageSection},
util::Dir,
};
use std::f32::consts::PI;
pub struct ShootAnimation;
type ShootAnimationDependency = (
Option<ToolKind>,
Option<ToolKind>,
Option<AbilityInfo>,
(Option<Hands>, Option<Hands>),
f32,
Vec3<f32>,
Vec3<f32>,
@ -29,8 +33,8 @@ impl Animation for ShootAnimation {
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(
active_tool_kind,
_second_tool_kind,
ability_info,
hands,
velocity,
orientation,
last_ori,
@ -61,7 +65,8 @@ impl Animation for ShootAnimation {
} else {
0.0
} * 1.3;
match active_tool_kind {
match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
let (move1, move2, move3) = match stage_section {
Some(StageSection::Buildup) => (anim_time, 0.0, 0.0),
@ -174,6 +179,10 @@ impl Animation for ShootAnimation {
next.lantern.orientation = Quaternion::rotation_x(0.0) * Quaternion::rotation_y(0.0);
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -123,52 +123,54 @@ impl Animation for SpinAnimation {
_ => {},
}
match hands {
(Some(Hands::Two), _) => match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0);
(Some(Hands::Two), _) | (None, Some(Hands::Two)) => {
match ability_info.and_then(|a| a.tool) {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0);
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
next.control.position = Vec3::new(
s_a.sc.0 + movement1base * 2.0 + movement2base * -7.0,
s_a.sc.1 + 8.0 + movement1base * 0.6 + movement2base * -15.0,
s_a.sc.2 + 1.0 + movement1base * 0.6 + movement2base * 1.5,
);
next.control.orientation =
Quaternion::rotation_x(-0.5 + s_a.sc.3 + movement1base * -1.2)
* Quaternion::rotation_y(s_a.sc.4 - 0.6 + movement2base * -0.2)
* Quaternion::rotation_z(s_a.sc.5 - 1.57 + movement1base * PI);
},
Some(ToolKind::Axe) => {
next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.ahl.3) * Quaternion::rotation_y(s_a.ahl.4);
next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.ahr.3) * Quaternion::rotation_z(s_a.ahr.5);
let (move1, move2, _move3) = match stage_section {
Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0),
Some(StageSection::Swing) => (1.0, anim_time, 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time.powi(4)),
_ => (0.0, 0.0, 0.0),
};
next.control.position = Vec3::new(
s_a.ac.0 + move1 * -1.0 + move2 * -2.0,
s_a.ac.1 + move1 * -3.0 + move2 * 3.0,
s_a.ac.2 + move1 * 6.0 + move2 * -15.0,
);
next.control.orientation =
Quaternion::rotation_x(s_a.ac.3 + move1 * 0.0 + move2 * -3.0)
* Quaternion::rotation_y(s_a.ac.4 + move1 * -0.0 + move2 * -0.4)
* Quaternion::rotation_z(s_a.ac.5 + move1 * -2.0 + move2 * -1.0)
},
_ => {},
next.control.position = Vec3::new(
s_a.sc.0 + movement1base * 2.0 + movement2base * -7.0,
s_a.sc.1 + 8.0 + movement1base * 0.6 + movement2base * -15.0,
s_a.sc.2 + 1.0 + movement1base * 0.6 + movement2base * 1.5,
);
next.control.orientation =
Quaternion::rotation_x(-0.5 + s_a.sc.3 + movement1base * -1.2)
* Quaternion::rotation_y(s_a.sc.4 - 0.6 + movement2base * -0.2)
* Quaternion::rotation_z(s_a.sc.5 - 1.57 + movement1base * PI);
},
Some(ToolKind::Axe) => {
next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.ahl.3) * Quaternion::rotation_y(s_a.ahl.4);
next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.ahr.3) * Quaternion::rotation_z(s_a.ahr.5);
let (move1, move2, _move3) = match stage_section {
Some(StageSection::Buildup) => (anim_time.powf(0.25), 0.0, 0.0),
Some(StageSection::Swing) => (1.0, anim_time, 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time.powi(4)),
_ => (0.0, 0.0, 0.0),
};
next.control.position = Vec3::new(
s_a.ac.0 + move1 * -1.0 + move2 * -2.0,
s_a.ac.1 + move1 * -3.0 + move2 * 3.0,
s_a.ac.2 + move1 * 6.0 + move2 * -15.0,
);
next.control.orientation =
Quaternion::rotation_x(s_a.ac.3 + move1 * 0.0 + move2 * -3.0)
* Quaternion::rotation_y(s_a.ac.4 + move1 * -0.0 + move2 * -0.4)
* Quaternion::rotation_z(s_a.ac.5 + move1 * -2.0 + move2 * -1.0)
},
_ => {},
}
},
(_, _) => {},
};
@ -245,6 +247,11 @@ impl Animation for SpinAnimation {
},
(_, _) => {},
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -102,7 +102,9 @@ impl Animation for SpinMeleeAnimation {
_ => {},
}
match hands {
(Some(Hands::Two), _) => match ability_info.and_then(|a| a.tool) {
(Some(Hands::Two), _) | (None, Some(Hands::Two)) => match ability_info
.and_then(|a| a.tool)
{
Some(ToolKind::Sword) => {
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0);
@ -202,6 +204,11 @@ impl Animation for SpinMeleeAnimation {
},
(_, _) => {},
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -32,7 +32,7 @@ impl Animation for StaggeredAnimation {
skeleton: &Self::Skeleton,
(
active_tool_kind,
_second_tool_kind,
second_tool_kind,
hands,
_velocity,
global_time,
@ -73,92 +73,94 @@ impl Animation for StaggeredAnimation {
if wield_status {
next.main.position = Vec3::new(0.0, 0.0, 0.0);
next.main.orientation = Quaternion::rotation_x(0.0);
match hands {
(Some(Hands::Two), _) => match active_tool_kind {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.shl.3) * Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.shr.3) * Quaternion::rotation_y(s_a.shr.4);
match (hands, active_tool_kind, second_tool_kind) {
((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => {
match tool {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.shl.3)
* Quaternion::rotation_y(s_a.shl.4);
next.hand_r.position = Vec3::new(s_a.shr.0, s_a.shr.1, s_a.shr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.shr.3)
* Quaternion::rotation_y(s_a.shr.4);
next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2);
next.control.orientation = Quaternion::rotation_x(s_a.sc.3);
},
Some(ToolKind::Axe) => {
next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.ahl.3) * Quaternion::rotation_y(s_a.ahl.4);
next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.ahr.3) * Quaternion::rotation_z(s_a.ahr.5);
next.control.position = Vec3::new(s_a.sc.0, s_a.sc.1, s_a.sc.2);
next.control.orientation = Quaternion::rotation_x(s_a.sc.3);
},
Some(ToolKind::Axe) => {
next.hand_l.position = Vec3::new(s_a.ahl.0, s_a.ahl.1, s_a.ahl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.ahl.3)
* Quaternion::rotation_y(s_a.ahl.4);
next.hand_r.position = Vec3::new(s_a.ahr.0, s_a.ahr.1, s_a.ahr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.ahr.3)
* Quaternion::rotation_z(s_a.ahr.5);
next.control.position = Vec3::new(s_a.ac.0, s_a.ac.1, s_a.ac.2);
next.control.orientation = Quaternion::rotation_x(s_a.ac.3)
* Quaternion::rotation_y(s_a.ac.4)
* Quaternion::rotation_z(s_a.ac.5);
},
Some(ToolKind::Hammer | ToolKind::Pick) => {
next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2);
next.hand_l.orientation =
Quaternion::rotation_x(s_a.hhl.3) * Quaternion::rotation_y(s_a.hhl.4);
next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.hhr.3) * Quaternion::rotation_y(s_a.hhr.4);
next.control.position = Vec3::new(s_a.ac.0, s_a.ac.1, s_a.ac.2);
next.control.orientation = Quaternion::rotation_x(s_a.ac.3)
* Quaternion::rotation_y(s_a.ac.4)
* Quaternion::rotation_z(s_a.ac.5);
},
Some(ToolKind::Hammer | ToolKind::Pick) => {
next.hand_l.position = Vec3::new(s_a.hhl.0, s_a.hhl.1, s_a.hhl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.hhl.3)
* Quaternion::rotation_y(s_a.hhl.4);
next.hand_r.position = Vec3::new(s_a.hhr.0, s_a.hhr.1, s_a.hhr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.hhr.3)
* Quaternion::rotation_y(s_a.hhr.4);
next.control.position = Vec3::new(s_a.hc.0, s_a.hc.1, s_a.hc.2);
next.control.orientation = Quaternion::rotation_x(s_a.hc.3)
* Quaternion::rotation_y(s_a.hc.4)
* Quaternion::rotation_z(s_a.hc.5);
},
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
next.hand_r.position = Vec3::new(s_a.sthr.0, s_a.sthr.1, s_a.sthr.2);
next.hand_r.orientation =
Quaternion::rotation_x(s_a.sthr.3) * Quaternion::rotation_y(s_a.sthr.4);
next.control.position = Vec3::new(s_a.hc.0, s_a.hc.1, s_a.hc.2);
next.control.orientation = Quaternion::rotation_x(s_a.hc.3)
* Quaternion::rotation_y(s_a.hc.4)
* Quaternion::rotation_z(s_a.hc.5);
},
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {
next.hand_r.position = Vec3::new(s_a.sthr.0, s_a.sthr.1, s_a.sthr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.sthr.3)
* Quaternion::rotation_y(s_a.sthr.4);
next.control.position = Vec3::new(s_a.stc.0, s_a.stc.1, s_a.stc.2);
next.control.position = Vec3::new(s_a.stc.0, s_a.stc.1, s_a.stc.2);
next.hand_l.position = Vec3::new(s_a.sthl.0, s_a.sthl.1, s_a.sthl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.sthl.3);
next.hand_l.position = Vec3::new(s_a.sthl.0, s_a.sthl.1, s_a.sthl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.sthl.3);
next.control.orientation = Quaternion::rotation_x(s_a.stc.3)
* Quaternion::rotation_y(s_a.stc.4)
* Quaternion::rotation_z(s_a.stc.5);
},
Some(ToolKind::Bow) => {
next.hand_l.position = Vec3::new(s_a.bhl.0, s_a.bhl.1, s_a.bhl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.bhl.3);
next.hand_r.position = Vec3::new(s_a.bhr.0, s_a.bhr.1, s_a.bhr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.bhr.3);
next.control.orientation = Quaternion::rotation_x(s_a.stc.3)
* Quaternion::rotation_y(s_a.stc.4)
* Quaternion::rotation_z(s_a.stc.5);
},
Some(ToolKind::Bow) => {
next.hand_l.position = Vec3::new(s_a.bhl.0, s_a.bhl.1, s_a.bhl.2);
next.hand_l.orientation = Quaternion::rotation_x(s_a.bhl.3);
next.hand_r.position = Vec3::new(s_a.bhr.0, s_a.bhr.1, s_a.bhr.2);
next.hand_r.orientation = Quaternion::rotation_x(s_a.bhr.3);
next.hold.position = Vec3::new(0.0, -1.0, -5.2);
next.hold.orientation = Quaternion::rotation_x(-1.57);
next.hold.scale = Vec3::one() * 1.0;
next.hold.position = Vec3::new(0.0, -1.0, -5.2);
next.hold.orientation = Quaternion::rotation_x(-1.57);
next.hold.scale = Vec3::one() * 1.0;
next.control.position = Vec3::new(s_a.bc.0, s_a.bc.1, s_a.bc.2);
next.control.orientation =
Quaternion::rotation_y(s_a.bc.4) * Quaternion::rotation_z(s_a.bc.5);
},
Some(ToolKind::Debug) => {
next.hand_l.position = Vec3::new(-7.0, 4.0, 3.0);
next.hand_l.orientation = Quaternion::rotation_x(1.27);
next.main.position = Vec3::new(-5.0, 5.0, 23.0);
next.main.orientation = Quaternion::rotation_x(3.14);
},
Some(ToolKind::Farming) => {
next.hand_l.position = Vec3::new(9.0, 1.0, 1.0);
next.hand_l.orientation = Quaternion::rotation_x(1.57);
next.hand_r.position = Vec3::new(9.0, 1.0, 11.0);
next.hand_r.orientation = Quaternion::rotation_x(1.57);
next.main.position = Vec3::new(7.5, 7.5, 13.2);
next.main.orientation = Quaternion::rotation_y(3.14);
next.control.position = Vec3::new(s_a.bc.0, s_a.bc.1, s_a.bc.2);
next.control.orientation =
Quaternion::rotation_y(s_a.bc.4) * Quaternion::rotation_z(s_a.bc.5);
},
Some(ToolKind::Debug) => {
next.hand_l.position = Vec3::new(-7.0, 4.0, 3.0);
next.hand_l.orientation = Quaternion::rotation_x(1.27);
next.main.position = Vec3::new(-5.0, 5.0, 23.0);
next.main.orientation = Quaternion::rotation_x(3.14);
},
Some(ToolKind::Farming) => {
next.hand_l.position = Vec3::new(9.0, 1.0, 1.0);
next.hand_l.orientation = Quaternion::rotation_x(1.57);
next.hand_r.position = Vec3::new(9.0, 1.0, 11.0);
next.hand_r.orientation = Quaternion::rotation_x(1.57);
next.main.position = Vec3::new(7.5, 7.5, 13.2);
next.main.orientation = Quaternion::rotation_y(3.14);
next.control.position = Vec3::new(-11.0, 1.8, 4.0);
},
_ => {},
next.control.position = Vec3::new(-11.0, 1.8, 4.0);
},
_ => {},
}
},
(_, _) => {},
((_, _), _, _) => {},
};
match hands {
(Some(Hands::One), _) => {
@ -249,6 +251,10 @@ impl Animation for StaggeredAnimation {
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * s_a.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0);
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -94,8 +94,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 {
(Some(Hands::Two), _) => match active_tool_kind {
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, 6.0);
next.main.orientation =
@ -112,7 +112,7 @@ impl Animation for StandAnimation {
Quaternion::rotation_y(2.5) * Quaternion::rotation_z(1.57);
},
},
(_, _) => {},
((_, _), _, _) => {},
};
match hands {
@ -148,6 +148,11 @@ impl Animation for StandAnimation {
(Some(Hands::One) | None, Some(Hands::One)) => Vec3::one(),
(_, _) => Vec3::zero(),
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -73,7 +73,7 @@ impl Animation for StunnedAnimation {
next.main.orientation = Quaternion::rotation_x(0.0);
match hands {
(Some(Hands::Two), _) => match active_tool_kind {
(Some(Hands::Two), _) | (None, Some(Hands::Two)) => match active_tool_kind {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
@ -213,6 +213,10 @@ impl Animation for StunnedAnimation {
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * s_a.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0);
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -171,7 +171,13 @@ impl Animation for SwimAnimation {
next.glider.position = Vec3::new(0.0, 0.0, 10.0);
next.glider.scale = Vec3::one() * 0.0;
match active_tool_kind {
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(-4.0, -5.0, 7.0);
next.main.orientation =
@ -258,6 +264,10 @@ impl Animation for SwimAnimation {
(_, _) => Vec3::zero(),
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -2,13 +2,20 @@ use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::ToolKind;
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
pub struct SwimWieldAnimation;
impl Animation for SwimWieldAnimation {
type Dependency = (Option<ToolKind>, Option<ToolKind>, f32, f32);
#[allow(clippy::type_complexity)]
type Dependency = (
Option<ToolKind>,
Option<ToolKind>,
(Option<Hands>, Option<Hands>),
f32,
f32,
);
type Skeleton = CharacterSkeleton;
#[cfg(feature = "use-dyn-lib")]
@ -18,7 +25,7 @@ impl Animation for SwimWieldAnimation {
#[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,
(active_tool_kind, second_tool_kind, hands, velocity, global_time): Self::Dependency,
anim_time: f32,
rate: &mut f32,
s_a: &SkeletonAttr,
@ -107,7 +114,14 @@ impl Animation for SwimWieldAnimation {
next.shorts.position = Vec3::new(0.0, s_a.shorts.0, s_a.shorts.1);
next.shorts.orientation = Quaternion::rotation_z(0.3);
}
match active_tool_kind {
let main_tool = if let (None, Some(Hands::Two)) = hands {
second_tool_kind
} else {
active_tool_kind
};
match main_tool {
Some(ToolKind::Sword) => {
next.hand_l.position = Vec3::new(-0.75, -1.0, -2.5);
next.hand_l.orientation =
@ -317,6 +331,10 @@ impl Animation for SwimWieldAnimation {
_ => {},
}
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -33,7 +33,7 @@ impl Animation for WieldAnimation {
skeleton: &Self::Skeleton,
(
active_tool_kind,
_second_tool_kind,
second_tool_kind,
hands,
orientation,
last_ori,
@ -151,8 +151,8 @@ impl Animation for WieldAnimation {
next.back.orientation = Quaternion::rotation_x(-0.2);
next.shorts.position = Vec3::new(0.0, s_a.shorts.0, s_a.shorts.1);
}
match hands {
(Some(Hands::Two), _) => match active_tool_kind {
match (hands, active_tool_kind, second_tool_kind) {
((Some(Hands::Two), _), tool, _) | ((None, Some(Hands::Two)), _, tool) => match tool {
Some(ToolKind::Sword) | Some(ToolKind::SwordSimple) => {
next.hand_l.position = Vec3::new(s_a.shl.0, s_a.shl.1, s_a.shl.2);
next.hand_l.orientation =
@ -298,7 +298,7 @@ impl Animation for WieldAnimation {
},
_ => {},
},
(_, _) => {},
((_, _), _, _) => {},
};
match hands {
(Some(Hands::One), _) => {
@ -332,6 +332,11 @@ impl Animation for WieldAnimation {
},
(_, _) => {},
};
if let (None, Some(Hands::Two)) = hands {
next.second = next.main;
}
next
}
}

View File

@ -923,8 +923,8 @@ impl FigureMgr {
anim::character::ShootAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
Some(s.static_data.ability_info),
hands,
rel_vel.magnitude(),
// TODO: Update to use the quaternion.
ori * anim::vek::Vec3::<f32>::unit_y(),
@ -955,8 +955,8 @@ impl FigureMgr {
anim::character::ShootAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
Some(s.static_data.ability_info),
hands,
rel_vel.magnitude(),
// TODO: Update to use the quaternion.
ori * anim::vek::Vec3::<f32>::unit_y(),
@ -1022,8 +1022,8 @@ impl FigureMgr {
anim::character::RepeaterAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
Some(s.static_data.ability_info),
hands,
rel_vel,
time,
Some(s.stage_section),
@ -1105,8 +1105,8 @@ impl FigureMgr {
anim::character::ShockwaveAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
Some(s.static_data.ability_info),
hands,
time,
rel_vel.magnitude(),
Some(s.stage_section),
@ -1133,8 +1133,8 @@ impl FigureMgr {
anim::character::ShockwaveAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
Some(s.static_data.ability_info),
hands,
time,
rel_vel.magnitude(),
Some(s.stage_section),
@ -1273,8 +1273,8 @@ impl FigureMgr {
anim::character::BeamAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
Some(s.static_data.ability_info),
hands,
time,
rel_vel.magnitude(),
Some(s.stage_section),
@ -1299,8 +1299,8 @@ impl FigureMgr {
anim::character::BeamAnimation::update_skeleton(
&target_base,
(
active_tool_kind,
second_tool_kind,
Some(s.static_data.ability_info),
hands,
time,
rel_vel.magnitude(),
Some(s.stage_section),
@ -1417,6 +1417,7 @@ impl FigureMgr {
(
active_tool_kind,
second_tool_kind,
hands,
rel_vel.magnitude(),
time,
),