This commit is contained in:
jshipsey 2022-02-04 23:59:57 -05:00
parent 6d34a6b544
commit 7ae85aef50
3 changed files with 8 additions and 54 deletions

View File

@ -1,6 +1,6 @@
use super::utils::*; use super::utils::*;
use crate::{ use crate::{
comp::{character_state::OutputEvents, CharacterState, InventoryAction, StateUpdate}, comp::{character_state::OutputEvents, CharacterState, StateUpdate},
states::{ states::{
behavior::{CharacterBehavior, JoinData}, behavior::{CharacterBehavior, JoinData},
idle, idle,
@ -9,7 +9,7 @@ use crate::{
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use vek::Vec2; use vek::Vec2;
const WALLRUN_ANTIGRAV: f32 = crate::consts::GRAVITY * 0.90; const WALLRUN_ANTIGRAV: f32 = crate::consts::GRAVITY * 0.5;
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)] #[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
pub struct Data; pub struct Data;
@ -20,6 +20,7 @@ impl CharacterBehavior for Data {
handle_wield(data, &mut update); handle_wield(data, &mut update);
handle_jump(data, output_events, &mut update, 1.0); handle_jump(data, output_events, &mut update, 1.0);
handle_climb(data, &mut update);
{ {
let lift = WALLRUN_ANTIGRAV; let lift = WALLRUN_ANTIGRAV;

View File

@ -2,23 +2,11 @@ use super::{
super::{vek::*, Animation}, super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr, CharacterSkeleton, SkeletonAttr,
}; };
use common::comp::item::{Hands, ToolKind}; use core::f32::consts::PI;
use core::{f32::consts::PI, ops::Mul};
pub struct WallrunAnimation; pub struct WallrunAnimation;
type WallrunAnimationDependency = ( type WallrunAnimationDependency = (Vec3<f32>, f32, Option<Vec3<f32>>);
Option<ToolKind>,
Option<ToolKind>,
(Option<Hands>, Option<Hands>),
Vec3<f32>,
Vec3<f32>,
Vec3<f32>,
f32,
Vec3<f32>,
f32,
Option<Vec3<f32>>,
);
impl Animation for WallrunAnimation { impl Animation for WallrunAnimation {
type Dependency<'a> = WallrunAnimationDependency; type Dependency<'a> = WallrunAnimationDependency;
@ -31,49 +19,27 @@ impl Animation for WallrunAnimation {
fn update_skeleton_inner<'a>( fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton, skeleton: &Self::Skeleton,
( (orientation, acc_vel, wall): Self::Dependency<'a>,
active_tool_kind, _anim_time: f32,
second_tool_kind,
hands,
velocity,
orientation,
last_ori,
global_time,
avg_vel,
acc_vel,
wall,
): Self::Dependency<'a>,
anim_time: f32,
rate: &mut f32, rate: &mut f32,
s_a: &SkeletonAttr, s_a: &SkeletonAttr,
) -> Self::Skeleton { ) -> Self::Skeleton {
let mut next = (*skeleton).clone(); let mut next = (*skeleton).clone();
let speed = Vec2::<f32>::from(velocity).magnitude();
*rate = 1.0; *rate = 1.0;
let speednorm = (speed / 9.4).powf(0.6);
let lab: f32 = 0.8; let lab: f32 = 0.8;
let footrotl = ((1.0 / (0.5 + (0.5) * ((acc_vel * 1.6 * lab + PI * 1.4).sin()).powi(2))) let footrotl = ((1.0 / (0.5 + (0.5) * ((acc_vel * 1.6 * lab + PI * 1.4).sin()).powi(2)))
.sqrt()) .sqrt())
* ((acc_vel * 1.6 * lab + PI * 1.4).sin()); * ((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))) let footrotr = ((1.0 / (0.5 + (0.5) * ((acc_vel * 1.6 * lab + PI * 0.4).sin()).powi(2)))
.sqrt()) .sqrt())
* ((acc_vel * 1.6 * lab + PI * 0.4).sin()); * ((acc_vel * 1.6 * lab + PI * 0.4).sin());
let shorte = ((1.0 / (0.8 + 0.2 * ((acc_vel * lab * 1.6).sin()).powi(2))).sqrt())
* ((acc_vel * lab * 1.6).sin());
let foothoril = (acc_vel * 2.2 * lab + PI * 1.45).sin(); let foothoril = (acc_vel * 2.2 * lab + PI * 1.45).sin();
let foothorir = (acc_vel * 2.2 * lab + PI * (0.45)).sin(); let foothorir = (acc_vel * 2.2 * lab + PI * (0.45)).sin();
let footvertl = (acc_vel * 1.6 * lab).sin();
let footvertr = (acc_vel * 1.6 * lab + PI).sin();
let footvertsl = (acc_vel * 1.6 * lab).sin();
let footvertsr = (acc_vel * 1.6 * lab + PI * 0.5).sin();
let shortalt = (acc_vel * lab * 2.2 + PI / 1.0).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()) let short = ((5.0 / (1.5 + 3.5 * ((acc_vel * lab * 1.6).sin()).powi(2))).sqrt())
@ -98,16 +64,10 @@ impl Animation for WallrunAnimation {
next.belt.orientation = Quaternion::rotation_x(0.3); next.belt.orientation = Quaternion::rotation_x(0.3);
next.shorts.orientation = Quaternion::rotation_x(0.5); next.shorts.orientation = Quaternion::rotation_x(0.5);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + shortalt * 0.0); next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + shortalt * 0.0);
//
next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_l.orientation = Quaternion::rotation_x(short * 0.15); next.shoulder_l.orientation = Quaternion::rotation_x(short * 0.15);
next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_r.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) { if wall.map_or(false, |e| e.y > 0.5) {

View File

@ -1712,18 +1712,11 @@ impl FigureMgr {
skeleton_attr, skeleton_attr,
) )
}, },
CharacterState::Wallrun(data) => { CharacterState::Wallrun { .. } => {
anim::character::WallrunAnimation::update_skeleton( anim::character::WallrunAnimation::update_skeleton(
&target_base, &target_base,
( (
active_tool_kind,
second_tool_kind,
hands,
rel_vel,
ori * anim::vek::Vec3::<f32>::unit_y(), ori * anim::vek::Vec3::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
time,
rel_avg_vel,
state.acc_vel, state.acc_vel,
wall_dir, wall_dir,
), ),