From 7d5ca0e7bfeeb3016abd5098411b40548ecf4f51 Mon Sep 17 00:00:00 2001 From: Marcel Date: Fri, 14 May 2021 13:43:20 +0000 Subject: [PATCH] Revert "Merge branch 'snowram/hacky-mount' into 'master'" This reverts merge request !2219 --- CHANGELOG.md | 1 - .../quadruped_medium_central_manifest.ron | 2 +- common/src/comp/body.rs | 41 ----- common/src/comp/character_state.rs | 1 - common/src/states/mod.rs | 1 - common/src/states/mount.rs | 50 ------ common/systems/src/character_behavior.rs | 10 +- common/systems/src/mount.rs | 9 +- common/systems/src/stats.rs | 1 - server/src/events/inventory_manip.rs | 14 -- voxygen/anim/src/biped_large/mod.rs | 9 +- voxygen/anim/src/biped_small/mod.rs | 9 +- voxygen/anim/src/bird_large/mod.rs | 9 +- voxygen/anim/src/bird_medium/mod.rs | 9 +- voxygen/anim/src/character/mod.rs | 88 +---------- voxygen/anim/src/character/mount.rs | 149 ------------------ voxygen/anim/src/dragon/mod.rs | 9 +- voxygen/anim/src/fish_medium/mod.rs | 9 +- voxygen/anim/src/fish_small/mod.rs | 9 +- voxygen/anim/src/fixture/mod.rs | 9 +- voxygen/anim/src/golem/mod.rs | 9 +- voxygen/anim/src/lib.rs | 12 +- voxygen/anim/src/object/mod.rs | 9 +- voxygen/anim/src/quadruped_low/mod.rs | 9 +- voxygen/anim/src/quadruped_medium/mod.rs | 20 +-- voxygen/anim/src/quadruped_small/mod.rs | 9 +- voxygen/anim/src/ship/mod.rs | 9 +- voxygen/anim/src/theropod/mod.rs | 9 +- voxygen/src/scene/figure/mod.rs | 70 ++------ 29 files changed, 77 insertions(+), 518 deletions(-) delete mode 100644 common/src/states/mount.rs delete mode 100644 voxygen/anim/src/character/mount.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fbd2228ce..006b3a95ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/assets/voxygen/voxel/quadruped_medium_central_manifest.ron b/assets/voxygen/voxel/quadruped_medium_central_manifest.ron index 6ad1c58005..72e6b57a67 100644 --- a/assets/voxygen/voxel/quadruped_medium_central_manifest.ron +++ b/assets/voxygen/voxel/quadruped_medium_central_manifest.ron @@ -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: ( diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index 63421765f4..21411bd035 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -659,49 +659,8 @@ impl Body { ) } - // Physical offset relative to the mountee pub fn mounting_offset(&self) -> Vec3 { 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(), } diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index 0029a5e8f6..d73be47340 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -47,7 +47,6 @@ pub enum CharacterState { Idle, Climb(climb::Data), Sit, - Mount, Dance, Talk, Sneak, diff --git a/common/src/states/mod.rs b/common/src/states/mod.rs index 1ca3b18b34..30b86e3766 100644 --- a/common/src/states/mod.rs +++ b/common/src/states/mod.rs @@ -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; diff --git a/common/src/states/mount.rs b/common/src/states/mount.rs deleted file mode 100644 index 459cba1ac6..0000000000 --- a/common/src/states/mount.rs +++ /dev/null @@ -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 - } -} diff --git a/common/systems/src/character_behavior.rs b/common/systems/src/character_behavior.rs index 1cc541a55c..a97350888b 100644 --- a/common/systems/src/character_behavior.rs +++ b/common/systems/src/character_behavior.rs @@ -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), diff --git a/common/systems/src/mount.rs b/common/systems/src/mount.rs index 328f0e93fb..016fb9eb60 100644 --- a/common/systems/src/mount.rs +++ b/common/systems/src/mount.rs @@ -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); } diff --git a/common/systems/src/stats.rs b/common/systems/src/stats.rs index c32a136dbd..4539978d62 100644 --- a/common/systems/src/stats.rs +++ b/common/systems/src/stats.rs @@ -193,7 +193,6 @@ impl<'a> System<'a> for Sys { CharacterState::Idle { .. } | CharacterState::Talk { .. } | CharacterState::Sit { .. } - | CharacterState::Mount { .. } | CharacterState::Dance { .. } | CharacterState::Sneak { .. } | CharacterState::Glide { .. } diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index e7aaa98c45..f1afa34712 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -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::() - .get(tameable_entity) - { - let _ = state.ecs().write_storage().insert( - tameable_entity, - comp::MountState::Unmounted, - ); - } - // Add to group system let clients = state.ecs().read_storage::(); let uids = state.ecs().read_storage::(); diff --git a/voxygen/anim/src/biped_large/mod.rs b/voxygen/anim/src/biped_large/mod.rs index cf2dc88c2b..1db51f23b6 100644 --- a/voxygen/anim/src/biped_large/mod.rs +++ b/voxygen/anim/src/biped_large/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let upper_torso = Mat4::::from(self.upper_torso); let torso_mat = base_mat * Mat4::::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::::from(self.hold)), ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.torso, - } + Vec3::default() } } diff --git a/voxygen/anim/src/biped_small/mod.rs b/voxygen/anim/src/biped_small/mod.rs index 1d4c0c1e57..ba89f7c4c4 100644 --- a/voxygen/anim/src/biped_small/mod.rs +++ b/voxygen/anim/src/biped_small/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let chest_mat = base_mat * Mat4::::from(self.chest); let pants_mat = chest_mat * Mat4::::from(self.pants); let control_mat = chest_mat * Mat4::::from(self.control); @@ -64,10 +64,7 @@ impl Skeleton for BipedSmallSkeleton { make_bone(base_mat * Mat4::::from(self.foot_l)), make_bone(base_mat * Mat4::::from(self.foot_r)), ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.chest, - } + Vec3::default() } } diff --git a/voxygen/anim/src/bird_large/mod.rs b/voxygen/anim/src/bird_large/mod.rs index fe2ad93863..55ac715d38 100644 --- a/voxygen/anim/src/bird_large/mod.rs +++ b/voxygen/anim/src/bird_large/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let chest_mat = base_mat * Mat4::::from(self.chest); let neck_mat = chest_mat * Mat4::::from(self.neck); let head_mat = neck_mat * Mat4::::from(self.head); @@ -91,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() } } diff --git a/voxygen/anim/src/bird_medium/mod.rs b/voxygen/anim/src/bird_medium/mod.rs index 14f85db654..ab72ea8173 100644 --- a/voxygen/anim/src/bird_medium/mod.rs +++ b/voxygen/anim/src/bird_medium/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let torso_mat = base_mat * Mat4::::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::::from(self.leg_l)), make_bone(base_mat * Mat4::::from(self.leg_r)), ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.torso, - } + Vec3::default() } } diff --git a/voxygen/anim/src/character/mod.rs b/voxygen/anim/src/character/mod.rs index 40e5603785..ad446fcff1 100644 --- a/voxygen/anim/src/character/mod.rs +++ b/voxygen/anim/src/character/mod.rs @@ -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>, - mountee_body: Option, }); impl CharacterSkeleton { - pub fn new( - holding_lantern: bool, - offsets: Option>, - mountee_body: Option, - ) -> 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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { - let mut torso_mat = base_mat * Mat4::::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::::from(Transform { - position: offset.position - - Vec3::from([0.0, hitbox_offsets.y, hitbox_offsets.z]), - orientation: offset.orientation, - scale: Vec3::::one(), - }) - * Mat4::::from(self.torso).translated_3d(visual_offset); - } - } + ) -> Vec3 { + let torso_mat = base_mat * Mat4::::from(self.torso); let chest_mat = torso_mat * Mat4::::from(self.chest); let head_mat = chest_mat * Mat4::::from(self.head); let shorts_mat = chest_mat * Mat4::::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::::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 { - 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(), - } -} diff --git a/voxygen/anim/src/character/mount.rs b/voxygen/anim/src/character/mount.rs deleted file mode 100644 index 95c8e9a85d..0000000000 --- a/voxygen/anim/src/character/mount.rs +++ /dev/null @@ -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, - Option, - f32, - Vec3, - Vec3, - Vec3, - Vec3, - Option>, - ); - 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 = Vec2::from(orientation); - let last_ori = Vec2::from(last_ori); - let speed = (Vec2::::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 - } -} diff --git a/voxygen/anim/src/dragon/mod.rs b/voxygen/anim/src/dragon/mod.rs index 4b3221dc40..9e5d39d200 100644 --- a/voxygen/anim/src/dragon/mod.rs +++ b/voxygen/anim/src/dragon/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let chest_front_mat = base_mat * Mat4::::from(self.chest_front); let chest_rear_mat = chest_front_mat * Mat4::::from(self.chest_rear); let head_lower_mat = chest_front_mat * Mat4::::from(self.head_lower); @@ -69,10 +69,7 @@ impl Skeleton for DragonSkeleton { make_bone(chest_rear_mat * Mat4::::from(self.foot_bl)), make_bone(chest_rear_mat * Mat4::::from(self.foot_br)), ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.chest_front, - } + Vec3::default() } } diff --git a/voxygen/anim/src/fish_medium/mod.rs b/voxygen/anim/src/fish_medium/mod.rs index 6ed92d7259..8c68c9e4d8 100644 --- a/voxygen/anim/src/fish_medium/mod.rs +++ b/voxygen/anim/src/fish_medium/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let chest_front_mat = base_mat * Mat4::::from(self.chest_front); let chest_back_mat = Mat4::::from(self.chest_back); let head_mat = Mat4::::from(self.head); @@ -47,10 +47,7 @@ impl Skeleton for FishMediumSkeleton { make_bone(chest_front_mat * Mat4::::from(self.fin_l)), make_bone(chest_front_mat * Mat4::::from(self.fin_r)), ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.chest_front, - } + Vec3::default() } } diff --git a/voxygen/anim/src/fish_small/mod.rs b/voxygen/anim/src/fish_small/mod.rs index 198ce1fac7..0a644da947 100644 --- a/voxygen/anim/src/fish_small/mod.rs +++ b/voxygen/anim/src/fish_small/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let chest_mat = base_mat * Mat4::::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::::from(self.fin_l)), make_bone(chest_mat * Mat4::::from(self.fin_r)), ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.chest, - } + Vec3::default() } } diff --git a/voxygen/anim/src/fixture/mod.rs b/voxygen/anim/src/fixture/mod.rs index f24e2918f8..edc2c38d80 100644 --- a/voxygen/anim/src/fixture/mod.rs +++ b/voxygen/anim/src/fixture/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { buf[0] = make_bone(base_mat); - Offsets { - lantern: Vec3::default(), - mount_bone: Transform::default(), - } + Vec3::default() } } diff --git a/voxygen/anim/src/golem/mod.rs b/voxygen/anim/src/golem/mod.rs index af19354a00..ef5acd9057 100644 --- a/voxygen/anim/src/golem/mod.rs +++ b/voxygen/anim/src/golem/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let torso_mat = base_mat * Mat4::::from(self.torso); let upper_torso_mat = torso_mat * Mat4::::from(self.upper_torso); let lower_torso_mat = upper_torso_mat * Mat4::::from(self.lower_torso); @@ -70,10 +70,7 @@ impl Skeleton for GolemSkeleton { make_bone(leg_l_mat * Mat4::::from(self.foot_l)), make_bone(leg_r_mat * Mat4::::from(self.foot_r)), ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.torso, - } + Vec3::default() } } diff --git a/voxygen/anim/src/lib.rs b/voxygen/anim/src/lib.rs index 6f73fd4081..733c4ec174 100644 --- a/voxygen/anim/src/lib.rs +++ b/voxygen/anim/src/lib.rs @@ -89,12 +89,6 @@ fn make_bone(mat: Mat4) -> FigureBoneData { pub type Bone = Transform; -// Offsets that will be returned after computing the skeleton matrices -pub struct Offsets { - pub lantern: Vec3, - pub mount_bone: Transform, -} - pub trait Skeleton: Send + Sync + 'static { type Attr; type Body; @@ -108,14 +102,14 @@ pub trait Skeleton: Send + Sync + 'static { &self, base_mat: Mat4, buf: &mut [FigureBoneData; MAX_BONE_COUNT], - ) -> Offsets; + ) -> Vec3; } pub fn compute_matrices( skeleton: &S, base_mat: Mat4, buf: &mut [FigureBoneData; MAX_BONE_COUNT], -) -> Offsets { +) -> Vec3 { #[cfg(not(feature = "use-dyn-lib"))] { S::compute_matrices_inner(skeleton, base_mat, buf) @@ -126,7 +120,7 @@ pub fn compute_matrices( let lib = &lock.as_ref().unwrap().lib; let compute_fn: libloading::Symbol< - fn(&S, Mat4, &mut [FigureBoneData; MAX_BONE_COUNT]) -> Offsets, + fn(&S, Mat4, &mut [FigureBoneData; MAX_BONE_COUNT]) -> Vec3, > = unsafe { lib.get(S::COMPUTE_FN) }.unwrap_or_else(|e| { panic!( "Trying to use: {} but had error: {:?}", diff --git a/voxygen/anim/src/object/mod.rs b/voxygen/anim/src/object/mod.rs index acafbd4497..7a58390ed0 100644 --- a/voxygen/anim/src/object/mod.rs +++ b/voxygen/anim/src/object/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let bone0_mat = base_mat * Mat4::::from(self.bone0); *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [ make_bone(bone0_mat * Mat4::scaling_3d(1.0 / 11.0)), make_bone(Mat4::::from(self.bone1) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */ ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.bone0, - } + Vec3::unit_z() * 0.5 } } diff --git a/voxygen/anim/src/quadruped_low/mod.rs b/voxygen/anim/src/quadruped_low/mod.rs index 5942a5cbc1..63d2dc644c 100644 --- a/voxygen/anim/src/quadruped_low/mod.rs +++ b/voxygen/anim/src/quadruped_low/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let chest_mat = base_mat * Mat4::::from(self.chest); let tail_front = chest_mat * Mat4::::from(self.tail_front); let head_lower_mat = chest_mat * Mat4::::from(self.head_lower); @@ -66,10 +66,7 @@ impl Skeleton for QuadrupedLowSkeleton { make_bone(chest_mat * Mat4::::from(self.foot_bl)), make_bone(chest_mat * Mat4::::from(self.foot_br)), ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.chest, - } + Vec3::default() } } diff --git a/voxygen/anim/src/quadruped_medium/mod.rs b/voxygen/anim/src/quadruped_medium/mod.rs index 611a7f4307..c4ae82537f 100644 --- a/voxygen/anim/src/quadruped_medium/mod.rs +++ b/voxygen/anim/src/quadruped_medium/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let torso_front_mat = base_mat * Mat4::::from(self.torso_front); let torso_back_mat = torso_front_mat * Mat4::::from(self.torso_back); let neck_mat = torso_front_mat * Mat4::::from(self.neck); @@ -81,10 +80,7 @@ impl Skeleton for QuadrupedMediumSkeleton { make_bone(leg_bl_mat * Mat4::::from(self.foot_bl)), make_bone(leg_br_mat * Mat4::::from(self.foot_br)), ]; - 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), diff --git a/voxygen/anim/src/quadruped_small/mod.rs b/voxygen/anim/src/quadruped_small/mod.rs index 537257b84a..5850882906 100644 --- a/voxygen/anim/src/quadruped_small/mod.rs +++ b/voxygen/anim/src/quadruped_small/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let chest_mat = base_mat * Mat4::::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::::from(self.leg_br)), make_bone(chest_mat * Mat4::::from(self.tail)), ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.chest, - } + Vec3::default() } } diff --git a/voxygen/anim/src/ship/mod.rs b/voxygen/anim/src/ship/mod.rs index 190ccaaedc..f9c86cf033 100644 --- a/voxygen/anim/src/ship/mod.rs +++ b/voxygen/anim/src/ship/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let bone0_mat = base_mat * Mat4::::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::::from(self.bone2) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */ make_bone(bone0_mat * Mat4::::from(self.bone3) * Mat4::scaling_3d(1.0 / 11.0)), /* Decorellated from ori */ ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.bone0, - } + Vec3::unit_z() * 0.5 } } diff --git a/voxygen/anim/src/theropod/mod.rs b/voxygen/anim/src/theropod/mod.rs index 75f0852b73..900b9d7d51 100644 --- a/voxygen/anim/src/theropod/mod.rs +++ b/voxygen/anim/src/theropod/mod.rs @@ -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, buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], - ) -> Offsets { + ) -> Vec3 { let chest_front_mat = base_mat * Mat4::::from(self.chest_front); let neck_mat = chest_front_mat * Mat4::::from(self.neck); let head_mat = neck_mat * Mat4::::from(self.head); @@ -71,10 +71,7 @@ impl Skeleton for TheropodSkeleton { make_bone(leg_l_mat * Mat4::::from(self.foot_l)), make_bone(leg_r_mat * Mat4::::from(self.foot_r)), ]; - Offsets { - lantern: Vec3::default(), - mount_bone: self.chest_front, - } + Vec3::default() } } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 25a4561d84..be968bb815 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -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::().maybe(), ecs.read_storage::().maybe(), ecs.read_storage::().maybe(), - ecs.read_storage::().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::() - .retrieve_entity_internal((*entity).into())?; - let bodies = ecs.read_storage::(); - 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::::unit_y(), - state.last_ori * anim::vek::Vec3::::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, locals: Consts, lantern_offset: anim::vek::Vec3, - mountee_offset: anim::vek::Transform, state_time: f32, last_ori: anim::vek::Quaternion, lpindex: u8, @@ -5386,14 +5343,14 @@ impl DerefMut for FigureState { impl FigureState { 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 FigureState { ); 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 FigureState { &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 {