wall contact, run anim tweaks

This commit is contained in:
jshipsey 2022-02-03 00:48:15 -05:00
parent b2d6b06e2e
commit 6f8cadc847
6 changed files with 120 additions and 36 deletions

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

@ -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

@ -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(|v| anim::vek::Vec3::from(v));
// 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,
@ -5412,6 +5408,7 @@ impl FigureMgr {
}
}
#[allow(clippy::too_many_arguments)] // TODO: Pending review in #587
fn get_model_for_render(
&self,
tick: u64,