mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Revert "Merge branch 'snowram/hacky-mount' into 'master'"
This reverts merge request !2219
This commit is contained in:
parent
7fe0db2261
commit
7d5ca0e7bf
@ -106,7 +106,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Merchants now use `/tell` instead of `/say` to communicate prices
|
||||
- Entities catch on fire if they stand too close to campfires
|
||||
- Water extinguishes entities on fire
|
||||
- Some tamed NPCs can now be mounted
|
||||
|
||||
### Removed
|
||||
|
||||
|
@ -159,7 +159,7 @@
|
||||
central: ("npc.tuskram.male.neck"),
|
||||
),
|
||||
jaw: (
|
||||
offset: (-5.0, 0.0, -8.0),
|
||||
offset: (-5.0, 0.0, -1.5),
|
||||
central: ("npc.tuskram.male.jaw"),
|
||||
),
|
||||
torso_front: (
|
||||
|
@ -659,49 +659,8 @@ impl Body {
|
||||
)
|
||||
}
|
||||
|
||||
// Physical offset relative to the mountee
|
||||
pub fn mounting_offset(&self) -> Vec3<f32> {
|
||||
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.0, 0.0, 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, 2.6])
|
||||
},
|
||||
(quadruped_medium::Species::Cattle, quadruped_medium::BodyType::Female) => {
|
||||
Vec3::from([0.7, 0.7, 2.2])
|
||||
},
|
||||
(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(),
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ pub enum CharacterState {
|
||||
Idle,
|
||||
Climb(climb::Data),
|
||||
Sit,
|
||||
Mount,
|
||||
Dance,
|
||||
Talk,
|
||||
Sneak,
|
||||
|
@ -19,7 +19,6 @@ pub mod glide_wield;
|
||||
pub mod healing_beam;
|
||||
pub mod idle;
|
||||
pub mod leap_melee;
|
||||
pub mod mount;
|
||||
pub mod repeater_ranged;
|
||||
pub mod roll;
|
||||
pub mod self_buff;
|
||||
|
@ -1,50 +0,0 @@
|
||||
use super::utils::*;
|
||||
use crate::{
|
||||
comp::{CharacterState, InventoryAction, StateUpdate},
|
||||
states::behavior::{CharacterBehavior, JoinData},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize, Eq, Hash)]
|
||||
pub struct Data;
|
||||
|
||||
impl CharacterBehavior for Data {
|
||||
fn behavior(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
|
||||
handle_wield(data, &mut update);
|
||||
handle_jump(data, &mut update, 1.0);
|
||||
|
||||
// Try to Fall/Stand up/Move
|
||||
if !data.physics.on_ground || data.inputs.move_dir.magnitude_squared() > 0.0 {
|
||||
update.character = CharacterState::Idle;
|
||||
}
|
||||
|
||||
update
|
||||
}
|
||||
|
||||
fn wield(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
attempt_wield(data, &mut update);
|
||||
update
|
||||
}
|
||||
|
||||
fn dance(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
attempt_dance(data, &mut update);
|
||||
update
|
||||
}
|
||||
|
||||
fn stand(&self, data: &JoinData) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
// Try to Fall/Stand up/Move
|
||||
update.character = CharacterState::Idle;
|
||||
update
|
||||
}
|
||||
|
||||
fn manipulate_loadout(&self, data: &JoinData, inv_action: InventoryAction) -> StateUpdate {
|
||||
let mut update = StateUpdate::from(data);
|
||||
handle_manipulate_loadout(&data, &mut update, inv_action);
|
||||
update
|
||||
}
|
||||
}
|
@ -315,9 +315,6 @@ impl<'a> System<'a> for Sys {
|
||||
CharacterState::Sit => {
|
||||
states::sit::Data::handle_event(&states::sit::Data, &j, action)
|
||||
},
|
||||
CharacterState::Mount => {
|
||||
states::mount::Data::handle_event(&states::mount::Data, &j, action)
|
||||
},
|
||||
CharacterState::Dance => {
|
||||
states::dance::Data::handle_event(&states::dance::Data, &j, action)
|
||||
},
|
||||
@ -355,9 +352,9 @@ impl<'a> System<'a> for Sys {
|
||||
// If mounted, character state is controlled by mount
|
||||
// TODO: Make mounting a state
|
||||
if let Some(Mounting(_)) = read_data.mountings.get(entity) {
|
||||
let mount_state = CharacterState::Mount {};
|
||||
if join_struct.char_state.get_unchecked() != &mount_state {
|
||||
*join_struct.char_state.get_mut_unchecked() = mount_state;
|
||||
let sit_state = CharacterState::Sit {};
|
||||
if join_struct.char_state.get_unchecked() != &sit_state {
|
||||
*join_struct.char_state.get_mut_unchecked() = sit_state;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -377,7 +374,6 @@ impl<'a> System<'a> for Sys {
|
||||
CharacterState::GlideWield => states::glide_wield::Data.behavior(&j),
|
||||
CharacterState::Stunned(data) => data.behavior(&j),
|
||||
CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, &j),
|
||||
CharacterState::Mount => states::mount::Data::behavior(&states::mount::Data, &j),
|
||||
CharacterState::Dance => states::dance::Data::behavior(&states::dance::Data, &j),
|
||||
CharacterState::Sneak => states::sneak::Data::behavior(&states::sneak::Data, &j),
|
||||
CharacterState::BasicBlock(data) => data.behavior(&j),
|
||||
|
@ -68,14 +68,7 @@ impl<'a> System<'a> for Sys {
|
||||
if let (Some(pos), Some(ori), Some(vel)) = (pos, ori, vel) {
|
||||
let mounting_offset =
|
||||
body.map_or(Vec3::unit_z(), Body::mounting_offset);
|
||||
let _ = positions.insert(
|
||||
mounter,
|
||||
Pos(Vec3 {
|
||||
x: pos.0.x + ori.look_dir().x * mounting_offset.x,
|
||||
y: pos.0.y + ori.look_dir().y * mounting_offset.y,
|
||||
z: pos.0.z + mounting_offset.z,
|
||||
}),
|
||||
);
|
||||
let _ = positions.insert(mounter, Pos(pos.0 + mounting_offset));
|
||||
let _ = orientations.insert(mounter, ori);
|
||||
let _ = velocities.insert(mounter, vel);
|
||||
}
|
||||
|
@ -193,7 +193,6 @@ impl<'a> System<'a> for Sys {
|
||||
CharacterState::Idle { .. }
|
||||
| CharacterState::Talk { .. }
|
||||
| CharacterState::Sit { .. }
|
||||
| CharacterState::Mount { .. }
|
||||
| CharacterState::Dance { .. }
|
||||
| CharacterState::Sneak { .. }
|
||||
| CharacterState::Glide { .. }
|
||||
|
@ -349,20 +349,6 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv
|
||||
.write_storage()
|
||||
.insert(tameable_entity, comp::Alignment::Owned(uid));
|
||||
|
||||
// Make entity mountable if its Body is QuadrupedMedium
|
||||
// TODO: Make mounting better so that all entities can be
|
||||
// mounted?
|
||||
if let Some(comp::Body::QuadrupedMedium(_)) = state
|
||||
.ecs()
|
||||
.read_storage::<comp::Body>()
|
||||
.get(tameable_entity)
|
||||
{
|
||||
let _ = state.ecs().write_storage().insert(
|
||||
tameable_entity,
|
||||
comp::MountState::Unmounted,
|
||||
);
|
||||
}
|
||||
|
||||
// Add to group system
|
||||
let clients = state.ecs().read_storage::<Client>();
|
||||
let uids = state.ecs().read_storage::<Uid>();
|
||||
|
@ -29,7 +29,7 @@ pub use self::{
|
||||
stunned::StunnedAnimation, summon::SummonAnimation, wield::WieldAnimation,
|
||||
};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -77,7 +77,7 @@ impl Skeleton for BipedLargeSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
let upper_torso = Mat4::<f32>::from(self.upper_torso);
|
||||
|
||||
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
|
||||
@ -124,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.torso,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ pub use self::{
|
||||
shoot::ShootAnimation, stunned::StunnedAnimation, wield::WieldAnimation,
|
||||
};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -47,7 +47,7 @@ impl Skeleton for BipedSmallSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
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,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.chest,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ pub use self::{
|
||||
stunned::StunnedAnimation, swim::SwimAnimation,
|
||||
};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -55,7 +55,7 @@ impl Skeleton for BirdLargeSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
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,10 +91,7 @@ impl Skeleton for BirdLargeSkeleton {
|
||||
make_bone(foot_l_mat),
|
||||
make_bone(foot_r_mat),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.chest,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ pub mod run;
|
||||
// Reexports
|
||||
pub use self::{feed::FeedAnimation, fly::FlyAnimation, idle::IdleAnimation, run::RunAnimation};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -36,7 +36,7 @@ impl Skeleton for BirdMediumSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
|
||||
|
||||
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
||||
@ -48,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.torso,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@ pub mod gliding;
|
||||
pub mod idle;
|
||||
pub mod jump;
|
||||
pub mod leapmelee;
|
||||
pub mod mount;
|
||||
pub mod repeater;
|
||||
pub mod roll;
|
||||
pub mod run;
|
||||
@ -36,13 +35,13 @@ pub use self::{
|
||||
chargeswing::ChargeswingAnimation, climb::ClimbAnimation, dance::DanceAnimation,
|
||||
dash::DashAnimation, equip::EquipAnimation, glidewield::GlideWieldAnimation,
|
||||
gliding::GlidingAnimation, idle::IdleAnimation, jump::JumpAnimation, leapmelee::LeapAnimation,
|
||||
mount::MountAnimation, repeater::RepeaterAnimation, roll::RollAnimation, run::RunAnimation,
|
||||
repeater::RepeaterAnimation, roll::RollAnimation, run::RunAnimation,
|
||||
shockwave::ShockwaveAnimation, shoot::ShootAnimation, sit::SitAnimation, sneak::SneakAnimation,
|
||||
spin::SpinAnimation, spinmelee::SpinMeleeAnimation, staggered::StaggeredAnimation,
|
||||
stand::StandAnimation, stunned::StunnedAnimation, swim::SwimAnimation,
|
||||
swimwield::SwimWieldAnimation, talk::TalkAnimation, wield::WieldAnimation,
|
||||
};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp;
|
||||
use core::convert::TryFrom;
|
||||
use std::f32::consts::PI;
|
||||
@ -72,20 +71,12 @@ skeleton_impls!(struct CharacterSkeleton {
|
||||
control_r,
|
||||
:: // Begin non-bone fields
|
||||
holding_lantern: bool,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
mountee_body: Option<comp::Body>,
|
||||
});
|
||||
|
||||
impl CharacterSkeleton {
|
||||
pub fn new(
|
||||
holding_lantern: bool,
|
||||
offsets: Option<Transform<f32, f32, f32>>,
|
||||
mountee_body: Option<comp::Body>,
|
||||
) -> Self {
|
||||
pub fn new(holding_lantern: bool) -> Self {
|
||||
Self {
|
||||
holding_lantern,
|
||||
offsets,
|
||||
mountee_body,
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
@ -105,22 +96,8 @@ impl Skeleton for CharacterSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
let mut torso_mat = base_mat * Mat4::<f32>::from(self.torso);
|
||||
if let Some(offset) = self.offsets {
|
||||
if let Some(body) = self.mountee_body {
|
||||
let hitbox_offsets = body.mounting_offset();
|
||||
let visual_offset = mounting_offset(body);
|
||||
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(visual_offset);
|
||||
}
|
||||
}
|
||||
) -> Vec3<f32> {
|
||||
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);
|
||||
let shorts_mat = chest_mat * Mat4::<f32>::from(self.shorts);
|
||||
@ -155,10 +132,7 @@ impl Skeleton for CharacterSkeleton {
|
||||
// FIXME: Should this be control_l_mat?
|
||||
make_bone(control_mat * hand_l_mat * Mat4::<f32>::from(self.hold)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: (lantern_mat * Vec4::new(0.0, 0.0, -4.0, 1.0)).xyz(),
|
||||
mount_bone: self.chest,
|
||||
}
|
||||
(lantern_mat * Vec4::new(0.0, 0.0, -4.0, 1.0)).xyz()
|
||||
}
|
||||
}
|
||||
|
||||
@ -355,53 +329,3 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mounting_offset(body: comp::Body) -> Vec3<f32> {
|
||||
match body {
|
||||
comp::Body::QuadrupedMedium(quadruped_medium) => {
|
||||
match (quadruped_medium.species, quadruped_medium.body_type) {
|
||||
(comp::quadruped_medium::Species::Grolgar, _) => Vec3::from([0.0, -0.6, 0.5]),
|
||||
(comp::quadruped_medium::Species::Saber, _) => Vec3::from([0.0, -0.75, 0.23]),
|
||||
(comp::quadruped_medium::Species::Tiger, _) => Vec3::from([0.0, -0.75, 0.23]),
|
||||
(comp::quadruped_medium::Species::Tuskram, _) => Vec3::from([0.0, -0.75, 0.25]),
|
||||
(comp::quadruped_medium::Species::Lion, _) => Vec3::from([0.0, -0.9, 0.25]),
|
||||
(comp::quadruped_medium::Species::Tarasque, _) => Vec3::from([0.0, -1.1, 0.3]),
|
||||
(comp::quadruped_medium::Species::Wolf, _) => Vec3::from([0.0, -0.7, 0.15]),
|
||||
(comp::quadruped_medium::Species::Frostfang, _) => Vec3::from([0.0, -0.8, 0.1]),
|
||||
(comp::quadruped_medium::Species::Mouflon, _) => Vec3::from([0.0, -0.8, 0.1]),
|
||||
(comp::quadruped_medium::Species::Catoblepas, _) => Vec3::from([0.0, -0.4, 0.4]),
|
||||
(comp::quadruped_medium::Species::Bonerattler, _) => Vec3::from([0.0, -0.3, 0.2]),
|
||||
(comp::quadruped_medium::Species::Deer, _) => Vec3::from([0.0, -0.9, 0.1]),
|
||||
(comp::quadruped_medium::Species::Hirdrasil, _) => Vec3::from([0.0, -1.0, 0.0]),
|
||||
(comp::quadruped_medium::Species::Roshwalr, _) => Vec3::from([0.0, -0.2, 0.7]),
|
||||
(comp::quadruped_medium::Species::Donkey, _) => Vec3::from([0.0, -0.5, 0.15]),
|
||||
(comp::quadruped_medium::Species::Camel, _) => Vec3::from([0.0, -1.4, 0.3]),
|
||||
(comp::quadruped_medium::Species::Zebra, _) => Vec3::from([0.0, -0.6, 0.1]),
|
||||
(comp::quadruped_medium::Species::Antelope, _) => Vec3::from([0.0, -0.8, 0.1]),
|
||||
(comp::quadruped_medium::Species::Kelpie, _) => Vec3::from([0.0, -0.8, 0.05]),
|
||||
(comp::quadruped_medium::Species::Horse, _) => Vec3::from([0.0, -0.8, 0.1]),
|
||||
(comp::quadruped_medium::Species::Barghest, _) => Vec3::from([0.0, -0.8, 0.6]),
|
||||
(
|
||||
comp::quadruped_medium::Species::Cattle,
|
||||
comp::quadruped_medium::BodyType::Male,
|
||||
) => Vec3::from([0.0, -0.4, 0.7]),
|
||||
(
|
||||
comp::quadruped_medium::Species::Cattle,
|
||||
comp::quadruped_medium::BodyType::Female,
|
||||
) => Vec3::from([0.0, -0.3, 0.5]),
|
||||
(comp::quadruped_medium::Species::Darkhound, _) => Vec3::from([0.0, -0.5, 0.2]),
|
||||
(comp::quadruped_medium::Species::Highland, _) => Vec3::from([0.0, -0.2, 0.8]),
|
||||
(comp::quadruped_medium::Species::Yak, _) => Vec3::from([0.0, -0.2, 0.8]),
|
||||
(comp::quadruped_medium::Species::Panda, _) => Vec3::from([0.0, -0.8, 0.2]),
|
||||
(comp::quadruped_medium::Species::Bear, _) => Vec3::from([0.0, -1.5, 0.6]),
|
||||
(comp::quadruped_medium::Species::Dreadhorn, _) => Vec3::from([0.0, -1.5, 1.6]),
|
||||
(comp::quadruped_medium::Species::Moose, _) => Vec3::from([0.0, -0.9, 0.3]),
|
||||
(comp::quadruped_medium::Species::Snowleopard, _) => Vec3::from([0.0, -0.9, 0.2]),
|
||||
}
|
||||
},
|
||||
|
||||
comp::Body::Ship(comp::ship::Body::DefaultAirship) => Vec3::from([0.0, 0.0, 10.0]),
|
||||
comp::Body::Dragon(_) => Vec3::from([0.0, -0.7, 6.4]),
|
||||
_ => Vec3::unit_z(),
|
||||
}
|
||||
}
|
||||
|
@ -1,149 +0,0 @@
|
||||
use super::{
|
||||
super::{vek::*, Animation},
|
||||
CharacterSkeleton, SkeletonAttr,
|
||||
};
|
||||
use common::comp::item::ToolKind;
|
||||
use std::{f32::consts::PI, ops::Mul};
|
||||
|
||||
pub struct MountAnimation;
|
||||
|
||||
impl Animation for MountAnimation {
|
||||
#[allow(clippy::type_complexity)]
|
||||
type Dependency<'a> = (
|
||||
Option<ToolKind>,
|
||||
Option<ToolKind>,
|
||||
f32,
|
||||
Vec3<f32>,
|
||||
Vec3<f32>,
|
||||
Vec3<f32>,
|
||||
Vec3<f32>,
|
||||
Option<Transform<f32, f32, f32>>,
|
||||
);
|
||||
type Skeleton = CharacterSkeleton;
|
||||
|
||||
#[cfg(feature = "use-dyn-lib")]
|
||||
const UPDATE_FN: &'static [u8] = b"character_mount\0";
|
||||
|
||||
#[cfg_attr(feature = "be-dyn-lib", export_name = "character_mount")]
|
||||
fn update_skeleton_inner<'a>(
|
||||
skeleton: &Self::Skeleton,
|
||||
(
|
||||
_active_tool_kind,
|
||||
_second_tool_kind,
|
||||
global_time,
|
||||
velocity,
|
||||
avg_vel,
|
||||
orientation,
|
||||
last_ori,
|
||||
_mount_offset,
|
||||
): Self::Dependency<'a>,
|
||||
anim_time: f32,
|
||||
_rate: &mut f32,
|
||||
s_a: &SkeletonAttr,
|
||||
) -> Self::Skeleton {
|
||||
let mut next = (*skeleton).clone();
|
||||
|
||||
let slow = (anim_time * 1.0).sin();
|
||||
let slowa = (anim_time * 1.0 + PI / 2.0).sin();
|
||||
let stop = (anim_time * 3.0).min(PI / 2.0).sin();
|
||||
|
||||
let head_look = Vec2::new(
|
||||
(global_time * 0.05 + anim_time / 15.0)
|
||||
.floor()
|
||||
.mul(7331.0)
|
||||
.sin()
|
||||
* 0.25,
|
||||
(global_time * 0.05 + anim_time / 15.0)
|
||||
.floor()
|
||||
.mul(1337.0)
|
||||
.sin()
|
||||
* 0.125,
|
||||
);
|
||||
|
||||
let ori: Vec2<f32> = Vec2::from(orientation);
|
||||
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)
|
||||
.map(|o| o.magnitude_squared())
|
||||
.map(|m| m > 0.001 && m.is_finite())
|
||||
.reduce_and()
|
||||
&& ori.angle_between(last_ori).is_finite()
|
||||
{
|
||||
ori.angle_between(last_ori).min(0.2)
|
||||
* last_ori.determine_side(Vec2::zero(), ori).signum()
|
||||
} else {
|
||||
0.0
|
||||
} * 1.3;
|
||||
|
||||
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 + slow * 0.1 + stop * -0.8);
|
||||
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, s_a.chest.1);
|
||||
next.chest.orientation = Quaternion::rotation_x(-0.6 + stop * 0.15);
|
||||
|
||||
next.belt.position = Vec3::new(0.0, s_a.belt.0 + stop * 1.2, s_a.belt.1);
|
||||
next.belt.orientation = Quaternion::rotation_x(stop * 0.3);
|
||||
|
||||
next.back.position = Vec3::new(0.0, s_a.back.0, s_a.back.1);
|
||||
|
||||
next.shorts.position = Vec3::new(0.0, s_a.shorts.0 + stop * 2.5, s_a.shorts.1 + stop * 0.6);
|
||||
next.shorts.orientation = Quaternion::rotation_x(stop * 0.6);
|
||||
|
||||
next.hand_l.position = Vec3::new(
|
||||
-s_a.hand.0 + 4.0,
|
||||
s_a.hand.1 + slowa * 0.15 + stop * 8.0,
|
||||
s_a.hand.2 + slow * 0.7 + stop * 4.0,
|
||||
);
|
||||
next.hand_l.orientation =
|
||||
Quaternion::rotation_x(PI / 2.0) * Quaternion::rotation_z(-PI / 2.0);
|
||||
|
||||
next.hand_r.position = Vec3::new(
|
||||
s_a.hand.0 - 4.0,
|
||||
s_a.hand.1 + slowa * 0.15 + stop * 8.0,
|
||||
s_a.hand.2 + slow * 0.7 + stop * 4.0,
|
||||
);
|
||||
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)
|
||||
* 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)
|
||||
* 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);
|
||||
|
||||
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.0, stop * -0.16) * s_a.scaler;
|
||||
|
||||
if skeleton.holding_lantern {
|
||||
next.hand_r.position = Vec3::new(
|
||||
s_a.hand.0 + 1.0 - head_look.x * 8.0,
|
||||
s_a.hand.1 + 5.0 + head_look.x * 6.0,
|
||||
s_a.hand.2 + 9.0 + head_look.y * 6.0,
|
||||
);
|
||||
next.hand_r.orientation = Quaternion::rotation_x(2.25)
|
||||
* Quaternion::rotation_z(0.9)
|
||||
* Quaternion::rotation_y(head_look.x * 3.0)
|
||||
* Quaternion::rotation_x(head_look.y * 3.0);
|
||||
|
||||
let fast = (anim_time * 5.0).sin();
|
||||
let fast2 = (anim_time * 4.5 + 8.0).sin();
|
||||
|
||||
next.lantern.position = Vec3::new(-0.5, -0.5, -2.5);
|
||||
next.lantern.orientation = next.hand_r.orientation.inverse()
|
||||
* Quaternion::rotation_x(fast * 0.1)
|
||||
* Quaternion::rotation_y(fast2 * 0.1);
|
||||
}
|
||||
|
||||
next
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ pub mod run;
|
||||
// Reexports
|
||||
pub use self::{fly::FlyAnimation, idle::IdleAnimation, run::RunAnimation};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -43,7 +43,7 @@ impl Skeleton for DragonSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
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,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.chest_front,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ pub mod swim;
|
||||
// Reexports
|
||||
pub use self::{idle::IdleAnimation, swim::SwimAnimation};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -33,7 +33,7 @@ impl Skeleton for FishMediumSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
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,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.chest_front,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ pub mod swim;
|
||||
// Reexports
|
||||
pub use self::{idle::IdleAnimation, swim::SwimAnimation};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -30,7 +30,7 @@ impl Skeleton for FishSmallSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
|
||||
|
||||
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
||||
@ -39,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.chest,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
|
||||
pub type Body = ();
|
||||
|
||||
@ -31,12 +31,9 @@ impl Skeleton for FixtureSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
buf[0] = make_bone(base_mat);
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: Transform::default(),
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ pub use self::{
|
||||
shockwave::ShockwaveAnimation, shoot::ShootAnimation, spinmelee::SpinMeleeAnimation,
|
||||
};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -47,7 +47,7 @@ impl Skeleton for GolemSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
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,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.torso,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -89,12 +89,6 @@ fn make_bone(mat: Mat4<f32>) -> FigureBoneData {
|
||||
|
||||
pub type Bone = Transform<f32, f32, f32>;
|
||||
|
||||
// Offsets that will be returned after computing the skeleton matrices
|
||||
pub struct Offsets {
|
||||
pub lantern: Vec3<f32>,
|
||||
pub mount_bone: Transform<f32, f32, f32>,
|
||||
}
|
||||
|
||||
pub trait Skeleton: Send + Sync + 'static {
|
||||
type Attr;
|
||||
type Body;
|
||||
@ -108,14 +102,14 @@ pub trait Skeleton: Send + Sync + 'static {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
|
||||
) -> Offsets;
|
||||
) -> Vec3<f32>;
|
||||
}
|
||||
|
||||
pub fn compute_matrices<S: Skeleton>(
|
||||
skeleton: &S,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
#[cfg(not(feature = "use-dyn-lib"))]
|
||||
{
|
||||
S::compute_matrices_inner(skeleton, base_mat, buf)
|
||||
@ -126,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]) -> Offsets,
|
||||
fn(&S, Mat4<f32>, &mut [FigureBoneData; MAX_BONE_COUNT]) -> Vec3<f32>,
|
||||
> = unsafe { lib.get(S::COMPUTE_FN) }.unwrap_or_else(|e| {
|
||||
panic!(
|
||||
"Trying to use: {} but had error: {:?}",
|
||||
|
@ -5,7 +5,7 @@ pub mod shoot;
|
||||
// Reexports
|
||||
pub use self::{beam::BeamAnimation, idle::IdleAnimation, shoot::ShootAnimation};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -29,17 +29,14 @@ impl Skeleton for ObjectSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
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 */
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.bone0,
|
||||
}
|
||||
Vec3::unit_z() * 0.5
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ pub use self::{
|
||||
stunned::StunnedAnimation, tailwhip::TailwhipAnimation,
|
||||
};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -48,7 +48,7 @@ impl Skeleton for QuadrupedLowSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
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,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.chest,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ pub use self::{
|
||||
run::RunAnimation, stunned::StunnedAnimation,
|
||||
};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -38,7 +38,6 @@ skeleton_impls!(struct QuadrupedMediumSkeleton {
|
||||
+ foot_fr,
|
||||
+ foot_bl,
|
||||
+ foot_br,
|
||||
mount,
|
||||
});
|
||||
|
||||
impl Skeleton for QuadrupedMediumSkeleton {
|
||||
@ -54,7 +53,7 @@ impl Skeleton for QuadrupedMediumSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
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);
|
||||
@ -81,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.torso_front,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +152,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(Frostfang, _) => (1.0, -2.0),
|
||||
(Mouflon, _) => (0.5, 1.5),
|
||||
(Catoblepas, _) => (-1.0, -6.5),
|
||||
(Bonerattler, _) => (0.0, 1.5),
|
||||
(Bonerattler, _) => (1.0, 2.5),
|
||||
(Deer, Male) => (1.5, 3.5),
|
||||
(Deer, Female) => (1.5, 3.5),
|
||||
(Hirdrasil, _) => (0.0, 5.0),
|
||||
@ -191,7 +187,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(Frostfang, _) => (0.5, 1.5),
|
||||
(Mouflon, _) => (-1.0, 1.0),
|
||||
(Catoblepas, _) => (19.5, -2.0),
|
||||
(Bonerattler, _) => (7.0, -0.5),
|
||||
(Bonerattler, _) => (9.0, -0.5),
|
||||
(Deer, _) => (-2.5, 1.0),
|
||||
(Hirdrasil, _) => (-1.0, 0.5),
|
||||
(Roshwalr, _) => (0.0, 1.0),
|
||||
@ -291,7 +287,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(Frostfang, _) => (9.0, 11.5),
|
||||
(Mouflon, _) => (11.0, 14.0),
|
||||
(Catoblepas, _) => (7.5, 19.5),
|
||||
(Bonerattler, _) => (6.0, 11.0),
|
||||
(Bonerattler, _) => (6.0, 12.5),
|
||||
(Deer, _) => (11.0, 13.5),
|
||||
(Hirdrasil, _) => (11.0, 14.5),
|
||||
(Roshwalr, _) => (6.0, 12.5),
|
||||
@ -391,7 +387,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(Frostfang, _) => (5.5, -5.5, -2.0),
|
||||
(Mouflon, _) => (4.0, -5.0, -4.0),
|
||||
(Catoblepas, _) => (7.0, 2.0, -5.0),
|
||||
(Bonerattler, _) => (5.5, 5.0, -2.5),
|
||||
(Bonerattler, _) => (5.5, 5.0, -4.0),
|
||||
(Deer, _) => (3.5, -4.5, -3.5),
|
||||
(Hirdrasil, _) => (4.5, -5.0, -2.5),
|
||||
(Roshwalr, _) => (8.0, -2.5, -2.5),
|
||||
@ -424,7 +420,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
|
||||
(Frostfang, _) => (3.5, -4.5, -2.0),
|
||||
(Mouflon, _) => (3.5, -8.0, -3.5),
|
||||
(Catoblepas, _) => (6.0, -2.5, -2.5),
|
||||
(Bonerattler, _) => (6.0, -8.0, -2.5),
|
||||
(Bonerattler, _) => (6.0, -8.0, -4.0),
|
||||
(Deer, _) => (3.0, -6.5, -3.5),
|
||||
(Hirdrasil, _) => (4.0, -6.5, -3.0),
|
||||
(Roshwalr, _) => (7.0, -7.0, -2.5),
|
||||
|
@ -11,7 +11,7 @@ pub use self::{
|
||||
run::RunAnimation, stunned::StunnedAnimation,
|
||||
};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -40,7 +40,7 @@ impl Skeleton for QuadrupedSmallSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
|
||||
|
||||
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
||||
@ -52,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.chest,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ pub mod idle;
|
||||
// Reexports
|
||||
pub use self::idle::IdleAnimation;
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -29,7 +29,7 @@ impl Skeleton for ShipSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
let bone0_mat = base_mat * Mat4::<f32>::from(self.bone0);
|
||||
|
||||
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
|
||||
@ -38,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 */
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.bone0,
|
||||
}
|
||||
Vec3::unit_z() * 0.5
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ pub use self::{
|
||||
jump::JumpAnimation, run::RunAnimation,
|
||||
};
|
||||
|
||||
use super::{make_bone, vek::*, FigureBoneData, Offsets, Skeleton};
|
||||
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
|
||||
use common::comp::{self};
|
||||
use core::convert::TryFrom;
|
||||
|
||||
@ -47,7 +47,7 @@ impl Skeleton for TheropodSkeleton {
|
||||
&self,
|
||||
base_mat: Mat4<f32>,
|
||||
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
|
||||
) -> Offsets {
|
||||
) -> Vec3<f32> {
|
||||
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,10 +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)),
|
||||
];
|
||||
Offsets {
|
||||
lantern: Vec3::default(),
|
||||
mount_bone: self.chest_front,
|
||||
}
|
||||
Vec3::default()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,12 +30,11 @@ use common::{
|
||||
inventory::slot::EquipSlot,
|
||||
item::{Hands, ItemKind, ToolKind},
|
||||
Body, CharacterState, Controller, Health, Inventory, Item, Last, LightAnimation,
|
||||
LightEmitter, Mounting, Ori, PhysicsState, PoiseState, Pos, Scale, Vel,
|
||||
LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale, Vel,
|
||||
},
|
||||
resources::DeltaTime,
|
||||
states::utils::StageSection,
|
||||
terrain::TerrainChunk,
|
||||
uid::UidAllocator,
|
||||
util::Dir,
|
||||
vol::RectRasterableVol,
|
||||
};
|
||||
@ -49,7 +48,7 @@ use core::{
|
||||
};
|
||||
use guillotiere::AtlasAllocator;
|
||||
use hashbrown::HashMap;
|
||||
use specs::{saveload::MarkerAllocator, Entity as EcsEntity, Join, LazyUpdate, WorldExt};
|
||||
use specs::{Entity as EcsEntity, Join, LazyUpdate, WorldExt};
|
||||
use treeculler::{BVol, BoundingSphere};
|
||||
use vek::*;
|
||||
|
||||
@ -586,7 +585,6 @@ impl FigureMgr {
|
||||
inventory,
|
||||
item,
|
||||
light_emitter,
|
||||
mountings,
|
||||
),
|
||||
) in (
|
||||
&ecs.entities(),
|
||||
@ -603,7 +601,6 @@ impl FigureMgr {
|
||||
ecs.read_storage::<Inventory>().maybe(),
|
||||
ecs.read_storage::<Item>().maybe(),
|
||||
ecs.read_storage::<LightEmitter>().maybe(),
|
||||
ecs.read_storage::<Mounting>().maybe(),
|
||||
)
|
||||
.join()
|
||||
.enumerate()
|
||||
@ -688,7 +685,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(ref mut meta) = state {
|
||||
let (in_frustum, lpindex) = if let Some(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(_));
|
||||
@ -749,19 +746,6 @@ impl FigureMgr {
|
||||
|
||||
let hands = (active_tool_hand, second_tool_hand);
|
||||
|
||||
// If a mountee exists, get its physical mounting offsets and its body
|
||||
let mut f = || -> Option<_> {
|
||||
let Mounting(entity) = mountings?;
|
||||
let entity = ecs
|
||||
.read_resource::<UidAllocator>()
|
||||
.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)))
|
||||
};
|
||||
let (mountee_offsets, mountee_body) = f().unwrap_or((None, None));
|
||||
|
||||
match body {
|
||||
Body::Humanoid(body) => {
|
||||
let (model, skeleton_attr) = self.model_cache.get_or_create_model(
|
||||
@ -789,14 +773,7 @@ impl FigureMgr {
|
||||
.character_states
|
||||
.entry(entity)
|
||||
.or_insert_with(|| {
|
||||
FigureState::new(
|
||||
renderer,
|
||||
CharacterSkeleton::new(
|
||||
holding_lantern,
|
||||
mountee_offsets,
|
||||
mountee_body,
|
||||
),
|
||||
)
|
||||
FigureState::new(renderer, CharacterSkeleton::new(holding_lantern))
|
||||
});
|
||||
|
||||
// Average velocity relative to the current ground
|
||||
@ -818,7 +795,7 @@ impl FigureMgr {
|
||||
) {
|
||||
// Standing
|
||||
(true, false, false) => anim::character::StandAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(holding_lantern, mountee_offsets, mountee_body),
|
||||
&CharacterSkeleton::new(holding_lantern),
|
||||
(active_tool_kind, second_tool_kind, hands, time, rel_avg_vel),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
@ -826,7 +803,7 @@ impl FigureMgr {
|
||||
),
|
||||
// Running
|
||||
(true, true, false) => anim::character::RunAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(holding_lantern, mountee_offsets, mountee_body),
|
||||
&CharacterSkeleton::new(holding_lantern),
|
||||
(
|
||||
active_tool_kind,
|
||||
second_tool_kind,
|
||||
@ -845,7 +822,7 @@ impl FigureMgr {
|
||||
),
|
||||
// In air
|
||||
(false, _, false) => anim::character::JumpAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(holding_lantern, mountee_offsets, mountee_body),
|
||||
&CharacterSkeleton::new(holding_lantern),
|
||||
(
|
||||
active_tool_kind,
|
||||
second_tool_kind,
|
||||
@ -862,7 +839,7 @@ impl FigureMgr {
|
||||
),
|
||||
// Swim
|
||||
(_, _, true) => anim::character::SwimAnimation::update_skeleton(
|
||||
&CharacterSkeleton::new(holding_lantern, mountee_offsets, mountee_body),
|
||||
&CharacterSkeleton::new(holding_lantern),
|
||||
(
|
||||
active_tool_kind,
|
||||
second_tool_kind,
|
||||
@ -1528,25 +1505,6 @@ impl FigureMgr {
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
CharacterState::Mount { .. } => {
|
||||
anim::character::MountAnimation::update_skeleton(
|
||||
&target_base,
|
||||
(
|
||||
active_tool_kind,
|
||||
second_tool_kind,
|
||||
time,
|
||||
rel_vel,
|
||||
rel_avg_vel,
|
||||
// TODO: Update to use the quaternion.
|
||||
ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
|
||||
mountee_offsets,
|
||||
),
|
||||
state.state_time,
|
||||
&mut state_animation_rate,
|
||||
skeleton_attr,
|
||||
)
|
||||
},
|
||||
CharacterState::GlideWield { .. } => {
|
||||
anim::character::GlideWieldAnimation::update_skeleton(
|
||||
&target_base,
|
||||
@ -5346,7 +5304,6 @@ pub struct FigureStateMeta {
|
||||
bone_consts: Consts<FigureBoneData>,
|
||||
locals: Consts<FigureLocals>,
|
||||
lantern_offset: anim::vek::Vec3<f32>,
|
||||
mountee_offset: anim::vek::Transform<f32, f32, f32>,
|
||||
state_time: f32,
|
||||
last_ori: anim::vek::Quaternion<f32>,
|
||||
lpindex: u8,
|
||||
@ -5386,14 +5343,14 @@ impl<S> DerefMut for FigureState<S> {
|
||||
impl<S: Skeleton> FigureState<S> {
|
||||
pub fn new(renderer: &mut Renderer, skeleton: S) -> Self {
|
||||
let mut buf = [Default::default(); anim::MAX_BONE_COUNT];
|
||||
let offsets = anim::compute_matrices(&skeleton, anim::vek::Mat4::identity(), &mut buf);
|
||||
let lantern_offset =
|
||||
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: offsets.lantern,
|
||||
mountee_offset: offsets.mount_bone,
|
||||
lantern_offset,
|
||||
state_time: 0.0,
|
||||
last_ori: Ori::default().into(),
|
||||
lpindex: 0,
|
||||
@ -5517,7 +5474,7 @@ impl<S: Skeleton> FigureState<S> {
|
||||
);
|
||||
renderer.update_consts(&mut self.locals, &[locals]).unwrap();
|
||||
|
||||
let offsets = anim::compute_matrices(&self.skeleton, mat, buf);
|
||||
let lantern_offset = anim::compute_matrices(&self.skeleton, mat, buf);
|
||||
|
||||
let new_bone_consts = figure_bone_data_from_anim(buf);
|
||||
|
||||
@ -5527,8 +5484,7 @@ impl<S: Skeleton> FigureState<S> {
|
||||
&new_bone_consts[0..S::BONE_COUNT],
|
||||
)
|
||||
.unwrap();
|
||||
self.lantern_offset = offsets.lantern;
|
||||
self.mountee_offset = offsets.mount_bone;
|
||||
self.lantern_offset = lantern_offset;
|
||||
|
||||
let smoothing = (5.0 * dt).min(1.0);
|
||||
if let Some(last_pos) = self.last_pos {
|
||||
|
Loading…
Reference in New Issue
Block a user