Clean unused mount offset

This commit is contained in:
Snowram 2021-05-08 01:52:01 +02:00
parent 486fbf940e
commit b063ec5a8f
21 changed files with 143 additions and 168 deletions

View File

@ -663,43 +663,44 @@ 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, 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.0, 0.0, 0.0]),
(quadruped_medium::Species::Barghest, _) => Vec3::from([0.5, 0.5, 0.0]),
(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::Cattle, quadruped_medium::BodyType::Male) => {
Vec3::from([0.5, 0.5, 0.0])
Vec3::from([0.5, 0.5, 2.6])
},
(quadruped_medium::Species::Cattle, quadruped_medium::BodyType::Female) => {
Vec3::from([0.7, 0.7, 0.0])
Vec3::from([0.7, 0.7, 2.2])
},
(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]),
(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]),
}
},
Body::Ship(ship::Body::DefaultAirship) => Vec3::from([0.0, 0.0, 10.0]),
_ => Vec3::unit_z(),
}

View File

@ -76,7 +76,6 @@ impl Skeleton for BipedLargeSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let upper_torso = Mat4::<f32>::from(self.upper_torso);

View File

@ -46,7 +46,6 @@ impl Skeleton for BipedSmallSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);

View File

@ -54,7 +54,6 @@ impl Skeleton for BirdLargeSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);

View File

@ -35,7 +35,6 @@ impl Skeleton for BirdMediumSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);

View File

@ -73,13 +73,19 @@ skeleton_impls!(struct CharacterSkeleton {
:: // Begin non-bone fields
holding_lantern: bool,
offsets: Option<Transform<f32, f32, f32>>,
hitbox_offsets: Option<vek::Vec3<f32>>,
});
impl CharacterSkeleton {
pub fn new(holding_lantern: bool, offsets: Option<Transform<f32, f32, f32>>) -> Self {
pub fn new(
holding_lantern: bool,
offsets: Option<Transform<f32, f32, f32>>,
hitbox_offsets: Option<vek::Vec3<f32>>,
) -> Self {
Self {
holding_lantern,
offsets,
hitbox_offsets,
..Self::default()
}
}
@ -98,15 +104,19 @@ impl Skeleton for CharacterSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
dbg!(self.torso);
let mut torso_mat = base_mat * Mat4::<f32>::from(self.torso);
if let Some(offset) = self.offsets {
dbg!(offset);
torso_mat = base_mat * Mat4::<f32>::from(Transform{position: offset.position, orientation: offset.orientation, scale: Vec3::<f32>::one()})
* Mat4::<f32>::from(self.torso);
let hitbox_offsets = self.hitbox_offsets.unwrap_or(vek::Vec3::<f32>::zero());
torso_mat = base_mat
* Mat4::<f32>::from(Transform {
position: offset.position
- Vec3::from([0.0, hitbox_offsets.y, hitbox_offsets.z]),
orientation: offset.orientation,
scale: Vec3::<f32>::one(),
})
* Mat4::<f32>::from(self.torso).translated_3d(Vec3::from([0.0, -0.8, 0.15])); //.translated_3d(Vec3::from([0.0, -0.8, 0.15])
}
let chest_mat = torso_mat * Mat4::<f32>::from(self.chest);
let head_mat = chest_mat * Mat4::<f32>::from(self.head);

View File

@ -9,7 +9,7 @@ pub struct MountAnimation;
impl Animation for MountAnimation {
#[allow(clippy::type_complexity)]
type Dependency = (
type Dependency<'a> = (
Option<ToolKind>,
Option<ToolKind>,
f32,
@ -17,7 +17,7 @@ impl Animation for MountAnimation {
Vec3<f32>,
Vec3<f32>,
Vec3<f32>,
Transform<f32, f32, f32>,
Option<Transform<f32, f32, f32>>,
);
type Skeleton = CharacterSkeleton;
@ -25,7 +25,7 @@ impl Animation for MountAnimation {
const UPDATE_FN: &'static [u8] = b"character_mount\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_mount")]
fn update_skeleton_inner(
fn update_skeleton_inner<'a>(
skeleton: &Self::Skeleton,
(
_active_tool_kind,
@ -35,8 +35,8 @@ impl Animation for MountAnimation {
avg_vel,
orientation,
last_ori,
mount_offset,
): Self::Dependency,
_mount_offset,
): Self::Dependency<'a>,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
@ -64,8 +64,8 @@ impl Animation for MountAnimation {
let last_ori = Vec2::from(last_ori);
let speed = (Vec2::<f32>::from(velocity).magnitude()).min(24.0);
let canceler = (speed / 24.0).powf(0.6);
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()) * canceler;
let tilt = if ::vek::Vec2::new(ori, last_ori)
let _x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()) * canceler;
let _tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()
@ -122,7 +122,7 @@ impl Animation for MountAnimation {
next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_r.orientation = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, -0.2, stop * -0.16) * s_a.scaler;
next.torso.position = Vec3::new(0.0, 0.0, stop * -0.16) * s_a.scaler;
if skeleton.holding_lantern {
next.hand_r.position = Vec3::new(

View File

@ -42,7 +42,6 @@ impl Skeleton for DragonSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);

View File

@ -32,7 +32,6 @@ impl Skeleton for FishMediumSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let chest_front_mat = base_mat * Mat4::<f32>::from(self.chest_front);

View File

@ -29,7 +29,6 @@ impl Skeleton for FishSmallSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);

View File

@ -30,7 +30,6 @@ impl Skeleton for FixtureSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
buf[0] = make_bone(base_mat);

View File

@ -46,7 +46,6 @@ impl Skeleton for GolemSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);

View File

@ -101,7 +101,6 @@ pub trait Skeleton: Send + Sync + 'static {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2];
}
@ -109,12 +108,11 @@ pub trait Skeleton: Send + Sync + 'static {
pub fn compute_matrices<S: Skeleton>(
skeleton: &S,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
#[cfg(not(feature = "use-dyn-lib"))]
{
S::compute_matrices_inner(skeleton, base_mat, offsets, buf)
S::compute_matrices_inner(skeleton, base_mat, buf)
}
#[cfg(feature = "use-dyn-lib")]
{
@ -122,7 +120,11 @@ 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]) -> [Transform<f32, f32, f32>; 2],
fn(
&S,
Mat4<f32>,
&mut [FigureBoneData; MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2],
> = unsafe { lib.get(S::COMPUTE_FN) }.unwrap_or_else(|e| {
panic!(
"Trying to use: {} but had error: {:?}",

View File

@ -28,7 +28,6 @@ impl Skeleton for ObjectSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let bone0_mat = base_mat * Mat4::<f32>::from(self.bone0);
@ -37,10 +36,7 @@ impl Skeleton for ObjectSkeleton {
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 */
];
[
Transform::default(),
Transform::default(),
]
[Transform::default(), Transform::default()]
}
}

View File

@ -47,7 +47,6 @@ impl Skeleton for QuadrupedLowSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);

View File

@ -52,10 +52,8 @@ impl Skeleton for QuadrupedMediumSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
dbg!(self.torso_back);
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);

View File

@ -39,7 +39,6 @@ impl Skeleton for QuadrupedSmallSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);

View File

@ -28,7 +28,6 @@ impl Skeleton for ShipSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
let bone0_mat = base_mat * Mat4::<f32>::from(self.bone0);
@ -39,10 +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 */
];
[
Transform::default(),
self.bone0,
]
[Transform::default(), self.bone0]
}
}

View File

@ -46,10 +46,8 @@ impl Skeleton for TheropodSkeleton {
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
offsets: Option<Transform<f32, f32, f32>>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> [Transform<f32, f32, f32>; 2] {
dbg!(self.chest_front);
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);

View File

@ -449,8 +449,10 @@ 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::Mat4::from_col_array(anim::vek::Mat4::<f32>::from(state.lantern_offset[0]).into_col_array()) * Vec4::one()).xyz();
light_anim.offset = (vek::Mat4::from_col_array(
anim::vek::Mat4::<f32>::from(state.lantern_offset).into_col_array(),
) * Vec4::one())
.xyz();
}
if !light_anim.strength.is_normal() {
light_anim.strength = 0.0;
@ -752,20 +754,19 @@ impl FigureMgr {
//let mut state_mountee = self.states.get_mut(entity.get(body), &entity);
let mut mountee_offsets = anim::vek::Transform::default(); //vek::Mat4::from_col_array(state.lantern_offset[0].into_col_array()
if let Some(Mounting(entity)) = mountings {
let mountee_entity = ecs
//vek::Mat4::from_col_array(state.lantern_offset[0].into_col_array()
let mut f = || -> Option<_> {
let Mounting(entity) = mountings?;
let entity = ecs
.read_resource::<UidAllocator>()
.retrieve_entity_internal((*entity).into());
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 = meta.lantern_offset[1];
}
}
}
}
.retrieve_entity_internal((*entity).into())?;
let bodies = ecs.read_storage::<Body>();
let body = bodies.get(entity)?;
let meta = self.states.get_mut(body, &entity)?;
Some((Some(meta.mountee_offset), Some(Body::mounting_offset(body))))
};
let (mountee_offsets, hitbox_offsets) = f().unwrap_or((None, None));
match body {
Body::Humanoid(body) => {
@ -796,8 +797,11 @@ impl FigureMgr {
.or_insert_with(|| {
FigureState::new(
renderer,
CharacterSkeleton::new(holding_lantern, Some(mountee_offsets)),
Some(mountee_offsets),
CharacterSkeleton::new(
holding_lantern,
mountee_offsets,
hitbox_offsets,
),
)
});
@ -820,7 +824,11 @@ impl FigureMgr {
) {
// Standing
(true, false, false) => anim::character::StandAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern, Some(mountee_offsets)),
&CharacterSkeleton::new(
holding_lantern,
mountee_offsets,
hitbox_offsets,
),
(active_tool_kind, second_tool_kind, hands, time, rel_avg_vel),
state.state_time,
&mut state_animation_rate,
@ -828,7 +836,11 @@ impl FigureMgr {
),
// Running
(true, true, false) => anim::character::RunAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern, Some(mountee_offsets)),
&CharacterSkeleton::new(
holding_lantern,
mountee_offsets,
hitbox_offsets,
),
(
active_tool_kind,
second_tool_kind,
@ -847,7 +859,11 @@ impl FigureMgr {
),
// In air
(false, _, false) => anim::character::JumpAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern, Some(mountee_offsets)),
&CharacterSkeleton::new(
holding_lantern,
mountee_offsets,
hitbox_offsets,
),
(
active_tool_kind,
second_tool_kind,
@ -864,7 +880,11 @@ impl FigureMgr {
),
// Swim
(_, _, true) => anim::character::SwimAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern, Some(mountee_offsets)),
&CharacterSkeleton::new(
holding_lantern,
mountee_offsets,
hitbox_offsets,
),
(
active_tool_kind,
second_tool_kind,
@ -1607,11 +1627,7 @@ impl FigureMgr {
.quadruped_small_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(
renderer,
QuadrupedSmallSkeleton::default(),
Some(mountee_offsets),
)
FigureState::new(renderer, QuadrupedSmallSkeleton::default())
});
// Average velocity relative to the current ground
@ -1813,11 +1829,7 @@ impl FigureMgr {
.quadruped_medium_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(
renderer,
QuadrupedMediumSkeleton::default(),
Some(mountee_offsets),
)
FigureState::new(renderer, QuadrupedMediumSkeleton::default())
});
// Average velocity relative to the current ground
@ -2144,11 +2156,7 @@ impl FigureMgr {
.quadruped_low_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(
renderer,
QuadrupedLowSkeleton::default(),
Some(mountee_offsets),
)
FigureState::new(renderer, QuadrupedLowSkeleton::default())
});
// Average velocity relative to the current ground
@ -2507,11 +2515,7 @@ impl FigureMgr {
.bird_medium_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(
renderer,
BirdMediumSkeleton::default(),
Some(mountee_offsets),
)
FigureState::new(renderer, BirdMediumSkeleton::default())
});
// Average velocity relative to the current ground
@ -2621,11 +2625,7 @@ impl FigureMgr {
.fish_medium_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(
renderer,
FishMediumSkeleton::default(),
Some(mountee_offsets),
)
FigureState::new(renderer, FishMediumSkeleton::default())
});
// Average velocity relative to the current ground
@ -2714,11 +2714,7 @@ impl FigureMgr {
.biped_small_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(
renderer,
BipedSmallSkeleton::default(),
Some(mountee_offsets),
)
FigureState::new(renderer, BipedSmallSkeleton::default())
});
// Average velocity relative to the current ground
@ -3061,9 +3057,10 @@ impl FigureMgr {
&slow_jobs,
);
let state = self.states.dragon_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, DragonSkeleton::default(), Some(mountee_offsets))
});
let state =
self.states.dragon_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, DragonSkeleton::default())
});
// Average velocity relative to the current ground
let rel_avg_vel = state.avg_vel - physics.ground_vel;
@ -3158,13 +3155,7 @@ impl FigureMgr {
.states
.theropod_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(
renderer,
TheropodSkeleton::default(),
Some(mountee_offsets),
)
});
.or_insert_with(|| FigureState::new(renderer, TheropodSkeleton::default()));
// Average velocity relative to the current ground
let rel_avg_vel = state.avg_vel - physics.ground_vel;
@ -3352,11 +3343,7 @@ impl FigureMgr {
.bird_large_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(
renderer,
BirdLargeSkeleton::default(),
Some(mountee_offsets),
)
FigureState::new(renderer, BirdLargeSkeleton::default())
});
let (character, last_character) = match (character, last_character) {
@ -3617,11 +3604,7 @@ impl FigureMgr {
.fish_small_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(
renderer,
FishSmallSkeleton::default(),
Some(mountee_offsets),
)
FigureState::new(renderer, FishSmallSkeleton::default())
});
// Average velocity relative to the current ground
@ -3710,11 +3693,7 @@ impl FigureMgr {
.biped_large_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(
renderer,
BipedLargeSkeleton::default(),
Some(mountee_offsets),
)
FigureState::new(renderer, BipedLargeSkeleton::default())
});
// Average velocity relative to the current ground
@ -4310,9 +4289,10 @@ impl FigureMgr {
&slow_jobs,
);
let state = self.states.golem_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, GolemSkeleton::default(), Some(mountee_offsets))
});
let state =
self.states.golem_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, GolemSkeleton::default())
});
// Average velocity relative to the current ground
let _rel_avg_vel = state.avg_vel - physics.ground_vel;
@ -4561,9 +4541,10 @@ impl FigureMgr {
&slow_jobs,
);
let state = self.states.object_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, ObjectSkeleton::default(), Some(mountee_offsets))
});
let state =
self.states.object_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, ObjectSkeleton::default())
});
// Average velocity relative to the current ground
let _rel_avg_vel = state.avg_vel - physics.ground_vel;
@ -4688,9 +4669,11 @@ impl FigureMgr {
&slow_jobs,
);
let state = self.states.ship_states.entry(entity).or_insert_with(|| {
FigureState::new(renderer, ShipSkeleton::default(), Some(mountee_offsets))
});
let state = self
.states
.ship_states
.entry(entity)
.or_insert_with(|| FigureState::new(renderer, ShipSkeleton::default()));
// Average velocity relative to the current ground
let _rel_avg_vel = state.avg_vel - physics.ground_vel;
@ -5384,7 +5367,8 @@ impl FigureColLights {
pub struct FigureStateMeta {
bone_consts: Consts<FigureBoneData>,
locals: Consts<FigureLocals>,
lantern_offset: [anim::vek::Transform<f32, f32, f32>; 2],
lantern_offset: anim::vek::Transform<f32, f32, f32>,
mountee_offset: anim::vek::Transform<f32, f32, f32>,
state_time: f32,
last_ori: anim::vek::Quaternion<f32>,
lpindex: u8,
@ -5422,16 +5406,16 @@ impl<S> DerefMut for FigureState<S> {
}
impl<S: Skeleton> FigureState<S> {
pub fn new(renderer: &mut Renderer, skeleton: S, offsets: Option<anim::vek::Transform::<f32, f32, f32>>) -> Self {
pub fn new(renderer: &mut Renderer, skeleton: S) -> Self {
let mut buf = [Default::default(); anim::MAX_BONE_COUNT];
let lantern_offset =
anim::compute_matrices(&skeleton, anim::vek::Mat4::identity(), None, &mut buf);
let body_offsets = anim::compute_matrices(&skeleton, anim::vek::Mat4::identity(), &mut buf);
let bone_consts = figure_bone_data_from_anim(&buf);
Self {
meta: FigureStateMeta {
bone_consts: renderer.create_consts(bone_consts).unwrap(),
locals: renderer.create_consts(&[FigureLocals::default()]).unwrap(),
lantern_offset,
lantern_offset: body_offsets[0],
mountee_offset: body_offsets[1],
state_time: 0.0,
last_ori: Ori::default().into(),
lpindex: 0,
@ -5555,7 +5539,7 @@ impl<S: Skeleton> FigureState<S> {
);
renderer.update_consts(&mut self.locals, &[locals]).unwrap();
let lantern_offset = anim::compute_matrices(&self.skeleton, mat, None, buf);
let body_offsets = anim::compute_matrices(&self.skeleton, mat, buf);
let new_bone_consts = figure_bone_data_from_anim(buf);
@ -5565,7 +5549,8 @@ impl<S: Skeleton> FigureState<S> {
&new_bone_consts[0..S::BONE_COUNT],
)
.unwrap();
self.lantern_offset = lantern_offset;
self.lantern_offset = body_offsets[0];
self.mountee_offset = body_offsets[1];
let smoothing = (5.0 * dt).min(1.0);
if let Some(last_pos) = self.last_pos {

View File

@ -163,10 +163,10 @@ impl Scene {
map_bounds,
figure_model_cache: FigureModelCache::new(),
figure_state: FigureState::new(renderer, CharacterSkeleton::default(), None),
figure_state: FigureState::new(renderer, CharacterSkeleton::default()),
backdrop: backdrop.map(|specifier| {
let mut state = FigureState::new(renderer, FixtureSkeleton::default(), None);
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));