From 48c97cd8293efd6a8c9f04691c67069ae2628dfa Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 21 Feb 2022 11:23:36 -0500 Subject: [PATCH] Glider trails --- voxygen/anim/src/arthropod/mod.rs | 4 +-- voxygen/anim/src/biped_large/mod.rs | 4 +-- voxygen/anim/src/biped_small/mod.rs | 4 +-- voxygen/anim/src/bird_large/mod.rs | 4 +-- voxygen/anim/src/bird_medium/mod.rs | 4 +-- voxygen/anim/src/character/gliding.rs | 2 ++ voxygen/anim/src/character/mod.rs | 38 ++++++++++++++++++++---- voxygen/anim/src/dragon/mod.rs | 4 +-- voxygen/anim/src/fish_medium/mod.rs | 4 +-- voxygen/anim/src/fish_small/mod.rs | 4 +-- voxygen/anim/src/fixture/mod.rs | 4 +-- voxygen/anim/src/golem/mod.rs | 4 +-- voxygen/anim/src/item_drop/mod.rs | 4 +-- voxygen/anim/src/lib.rs | 4 +-- voxygen/anim/src/object/mod.rs | 4 +-- voxygen/anim/src/quadruped_low/mod.rs | 4 +-- voxygen/anim/src/quadruped_medium/mod.rs | 4 +-- voxygen/anim/src/quadruped_small/mod.rs | 4 +-- voxygen/anim/src/ship/mod.rs | 4 +-- voxygen/anim/src/theropod/mod.rs | 4 +-- voxygen/src/scene/figure/mod.rs | 4 +-- voxygen/src/scene/figure/volume.rs | 4 +-- 22 files changed, 75 insertions(+), 45 deletions(-) diff --git a/voxygen/anim/src/arthropod/mod.rs b/voxygen/anim/src/arthropod/mod.rs index ae7de05669..eefe828ae7 100644 --- a/voxygen/anim/src/arthropod/mod.rs +++ b/voxygen/anim/src/arthropod/mod.rs @@ -113,8 +113,8 @@ impl Skeleton for ArthropodSkeleton { orientation: mount_orientation, scale: Vec3::one(), }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/biped_large/mod.rs b/voxygen/anim/src/biped_large/mod.rs index f06af4c2b3..1515bcd258 100644 --- a/voxygen/anim/src/biped_large/mod.rs +++ b/voxygen/anim/src/biped_large/mod.rs @@ -137,8 +137,8 @@ impl Skeleton for BipedLargeSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/biped_small/mod.rs b/voxygen/anim/src/biped_small/mod.rs index b9592900a3..09fee85b28 100644 --- a/voxygen/anim/src/biped_small/mod.rs +++ b/voxygen/anim/src/biped_small/mod.rs @@ -83,8 +83,8 @@ impl Skeleton for BipedSmallSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/bird_large/mod.rs b/voxygen/anim/src/bird_large/mod.rs index 8fa4c3b4c2..ef0caea2a1 100644 --- a/voxygen/anim/src/bird_large/mod.rs +++ b/voxygen/anim/src/bird_large/mod.rs @@ -106,8 +106,8 @@ impl Skeleton for BirdLargeSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/bird_medium/mod.rs b/voxygen/anim/src/bird_medium/mod.rs index 1953518634..83ee2507a6 100644 --- a/voxygen/anim/src/bird_medium/mod.rs +++ b/voxygen/anim/src/bird_medium/mod.rs @@ -60,8 +60,8 @@ impl Skeleton for BirdMediumSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/character/gliding.rs b/voxygen/anim/src/character/gliding.rs index 7bacb1fe9d..4fd4f595fa 100644 --- a/voxygen/anim/src/character/gliding.rs +++ b/voxygen/anim/src/character/gliding.rs @@ -26,6 +26,8 @@ impl Animation for GlidingAnimation { ) -> Self::Skeleton { let mut next = (*skeleton).clone(); + next.glider_trails = true; + let speednorm = velocity.magnitude().min(50.0) / 50.0; let slow = (acc_vel * 0.5).sin(); diff --git a/voxygen/anim/src/character/mod.rs b/voxygen/anim/src/character/mod.rs index c4293d3d37..a8bb230c4d 100644 --- a/voxygen/anim/src/character/mod.rs +++ b/voxygen/anim/src/character/mod.rs @@ -80,6 +80,8 @@ skeleton_impls!(struct CharacterSkeleton { holding_lantern: bool, main_weapon_trail: bool, off_weapon_trail: bool, + // Cannot exist at same time as weapon trails. Since gliding and attacking are mutually exclusive, should never be a concern. + glider_trails: bool, }); impl CharacterSkeleton { @@ -129,6 +131,7 @@ impl Skeleton for CharacterSkeleton { } * Mat4::::from(self.lantern); let main_mat = control_l_mat * Mat4::::from(self.main); let second_mat = control_r_mat * Mat4::::from(self.second); + let glider_mat = chest_mat * Mat4::::from(self.glider); *(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [ make_bone(head_mat), @@ -142,7 +145,7 @@ impl Skeleton for CharacterSkeleton { make_bone(torso_mat * Mat4::::from(self.foot_r)), make_bone(chest_mat * Mat4::::from(self.shoulder_l)), make_bone(chest_mat * Mat4::::from(self.shoulder_r)), - make_bone(chest_mat * Mat4::::from(self.glider)), + make_bone(glider_mat), make_bone(main_mat), make_bone(second_mat), make_bone(lantern_mat), @@ -163,6 +166,24 @@ impl Skeleton for CharacterSkeleton { Vec4::new(0.0, 0.0, lengths.1, 1.0), ) }; + // Offsets + const GLIDER_VERT: f32 = 5.0; + const GLIDER_HORIZ: f32 = 15.0; + // Trail width + const GLIDER_WIDTH: f32 = 1.0; + let glider_offsets_0 = |_| { + ( + Vec4::new(GLIDER_HORIZ, 0.0, GLIDER_VERT, 1.0), + Vec4::new(GLIDER_HORIZ + GLIDER_WIDTH, 0.0, GLIDER_VERT, 1.0), + ) + }; + let glider_offsets_1 = |_| { + ( + Vec4::new(-GLIDER_HORIZ, 0.0, GLIDER_VERT, 1.0), + Vec4::new(-(GLIDER_HORIZ + GLIDER_WIDTH), 0.0, GLIDER_VERT, 1.0), + ) + }; + let weapon_trails = self.main_weapon_trail || self.off_weapon_trail; Offsets { lantern: Some((lantern_mat * Vec4::new(0.0, 0.5, -6.0, 1.0)).xyz()), // TODO: see quadruped_medium for how to animate this @@ -173,10 +194,17 @@ impl Skeleton for CharacterSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: self.main_weapon_trail.then_some((main_mat, weapon_offsets)), - off_weapon_trail_mat: self - .off_weapon_trail - .then_some((second_mat, weapon_offsets)), + primary_trail_mat: if weapon_trails { + self.main_weapon_trail.then_some((main_mat, weapon_offsets)) + } else { + self.glider_trails.then_some((glider_mat, glider_offsets_0)) + }, + secondary_trail_mat: if weapon_trails { + self.off_weapon_trail + .then_some((second_mat, weapon_offsets)) + } else { + self.glider_trails.then_some((glider_mat, glider_offsets_1)) + }, } } } diff --git a/voxygen/anim/src/dragon/mod.rs b/voxygen/anim/src/dragon/mod.rs index ebaa54d108..d89d29d1d6 100644 --- a/voxygen/anim/src/dragon/mod.rs +++ b/voxygen/anim/src/dragon/mod.rs @@ -81,8 +81,8 @@ impl Skeleton for DragonSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/fish_medium/mod.rs b/voxygen/anim/src/fish_medium/mod.rs index 5b3211940d..9b79e27d47 100644 --- a/voxygen/anim/src/fish_medium/mod.rs +++ b/voxygen/anim/src/fish_medium/mod.rs @@ -60,8 +60,8 @@ impl Skeleton for FishMediumSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/fish_small/mod.rs b/voxygen/anim/src/fish_small/mod.rs index 6fde7c2615..4848d69c11 100644 --- a/voxygen/anim/src/fish_small/mod.rs +++ b/voxygen/anim/src/fish_small/mod.rs @@ -51,8 +51,8 @@ impl Skeleton for FishSmallSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/fixture/mod.rs b/voxygen/anim/src/fixture/mod.rs index f5c3c71511..31f7d59d68 100644 --- a/voxygen/anim/src/fixture/mod.rs +++ b/voxygen/anim/src/fixture/mod.rs @@ -37,8 +37,8 @@ impl Skeleton for FixtureSkeleton { Offsets { lantern: None, mount_bone: Transform::default(), - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/golem/mod.rs b/voxygen/anim/src/golem/mod.rs index a08addda6f..bbe7920ad3 100644 --- a/voxygen/anim/src/golem/mod.rs +++ b/voxygen/anim/src/golem/mod.rs @@ -83,8 +83,8 @@ impl Skeleton for GolemSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/item_drop/mod.rs b/voxygen/anim/src/item_drop/mod.rs index 74838b7520..feaae4a369 100644 --- a/voxygen/anim/src/item_drop/mod.rs +++ b/voxygen/anim/src/item_drop/mod.rs @@ -43,8 +43,8 @@ impl Skeleton for ItemDropSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/lib.rs b/voxygen/anim/src/lib.rs index 9baf10cec9..2c41e00d67 100644 --- a/voxygen/anim/src/lib.rs +++ b/voxygen/anim/src/lib.rs @@ -104,8 +104,8 @@ pub fn init() { lazy_static::initialize(&LIB); } pub struct Offsets { pub lantern: Option>, pub mount_bone: Transform, - pub main_weapon_trail_mat: Option<(Mat4, fn(Option) -> (Vec4, Vec4))>, - pub off_weapon_trail_mat: Option<(Mat4, fn(Option) -> (Vec4, Vec4))>, + pub primary_trail_mat: Option<(Mat4, fn(Option) -> (Vec4, Vec4))>, + pub secondary_trail_mat: Option<(Mat4, fn(Option) -> (Vec4, Vec4))>, } pub trait Skeleton: Send + Sync + 'static { diff --git a/voxygen/anim/src/object/mod.rs b/voxygen/anim/src/object/mod.rs index c222bfe898..8562efc17f 100644 --- a/voxygen/anim/src/object/mod.rs +++ b/voxygen/anim/src/object/mod.rs @@ -49,8 +49,8 @@ impl Skeleton for ObjectSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/quadruped_low/mod.rs b/voxygen/anim/src/quadruped_low/mod.rs index 642ad3f925..9d4379e7c8 100644 --- a/voxygen/anim/src/quadruped_low/mod.rs +++ b/voxygen/anim/src/quadruped_low/mod.rs @@ -97,8 +97,8 @@ impl Skeleton for QuadrupedLowSkeleton { orientation: mount_orientation, scale: Vec3::one(), }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/quadruped_medium/mod.rs b/voxygen/anim/src/quadruped_medium/mod.rs index 1f8a862752..f077b21679 100644 --- a/voxygen/anim/src/quadruped_medium/mod.rs +++ b/voxygen/anim/src/quadruped_medium/mod.rs @@ -109,8 +109,8 @@ impl Skeleton for QuadrupedMediumSkeleton { orientation: mount_orientation, scale: Vec3::one(), }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/quadruped_small/mod.rs b/voxygen/anim/src/quadruped_small/mod.rs index 15896b8491..a45f22d580 100644 --- a/voxygen/anim/src/quadruped_small/mod.rs +++ b/voxygen/anim/src/quadruped_small/mod.rs @@ -74,8 +74,8 @@ impl Skeleton for QuadrupedSmallSkeleton { orientation: mount_orientation, scale: Vec3::one(), }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/ship/mod.rs b/voxygen/anim/src/ship/mod.rs index aa675c6c79..92eec74962 100644 --- a/voxygen/anim/src/ship/mod.rs +++ b/voxygen/anim/src/ship/mod.rs @@ -53,8 +53,8 @@ impl Skeleton for ShipSkeleton { ), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/anim/src/theropod/mod.rs b/voxygen/anim/src/theropod/mod.rs index bf7f30dfab..74f3c949c3 100644 --- a/voxygen/anim/src/theropod/mod.rs +++ b/voxygen/anim/src/theropod/mod.rs @@ -84,8 +84,8 @@ impl Skeleton for TheropodSkeleton { .into(), ..Default::default() }, - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } } } diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 9181a1effb..86cdd43d0f 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -6474,7 +6474,7 @@ impl FigureState { if let (Some(trail_mgr), Some(entity)) = (trail_mgr, entity) { handle_weapon_trails( trail_mgr, - offsets.main_weapon_trail_mat, + offsets.primary_trail_mat, &mut self.main_abs_trail_points, *entity, true, @@ -6483,7 +6483,7 @@ impl FigureState { ); handle_weapon_trails( trail_mgr, - offsets.off_weapon_trail_mat, + offsets.secondary_trail_mat, &mut self.off_abs_trail_points, *entity, false, diff --git a/voxygen/src/scene/figure/volume.rs b/voxygen/src/scene/figure/volume.rs index 968c76e840..ac31a55b57 100644 --- a/voxygen/src/scene/figure/volume.rs +++ b/voxygen/src/scene/figure/volume.rs @@ -49,8 +49,8 @@ impl anim::Skeleton for VolumeKey { anim::Offsets { lantern: None, mount_bone: anim::vek::Transform::default(), - main_weapon_trail_mat: None, - off_weapon_trail_mat: None, + primary_trail_mat: None, + secondary_trail_mat: None, } }