Add Body as a parameter to compute_matrices and start to pull whole body scaling out of the animation files

This commit is contained in:
Imbris 2021-06-26 03:06:41 -04:00
parent b2bf83e200
commit 6a15501b27
59 changed files with 156 additions and 136 deletions

View File

@ -62,7 +62,7 @@ impl Animation for IdleAnimation {
next.hand_r.scale = Vec3::one() * 1.04;
next.lower_torso.scale = Vec3::one() * 1.02;
next.hold.scale = Vec3::one() * 0.0;
next.torso.scale = Vec3::one() / 8.0 * s_a.scaler;
next.torso.scale = Vec3::one();
next.second.scale = Vec3::one() * 0.0;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + torso * 0.2);

View File

@ -118,7 +118,6 @@ impl Animation for JumpAnimation {
next.torso.position = Vec3::new(0.0, 0.0, 0.0) / 8.0 * s_a.scaler;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 8.0 * s_a.scaler;
next
}

View File

@ -79,8 +79,10 @@ impl Skeleton for BipedLargeSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let upper_torso = Mat4::<f32>::from(self.upper_torso);
let upper_torso = Mat4::<f32>::from(self.upper_torso)
* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 8.0);
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
let upper_torso_mat = torso_mat * upper_torso;

View File

@ -138,7 +138,7 @@ impl Animation for RunAnimation {
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.scale = Vec3::one() * 1.04;
next.hold.scale = Vec3::one() * 0.0;
next.torso.scale = Vec3::one() / 8.0 * s_a.scaler;
next.torso.scale = Vec3::one();
next.second.scale = Vec3::one() * 0.0;
if s_a.beast {

View File

@ -47,8 +47,10 @@ impl Skeleton for BipedSmallSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
//TODO: * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0);
let pants_mat = chest_mat * Mat4::<f32>::from(self.pants);
let control_mat = chest_mat * Mat4::<f32>::from(self.control);
let control_l_mat = Mat4::<f32>::from(self.control_l);

View File

@ -57,7 +57,6 @@ impl Animation for AlphaAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.chest.position =
Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + wave_slow_cos * 0.06) * s_a.scaler / 8.0;

View File

@ -57,7 +57,6 @@ impl Animation for BreatheAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.chest.position = Vec3::new(
0.0,

View File

@ -93,7 +93,6 @@ impl Animation for DashAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_x(

View File

@ -45,7 +45,6 @@ impl Animation for FeedAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + wave_slow_cos * 0.06 - 1.8)
* s_a.scaler

View File

@ -64,7 +64,6 @@ impl Animation for FlyAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1);
next.neck.orientation =

View File

@ -43,7 +43,6 @@ impl Animation for IdleAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + wave_slow_cos * 0.06 + 1.5)
* s_a.scaler

View File

@ -57,8 +57,13 @@ impl Skeleton for BirdLargeSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
let chest_mat = base_mat
* Mat4::<f32>::from(self.chest)
// TODO: refactor animations so that we can apply this after the chest transform
// (note: this todo applies to all the other skeletons as well)
* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 8.0);
let neck_mat = chest_mat * Mat4::<f32>::from(self.neck);
let head_mat = neck_mat * Mat4::<f32>::from(self.head);
let beak_mat = head_mat * Mat4::<f32>::from(self.beak);

View File

@ -71,7 +71,6 @@ impl Animation for RunAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_x(-0.1 * speednorm + short * -0.05)

View File

@ -44,7 +44,6 @@ impl Animation for ShockwaveAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.chest.position =
Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + movement1abs * 1.5) * s_a.scaler / 8.0;

View File

@ -49,7 +49,6 @@ impl Animation for ShootAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.chest.position = Vec3::new(
0.0,

View File

@ -43,7 +43,6 @@ impl Animation for StunnedAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.chest.position =
Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + wave_slow_cos * 0.06) * s_a.scaler / 8.0;

View File

@ -50,7 +50,6 @@ impl Animation for SummonAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.chest.position = Vec3::new(
0.0,

View File

@ -47,7 +47,6 @@ impl Animation for SwimAnimation {
next.leg_r.scale = Vec3::one() / 8.0 * 0.98;
next.foot_l.scale = Vec3::one() * 1.02;
next.foot_r.scale = Vec3::one() * 1.02;
next.chest.scale = Vec3::one() * s_a.scaler / 8.0;
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + wave_slow_cos * 0.06 + 1.5)
* s_a.scaler

View File

@ -36,8 +36,10 @@ impl Skeleton for BirdMediumSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
//TODO: * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(torso_mat * Mat4::<f32>::from(self.head)),

View File

@ -43,7 +43,6 @@ impl Animation for IdleAnimation {
next.back.scale = Vec3::one() * 1.02;
next.hold.scale = Vec3::one() * 0.0;
next.lantern.scale = Vec3::one() * 0.65;
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler;
next.shoulder_l.scale = Vec3::one() * 1.1;
next.shoulder_r.scale = Vec3::one() * 1.1;

View File

@ -207,7 +207,6 @@ impl Animation for JumpAnimation {
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * s_a.scaler;
next.torso.orientation = Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler;
match hands {
(Some(Hands::One), _) => match active_tool_kind {

View File

@ -98,8 +98,11 @@ impl Skeleton for CharacterSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
let torso_mat = base_mat
* Mat4::<f32>::from(self.torso)
* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0);
let chest_mat = torso_mat * Mat4::<f32>::from(self.chest);
let head_mat = chest_mat * Mat4::<f32>::from(self.head);
let shorts_mat = chest_mat * Mat4::<f32>::from(self.shorts);

View File

@ -84,7 +84,6 @@ impl Animation for MountAnimation {
next.back.scale = Vec3::one() * 1.02;
next.hold.scale = Vec3::one() * 0.0;
next.lantern.scale = Vec3::one() * 0.65;
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler;
next.shoulder_l.scale = Vec3::one() * 1.1;
next.shoulder_r.scale = Vec3::one() * 1.1;

View File

@ -276,7 +276,6 @@ impl Animation for RunAnimation {
}
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * s_a.scaler;
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler;
match hands {
(Some(Hands::One), _) => match active_tool_kind {

View File

@ -60,7 +60,6 @@ impl Animation for StandAnimation {
next.back.scale = Vec3::one() * 1.02;
next.hold.scale = Vec3::one() * 0.0;
next.lantern.scale = Vec3::one() * 0.65;
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler;
next.shoulder_l.scale = Vec3::one() * 1.1;
next.shoulder_r.scale = Vec3::one() * 1.1;

View File

@ -238,7 +238,6 @@ impl Animation for SwimAnimation {
+ avgspeed * avg_vel.z * -0.003,
) * Quaternion::rotation_y(tilt * 2.0)
* Quaternion::rotation_z(tilt * 3.0);
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler;
match hands {
(Some(Hands::One), _) => match active_tool_kind {
Some(ToolKind::Axe) | Some(ToolKind::Hammer) | Some(ToolKind::Sword) => {

View File

@ -77,7 +77,6 @@ impl Animation for SwimWieldAnimation {
if velocity > 0.01 {
next.torso.position = Vec3::new(0.0, 0.0, 1.0) * s_a.scaler;
next.torso.orientation = Quaternion::rotation_x(velocity * -0.05);
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler;
next.back.position = Vec3::new(0.0, s_a.back.0, s_a.back.1);
next.back.orientation = Quaternion::rotation_x(
@ -93,7 +92,6 @@ impl Animation for SwimWieldAnimation {
next.chest.position =
Vec3::new(0.0 + slowalt * 0.5, s_a.chest.0, s_a.chest.1 + u_slow * 0.5);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * s_a.scaler;
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler;
next.foot_l.position = Vec3::new(-s_a.foot.0, -2.0 + s_a.foot.1, s_a.foot.2);

View File

@ -43,8 +43,10 @@ impl Skeleton for DragonSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
//* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 1.0);
let chest_rear_mat = chest_front_mat * Mat4::<f32>::from(self.chest_rear);
let head_lower_mat = chest_front_mat * Mat4::<f32>::from(self.head_lower);
let wing_in_l_mat = chest_front_mat * Mat4::<f32>::from(self.wing_in_l);

View File

@ -30,7 +30,6 @@ impl Animation for IdleAnimation {
let slowalt = (anim_time * 3.5 + PI + 0.2).sin();
next.jaw.scale = Vec3::one() * 0.98;
next.chest_front.scale = Vec3::one() / 11.0;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_z(slowalt * -0.1);

View File

@ -33,8 +33,10 @@ impl Skeleton for FishMediumSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
let chest_front_mat =
base_mat * Mat4::<f32>::from(self.chest_front) * Mat4::scaling_3d(1.0 / 11.0);
let chest_back_mat = Mat4::<f32>::from(self.chest_back);
let head_mat = Mat4::<f32>::from(self.head);

View File

@ -47,8 +47,6 @@ impl Animation for SwimAnimation {
let vel = (velocity.magnitude()).min(s_a.amplitude);
let slowvel = vel * 0.1;
next.chest_front.scale = Vec3::one() / 11.0;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_z(slowalt * -0.1 + tilt * -2.0);

View File

@ -28,8 +28,6 @@ impl Animation for IdleAnimation {
let slow = (anim_time * 3.5 + PI).sin();
next.chest.scale = Vec3::one() / 13.0;
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) / 13.0;
next.tail.position = Vec3::new(0.0, s_a.tail.0, s_a.tail.1);

View File

@ -30,8 +30,9 @@ impl Skeleton for FishSmallSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
let chest_mat = base_mat * Mat4::<f32>::from(self.chest) * Mat4::scaling_3d(1.0 / 13.0);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(chest_mat),

View File

@ -45,8 +45,6 @@ impl Animation for SwimAnimation {
let vel = (velocity.magnitude()).min(s_a.amplitude);
let slowvel = vel * 0.1;
next.chest.scale = Vec3::one() / 13.0;
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) / 13.0;
next.chest.orientation = Quaternion::rotation_x(velocity.z.abs() * -0.005 + x_tilt)
* Quaternion::rotation_z(fast * -0.1);

View File

@ -31,6 +31,7 @@ impl Skeleton for FixtureSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
(): Self::Body,
) -> Offsets {
buf[0] = make_bone(base_mat);
Offsets {

View File

@ -41,7 +41,6 @@ impl Animation for IdleAnimation {
);
next.head.scale = Vec3::one() * 1.02;
next.jaw.scale = Vec3::one() * 1.02;
next.upper_torso.scale = Vec3::one() * s_a.scaler / 8.0;
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.scale = Vec3::one() * 1.04;
next.leg_l.scale = Vec3::one() * 1.02;

View File

@ -47,8 +47,11 @@ impl Skeleton for GolemSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
let torso_mat = base_mat
* Mat4::<f32>::from(self.torso)
* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 8.0);
let upper_torso_mat = torso_mat * Mat4::<f32>::from(self.upper_torso);
let lower_torso_mat = upper_torso_mat * Mat4::<f32>::from(self.lower_torso);
let leg_l_mat = lower_torso_mat * Mat4::<f32>::from(self.leg_l);

View File

@ -67,7 +67,6 @@ impl Animation for RunAnimation {
next.head.scale = Vec3::one() * 1.02;
next.jaw.scale = Vec3::one() * 1.02;
next.upper_torso.scale = Vec3::one() * s_a.scaler / 8.0;
next.hand_l.scale = Vec3::one() * 1.04;
next.hand_r.scale = Vec3::one() * 1.04;
next.leg_l.scale = Vec3::one() * 1.02;

View File

@ -117,6 +117,7 @@ pub trait Skeleton: Send + Sync + 'static {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets;
}
@ -124,10 +125,11 @@ pub fn compute_matrices<S: Skeleton>(
skeleton: &S,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
body: S::Body,
) -> Offsets {
#[cfg(not(feature = "use-dyn-lib"))]
{
S::compute_matrices_inner(skeleton, base_mat, buf)
S::compute_matrices_inner(skeleton, base_mat, buf, body)
}
#[cfg(feature = "use-dyn-lib")]
{
@ -136,7 +138,7 @@ pub fn compute_matrices<S: Skeleton>(
#[allow(clippy::type_complexity)]
let compute_fn: voxygen_dynlib::Symbol<
fn(&S, Mat4<f32>, &mut [FigureBoneData; MAX_BONE_COUNT]) -> Offsets,
fn(&S, Mat4<f32>, &mut [FigureBoneData; MAX_BONE_COUNT], S::Body) -> Offsets,
> = unsafe { lib.get(S::COMPUTE_FN) }.unwrap_or_else(|e| {
panic!(
"Trying to use: {} but had error: {:?}",
@ -148,7 +150,7 @@ pub fn compute_matrices<S: Skeleton>(
)
});
compute_fn(skeleton, base_mat, buf)
compute_fn(skeleton, base_mat, buf, body)
}
}

View File

@ -29,6 +29,7 @@ impl Skeleton for ObjectSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let bone0_mat = base_mat * Mat4::<f32>::from(self.bone0);

View File

@ -40,7 +40,6 @@ impl Animation for IdleAnimation {
* 0.1,
);
next.jaw.scale = Vec3::one() * 0.98;
next.chest.scale = Vec3::one() * s_a.scaler / 11.0;
next.tail_front.scale = Vec3::one() * 0.98;
next.tail_rear.scale = Vec3::one() * 0.98;

View File

@ -23,7 +23,6 @@ impl Animation for JumpAnimation {
let mut next = (*skeleton).clone();
next.jaw.scale = Vec3::one() * 0.98;
next.chest.scale = Vec3::one() * s_a.scaler / 11.0;
next.tail_front.scale = Vec3::one() * 0.98;
next.tail_rear.scale = Vec3::one() * 0.98;

View File

@ -48,8 +48,11 @@ impl Skeleton for QuadrupedLowSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
let chest_mat = base_mat
* Mat4::<f32>::from(self.chest)
* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0);
let tail_front = chest_mat * Mat4::<f32>::from(self.tail_front);
let head_lower_mat = chest_mat * Mat4::<f32>::from(self.head_lower);
let head_upper_mat = head_lower_mat * Mat4::<f32>::from(self.head_upper);

View File

@ -75,7 +75,6 @@ impl Animation for RunAnimation {
} * 1.3;
next.jaw.scale = Vec3::one() * 0.98;
next.chest.scale = Vec3::one() * s_a.scaler / 11.0;
next.tail_front.scale = Vec3::one() * 0.98;
next.tail_rear.scale = Vec3::one() * 0.98;

View File

@ -24,7 +24,6 @@ impl Animation for JumpAnimation {
next.neck.scale = Vec3::one() * 1.02;
next.jaw.scale = Vec3::one() * 1.02;
next.torso_front.scale = Vec3::one() * s_a.scaler / 11.0;
next.leg_fl.scale = Vec3::one() * 1.02;
next.leg_fr.scale = Vec3::one() * 1.02;
next.leg_bl.scale = Vec3::one() * 1.02;

View File

@ -54,8 +54,11 @@ impl Skeleton for QuadrupedMediumSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let torso_front_mat = base_mat * Mat4::<f32>::from(self.torso_front);
let torso_front_mat = base_mat
* Mat4::<f32>::from(self.torso_front)
* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0);
let torso_back_mat = torso_front_mat * Mat4::<f32>::from(self.torso_back);
let neck_mat = torso_front_mat * Mat4::<f32>::from(self.neck);
let leg_fl_mat = torso_front_mat * Mat4::<f32>::from(self.leg_fl);

View File

@ -91,7 +91,6 @@ impl Animation for RunAnimation {
next.neck.scale = Vec3::one() * 1.02;
next.jaw.scale = Vec3::one() * 1.02;
next.torso_front.scale = Vec3::one() * s_a.scaler / 11.0;
next.leg_fl.scale = Vec3::one() * 1.02;
next.leg_fr.scale = Vec3::one() * 1.02;
next.leg_bl.scale = Vec3::one() * 1.02;

View File

@ -40,7 +40,6 @@ impl Animation for FeedAnimation {
.sin()
* 0.5,
);
next.chest.scale = Vec3::one() / 11.0 * s_a.scaler;
next.head.position = Vec3::new(0.0, s_a.head.0 + 1.5, s_a.head.1 + slow * 0.2);
next.head.orientation = Quaternion::rotation_z(head_look.y)

View File

@ -46,7 +46,6 @@ impl Animation for IdleAnimation {
next.chest.position = Vec3::new(slow * 0.05, s_a.chest.0, s_a.chest.1) / 11.0 * s_a.scaler;
next.chest.orientation = Quaternion::rotation_y(slow * 0.05);
next.chest.scale = Vec3::one() / 11.0 * s_a.scaler;
next.leg_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2 + slow * -0.2);
next.leg_fl.orientation =

View File

@ -26,7 +26,6 @@ impl Animation for JumpAnimation {
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) * s_a.scaler / 11.0;
next.chest.orientation = Quaternion::rotation_y(0.0);
next.chest.scale = Vec3::one() * s_a.scaler / 11.0;
next.leg_fl.position = Vec3::new(-s_a.feet_f.0, s_a.feet_f.1, s_a.feet_f.2);
next.leg_fl.orientation = Quaternion::rotation_x(0.0);

View File

@ -40,8 +40,11 @@ impl Skeleton for QuadrupedSmallSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
let chest_mat = base_mat
* Mat4::<f32>::from(self.chest)
* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(chest_mat * Mat4::<f32>::from(self.head)),

View File

@ -76,7 +76,6 @@ impl Animation for RunAnimation {
Quaternion::rotation_x(vertcancel * short * 0.2 * s_a.spring + x_tilt)
* Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(s_a.lateral * short * 0.2 + tilt * -1.5);
next.chest.scale = Vec3::one() / 11.0 * s_a.scaler;
next.leg_fl.position = Vec3::new(
-s_a.feet_f.0,

View File

@ -29,6 +29,7 @@ impl Skeleton for ShipSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let bone0_mat = base_mat * Mat4::<f32>::from(self.bone0);

View File

@ -47,7 +47,6 @@ impl Animation for IdleAnimation {
next.hand_r.scale = Vec3::one() * 0.98;
next.tail_front.scale = Vec3::one() * 1.02;
next.tail_back.scale = Vec3::one() * 0.98;
next.chest_front.scale = Vec3::one() / s_a.scaler;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + breathe * 0.3);
next.head.orientation = Quaternion::rotation_x(head_look.y + breathe * 0.1 - 0.1)

View File

@ -26,7 +26,6 @@ impl Animation for JumpAnimation {
next.jaw.scale = Vec3::one() * 0.98;
next.foot_l.scale = Vec3::one() * 0.96;
next.foot_r.scale = Vec3::one() * 0.96;
next.chest_front.scale = Vec3::one() / s_a.scaler;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_x(-0.1);

View File

@ -47,8 +47,11 @@ impl Skeleton for TheropodSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body,
) -> Offsets {
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
let chest_front_mat = base_mat
* Mat4::<f32>::from(self.chest_front)
* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 1.0);
let neck_mat = chest_front_mat * Mat4::<f32>::from(self.neck);
let head_mat = neck_mat * Mat4::<f32>::from(self.head);
let chest_back_mat = chest_front_mat * Mat4::<f32>::from(self.chest_back);

View File

@ -68,7 +68,6 @@ impl Animation for RunAnimation {
next.jaw.scale = Vec3::one() * 0.98;
next.foot_l.scale = Vec3::one() * 0.96;
next.foot_r.scale = Vec3::one() * 0.96;
next.chest_front.scale = Vec3::one() / s_a.scaler;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_x(-0.1 * speednorm + short * -0.05)

View File

@ -764,12 +764,14 @@ impl FigureMgr {
Some((meta.mount_transform, meta.mount_world_pos))
})();
let body = *body;
let common_params = FigureUpdateCommonParameters {
pos: pos.0,
ori,
scale,
mount_transform_pos,
body: Some(*body),
body: Some(body),
col,
dt,
_lpindex: lpindex,
@ -785,7 +787,7 @@ impl FigureMgr {
let (model, skeleton_attr) = self.model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -807,7 +809,11 @@ impl FigureMgr {
.character_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, CharacterSkeleton::new(holding_lantern))
FigureState::new(
renderer,
CharacterSkeleton::new(holding_lantern),
body,
)
});
// Average velocity relative to the current ground
@ -1589,6 +1595,7 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::QuadrupedSmall(body) => {
@ -1596,7 +1603,7 @@ impl FigureMgr {
self.quadruped_small_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -1609,7 +1616,7 @@ impl FigureMgr {
.quadruped_small_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, QuadrupedSmallSkeleton::default())
FigureState::new(renderer, QuadrupedSmallSkeleton::default(), body)
});
// Average velocity relative to the current ground
@ -1777,6 +1784,7 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::QuadrupedMedium(body) => {
@ -1784,7 +1792,7 @@ impl FigureMgr {
self.quadruped_medium_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -1797,7 +1805,7 @@ impl FigureMgr {
.quadruped_medium_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, QuadrupedMediumSkeleton::default())
FigureState::new(renderer, QuadrupedMediumSkeleton::default(), body)
});
// Average velocity relative to the current ground
@ -2090,6 +2098,7 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::QuadrupedLow(body) => {
@ -2097,7 +2106,7 @@ impl FigureMgr {
self.quadruped_low_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -2110,7 +2119,7 @@ impl FigureMgr {
.quadruped_low_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, QuadrupedLowSkeleton::default())
FigureState::new(renderer, QuadrupedLowSkeleton::default(), body)
});
// Average velocity relative to the current ground
@ -2436,13 +2445,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::BirdMedium(body) => {
let (model, skeleton_attr) = self.bird_medium_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -2455,7 +2465,7 @@ impl FigureMgr {
.bird_medium_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, BirdMediumSkeleton::default())
FigureState::new(renderer, BirdMediumSkeleton::default(), body)
});
// Average velocity relative to the current ground
@ -2536,13 +2546,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::FishMedium(body) => {
let (model, skeleton_attr) = self.fish_medium_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -2555,7 +2566,7 @@ impl FigureMgr {
.fish_medium_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, FishMediumSkeleton::default())
FigureState::new(renderer, FishMediumSkeleton::default(), body)
});
// Average velocity relative to the current ground
@ -2615,13 +2626,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::BipedSmall(body) => {
let (model, skeleton_attr) = self.biped_small_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -2634,7 +2646,7 @@ impl FigureMgr {
.biped_small_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, BipedSmallSkeleton::default())
FigureState::new(renderer, BipedSmallSkeleton::default(), body)
});
// Average velocity relative to the current ground
@ -2949,13 +2961,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::Dragon(body) => {
let (model, skeleton_attr) = self.dragon_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -2963,10 +2976,9 @@ impl FigureMgr {
&slow_jobs,
);
let state =
self.states.dragon_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, DragonSkeleton::default())
});
let state = self.states.dragon_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, DragonSkeleton::default(), body)
});
// Average velocity relative to the current ground
let rel_avg_vel = state.avg_vel - physics.ground_vel;
@ -3033,13 +3045,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::Theropod(body) => {
let (model, skeleton_attr) = self.theropod_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -3051,7 +3064,9 @@ impl FigureMgr {
.states
.theropod_states
.entry(entity)
.or_insert_with(|| FigureState::new(renderer, TheropodSkeleton::default()));
.or_insert_with(|| {
FigureState::new(renderer, TheropodSkeleton::default(), body)
});
// Average velocity relative to the current ground
let rel_avg_vel = state.avg_vel - physics.ground_vel;
@ -3206,13 +3221,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::BirdLarge(body) => {
let (model, skeleton_attr) = self.bird_large_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -3225,7 +3241,7 @@ impl FigureMgr {
.bird_large_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, BirdLargeSkeleton::default())
FigureState::new(renderer, BirdLargeSkeleton::default(), body)
});
let (character, last_character) = match (character, last_character) {
@ -3517,13 +3533,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::FishSmall(body) => {
let (model, skeleton_attr) = self.fish_small_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -3536,7 +3553,7 @@ impl FigureMgr {
.fish_small_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, FishSmallSkeleton::default())
FigureState::new(renderer, FishSmallSkeleton::default(), body)
});
// Average velocity relative to the current ground
@ -3596,13 +3613,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::BipedLarge(body) => {
let (model, skeleton_attr) = self.biped_large_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -3615,7 +3633,7 @@ impl FigureMgr {
.biped_large_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, BipedLargeSkeleton::default())
FigureState::new(renderer, BipedLargeSkeleton::default(), body)
});
// Average velocity relative to the current ground
@ -4214,13 +4232,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::Golem(body) => {
let (model, skeleton_attr) = self.golem_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -4228,10 +4247,9 @@ impl FigureMgr {
&slow_jobs,
);
let state =
self.states.golem_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, GolemSkeleton::default())
});
let state = self.states.golem_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, GolemSkeleton::default(), body)
});
// Average velocity relative to the current ground
let _rel_avg_vel = state.avg_vel - physics.ground_vel;
@ -4452,13 +4470,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::Object(body) => {
let (model, skeleton_attr) = self.object_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -4466,10 +4485,9 @@ impl FigureMgr {
&slow_jobs,
);
let state =
self.states.object_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, ObjectSkeleton::default())
});
let state = self.states.object_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, ObjectSkeleton::default(), body)
});
// Average velocity relative to the current ground
let _rel_avg_vel = state.avg_vel - physics.ground_vel;
@ -4527,7 +4545,7 @@ impl FigureMgr {
active_tool_kind,
second_tool_kind,
Some(s.stage_section),
*body,
body,
),
stage_progress,
&mut state_animation_rate,
@ -4552,7 +4570,7 @@ impl FigureMgr {
active_tool_kind,
second_tool_kind,
Some(s.stage_section),
*body,
body,
),
stage_progress,
&mut state_animation_rate,
@ -4570,13 +4588,14 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
Body::Ship(body) => {
let (model, skeleton_attr) = self.ship_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -4584,11 +4603,9 @@ impl FigureMgr {
&slow_jobs,
);
let state = self
.states
.ship_states
.entry(entity)
.or_insert_with(|| FigureState::new(renderer, ShipSkeleton::default()));
let state = self.states.ship_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, ShipSkeleton::default(), body)
});
// Average velocity relative to the current ground
let _rel_avg_vel = state.avg_vel - physics.ground_vel;
@ -4653,6 +4670,7 @@ impl FigureMgr {
&common_params,
state_animation_rate,
model,
body,
);
},
}
@ -4821,6 +4839,8 @@ impl FigureMgr {
figure_lod_render_distance: f32,
filter_state: impl Fn(&FigureStateMeta) -> bool,
) -> Option<FigureModelRef> {
let body = *body;
let player_camera_mode = if is_player {
camera.get_mode()
} else {
@ -4876,7 +4896,7 @@ impl FigureMgr {
state.bound(),
model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -4892,7 +4912,7 @@ impl FigureMgr {
state.bound(),
quadruped_small_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -4908,7 +4928,7 @@ impl FigureMgr {
state.bound(),
quadruped_medium_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -4924,7 +4944,7 @@ impl FigureMgr {
state.bound(),
quadruped_low_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -4940,7 +4960,7 @@ impl FigureMgr {
state.bound(),
bird_medium_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -4956,7 +4976,7 @@ impl FigureMgr {
state.bound(),
fish_medium_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -4972,7 +4992,7 @@ impl FigureMgr {
state.bound(),
theropod_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -4988,7 +5008,7 @@ impl FigureMgr {
state.bound(),
dragon_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -5004,7 +5024,7 @@ impl FigureMgr {
state.bound(),
bird_large_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -5020,7 +5040,7 @@ impl FigureMgr {
state.bound(),
fish_small_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -5036,7 +5056,7 @@ impl FigureMgr {
state.bound(),
biped_large_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -5052,7 +5072,7 @@ impl FigureMgr {
state.bound(),
biped_small_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -5068,7 +5088,7 @@ impl FigureMgr {
state.bound(),
golem_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -5084,7 +5104,7 @@ impl FigureMgr {
state.bound(),
object_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -5100,7 +5120,7 @@ impl FigureMgr {
state.bound(),
ship_model_cache.get_model(
col_lights,
*body,
body,
inventory,
tick,
player_camera_mode,
@ -5305,9 +5325,10 @@ pub struct FigureUpdateCommonParameters<'a> {
}
impl<S: Skeleton> FigureState<S> {
pub fn new(renderer: &mut Renderer, skeleton: S) -> Self {
pub fn new(renderer: &mut Renderer, skeleton: S, body: S::Body) -> Self {
let mut buf = [Default::default(); anim::MAX_BONE_COUNT];
let offsets = anim::compute_matrices(&skeleton, anim::vek::Mat4::identity(), &mut buf);
let offsets =
anim::compute_matrices(&skeleton, anim::vek::Mat4::identity(), &mut buf, body);
let bone_consts = figure_bone_data_from_anim(&buf);
Self {
meta: FigureStateMeta {
@ -5351,6 +5372,10 @@ impl<S: Skeleton> FigureState<S> {
}: &FigureUpdateCommonParameters,
state_animation_rate: f32,
model: Option<&FigureModelEntry<N>>,
// TODO: there is the potential to drop the optional body from the common params and just
// use this one but we need to add a function to the skelton trait or something in order to
// get the mounter offset
skel_body: S::Body,
) {
// NOTE: As long as update() always gets called after get_or_create_model(), and
// visibility is not set again until after the model is rendered, we
@ -5463,7 +5488,7 @@ impl<S: Skeleton> FigureState<S> {
);
renderer.update_consts(&mut self.meta.bound.0, &[locals]);
let offsets = anim::compute_matrices(&self.skeleton, mat, buf);
let offsets = anim::compute_matrices(&self.skeleton, mat, buf, skel_body);
let new_bone_consts = figure_bone_data_from_anim(buf);

View File

@ -71,7 +71,7 @@ pub struct Scene {
col_lights: FigureColLights,
backdrop: Option<(FigureModelEntry<1>, FigureState<FixtureSkeleton>)>,
figure_model_cache: FigureModelCache,
figure_state: FigureState<CharacterSkeleton>,
figure_state: Option<FigureState<CharacterSkeleton>>,
//turning_camera: bool,
turning_character: bool,
@ -129,10 +129,10 @@ impl Scene {
map_bounds,
figure_model_cache: FigureModelCache::new(),
figure_state: FigureState::new(renderer, CharacterSkeleton::default()),
figure_state: None,
backdrop: backdrop.map(|specifier| {
let mut state = FigureState::new(renderer, FixtureSkeleton::default());
let mut state = FigureState::new(renderer, FixtureSkeleton::default(), ());
let mut greedy = FigureModel::make_greedy();
let mut opaque_mesh = Mesh::new();
let (segment, offset) = load_mesh(specifier, Vec3::new(-55.0, -49.5, -2.0));
@ -165,7 +165,7 @@ impl Scene {
terrain: None,
ground_vel: Vec3::zero(),
};
state.update(renderer, &mut buf, &common_params, 1.0, Some(&model));
state.update(renderer, &mut buf, &common_params, 1.0, Some(&model), ());
(model, state)
}),
col_lights,
@ -294,8 +294,11 @@ impl Scene {
let hands = (active_tool_hand, second_tool_hand);
if let Some(body) = scene_data.body {
let figure_state = self.figure_state.get_or_insert_with(|| {
FigureState::new(renderer, CharacterSkeleton::default(), body)
});
let tgt_skeleton = IdleAnimation::update_skeleton(
self.figure_state.skeleton_mut(),
figure_state.skeleton_mut(),
(
active_tool_kind,
second_tool_kind,
@ -307,8 +310,8 @@ impl Scene {
&SkeletonAttr::from(&body),
);
let dt_lerp = (scene_data.delta_time * 15.0).min(1.0);
*self.figure_state.skeleton_mut() =
anim::vek::Lerp::lerp(&*self.figure_state.skeleton_mut(), &tgt_skeleton, dt_lerp);
*figure_state.skeleton_mut() =
anim::vek::Lerp::lerp(&*figure_state.skeleton_mut(), &tgt_skeleton, dt_lerp);
let model = self
.figure_model_cache
@ -343,8 +346,7 @@ impl Scene {
ground_vel: Vec3::zero(),
};
self.figure_state
.update(renderer, &mut buf, &common_params, 1.0, model);
figure_state.update(renderer, &mut buf, &common_params, 1.0, model, body);
}
}
@ -368,13 +370,9 @@ impl Scene {
None,
);
if let Some(model) = model {
if let Some((model, figure_state)) = model.zip(self.figure_state.as_ref()) {
if let Some(lod) = model.lod_model(0) {
figure_drawer.draw(
lod,
self.figure_state.bound(),
self.col_lights.texture(model),
);
figure_drawer.draw(lod, figure_state.bound(), self.col_lights.texture(model));
}
}
}