Expose the mounting bone to the mounter anims

This commit is contained in:
Snowram 2021-05-02 17:22:25 +02:00
parent e4f3064b8a
commit 026ba616ff
20 changed files with 114 additions and 84 deletions

View File

@ -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]),

View File

@ -77,7 +77,7 @@ impl Skeleton for BipedLargeSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let upper_torso = Mat4::<f32>::from(self.upper_torso);
let torso_mat = base_mat * Mat4::<f32>::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::<f32>::from(self.hold)),
];
Vec3::default()
[Vec3::default(), Vec3::default()]
}
}

View File

@ -47,7 +47,7 @@ impl Skeleton for BipedSmallSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
let pants_mat = chest_mat * Mat4::<f32>::from(self.pants);
let control_mat = chest_mat * Mat4::<f32>::from(self.control);
@ -64,7 +64,7 @@ impl Skeleton for BipedSmallSkeleton {
make_bone(base_mat * Mat4::<f32>::from(self.foot_l)),
make_bone(base_mat * Mat4::<f32>::from(self.foot_r)),
];
Vec3::default()
[Vec3::default(), Vec3::default()]
}
}

View File

@ -55,7 +55,7 @@ impl Skeleton for BirdLargeSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
let neck_mat = chest_mat * Mat4::<f32>::from(self.neck);
let head_mat = neck_mat * Mat4::<f32>::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()]
}
}

View File

@ -36,7 +36,7 @@ impl Skeleton for BirdMediumSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let torso_mat = base_mat * Mat4::<f32>::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::<f32>::from(self.leg_l)),
make_bone(base_mat * Mat4::<f32>::from(self.leg_r)),
];
Vec3::default()
[Vec3::default(), (torso_mat * Vec4::one()).xyz()]
}
}

View File

@ -97,7 +97,7 @@ impl Skeleton for CharacterSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
let chest_mat = torso_mat * Mat4::<f32>::from(self.chest);
let head_mat = chest_mat * Mat4::<f32>::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::<f32>::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(),
]
}
}

View File

@ -17,6 +17,7 @@ impl Animation for MountAnimation {
Vec3<f32>,
Vec3<f32>,
Vec3<f32>,
Vec3<f32>,
);
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);

View File

@ -43,7 +43,7 @@ impl Skeleton for DragonSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
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);
@ -69,7 +69,7 @@ impl Skeleton for DragonSkeleton {
make_bone(chest_rear_mat * Mat4::<f32>::from(self.foot_bl)),
make_bone(chest_rear_mat * Mat4::<f32>::from(self.foot_br)),
];
Vec3::default()
[Vec3::default(), (chest_front_mat * Vec4::one()).xyz()]
}
}

View File

@ -33,7 +33,7 @@ impl Skeleton for FishMediumSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
let chest_back_mat = Mat4::<f32>::from(self.chest_back);
let head_mat = Mat4::<f32>::from(self.head);
@ -47,7 +47,7 @@ impl Skeleton for FishMediumSkeleton {
make_bone(chest_front_mat * Mat4::<f32>::from(self.fin_l)),
make_bone(chest_front_mat * Mat4::<f32>::from(self.fin_r)),
];
Vec3::default()
[Vec3::default(), Vec3::default()]
}
}

View File

@ -30,7 +30,7 @@ impl Skeleton for FishSmallSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let chest_mat = base_mat * Mat4::<f32>::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::<f32>::from(self.fin_l)),
make_bone(chest_mat * Mat4::<f32>::from(self.fin_r)),
];
Vec3::default()
[Vec3::default(), Vec3::default()]
}
}

View File

@ -31,9 +31,9 @@ impl Skeleton for FixtureSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
buf[0] = make_bone(base_mat);
Vec3::default()
[Vec3::default(), Vec3::default()]
}
}

View File

@ -47,7 +47,7 @@ impl Skeleton for GolemSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
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);
@ -70,7 +70,7 @@ impl Skeleton for GolemSkeleton {
make_bone(leg_l_mat * Mat4::<f32>::from(self.foot_l)),
make_bone(leg_r_mat * Mat4::<f32>::from(self.foot_r)),
];
Vec3::default()
[Vec3::default(), (torso_mat * Vec4::one()).xyz()]
}
}

View File

@ -102,14 +102,14 @@ pub trait Skeleton: Send + Sync + 'static {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
) -> Vec3<f32>;
) -> [Vec3<f32>; 2];
}
pub fn compute_matrices<S: Skeleton>(
skeleton: &S,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
#[cfg(not(feature = "use-dyn-lib"))]
{
S::compute_matrices_inner(skeleton, base_mat, buf)
@ -120,7 +120,7 @@ pub fn compute_matrices<S: Skeleton>(
let lib = &lock.as_ref().unwrap().lib;
let compute_fn: libloading::Symbol<
fn(&S, Mat4<f32>, &mut [FigureBoneData; MAX_BONE_COUNT]) -> Vec3<f32>,
fn(&S, Mat4<f32>, &mut [FigureBoneData; MAX_BONE_COUNT]) -> [Vec3<f32>; 2],
> = unsafe { lib.get(S::COMPUTE_FN) }.unwrap_or_else(|e| {
panic!(
"Trying to use: {} but had error: {:?}",

View File

@ -29,14 +29,14 @@ impl Skeleton for ObjectSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let bone0_mat = base_mat * Mat4::<f32>::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::<f32>::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()]
}
}

View File

@ -48,7 +48,7 @@ impl Skeleton for QuadrupedLowSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
let tail_front = chest_mat * Mat4::<f32>::from(self.tail_front);
let head_lower_mat = chest_mat * Mat4::<f32>::from(self.head_lower);
@ -66,7 +66,7 @@ impl Skeleton for QuadrupedLowSkeleton {
make_bone(chest_mat * Mat4::<f32>::from(self.foot_bl)),
make_bone(chest_mat * Mat4::<f32>::from(self.foot_br)),
];
Vec3::default()
[Vec3::default(), (chest_mat * Vec4::one()).xyz()]
}
}

View File

@ -53,7 +53,7 @@ impl Skeleton for QuadrupedMediumSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let torso_front_mat = base_mat * Mat4::<f32>::from(self.torso_front);
let torso_back_mat = torso_front_mat * Mat4::<f32>::from(self.torso_back);
let neck_mat = torso_front_mat * Mat4::<f32>::from(self.neck);
@ -80,7 +80,7 @@ impl Skeleton for QuadrupedMediumSkeleton {
make_bone(leg_bl_mat * Mat4::<f32>::from(self.foot_bl)),
make_bone(leg_br_mat * Mat4::<f32>::from(self.foot_br)),
];
Vec3::default()
[Vec3::default(), (torso_front_mat * Vec4::one()).xyz()]
}
}

View File

@ -40,7 +40,7 @@ impl Skeleton for QuadrupedSmallSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let chest_mat = base_mat * Mat4::<f32>::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::<f32>::from(self.leg_br)),
make_bone(chest_mat * Mat4::<f32>::from(self.tail)),
];
Vec3::default()
[Vec3::default(), (chest_mat * Vec4::one()).xyz()]
}
}

View File

@ -29,7 +29,7 @@ impl Skeleton for ShipSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let bone0_mat = base_mat * Mat4::<f32>::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::<f32>::from(self.bone2) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */
make_bone(bone0_mat * Mat4::<f32>::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()]
}
}

View File

@ -47,7 +47,7 @@ impl Skeleton for TheropodSkeleton {
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
) -> [Vec3<f32>; 2] {
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);
let neck_mat = chest_front_mat * Mat4::<f32>::from(self.neck);
let head_mat = neck_mat * Mat4::<f32>::from(self.head);
@ -71,7 +71,7 @@ impl Skeleton for TheropodSkeleton {
make_bone(leg_l_mat * Mat4::<f32>::from(self.foot_l)),
make_bone(leg_r_mat * Mat4::<f32>::from(self.foot_r)),
];
Vec3::default()
[Vec3::default(), (chest_front_mat * Vec4::one()).xyz()]
}
}

View File

@ -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::<Inventory>().maybe(),
ecs.read_storage::<Item>().maybe(),
ecs.read_storage::<LightEmitter>().maybe(),
ecs.read_storage::<Mounting>().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::<UidAllocator>()
.retrieve_entity_internal((*entity).into());
dbg!(mountee_entity);
if let Some(entity) = mountee_entity {
if let Some(body) = ecs.read_storage::<Body>().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::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
mountee_offsets.into(),
),
state.state_time,
&mut state_animation_rate,
@ -5321,7 +5344,7 @@ impl FigureColLights {
pub struct FigureStateMeta {
bone_consts: Consts<FigureBoneData>,
locals: Consts<FigureLocals>,
lantern_offset: anim::vek::Vec3<f32>,
lantern_offset: [anim::vek::Vec3<f32>; 2],
state_time: f32,
last_ori: anim::vek::Quaternion<f32>,
lpindex: u8,