diff --git a/voxygen/anim/src/biped_large/idle.rs b/voxygen/anim/src/biped_large/idle.rs index 870d25f424..e8d9049d01 100644 --- a/voxygen/anim/src/biped_large/idle.rs +++ b/voxygen/anim/src/biped_large/idle.rs @@ -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); diff --git a/voxygen/anim/src/biped_large/jump.rs b/voxygen/anim/src/biped_large/jump.rs index b31c4dbdf4..682fbe0e0c 100644 --- a/voxygen/anim/src/biped_large/jump.rs +++ b/voxygen/anim/src/biped_large/jump.rs @@ -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 } diff --git a/voxygen/anim/src/biped_large/mod.rs b/voxygen/anim/src/biped_large/mod.rs index 3acd952bbd..36613f0bde 100644 --- a/voxygen/anim/src/biped_large/mod.rs +++ b/voxygen/anim/src/biped_large/mod.rs @@ -79,8 +79,10 @@ impl Skeleton for BipedLargeSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { - let upper_torso = Mat4::::from(self.upper_torso); + let upper_torso = Mat4::::from(self.upper_torso) + * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 8.0); let torso_mat = base_mat * Mat4::::from(self.torso); let upper_torso_mat = torso_mat * upper_torso; diff --git a/voxygen/anim/src/biped_large/run.rs b/voxygen/anim/src/biped_large/run.rs index d88245ae8c..fce748be8a 100644 --- a/voxygen/anim/src/biped_large/run.rs +++ b/voxygen/anim/src/biped_large/run.rs @@ -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 { diff --git a/voxygen/anim/src/biped_small/mod.rs b/voxygen/anim/src/biped_small/mod.rs index 1d4c0c1e57..467fc2f6ed 100644 --- a/voxygen/anim/src/biped_small/mod.rs +++ b/voxygen/anim/src/biped_small/mod.rs @@ -47,8 +47,10 @@ impl Skeleton for BipedSmallSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { let chest_mat = base_mat * Mat4::::from(self.chest); + //TODO: * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0); let pants_mat = chest_mat * Mat4::::from(self.pants); let control_mat = chest_mat * Mat4::::from(self.control); let control_l_mat = Mat4::::from(self.control_l); diff --git a/voxygen/anim/src/bird_large/alpha.rs b/voxygen/anim/src/bird_large/alpha.rs index 39f18af013..68bdb5be32 100644 --- a/voxygen/anim/src/bird_large/alpha.rs +++ b/voxygen/anim/src/bird_large/alpha.rs @@ -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; diff --git a/voxygen/anim/src/bird_large/breathe.rs b/voxygen/anim/src/bird_large/breathe.rs index 518df0b4af..128c95e4a1 100644 --- a/voxygen/anim/src/bird_large/breathe.rs +++ b/voxygen/anim/src/bird_large/breathe.rs @@ -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, diff --git a/voxygen/anim/src/bird_large/dash.rs b/voxygen/anim/src/bird_large/dash.rs index 65717f32fd..cbe5015a20 100644 --- a/voxygen/anim/src/bird_large/dash.rs +++ b/voxygen/anim/src/bird_large/dash.rs @@ -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( diff --git a/voxygen/anim/src/bird_large/feed.rs b/voxygen/anim/src/bird_large/feed.rs index ccc6078cc5..f9a55077eb 100644 --- a/voxygen/anim/src/bird_large/feed.rs +++ b/voxygen/anim/src/bird_large/feed.rs @@ -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 diff --git a/voxygen/anim/src/bird_large/fly.rs b/voxygen/anim/src/bird_large/fly.rs index 9c042b87ae..33efc0a2c1 100644 --- a/voxygen/anim/src/bird_large/fly.rs +++ b/voxygen/anim/src/bird_large/fly.rs @@ -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 = diff --git a/voxygen/anim/src/bird_large/idle.rs b/voxygen/anim/src/bird_large/idle.rs index bcedcd54dc..061b431eb2 100644 --- a/voxygen/anim/src/bird_large/idle.rs +++ b/voxygen/anim/src/bird_large/idle.rs @@ -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 diff --git a/voxygen/anim/src/bird_large/mod.rs b/voxygen/anim/src/bird_large/mod.rs index 35a699d8c5..b2c21876c8 100644 --- a/voxygen/anim/src/bird_large/mod.rs +++ b/voxygen/anim/src/bird_large/mod.rs @@ -57,8 +57,13 @@ impl Skeleton for BirdLargeSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { - let chest_mat = base_mat * Mat4::::from(self.chest); + let chest_mat = base_mat + * Mat4::::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::::from(self.neck); let head_mat = neck_mat * Mat4::::from(self.head); let beak_mat = head_mat * Mat4::::from(self.beak); diff --git a/voxygen/anim/src/bird_large/run.rs b/voxygen/anim/src/bird_large/run.rs index b71ea77af3..a2b523f632 100644 --- a/voxygen/anim/src/bird_large/run.rs +++ b/voxygen/anim/src/bird_large/run.rs @@ -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) diff --git a/voxygen/anim/src/bird_large/shockwave.rs b/voxygen/anim/src/bird_large/shockwave.rs index 9208c62d42..c9ea5844e1 100644 --- a/voxygen/anim/src/bird_large/shockwave.rs +++ b/voxygen/anim/src/bird_large/shockwave.rs @@ -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; diff --git a/voxygen/anim/src/bird_large/shoot.rs b/voxygen/anim/src/bird_large/shoot.rs index 673afe07a5..4ed3787396 100644 --- a/voxygen/anim/src/bird_large/shoot.rs +++ b/voxygen/anim/src/bird_large/shoot.rs @@ -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, diff --git a/voxygen/anim/src/bird_large/stunned.rs b/voxygen/anim/src/bird_large/stunned.rs index 68e016e104..ba580c6b95 100644 --- a/voxygen/anim/src/bird_large/stunned.rs +++ b/voxygen/anim/src/bird_large/stunned.rs @@ -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; diff --git a/voxygen/anim/src/bird_large/summon.rs b/voxygen/anim/src/bird_large/summon.rs index 0853162d59..1f96750cf8 100644 --- a/voxygen/anim/src/bird_large/summon.rs +++ b/voxygen/anim/src/bird_large/summon.rs @@ -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, diff --git a/voxygen/anim/src/bird_large/swim.rs b/voxygen/anim/src/bird_large/swim.rs index f3eb1219cc..17100e2be2 100644 --- a/voxygen/anim/src/bird_large/swim.rs +++ b/voxygen/anim/src/bird_large/swim.rs @@ -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 diff --git a/voxygen/anim/src/bird_medium/mod.rs b/voxygen/anim/src/bird_medium/mod.rs index 52c0ae41fe..59610cc003 100644 --- a/voxygen/anim/src/bird_medium/mod.rs +++ b/voxygen/anim/src/bird_medium/mod.rs @@ -36,8 +36,10 @@ impl Skeleton for BirdMediumSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { let torso_mat = base_mat * Mat4::::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::::from(self.head)), diff --git a/voxygen/anim/src/character/idle.rs b/voxygen/anim/src/character/idle.rs index b8934df70a..30014247ae 100644 --- a/voxygen/anim/src/character/idle.rs +++ b/voxygen/anim/src/character/idle.rs @@ -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; diff --git a/voxygen/anim/src/character/jump.rs b/voxygen/anim/src/character/jump.rs index 0458c95ec3..bdbc86774d 100644 --- a/voxygen/anim/src/character/jump.rs +++ b/voxygen/anim/src/character/jump.rs @@ -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 { diff --git a/voxygen/anim/src/character/mod.rs b/voxygen/anim/src/character/mod.rs index cd393610af..e07effd307 100644 --- a/voxygen/anim/src/character/mod.rs +++ b/voxygen/anim/src/character/mod.rs @@ -98,8 +98,11 @@ impl Skeleton for CharacterSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { - let torso_mat = base_mat * Mat4::::from(self.torso); + let torso_mat = base_mat + * Mat4::::from(self.torso) + * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0); let chest_mat = torso_mat * Mat4::::from(self.chest); let head_mat = chest_mat * Mat4::::from(self.head); let shorts_mat = chest_mat * Mat4::::from(self.shorts); diff --git a/voxygen/anim/src/character/mount.rs b/voxygen/anim/src/character/mount.rs index 29ec687a56..da847e440e 100644 --- a/voxygen/anim/src/character/mount.rs +++ b/voxygen/anim/src/character/mount.rs @@ -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; diff --git a/voxygen/anim/src/character/run.rs b/voxygen/anim/src/character/run.rs index 354e5af649..3c838235dd 100644 --- a/voxygen/anim/src/character/run.rs +++ b/voxygen/anim/src/character/run.rs @@ -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 { diff --git a/voxygen/anim/src/character/stand.rs b/voxygen/anim/src/character/stand.rs index cbd66e2c7d..8275f31ce9 100644 --- a/voxygen/anim/src/character/stand.rs +++ b/voxygen/anim/src/character/stand.rs @@ -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; diff --git a/voxygen/anim/src/character/swim.rs b/voxygen/anim/src/character/swim.rs index a2e39457ad..d906e9afad 100644 --- a/voxygen/anim/src/character/swim.rs +++ b/voxygen/anim/src/character/swim.rs @@ -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) => { diff --git a/voxygen/anim/src/character/swimwield.rs b/voxygen/anim/src/character/swimwield.rs index 9a325fb8b0..038c1c9588 100644 --- a/voxygen/anim/src/character/swimwield.rs +++ b/voxygen/anim/src/character/swimwield.rs @@ -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); diff --git a/voxygen/anim/src/dragon/mod.rs b/voxygen/anim/src/dragon/mod.rs index 4b3221dc40..28efbd3562 100644 --- a/voxygen/anim/src/dragon/mod.rs +++ b/voxygen/anim/src/dragon/mod.rs @@ -43,8 +43,10 @@ impl Skeleton for DragonSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { let chest_front_mat = base_mat * Mat4::::from(self.chest_front); + //* Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 1.0); let chest_rear_mat = chest_front_mat * Mat4::::from(self.chest_rear); let head_lower_mat = chest_front_mat * Mat4::::from(self.head_lower); let wing_in_l_mat = chest_front_mat * Mat4::::from(self.wing_in_l); diff --git a/voxygen/anim/src/fish_medium/idle.rs b/voxygen/anim/src/fish_medium/idle.rs index fafb57efb5..57f8154489 100644 --- a/voxygen/anim/src/fish_medium/idle.rs +++ b/voxygen/anim/src/fish_medium/idle.rs @@ -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); diff --git a/voxygen/anim/src/fish_medium/mod.rs b/voxygen/anim/src/fish_medium/mod.rs index 6ed92d7259..b6a16b2a8f 100644 --- a/voxygen/anim/src/fish_medium/mod.rs +++ b/voxygen/anim/src/fish_medium/mod.rs @@ -33,8 +33,10 @@ impl Skeleton for FishMediumSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { - let chest_front_mat = base_mat * Mat4::::from(self.chest_front); + let chest_front_mat = + base_mat * Mat4::::from(self.chest_front) * Mat4::scaling_3d(1.0 / 11.0); let chest_back_mat = Mat4::::from(self.chest_back); let head_mat = Mat4::::from(self.head); diff --git a/voxygen/anim/src/fish_medium/swim.rs b/voxygen/anim/src/fish_medium/swim.rs index 657bb27bbd..879ef59cf3 100644 --- a/voxygen/anim/src/fish_medium/swim.rs +++ b/voxygen/anim/src/fish_medium/swim.rs @@ -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); diff --git a/voxygen/anim/src/fish_small/idle.rs b/voxygen/anim/src/fish_small/idle.rs index c1fca1f348..1c17f2bbc3 100644 --- a/voxygen/anim/src/fish_small/idle.rs +++ b/voxygen/anim/src/fish_small/idle.rs @@ -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); diff --git a/voxygen/anim/src/fish_small/mod.rs b/voxygen/anim/src/fish_small/mod.rs index 198ce1fac7..7b00acfbb8 100644 --- a/voxygen/anim/src/fish_small/mod.rs +++ b/voxygen/anim/src/fish_small/mod.rs @@ -30,8 +30,9 @@ impl Skeleton for FishSmallSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { - let chest_mat = base_mat * Mat4::::from(self.chest); + let chest_mat = base_mat * Mat4::::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), diff --git a/voxygen/anim/src/fish_small/swim.rs b/voxygen/anim/src/fish_small/swim.rs index 8f1d94fe85..bbff763433 100644 --- a/voxygen/anim/src/fish_small/swim.rs +++ b/voxygen/anim/src/fish_small/swim.rs @@ -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); diff --git a/voxygen/anim/src/fixture/mod.rs b/voxygen/anim/src/fixture/mod.rs index f24e2918f8..26f310ae2a 100644 --- a/voxygen/anim/src/fixture/mod.rs +++ b/voxygen/anim/src/fixture/mod.rs @@ -31,6 +31,7 @@ impl Skeleton for FixtureSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + (): Self::Body, ) -> Offsets { buf[0] = make_bone(base_mat); Offsets { diff --git a/voxygen/anim/src/golem/idle.rs b/voxygen/anim/src/golem/idle.rs index 4bf88aa388..1a17b9c075 100644 --- a/voxygen/anim/src/golem/idle.rs +++ b/voxygen/anim/src/golem/idle.rs @@ -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; diff --git a/voxygen/anim/src/golem/mod.rs b/voxygen/anim/src/golem/mod.rs index af19354a00..8096567c7f 100644 --- a/voxygen/anim/src/golem/mod.rs +++ b/voxygen/anim/src/golem/mod.rs @@ -47,8 +47,11 @@ impl Skeleton for GolemSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { - let torso_mat = base_mat * Mat4::::from(self.torso); + let torso_mat = base_mat + * Mat4::::from(self.torso) + * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 8.0); let upper_torso_mat = torso_mat * Mat4::::from(self.upper_torso); let lower_torso_mat = upper_torso_mat * Mat4::::from(self.lower_torso); let leg_l_mat = lower_torso_mat * Mat4::::from(self.leg_l); diff --git a/voxygen/anim/src/golem/run.rs b/voxygen/anim/src/golem/run.rs index d9f0fe504a..9ac7a7ddd4 100644 --- a/voxygen/anim/src/golem/run.rs +++ b/voxygen/anim/src/golem/run.rs @@ -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; diff --git a/voxygen/anim/src/lib.rs b/voxygen/anim/src/lib.rs index 39d7530bbf..4077a42807 100644 --- a/voxygen/anim/src/lib.rs +++ b/voxygen/anim/src/lib.rs @@ -117,6 +117,7 @@ pub trait Skeleton: Send + Sync + 'static { &self, base_mat: Mat4, buf: &mut [FigureBoneData; MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets; } @@ -124,10 +125,11 @@ pub fn compute_matrices( skeleton: &S, base_mat: Mat4, 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( #[allow(clippy::type_complexity)] let compute_fn: voxygen_dynlib::Symbol< - fn(&S, Mat4, &mut [FigureBoneData; MAX_BONE_COUNT]) -> Offsets, + fn(&S, Mat4, &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( ) }); - compute_fn(skeleton, base_mat, buf) + compute_fn(skeleton, base_mat, buf, body) } } diff --git a/voxygen/anim/src/object/mod.rs b/voxygen/anim/src/object/mod.rs index acafbd4497..6ef7a2d826 100644 --- a/voxygen/anim/src/object/mod.rs +++ b/voxygen/anim/src/object/mod.rs @@ -29,6 +29,7 @@ impl Skeleton for ObjectSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { let bone0_mat = base_mat * Mat4::::from(self.bone0); diff --git a/voxygen/anim/src/quadruped_low/idle.rs b/voxygen/anim/src/quadruped_low/idle.rs index c0601d27d4..93c4776ffb 100644 --- a/voxygen/anim/src/quadruped_low/idle.rs +++ b/voxygen/anim/src/quadruped_low/idle.rs @@ -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; diff --git a/voxygen/anim/src/quadruped_low/jump.rs b/voxygen/anim/src/quadruped_low/jump.rs index faf2c80c2e..0f8a583c48 100644 --- a/voxygen/anim/src/quadruped_low/jump.rs +++ b/voxygen/anim/src/quadruped_low/jump.rs @@ -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; diff --git a/voxygen/anim/src/quadruped_low/mod.rs b/voxygen/anim/src/quadruped_low/mod.rs index 7357813f1e..382f702854 100644 --- a/voxygen/anim/src/quadruped_low/mod.rs +++ b/voxygen/anim/src/quadruped_low/mod.rs @@ -48,8 +48,11 @@ impl Skeleton for QuadrupedLowSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { - let chest_mat = base_mat * Mat4::::from(self.chest); + let chest_mat = base_mat + * Mat4::::from(self.chest) + * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0); let tail_front = chest_mat * Mat4::::from(self.tail_front); let head_lower_mat = chest_mat * Mat4::::from(self.head_lower); let head_upper_mat = head_lower_mat * Mat4::::from(self.head_upper); diff --git a/voxygen/anim/src/quadruped_low/run.rs b/voxygen/anim/src/quadruped_low/run.rs index e70620e5b4..349c2c717e 100644 --- a/voxygen/anim/src/quadruped_low/run.rs +++ b/voxygen/anim/src/quadruped_low/run.rs @@ -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; diff --git a/voxygen/anim/src/quadruped_medium/jump.rs b/voxygen/anim/src/quadruped_medium/jump.rs index d03ca09a69..1ab939a040 100644 --- a/voxygen/anim/src/quadruped_medium/jump.rs +++ b/voxygen/anim/src/quadruped_medium/jump.rs @@ -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; diff --git a/voxygen/anim/src/quadruped_medium/mod.rs b/voxygen/anim/src/quadruped_medium/mod.rs index 9ac7da9031..83387f5cdd 100644 --- a/voxygen/anim/src/quadruped_medium/mod.rs +++ b/voxygen/anim/src/quadruped_medium/mod.rs @@ -54,8 +54,11 @@ impl Skeleton for QuadrupedMediumSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { - let torso_front_mat = base_mat * Mat4::::from(self.torso_front); + let torso_front_mat = base_mat + * Mat4::::from(self.torso_front) + * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 11.0); let torso_back_mat = torso_front_mat * Mat4::::from(self.torso_back); let neck_mat = torso_front_mat * Mat4::::from(self.neck); let leg_fl_mat = torso_front_mat * Mat4::::from(self.leg_fl); diff --git a/voxygen/anim/src/quadruped_medium/run.rs b/voxygen/anim/src/quadruped_medium/run.rs index 60c663ce2c..96414103f0 100644 --- a/voxygen/anim/src/quadruped_medium/run.rs +++ b/voxygen/anim/src/quadruped_medium/run.rs @@ -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; diff --git a/voxygen/anim/src/quadruped_small/feed.rs b/voxygen/anim/src/quadruped_small/feed.rs index f4588c78e5..2b8213f532 100644 --- a/voxygen/anim/src/quadruped_small/feed.rs +++ b/voxygen/anim/src/quadruped_small/feed.rs @@ -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) diff --git a/voxygen/anim/src/quadruped_small/idle.rs b/voxygen/anim/src/quadruped_small/idle.rs index 88c9d34de5..a4bf1a6ef9 100644 --- a/voxygen/anim/src/quadruped_small/idle.rs +++ b/voxygen/anim/src/quadruped_small/idle.rs @@ -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 = diff --git a/voxygen/anim/src/quadruped_small/jump.rs b/voxygen/anim/src/quadruped_small/jump.rs index 9647b52007..6c924a9448 100644 --- a/voxygen/anim/src/quadruped_small/jump.rs +++ b/voxygen/anim/src/quadruped_small/jump.rs @@ -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); diff --git a/voxygen/anim/src/quadruped_small/mod.rs b/voxygen/anim/src/quadruped_small/mod.rs index 537257b84a..a69ed01f12 100644 --- a/voxygen/anim/src/quadruped_small/mod.rs +++ b/voxygen/anim/src/quadruped_small/mod.rs @@ -40,8 +40,11 @@ impl Skeleton for QuadrupedSmallSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { - let chest_mat = base_mat * Mat4::::from(self.chest); + let chest_mat = base_mat + * Mat4::::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::::from(self.head)), diff --git a/voxygen/anim/src/quadruped_small/run.rs b/voxygen/anim/src/quadruped_small/run.rs index 15e33f001e..ef807671bd 100644 --- a/voxygen/anim/src/quadruped_small/run.rs +++ b/voxygen/anim/src/quadruped_small/run.rs @@ -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, diff --git a/voxygen/anim/src/ship/mod.rs b/voxygen/anim/src/ship/mod.rs index c9c4cb7ef4..4b69adf237 100644 --- a/voxygen/anim/src/ship/mod.rs +++ b/voxygen/anim/src/ship/mod.rs @@ -29,6 +29,7 @@ impl Skeleton for ShipSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { let bone0_mat = base_mat * Mat4::::from(self.bone0); diff --git a/voxygen/anim/src/theropod/idle.rs b/voxygen/anim/src/theropod/idle.rs index e91b1b895a..b4a3b492cb 100644 --- a/voxygen/anim/src/theropod/idle.rs +++ b/voxygen/anim/src/theropod/idle.rs @@ -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) diff --git a/voxygen/anim/src/theropod/jump.rs b/voxygen/anim/src/theropod/jump.rs index fde92cdc0f..aa9bb049cc 100644 --- a/voxygen/anim/src/theropod/jump.rs +++ b/voxygen/anim/src/theropod/jump.rs @@ -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); diff --git a/voxygen/anim/src/theropod/mod.rs b/voxygen/anim/src/theropod/mod.rs index 75f0852b73..1794dfda01 100644 --- a/voxygen/anim/src/theropod/mod.rs +++ b/voxygen/anim/src/theropod/mod.rs @@ -47,8 +47,11 @@ impl Skeleton for TheropodSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], + body: Self::Body, ) -> Offsets { - let chest_front_mat = base_mat * Mat4::::from(self.chest_front); + let chest_front_mat = base_mat + * Mat4::::from(self.chest_front) + * Mat4::scaling_3d(SkeletonAttr::from(&body).scaler / 1.0); let neck_mat = chest_front_mat * Mat4::::from(self.neck); let head_mat = neck_mat * Mat4::::from(self.head); let chest_back_mat = chest_front_mat * Mat4::::from(self.chest_back); diff --git a/voxygen/anim/src/theropod/run.rs b/voxygen/anim/src/theropod/run.rs index 615bce9e03..097bba1c84 100644 --- a/voxygen/anim/src/theropod/run.rs +++ b/voxygen/anim/src/theropod/run.rs @@ -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) diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 92c9a26433..22c469c68e 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -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 { + 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 FigureState { - 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 FigureState { }: &FigureUpdateCommonParameters, state_animation_rate: f32, model: Option<&FigureModelEntry>, + // 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 FigureState { ); 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); diff --git a/voxygen/src/scene/simple.rs b/voxygen/src/scene/simple.rs index df6ef56439..50c923385a 100644 --- a/voxygen/src/scene/simple.rs +++ b/voxygen/src/scene/simple.rs @@ -71,7 +71,7 @@ pub struct Scene { col_lights: FigureColLights, backdrop: Option<(FigureModelEntry<1>, FigureState)>, figure_model_cache: FigureModelCache, - figure_state: FigureState, + figure_state: Option>, //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)); } } }