diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index 83433ddcc1..5138dc9580 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -663,41 +663,41 @@ impl Body { match self { Body::QuadrupedMedium(quadruped_medium) => { match (quadruped_medium.species, quadruped_medium.body_type) { - (quadruped_medium::Species::Grolgar, _) => Vec3::from([0.5, 0.5, 1.8]), - (quadruped_medium::Species::Saber, _) => Vec3::from([0.3, 0.3, 1.3]), - (quadruped_medium::Species::Tiger, _) => Vec3::from([0.2, 0.2, 1.4]), - (quadruped_medium::Species::Tuskram, _) => Vec3::from([-0.5, -0.5, 1.5]), - (quadruped_medium::Species::Lion, _) => Vec3::from([0.3, 0.3, 1.5]), - (quadruped_medium::Species::Tarasque, _) => Vec3::from([0.6, 0.6, 2.0]), - (quadruped_medium::Species::Wolf, _) => Vec3::from([0.5, 0.5, 1.3]), - (quadruped_medium::Species::Frostfang, _) => Vec3::from([0.5, 0.5, 1.2]), - (quadruped_medium::Species::Mouflon, _) => Vec3::from([0.3, 0.3, 1.2]), - (quadruped_medium::Species::Catoblepas, _) => Vec3::from([0.0, 0.0, 2.0]), - (quadruped_medium::Species::Bonerattler, _) => Vec3::from([0.5, 0.5, 1.2]), - (quadruped_medium::Species::Deer, _) => Vec3::from([0.2, 0.2, 1.3]), - (quadruped_medium::Species::Hirdrasil, _) => Vec3::from([0.0, 0.0, 1.4]), - (quadruped_medium::Species::Roshwalr, _) => Vec3::from([0.5, 0.5, 1.8]), - (quadruped_medium::Species::Donkey, _) => Vec3::from([0.5, 0.5, 1.5]), - (quadruped_medium::Species::Camel, _) => Vec3::from([-0.1, -0.1, 2.8]), - (quadruped_medium::Species::Zebra, _) => Vec3::from([0.5, 0.5, 1.8]), - (quadruped_medium::Species::Antelope, _) => Vec3::from([0.3, 0.3, 1.4]), - (quadruped_medium::Species::Kelpie, _) => Vec3::from([0.5, 0.5, 1.9]), - (quadruped_medium::Species::Horse, _) => Vec3::from([0.1, 0.1, 2.0]), - (quadruped_medium::Species::Barghest, _) => Vec3::from([0.5, 0.5, 2.2]), + (quadruped_medium::Species::Grolgar, _) => Vec3::from([0.5, 0.5, 0.0]), + (quadruped_medium::Species::Saber, _) => Vec3::from([0.3, 0.3, 0.0]), + (quadruped_medium::Species::Tiger, _) => Vec3::from([0.2, 0.2, 0.0]), + (quadruped_medium::Species::Tuskram, _) => Vec3::from([-0.5, -0.5, 0.0]), + (quadruped_medium::Species::Lion, _) => Vec3::from([0.3, 0.3, 0.0]), + (quadruped_medium::Species::Tarasque, _) => Vec3::from([0.6, 0.6, 0.0]), + (quadruped_medium::Species::Wolf, _) => Vec3::from([0.5, 0.5, 0.0]), + (quadruped_medium::Species::Frostfang, _) => Vec3::from([0.5, 0.5, 0.0]), + (quadruped_medium::Species::Mouflon, _) => Vec3::from([0.3, 0.3, 0.0]), + (quadruped_medium::Species::Catoblepas, _) => Vec3::from([0.0, 0.0, 0.0]), + (quadruped_medium::Species::Bonerattler, _) => Vec3::from([0.5, 0.5, 0.0]), + (quadruped_medium::Species::Deer, _) => Vec3::from([0.2, 0.2, 0.0]), + (quadruped_medium::Species::Hirdrasil, _) => Vec3::from([0.0, 0.0, 0.0]), + (quadruped_medium::Species::Roshwalr, _) => Vec3::from([0.5, 0.5, 0.0]), + (quadruped_medium::Species::Donkey, _) => Vec3::from([0.5, 0.5, 0.0]), + (quadruped_medium::Species::Camel, _) => Vec3::from([-0.1, -0.1, 0.0]), + (quadruped_medium::Species::Zebra, _) => Vec3::from([0.5, 0.5, 0.0]), + (quadruped_medium::Species::Antelope, _) => Vec3::from([0.3, 0.3, 0.0]), + (quadruped_medium::Species::Kelpie, _) => Vec3::from([0.5, 0.5, 0.0]), + (quadruped_medium::Species::Horse, _) => Vec3::from([0.1, 0.1, 0.0]), + (quadruped_medium::Species::Barghest, _) => Vec3::from([0.5, 0.5, 0.0]), (quadruped_medium::Species::Cattle, quadruped_medium::BodyType::Male) => { - Vec3::from([0.5, 0.5, 2.6]) + Vec3::from([0.5, 0.5, 0.0]) }, (quadruped_medium::Species::Cattle, quadruped_medium::BodyType::Female) => { - Vec3::from([0.7, 0.7, 2.2]) + Vec3::from([0.7, 0.7, 0.0]) }, - (quadruped_medium::Species::Darkhound, _) => Vec3::from([0.5, 0.5, 1.4]), - (quadruped_medium::Species::Highland, _) => Vec3::from([0.5, 0.5, 2.3]), - (quadruped_medium::Species::Yak, _) => Vec3::from([0.0, 0.0, 3.0]), - (quadruped_medium::Species::Panda, _) => Vec3::from([-0.2, -0.2, 1.4]), - (quadruped_medium::Species::Bear, _) => Vec3::from([-0.4, -0.4, 2.5]), - (quadruped_medium::Species::Dreadhorn, _) => Vec3::from([0.2, 0.2, 3.5]), - (quadruped_medium::Species::Moose, _) => Vec3::from([-0.6, -0.6, 2.1]), - (quadruped_medium::Species::Snowleopard, _) => Vec3::from([-0.5, -0.5, 1.4]), + (quadruped_medium::Species::Darkhound, _) => Vec3::from([0.5, 0.5, 0.0]), + (quadruped_medium::Species::Highland, _) => Vec3::from([0.5, 0.5, 0.0]), + (quadruped_medium::Species::Yak, _) => Vec3::from([0.0, 0.0, 0.0]), + (quadruped_medium::Species::Panda, _) => Vec3::from([-0.2, -0.2, 0.0]), + (quadruped_medium::Species::Bear, _) => Vec3::from([-0.4, -0.4, 0.0]), + (quadruped_medium::Species::Dreadhorn, _) => Vec3::from([0.2, 0.2, 0.0]), + (quadruped_medium::Species::Moose, _) => Vec3::from([-0.6, -0.6, 0.0]), + (quadruped_medium::Species::Snowleopard, _) => Vec3::from([-0.5, -0.5, 0.0]), } }, Body::Ship(ship::Body::DefaultAirship) => Vec3::from([0.0, 0.0, 10.0]), diff --git a/voxygen/anim/src/biped_large/mod.rs b/voxygen/anim/src/biped_large/mod.rs index 1db51f23b6..d8d75f1e59 100644 --- a/voxygen/anim/src/biped_large/mod.rs +++ b/voxygen/anim/src/biped_large/mod.rs @@ -77,7 +77,7 @@ impl Skeleton for BipedLargeSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let upper_torso = Mat4::::from(self.upper_torso); let torso_mat = base_mat * Mat4::::from(self.torso); @@ -124,7 +124,7 @@ impl Skeleton for BipedLargeSkeleton { // FIXME: Should this be control_l_mat? make_bone(upper_torso_mat * control_mat * hand_l_mat * Mat4::::from(self.hold)), ]; - Vec3::default() + [Vec3::default(), Vec3::default()] } } diff --git a/voxygen/anim/src/biped_small/mod.rs b/voxygen/anim/src/biped_small/mod.rs index ba89f7c4c4..09d22e4ea8 100644 --- a/voxygen/anim/src/biped_small/mod.rs +++ b/voxygen/anim/src/biped_small/mod.rs @@ -47,7 +47,7 @@ impl Skeleton for BipedSmallSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let chest_mat = base_mat * Mat4::::from(self.chest); let pants_mat = chest_mat * Mat4::::from(self.pants); let control_mat = chest_mat * Mat4::::from(self.control); @@ -64,7 +64,7 @@ impl Skeleton for BipedSmallSkeleton { make_bone(base_mat * Mat4::::from(self.foot_l)), make_bone(base_mat * Mat4::::from(self.foot_r)), ]; - Vec3::default() + [Vec3::default(), Vec3::default()] } } diff --git a/voxygen/anim/src/bird_large/mod.rs b/voxygen/anim/src/bird_large/mod.rs index 55ac715d38..750665229e 100644 --- a/voxygen/anim/src/bird_large/mod.rs +++ b/voxygen/anim/src/bird_large/mod.rs @@ -55,7 +55,7 @@ impl Skeleton for BirdLargeSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let chest_mat = base_mat * Mat4::::from(self.chest); let neck_mat = chest_mat * Mat4::::from(self.neck); let head_mat = neck_mat * Mat4::::from(self.head); @@ -91,7 +91,7 @@ impl Skeleton for BirdLargeSkeleton { make_bone(foot_l_mat), make_bone(foot_r_mat), ]; - Vec3::default() + [Vec3::default(), (chest_mat * Vec4::one()).xyz()] } } diff --git a/voxygen/anim/src/bird_medium/mod.rs b/voxygen/anim/src/bird_medium/mod.rs index ab72ea8173..5725ad3556 100644 --- a/voxygen/anim/src/bird_medium/mod.rs +++ b/voxygen/anim/src/bird_medium/mod.rs @@ -36,7 +36,7 @@ impl Skeleton for BirdMediumSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let torso_mat = base_mat * Mat4::::from(self.torso); *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [ @@ -48,7 +48,7 @@ impl Skeleton for BirdMediumSkeleton { make_bone(base_mat * Mat4::::from(self.leg_l)), make_bone(base_mat * Mat4::::from(self.leg_r)), ]; - Vec3::default() + [Vec3::default(), (torso_mat * Vec4::one()).xyz()] } } diff --git a/voxygen/anim/src/character/mod.rs b/voxygen/anim/src/character/mod.rs index ea47f85433..ed7ec769c8 100644 --- a/voxygen/anim/src/character/mod.rs +++ b/voxygen/anim/src/character/mod.rs @@ -97,7 +97,7 @@ impl Skeleton for CharacterSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let torso_mat = base_mat * Mat4::::from(self.torso); let chest_mat = torso_mat * Mat4::::from(self.chest); let head_mat = chest_mat * Mat4::::from(self.head); @@ -133,7 +133,10 @@ impl Skeleton for CharacterSkeleton { // FIXME: Should this be control_l_mat? make_bone(control_mat * hand_l_mat * Mat4::::from(self.hold)), ]; - (lantern_mat * Vec4::new(0.0, 0.0, -4.0, 1.0)).xyz() + [ + (lantern_mat * Vec4::new(0.0, 0.0, -4.0, 1.0)).xyz(), + (chest_mat * Vec4::zero()).xyz(), + ] } } diff --git a/voxygen/anim/src/character/mount.rs b/voxygen/anim/src/character/mount.rs index 3c9b6cef52..f9d723ed0d 100644 --- a/voxygen/anim/src/character/mount.rs +++ b/voxygen/anim/src/character/mount.rs @@ -17,6 +17,7 @@ impl Animation for MountAnimation { Vec3, Vec3, Vec3, + Vec3, ); type Skeleton = CharacterSkeleton; @@ -34,6 +35,7 @@ impl Animation for MountAnimation { avg_vel, orientation, last_ori, + mount_offset, ): Self::Dependency, anim_time: f32, _rate: &mut f32, @@ -43,7 +45,6 @@ impl Animation for MountAnimation { let slow = (anim_time * 1.0).sin(); let slowa = (anim_time * 1.0 + PI / 2.0).sin(); - let fast = (anim_time * 12.0).sin(); let stop = (anim_time * 3.0).min(PI / 2.0).sin(); let head_look = Vec2::new( @@ -80,14 +81,7 @@ impl Animation for MountAnimation { next.head.orientation = Quaternion::rotation_z(head_look.x + slow * 0.2 - slow * 0.1) * Quaternion::rotation_x((0.4 + slowa * -0.1 + slow * 0.1 + head_look.y).abs()); - next.chest.position = Vec3::new( - 0.0, - s_a.chest.0 + stop * -0.4, - s_a.chest.1 - + slow * 0.1 - + stop * -0.8 - + fast * (velocity.xy().magnitude() / 10.0).min(1.7), - ); + next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + mount_offset.z * 14.0); next.chest.orientation = Quaternion::rotation_x(-0.6 + stop * 0.15 + x_tilt * (canceler * 6.0).min(2.0)) * Quaternion::rotation_y(tilt * 3.1); @@ -116,11 +110,21 @@ impl Animation for MountAnimation { next.hand_r.orientation = Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(PI / 2.0); - next.foot_l.position = Vec3::new(-s_a.foot.0 - 2.0, 4.0 + s_a.foot.1, s_a.foot.2); - next.foot_l.orientation = Quaternion::rotation_x(slow * 0.1 + stop * 0.4 + slow * 0.1); + next.foot_l.position = Vec3::new( + -s_a.foot.0 - 2.0, + 4.0 + s_a.foot.1, + s_a.foot.2 + mount_offset.z * 14.0, + ); + next.foot_l.orientation = Quaternion::rotation_x(slow * 0.1 + stop * 0.4 + slow * 0.1) + * Quaternion::rotation_y(0.5); - next.foot_r.position = Vec3::new(s_a.foot.0 + 2.0, 4.0 + s_a.foot.1, s_a.foot.2); - next.foot_r.orientation = Quaternion::rotation_x(slowa * 0.1 + stop * 0.4 + slowa * 0.1); + next.foot_r.position = Vec3::new( + s_a.foot.0 + 2.0, + 4.0 + s_a.foot.1, + s_a.foot.2 + mount_offset.z * 14.0, + ); + next.foot_r.orientation = Quaternion::rotation_x(slowa * 0.1 + stop * 0.4 + slowa * 0.1) + * Quaternion::rotation_y(-0.5); next.shoulder_l.position = Vec3::new(-s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2); next.shoulder_l.orientation = Quaternion::rotation_x(0.0); diff --git a/voxygen/anim/src/dragon/mod.rs b/voxygen/anim/src/dragon/mod.rs index 9e5d39d200..13a2c0f1c3 100644 --- a/voxygen/anim/src/dragon/mod.rs +++ b/voxygen/anim/src/dragon/mod.rs @@ -43,7 +43,7 @@ impl Skeleton for DragonSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let chest_front_mat = base_mat * Mat4::::from(self.chest_front); let chest_rear_mat = chest_front_mat * Mat4::::from(self.chest_rear); let head_lower_mat = chest_front_mat * Mat4::::from(self.head_lower); @@ -69,7 +69,7 @@ impl Skeleton for DragonSkeleton { make_bone(chest_rear_mat * Mat4::::from(self.foot_bl)), make_bone(chest_rear_mat * Mat4::::from(self.foot_br)), ]; - Vec3::default() + [Vec3::default(), (chest_front_mat * Vec4::one()).xyz()] } } diff --git a/voxygen/anim/src/fish_medium/mod.rs b/voxygen/anim/src/fish_medium/mod.rs index 8c68c9e4d8..1545332d4e 100644 --- a/voxygen/anim/src/fish_medium/mod.rs +++ b/voxygen/anim/src/fish_medium/mod.rs @@ -33,7 +33,7 @@ impl Skeleton for FishMediumSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let chest_front_mat = base_mat * Mat4::::from(self.chest_front); let chest_back_mat = Mat4::::from(self.chest_back); let head_mat = Mat4::::from(self.head); @@ -47,7 +47,7 @@ impl Skeleton for FishMediumSkeleton { make_bone(chest_front_mat * Mat4::::from(self.fin_l)), make_bone(chest_front_mat * Mat4::::from(self.fin_r)), ]; - Vec3::default() + [Vec3::default(), Vec3::default()] } } diff --git a/voxygen/anim/src/fish_small/mod.rs b/voxygen/anim/src/fish_small/mod.rs index 0a644da947..2a8a232539 100644 --- a/voxygen/anim/src/fish_small/mod.rs +++ b/voxygen/anim/src/fish_small/mod.rs @@ -30,7 +30,7 @@ impl Skeleton for FishSmallSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let chest_mat = base_mat * Mat4::::from(self.chest); *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [ @@ -39,7 +39,7 @@ impl Skeleton for FishSmallSkeleton { make_bone(chest_mat * Mat4::::from(self.fin_l)), make_bone(chest_mat * Mat4::::from(self.fin_r)), ]; - Vec3::default() + [Vec3::default(), Vec3::default()] } } diff --git a/voxygen/anim/src/fixture/mod.rs b/voxygen/anim/src/fixture/mod.rs index edc2c38d80..9c6941ee59 100644 --- a/voxygen/anim/src/fixture/mod.rs +++ b/voxygen/anim/src/fixture/mod.rs @@ -31,9 +31,9 @@ impl Skeleton for FixtureSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { buf[0] = make_bone(base_mat); - Vec3::default() + [Vec3::default(), Vec3::default()] } } diff --git a/voxygen/anim/src/golem/mod.rs b/voxygen/anim/src/golem/mod.rs index ef5acd9057..a0d7e39502 100644 --- a/voxygen/anim/src/golem/mod.rs +++ b/voxygen/anim/src/golem/mod.rs @@ -47,7 +47,7 @@ impl Skeleton for GolemSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let torso_mat = base_mat * Mat4::::from(self.torso); let upper_torso_mat = torso_mat * Mat4::::from(self.upper_torso); let lower_torso_mat = upper_torso_mat * Mat4::::from(self.lower_torso); @@ -70,7 +70,7 @@ impl Skeleton for GolemSkeleton { make_bone(leg_l_mat * Mat4::::from(self.foot_l)), make_bone(leg_r_mat * Mat4::::from(self.foot_r)), ]; - Vec3::default() + [Vec3::default(), (torso_mat * Vec4::one()).xyz()] } } diff --git a/voxygen/anim/src/lib.rs b/voxygen/anim/src/lib.rs index 733c4ec174..f831b3ed7c 100644 --- a/voxygen/anim/src/lib.rs +++ b/voxygen/anim/src/lib.rs @@ -102,14 +102,14 @@ pub trait Skeleton: Send + Sync + 'static { &self, base_mat: Mat4, buf: &mut [FigureBoneData; MAX_BONE_COUNT], - ) -> Vec3; + ) -> [Vec3; 2]; } pub fn compute_matrices( skeleton: &S, base_mat: Mat4, buf: &mut [FigureBoneData; MAX_BONE_COUNT], -) -> Vec3 { +) -> [Vec3; 2] { #[cfg(not(feature = "use-dyn-lib"))] { S::compute_matrices_inner(skeleton, base_mat, buf) @@ -120,7 +120,7 @@ pub fn compute_matrices( let lib = &lock.as_ref().unwrap().lib; let compute_fn: libloading::Symbol< - fn(&S, Mat4, &mut [FigureBoneData; MAX_BONE_COUNT]) -> Vec3, + fn(&S, Mat4, &mut [FigureBoneData; MAX_BONE_COUNT]) -> [Vec3; 2], > = unsafe { lib.get(S::COMPUTE_FN) }.unwrap_or_else(|e| { panic!( "Trying to use: {} but had error: {:?}", diff --git a/voxygen/anim/src/object/mod.rs b/voxygen/anim/src/object/mod.rs index 7a58390ed0..1abd6f46b6 100644 --- a/voxygen/anim/src/object/mod.rs +++ b/voxygen/anim/src/object/mod.rs @@ -29,14 +29,14 @@ impl Skeleton for ObjectSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let bone0_mat = base_mat * Mat4::::from(self.bone0); *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [ make_bone(bone0_mat * Mat4::scaling_3d(1.0 / 11.0)), make_bone(Mat4::::from(self.bone1) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */ ]; - Vec3::unit_z() * 0.5 + [Vec3::unit_z() * 0.5, Vec3::default()] } } diff --git a/voxygen/anim/src/quadruped_low/mod.rs b/voxygen/anim/src/quadruped_low/mod.rs index 63d2dc644c..7b57d16334 100644 --- a/voxygen/anim/src/quadruped_low/mod.rs +++ b/voxygen/anim/src/quadruped_low/mod.rs @@ -48,7 +48,7 @@ impl Skeleton for QuadrupedLowSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let chest_mat = base_mat * Mat4::::from(self.chest); let tail_front = chest_mat * Mat4::::from(self.tail_front); let head_lower_mat = chest_mat * Mat4::::from(self.head_lower); @@ -66,7 +66,7 @@ impl Skeleton for QuadrupedLowSkeleton { make_bone(chest_mat * Mat4::::from(self.foot_bl)), make_bone(chest_mat * Mat4::::from(self.foot_br)), ]; - Vec3::default() + [Vec3::default(), (chest_mat * Vec4::one()).xyz()] } } diff --git a/voxygen/anim/src/quadruped_medium/mod.rs b/voxygen/anim/src/quadruped_medium/mod.rs index c4ae82537f..c78f752e34 100644 --- a/voxygen/anim/src/quadruped_medium/mod.rs +++ b/voxygen/anim/src/quadruped_medium/mod.rs @@ -53,7 +53,7 @@ impl Skeleton for QuadrupedMediumSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let torso_front_mat = base_mat * Mat4::::from(self.torso_front); let torso_back_mat = torso_front_mat * Mat4::::from(self.torso_back); let neck_mat = torso_front_mat * Mat4::::from(self.neck); @@ -80,7 +80,7 @@ impl Skeleton for QuadrupedMediumSkeleton { make_bone(leg_bl_mat * Mat4::::from(self.foot_bl)), make_bone(leg_br_mat * Mat4::::from(self.foot_br)), ]; - Vec3::default() + [Vec3::default(), (torso_front_mat * Vec4::one()).xyz()] } } diff --git a/voxygen/anim/src/quadruped_small/mod.rs b/voxygen/anim/src/quadruped_small/mod.rs index 5850882906..e04c82bbd4 100644 --- a/voxygen/anim/src/quadruped_small/mod.rs +++ b/voxygen/anim/src/quadruped_small/mod.rs @@ -40,7 +40,7 @@ impl Skeleton for QuadrupedSmallSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let chest_mat = base_mat * Mat4::::from(self.chest); *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [ @@ -52,7 +52,7 @@ impl Skeleton for QuadrupedSmallSkeleton { make_bone(chest_mat * Mat4::::from(self.leg_br)), make_bone(chest_mat * Mat4::::from(self.tail)), ]; - Vec3::default() + [Vec3::default(), (chest_mat * Vec4::one()).xyz()] } } diff --git a/voxygen/anim/src/ship/mod.rs b/voxygen/anim/src/ship/mod.rs index f9c86cf033..fb2d6c689a 100644 --- a/voxygen/anim/src/ship/mod.rs +++ b/voxygen/anim/src/ship/mod.rs @@ -29,7 +29,7 @@ impl Skeleton for ShipSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let bone0_mat = base_mat * Mat4::::from(self.bone0); *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [ @@ -38,7 +38,7 @@ impl Skeleton for ShipSkeleton { make_bone(bone0_mat * Mat4::::from(self.bone2) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */ make_bone(bone0_mat * Mat4::::from(self.bone3) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */ ]; - Vec3::unit_z() * 0.5 + [Vec3::unit_z() * 0.5, (bone0_mat * Vec4::one()).xyz()] } } diff --git a/voxygen/anim/src/theropod/mod.rs b/voxygen/anim/src/theropod/mod.rs index 900b9d7d51..05103f017e 100644 --- a/voxygen/anim/src/theropod/mod.rs +++ b/voxygen/anim/src/theropod/mod.rs @@ -47,7 +47,7 @@ impl Skeleton for TheropodSkeleton { &self, base_mat: Mat4, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Vec3 { + ) -> [Vec3; 2] { let chest_front_mat = base_mat * Mat4::::from(self.chest_front); let neck_mat = chest_front_mat * Mat4::::from(self.neck); let head_mat = neck_mat * Mat4::::from(self.head); @@ -71,7 +71,7 @@ impl Skeleton for TheropodSkeleton { make_bone(leg_l_mat * Mat4::::from(self.foot_l)), make_bone(leg_r_mat * Mat4::::from(self.foot_r)), ]; - Vec3::default() + [Vec3::default(), (chest_front_mat * Vec4::one()).xyz()] } } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index ab97c2b774..e0fc3ed5e6 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -30,11 +30,12 @@ use common::{ inventory::slot::EquipSlot, item::{Hands, ItemKind, ToolKind}, Body, CharacterState, Controller, Health, Inventory, Item, Last, LightAnimation, - LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale, Vel, + LightEmitter, Mounting, Ori, PhysicsState, PoiseState, Pos, Scale, Vel, }, resources::DeltaTime, states::utils::StageSection, terrain::TerrainChunk, + uid::UidAllocator, util::Dir, vol::RectRasterableVol, }; @@ -48,7 +49,7 @@ use core::{ }; use guillotiere::AtlasAllocator; use hashbrown::HashMap; -use specs::{Entity as EcsEntity, Join, LazyUpdate, WorldExt}; +use specs::{saveload::MarkerAllocator, Entity as EcsEntity, Join, LazyUpdate, WorldExt}; use treeculler::{BVol, BoundingSphere}; use vek::*; @@ -448,7 +449,7 @@ impl FigureMgr { (vek::Rgb::zero(), 0.0, 0.0, true) }; if let Some(state) = body.and_then(|body| self.states.get_mut(body, &entity)) { - light_anim.offset = vek::Vec3::from(state.lantern_offset); + light_anim.offset = vek::Vec3::from(state.lantern_offset[0]); } if !light_anim.strength.is_normal() { light_anim.strength = 0.0; @@ -585,6 +586,7 @@ impl FigureMgr { inventory, item, light_emitter, + mountings, ), ) in ( &ecs.entities(), @@ -601,6 +603,7 @@ impl FigureMgr { ecs.read_storage::().maybe(), ecs.read_storage::().maybe(), ecs.read_storage::().maybe(), + ecs.read_storage::().maybe(), ) .join() .enumerate() @@ -685,7 +688,7 @@ impl FigureMgr { // shadow correctly until their next update. For now, we treat this // as an acceptable tradeoff. let radius = scale.unwrap_or(&Scale(1.0)).0 * 2.0; - let (in_frustum, lpindex) = if let Some(mut meta) = state { + let (in_frustum, lpindex) = if let Some(ref mut meta) = state { let (in_frustum, lpindex) = BoundingSphere::new(pos.0.into_array(), radius) .coherent_test_against_frustum(frustum, meta.lpindex); let in_frustum = in_frustum || matches!(body, Body::Ship(_)); @@ -746,6 +749,25 @@ impl FigureMgr { let hands = (active_tool_hand, second_tool_hand); + //let mut state_mountee = self.states.get_mut(entity.get(body), &entity); + + let mut mountee_offsets = vek::Vec3::new(0.0, 0.0, 0.0); + if let Some(Mounting(entity)) = mountings { + let mountee_entity = ecs + .read_resource::() + .retrieve_entity_internal((*entity).into()); + dbg!(mountee_entity); + if let Some(entity) = mountee_entity { + if let Some(body) = ecs.read_storage::().get(entity) { + let mountee_state = self.states.get_mut(body, &entity); + if let Some(meta) = mountee_state { + mountee_offsets = vek::Vec3::from(meta.lantern_offset[1]); + dbg!(mountee_offsets); + } + } + } + } + match body { Body::Humanoid(body) => { let (model, skeleton_attr) = self.model_cache.get_or_create_model( @@ -1517,6 +1539,7 @@ impl FigureMgr { // TODO: Update to use the quaternion. ori * anim::vek::Vec3::::unit_y(), state.last_ori * anim::vek::Vec3::::unit_y(), + mountee_offsets.into(), ), state.state_time, &mut state_animation_rate, @@ -5321,7 +5344,7 @@ impl FigureColLights { pub struct FigureStateMeta { bone_consts: Consts, locals: Consts, - lantern_offset: anim::vek::Vec3, + lantern_offset: [anim::vek::Vec3; 2], state_time: f32, last_ori: anim::vek::Quaternion, lpindex: u8,