Merge branch 'slipped/animtweaks' into 'master'

wallrun

See merge request veloren/veloren!3181
This commit is contained in:
Justin Shipsey 2022-02-10 01:13:24 +00:00
commit 88999068b2
15 changed files with 390 additions and 37 deletions

View File

@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Shader dithering to remove banding from scenes with large colour gradients
- Convert giant trees to site2
- Add new upgraded travelers
- Wallrunning
### Changed

View File

@ -312,11 +312,11 @@
),
"Iron": (
left: (
vox_spec: ("armor.mail.iron.hand", (-2.5, -1.0, -3.0)),
vox_spec: ("armor.mail.iron.hand", (-1.5, -1.5, -3.0)),
color: None
),
right: (
vox_spec: ("armor.mail.iron.hand", (-1.5, -1.0, -3.0)),
vox_spec: ("armor.mail.iron.hand", (-1.5, -1.5, -3.0)),
color: None
)
),

View File

@ -165,7 +165,7 @@
]
),
(Elf, Female): (
offset: (-8.0, -4.0, -2.0),
offset: (-8.0, -5.0, -2.0),
head: ("figure.head.elf.female", (0, 2, 0)),
eyes: [
Some(("figure.eyes.general.female_styled-0", (3, 9, 2))),

View File

@ -121,6 +121,8 @@ pub enum CharacterState {
/// Handles logic for interacting with a sprite, e.g. using a chest or
/// picking a plant
SpriteInteract(sprite_interact::Data),
/// Runs on the wall
Wallrun(wallrun::Data),
}
impl CharacterState {
@ -294,6 +296,7 @@ impl CharacterState {
CharacterState::Idle(data) => data.behavior(j, output_events),
CharacterState::Talk => states::talk::Data.behavior(j, output_events),
CharacterState::Climb(data) => data.behavior(j, output_events),
CharacterState::Wallrun(data) => data.behavior(j, output_events),
CharacterState::Glide(data) => data.behavior(j, output_events),
CharacterState::GlideWield(data) => data.behavior(j, output_events),
CharacterState::Stunned(data) => data.behavior(j, output_events),
@ -339,6 +342,7 @@ impl CharacterState {
CharacterState::Idle(data) => data.handle_event(j, output_events, action),
CharacterState::Talk => states::talk::Data.handle_event(j, output_events, action),
CharacterState::Climb(data) => data.handle_event(j, output_events, action),
CharacterState::Wallrun(data) => data.handle_event(j, output_events, action),
CharacterState::Glide(data) => data.handle_event(j, output_events, action),
CharacterState::GlideWield(data) => data.handle_event(j, output_events, action),
CharacterState::Stunned(data) => data.handle_event(j, output_events, action),

View File

@ -19,6 +19,7 @@ impl CharacterBehavior for Data {
handle_jump(data, output_events, &mut update, 1.0);
handle_wield(data, &mut update);
handle_climb(data, &mut update);
handle_wallrun(data, &mut update);
handle_dodge_input(data, &mut update);
// Try to Fall/Stand up/Move

View File

@ -30,4 +30,5 @@ pub mod stunned;
pub mod talk;
pub mod use_item;
pub mod utils;
pub mod wallrun;
pub mod wielding;

View File

@ -657,6 +657,22 @@ pub fn handle_climb(data: &JoinData<'_>, update: &mut StateUpdate) -> bool {
}
}
pub fn handle_wallrun(data: &JoinData<'_>, update: &mut StateUpdate) -> bool {
if data.physics.on_wall.is_some()
&& data.physics.on_ground.is_none()
&& !data
.physics
.in_liquid()
.map(|depth| depth > 1.0)
.unwrap_or(false)
&& data.body.can_climb()
{
update.character = CharacterState::Wallrun(wallrun::Data);
true
} else {
false
}
}
/// Checks that player can Swap Weapons and updates `Loadout` if so
pub fn attempt_swap_equipped_weapons(data: &JoinData<'_>, update: &mut StateUpdate) {
if data

View File

@ -0,0 +1,41 @@
use super::utils::*;
use crate::{
comp::{character_state::OutputEvents, CharacterState, StateUpdate},
states::{
behavior::{CharacterBehavior, JoinData},
idle,
},
};
use serde::{Deserialize, Serialize};
use vek::Vec2;
const WALLRUN_ANTIGRAV: f32 = crate::consts::GRAVITY * 0.5;
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
pub struct Data;
impl CharacterBehavior for Data {
fn behavior(&self, data: &JoinData, output_events: &mut OutputEvents) -> StateUpdate {
let mut update = StateUpdate::from(data);
handle_wield(data, &mut update);
handle_jump(data, output_events, &mut update, 1.0);
handle_climb(data, &mut update);
{
let lift = WALLRUN_ANTIGRAV;
update.vel.0.z += data.dt.0
* lift
* (Vec2::<f32>::from(update.vel.0).magnitude() * 0.075)
.min(1.0)
.max(0.2);
}
// fall off wall or hit ground
if data.physics.on_wall.is_none() || data.physics.on_ground.is_some() {
update.character = CharacterState::Idle(idle::Data { is_sneaking: false });
}
update
}
}

View File

@ -197,6 +197,7 @@ impl<'a> System<'a> for Sys {
},
// Abilities that temporarily stall energy gain, but preserve regen_rate.
CharacterState::Roll { .. }
| CharacterState::Wallrun { .. }
| CharacterState::Climb { .. }
| CharacterState::Stunned { .. }
| CharacterState::BasicBlock { .. }

View File

@ -32,6 +32,7 @@ pub mod stunned;
pub mod swim;
pub mod swimwield;
pub mod talk;
pub mod wallrun;
pub mod wield;
// Reexports
@ -46,7 +47,7 @@ pub use self::{
sneakequip::SneakEquipAnimation, sneakwield::SneakWieldAnimation, spin::SpinAnimation,
spinmelee::SpinMeleeAnimation, staggered::StaggeredAnimation, stand::StandAnimation,
stunned::StunnedAnimation, swim::SwimAnimation, swimwield::SwimWieldAnimation,
talk::TalkAnimation, wield::WieldAnimation,
talk::TalkAnimation, wallrun::WallrunAnimation, wield::WieldAnimation,
};
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
use common::comp;

View File

@ -64,9 +64,9 @@ impl Animation for RollAnimation {
};
let (movement1base, movement2, movement3) = match stage_section {
Some(StageSection::Buildup) => (anim_time.powf(2.0), 0.0, 0.0),
Some(StageSection::Movement) => (1.0, anim_time.powf(0.75), 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time.powf(0.75)),
Some(StageSection::Buildup) => (anim_time, 0.0, 0.0),
Some(StageSection::Movement) => (1.0, anim_time, 0.0),
Some(StageSection::Recover) => (1.0, 1.0, anim_time),
_ => (0.0, 0.0, 0.0),
};
let pullback = 1.0 - movement3;

View File

@ -17,6 +17,7 @@ type RunAnimationDependency = (
f32,
Vec3<f32>,
f32,
Option<Vec3<f32>>,
);
impl Animation for RunAnimation {
@ -40,6 +41,7 @@ impl Animation for RunAnimation {
global_time,
avg_vel,
acc_vel,
wall,
): Self::Dependency<'a>,
anim_time: f32,
rate: &mut f32,
@ -52,7 +54,7 @@ impl Animation for RunAnimation {
let impact = (avg_vel.z).max(-8.0);
let speednorm = (speed / 9.4).powf(0.6);
let lab: f32 = 1.0;
let lab: f32 = 0.8;
let footrotl = ((1.0 / (0.5 + (0.5) * ((acc_vel * 1.6 * lab + PI * 1.4).sin()).powi(2)))
.sqrt())
@ -68,8 +70,6 @@ impl Animation for RunAnimation {
let shorte = ((1.0 / (0.8 + 0.2 * ((acc_vel * lab * 1.6).sin()).powi(2))).sqrt())
* ((acc_vel * lab * 1.6).sin());
let shortalter = (acc_vel * lab * 1.6 + PI / -2.0).sin();
let foothoril = (acc_vel * 1.6 * lab + PI * 1.45).sin();
let foothorir = (acc_vel * 1.6 * lab + PI * (0.45)).sin();
let footstrafel = (acc_vel * 1.6 * lab + PI * 1.45).sin();
@ -80,7 +80,8 @@ impl Animation for RunAnimation {
let footvertsl = (acc_vel * 1.6 * lab).sin();
let footvertsr = (acc_vel * 1.6 * lab + PI * 0.5).sin();
let shortalt = (acc_vel * lab * 1.6 + PI / 2.0).sin();
let shortalt = (acc_vel * lab * 3.2 + PI / 1.0).sin();
let shortalt2 = (acc_vel * lab * 3.2).sin();
let short = ((5.0 / (1.5 + 3.5 * ((acc_vel * lab * 1.6).sin()).powi(2))).sqrt())
* ((acc_vel * lab * 1.6).sin());
@ -108,21 +109,21 @@ impl Animation for RunAnimation {
(global_time + anim_time / 18.0).floor().mul(1337.0).sin() * 0.1,
);
next.head.position = Vec3::new(0.0, 1.0 * speednorm + s_a.head.0, s_a.head.1 + short * 0.1);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + short * 0.1);
next.head.orientation =
Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 - short * 0.02)
* Quaternion::rotation_x(head_look.y + 0.45 * speednorm);
Quaternion::rotation_z(tilt * -2.5 + head_look.x * 0.2 + short * -0.06)
* Quaternion::rotation_x(head_look.y + 0.45 * speednorm + shortalt2 * -0.05);
next.head.scale = Vec3::one() * s_a.head_scale;
next.chest.position = Vec3::new(
0.0,
s_a.chest.0,
s_a.chest.1 + 1.0 * speednorm + shortalt * -0.8,
s_a.chest.1 + 1.0 * speednorm + shortalt * -0.2,
);
next.chest.orientation = Quaternion::rotation_z(short * 0.06 + tilt * -0.6)
next.chest.orientation = Quaternion::rotation_z(short * 0.16 + tilt * -0.6)
* Quaternion::rotation_y(tilt * 1.6)
* Quaternion::rotation_x(
impact * 0.06 + shortalter * 0.035 + speednorm * -0.5 + (tilt.abs()),
impact * 0.06 + shortalt2 * 0.03 + speednorm * -0.5 + (tilt.abs()),
);
next.belt.position = Vec3::new(0.0, 0.25 + s_a.belt.0, 0.25 + s_a.belt.1);
@ -161,10 +162,10 @@ impl Animation for RunAnimation {
next.foot_l.position = Vec3::new(
-s_a.foot.0 + footstrafel * sideabs * 3.0 + tilt * -2.0,
s_a.foot.1
+ (1.0 - sideabs) * (-0.5 * speednorm + foothoril * -7.5 * speednorm)
+ (1.0 - sideabs) * (-0.5 * speednorm + foothoril * -10.5 * speednorm)
+ (direction * 5.0).max(0.0),
s_a.foot.2
+ (1.0 - sideabs) * (2.0 * speednorm + ((footvertl * -2.1 * speednorm).max(-1.0)))
+ (1.0 - sideabs) * (2.0 * speednorm + ((footvertl * -2.5 * speednorm).max(-1.0)))
+ side * ((footvertsl * 1.5).max(-1.0)),
);
next.foot_l.orientation = Quaternion::rotation_x(
@ -176,10 +177,10 @@ impl Animation for RunAnimation {
next.foot_r.position = Vec3::new(
s_a.foot.0 + footstrafer * sideabs * 3.0 + tilt * -2.0,
s_a.foot.1
+ (1.0 - sideabs) * (-0.5 * speednorm + foothorir * -7.5 * speednorm)
+ (1.0 - sideabs) * (-0.5 * speednorm + foothorir * -10.5 * speednorm)
+ (direction * 5.0).max(0.0),
s_a.foot.2
+ (1.0 - sideabs) * (2.0 * speednorm + ((footvertr * -2.1 * speednorm).max(-1.0)))
+ (1.0 - sideabs) * (2.0 * speednorm + ((footvertr * -2.5 * speednorm).max(-1.0)))
+ side * ((footvertsr * -1.5).max(-1.0)),
);
next.foot_r.orientation = Quaternion::rotation_x(
@ -309,6 +310,95 @@ impl Animation for RunAnimation {
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);
let left_sub = (orientation.x).max(0.0);
next.hand_l.position = Vec3::new(
-s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * left_sub,
);
next.hand_r.position = Vec3::new(
s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * right_sub,
);
next.hand_l.orientation =
Quaternion::rotation_x(push * 2.0 + footrotr * -0.2 * right_sub)
* Quaternion::rotation_y(1.0 * left_sub)
* Quaternion::rotation_z(2.5 * left_sub + 1.0 * right_sub);
next.hand_r.orientation =
Quaternion::rotation_x(push * 2.0 + footrotl * -0.2 * left_sub)
* Quaternion::rotation_y(-1.0 * right_sub)
* Quaternion::rotation_z(-2.5 * right_sub - 1.0 * left_sub);
} else if wall.map_or(false, |e| e.y < -0.5) {
let push = (1.0 - orientation.x.abs()).powi(2);
let right_sub = (orientation.x).max(0.0);
let left_sub = -(orientation.x).min(0.0);
next.hand_l.position = Vec3::new(
-s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * left_sub,
);
next.hand_r.position = Vec3::new(
s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * right_sub,
);
next.hand_l.orientation =
Quaternion::rotation_x(push * 2.0 + footrotr * -0.2 * right_sub)
* Quaternion::rotation_y(1.0 * left_sub)
* Quaternion::rotation_z(2.5 * left_sub + 1.0 * right_sub);
next.hand_r.orientation =
Quaternion::rotation_x(push * 2.0 + footrotl * -0.2 * left_sub)
* Quaternion::rotation_y(-1.0 * right_sub)
* Quaternion::rotation_z(-2.5 * right_sub - 1.0 * left_sub);
} else if wall.map_or(false, |e| e.x < -0.5) {
let push = (1.0 - orientation.y.abs()).powi(2);
let right_sub = -(orientation.y).min(0.0);
let left_sub = (orientation.y).max(0.0);
next.hand_l.position = Vec3::new(
-s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * left_sub,
);
next.hand_r.position = Vec3::new(
s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * right_sub,
);
next.hand_l.orientation =
Quaternion::rotation_x(push * 2.0 + footrotr * -0.2 * right_sub)
* Quaternion::rotation_y(1.0 * left_sub)
* Quaternion::rotation_z(2.5 * left_sub + 1.0 * right_sub);
next.hand_r.orientation =
Quaternion::rotation_x(push * 2.0 + footrotl * -0.2 * left_sub)
* Quaternion::rotation_y(-1.0 * right_sub)
* Quaternion::rotation_z(-2.5 * right_sub - 1.0 * left_sub);
} else if wall.map_or(false, |e| e.x > 0.5) {
let push = (1.0 - orientation.y.abs()).powi(2);
let right_sub = (orientation.y).max(0.0);
let left_sub = -(orientation.y).min(0.0);
next.hand_l.position = Vec3::new(
-s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * left_sub,
);
next.hand_r.position = Vec3::new(
s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * right_sub,
);
next.hand_l.orientation =
Quaternion::rotation_x(push * 2.0 + footrotr * -0.2 * right_sub)
* Quaternion::rotation_y(1.0 * left_sub)
* Quaternion::rotation_z(2.5 * left_sub + 1.0 * right_sub);
next.hand_r.orientation =
Quaternion::rotation_x(push * 2.0 + footrotl * -0.2 * left_sub)
* Quaternion::rotation_y(-1.0 * right_sub)
* Quaternion::rotation_z(-2.5 * right_sub - 1.0 * left_sub);
};
next
}

View File

@ -0,0 +1,190 @@
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use core::f32::consts::PI;
pub struct WallrunAnimation;
type WallrunAnimationDependency = (Vec3<f32>, f32, Option<Vec3<f32>>);
impl Animation for WallrunAnimation {
type Dependency<'a> = WallrunAnimationDependency;
type Skeleton = CharacterSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"character_wallrun\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_wallrun")]
fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton,
(orientation, acc_vel, wall): Self::Dependency<'a>,
_anim_time: f32,
rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
*rate = 1.0;
let lab: f32 = 0.8;
let footrotl = ((1.0 / (0.5 + (0.5) * ((acc_vel * 1.6 * lab + PI * 1.4).sin()).powi(2)))
.sqrt())
* ((acc_vel * 1.6 * lab + PI * 1.4).sin());
let footrotr = ((1.0 / (0.5 + (0.5) * ((acc_vel * 1.6 * lab + PI * 0.4).sin()).powi(2)))
.sqrt())
* ((acc_vel * 1.6 * lab + PI * 0.4).sin());
let foothoril = (acc_vel * 2.2 * lab + PI * 1.45).sin();
let foothorir = (acc_vel * 2.2 * lab + PI * (0.45)).sin();
let shortalt = (acc_vel * lab * 2.2 + PI / 1.0).sin();
let short = ((5.0 / (1.5 + 3.5 * ((acc_vel * lab * 1.6).sin()).powi(2))).sqrt())
* ((acc_vel * lab * 1.6).sin());
next.shorts.position = Vec3::new(0.0, s_a.shorts.0 + 2.0, s_a.shorts.1 + 1.0);
next.belt.position = Vec3::new(0.0, s_a.belt.0 + 1.0, s_a.belt.1);
next.foot_l.position = Vec3::new(
-s_a.foot.0,
s_a.foot.1 + foothorir * 6.0,
s_a.foot.2 + shortalt * 2.0 + 2.0,
);
next.foot_l.orientation = Quaternion::rotation_x(0.6 + shortalt * 0.8);
next.foot_r.position = Vec3::new(
s_a.foot.0,
s_a.foot.1 + foothoril * 6.0,
s_a.foot.2 + shortalt * -2.0 + 2.0,
);
next.foot_r.orientation = Quaternion::rotation_x(0.6 - shortalt * 0.8);
next.belt.orientation = Quaternion::rotation_x(0.3);
next.shorts.orientation = Quaternion::rotation_x(0.5);
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + shortalt * 0.0);
next.shoulder_l.orientation = Quaternion::rotation_x(short * 0.15);
next.shoulder_r.orientation = Quaternion::rotation_x(short * -0.15);
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);
let left_sub = (orientation.x).max(0.0);
next.hand_l.position = Vec3::new(
-s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * left_sub,
);
next.hand_r.position = Vec3::new(
s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * right_sub,
);
next.hand_l.orientation =
Quaternion::rotation_x(push * 2.0 + footrotr * -0.2 * right_sub)
* Quaternion::rotation_y(1.0 * left_sub)
* Quaternion::rotation_z(2.5 * left_sub + 1.0 * right_sub);
next.hand_r.orientation =
Quaternion::rotation_x(push * 2.0 + footrotl * -0.2 * left_sub)
* Quaternion::rotation_y(-1.0 * right_sub)
* Quaternion::rotation_z(-2.5 * right_sub - 1.0 * left_sub);
next.torso.orientation = Quaternion::rotation_y(orientation.x / 1.5);
next.chest.orientation = Quaternion::rotation_y(orientation.x / -3.0)
* Quaternion::rotation_z(shortalt * -0.2);
next.head.orientation = Quaternion::rotation_z(shortalt * 0.25)
* Quaternion::rotation_z(orientation.x / -2.0)
* Quaternion::rotation_x(-0.1);
} else if wall.map_or(false, |e| e.y < -0.5) {
let push = (1.0 - orientation.x.abs()).powi(2);
let right_sub = (orientation.x).max(0.0);
let left_sub = -(orientation.x).min(0.0);
next.hand_l.position = Vec3::new(
-s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * left_sub,
);
next.hand_r.position = Vec3::new(
s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * right_sub,
);
next.hand_l.orientation =
Quaternion::rotation_x(push * 2.0 + footrotr * -0.2 * right_sub)
* Quaternion::rotation_y(1.0 * left_sub)
* Quaternion::rotation_z(2.5 * left_sub + 1.0 * right_sub);
next.hand_r.orientation =
Quaternion::rotation_x(push * 2.0 + footrotl * -0.2 * left_sub)
* Quaternion::rotation_y(-1.0 * right_sub)
* Quaternion::rotation_z(-2.5 * right_sub - 1.0 * left_sub);
next.chest.orientation = Quaternion::rotation_y(orientation.x);
next.torso.orientation = Quaternion::rotation_y(orientation.x / -1.5);
next.chest.orientation = Quaternion::rotation_y(orientation.x / 3.0)
* Quaternion::rotation_z(shortalt * -0.2);
next.head.orientation = Quaternion::rotation_z(shortalt * 0.25)
* Quaternion::rotation_z(orientation.x / 2.0)
* Quaternion::rotation_x(-0.1);
} else if wall.map_or(false, |e| e.x < -0.5) {
let push = (1.0 - orientation.y.abs()).powi(2);
let right_sub = -(orientation.y).min(0.0);
let left_sub = (orientation.y).max(0.0);
next.hand_l.position = Vec3::new(
-s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * left_sub,
);
next.hand_r.position = Vec3::new(
s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * right_sub,
);
next.hand_l.orientation =
Quaternion::rotation_x(push * 2.0 + footrotr * -0.2 * right_sub)
* Quaternion::rotation_y(1.0 * left_sub)
* Quaternion::rotation_z(2.5 * left_sub + 1.0 * right_sub);
next.hand_r.orientation =
Quaternion::rotation_x(push * 2.0 + footrotl * -0.2 * left_sub)
* Quaternion::rotation_y(-1.0 * right_sub)
* Quaternion::rotation_z(-2.5 * right_sub - 1.0 * left_sub);
next.torso.orientation = Quaternion::rotation_y(orientation.y / 1.5);
next.chest.orientation = Quaternion::rotation_y(orientation.y / -3.0)
* Quaternion::rotation_z(shortalt * -0.2);
next.head.orientation = Quaternion::rotation_z(shortalt * 0.25)
* Quaternion::rotation_z(orientation.y / -2.0)
* Quaternion::rotation_x(-0.1);
} else if wall.map_or(false, |e| e.x > 0.5) {
let push = (1.0 - orientation.y.abs()).powi(2);
let right_sub = (orientation.y).max(0.0);
let left_sub = -(orientation.y).min(0.0);
next.hand_l.position = Vec3::new(
-s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * left_sub,
);
next.hand_r.position = Vec3::new(
s_a.hand.0,
s_a.hand.1,
s_a.hand.2 + push * 5.0 + 2.0 * right_sub,
);
next.hand_l.orientation =
Quaternion::rotation_x(push * 2.0 + footrotr * -0.2 * right_sub)
* Quaternion::rotation_y(1.0 * left_sub)
* Quaternion::rotation_z(2.5 * left_sub + 1.0 * right_sub);
next.hand_r.orientation =
Quaternion::rotation_x(push * 2.0 + footrotl * -0.2 * left_sub)
* Quaternion::rotation_y(-1.0 * right_sub)
* Quaternion::rotation_z(-2.5 * right_sub - 1.0 * left_sub);
next.torso.orientation = Quaternion::rotation_y(orientation.y / -1.5);
next.chest.orientation = Quaternion::rotation_y(orientation.y / 3.0)
* Quaternion::rotation_z(shortalt * -0.2);
next.head.orientation = Quaternion::rotation_z(shortalt * 0.25)
* Quaternion::rotation_z(orientation.y / 2.0)
* Quaternion::rotation_x(-0.1);
};
next
}
}

View File

@ -45,7 +45,7 @@ impl Animation for WieldAnimation {
s_a: &SkeletonAttr,
) -> Self::Skeleton {
*rate = 1.0;
let lab: f32 = 1.0;
let lab: f32 = 0.8;
let speed = Vec2::<f32>::from(velocity).magnitude();
let speednorm = speed / 9.5;
let mut next = (*skeleton).clone();
@ -209,13 +209,10 @@ impl Animation for WieldAnimation {
* Quaternion::rotation_y(s_a.hhr.4)
* Quaternion::rotation_z(s_a.hhr.5);
next.control.position = Vec3::new(
s_a.hc.0,
s_a.hc.1 + speed * 0.2,
s_a.hc.2 + speed * 0.8 + direction * -5.0,
);
next.control.position =
Vec3::new(s_a.hc.0, s_a.hc.1, s_a.hc.2 + direction * -5.0);
next.control.orientation = Quaternion::rotation_x(s_a.hc.3 + u_slow * 0.15)
* Quaternion::rotation_y(s_a.hc.4 + speed * -0.04)
* Quaternion::rotation_y(s_a.hc.4)
* Quaternion::rotation_z(s_a.hc.5 + u_slowalt * 0.07);
},
Some(ToolKind::Staff) | Some(ToolKind::Sceptre) => {

View File

@ -685,6 +685,7 @@ impl FigureMgr {
// Velocity relative to the current ground
let rel_vel = anim::vek::Vec3::<f32>::from(vel.0 - physics.ground_vel);
let look_dir = controller.map(|c| c.inputs.look_dir).unwrap_or_default();
let is_player = scene_data.player_entity == entity;
let player_camera_mode = if is_player {
camera_mode
@ -704,13 +705,7 @@ impl FigureMgr {
(anim::vek::Vec3::<f32>::from(pos.0),),
anim::vek::Quaternion::<f32>::default(),
));
// TODO: Maintain look dir state separate from the controller and sync it for
// all entities. Then read from that instead of the controller here.
let look_dir = controller
.map(|c| c.inputs.look_dir)
.unwrap_or_else(|| Ori::new(ori.into_vec4().into()).look_dir());
let wall_dir = physics.on_wall.map(anim::vek::Vec3::from);
// Maintaining figure data and sending new figure data to the GPU turns out to
// be a very expensive operation. We want to avoid doing it as much
// as possible, so we make the assumption that players don't care so
@ -906,8 +901,8 @@ impl FigureMgr {
let target_base = match (
physics.on_ground.is_some(),
rel_vel.magnitude_squared() > MOVING_THRESHOLD_SQR, // Moving
physics.in_liquid().is_some(), // In water
rel_vel.magnitude_squared() > 0.01, // Moving
physics.in_liquid().is_some(), // In water
is_rider.is_some(),
) {
// Standing
@ -944,6 +939,7 @@ impl FigureMgr {
time,
rel_avg_vel,
state.acc_vel,
wall_dir,
),
state.state_time,
&mut state_animation_rate,
@ -1716,6 +1712,19 @@ impl FigureMgr {
skeleton_attr,
)
},
CharacterState::Wallrun { .. } => {
anim::character::WallrunAnimation::update_skeleton(
&target_base,
(
ori * anim::vek::Vec3::<f32>::unit_y(),
state.acc_vel,
wall_dir,
),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
)
},
CharacterState::Dance { .. } => {
anim::character::DanceAnimation::update_skeleton(
&target_base,
@ -5412,6 +5421,7 @@ impl FigureMgr {
}
}
#[allow(clippy::too_many_arguments)] // TODO: Pending review in #587
fn get_model_for_render(
&self,
tick: u64,