diff --git a/CHANGELOG.md b/CHANGELOG.md index 91effc1637..339da87968 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Campfires now despawn when underwater - Players no longer spawn underground if their waypoint is underground - Map will now zoom around the cursor's position and drag correctly +- No more jittering while running down slopes with the glider out ## [0.10.0] - 2021-06-12 diff --git a/client/src/lib.rs b/client/src/lib.rs index ae69cbf55a..018ca47a64 100644 --- a/client/src/lib.rs +++ b/client/src/lib.rs @@ -1231,7 +1231,7 @@ impl Client { .map(|cs| { matches!( cs, - comp::CharacterState::GlideWield | comp::CharacterState::Glide(_) + comp::CharacterState::GlideWield(_) | comp::CharacterState::Glide(_) ) }); diff --git a/common/src/comp/character_state.rs b/common/src/comp/character_state.rs index a0f2be1ee5..2df87fcae6 100644 --- a/common/src/comp/character_state.rs +++ b/common/src/comp/character_state.rs @@ -59,7 +59,7 @@ pub enum CharacterState { Talk, Sneak, Glide(glide::Data), - GlideWield, + GlideWield(glide_wield::Data), /// A stunned state Stunned(stunned::Data), /// A basic blocking state @@ -189,7 +189,7 @@ impl CharacterState { | CharacterState::Equipping(_) | CharacterState::Dance | CharacterState::Glide(_) - | CharacterState::GlideWield + | CharacterState::GlideWield(_) | CharacterState::Talk | CharacterState::Roll(_), ) @@ -228,7 +228,7 @@ impl CharacterState { CharacterState::Talk => states::talk::Data.behavior(j), CharacterState::Climb(data) => data.behavior(j), CharacterState::Glide(data) => data.behavior(j), - CharacterState::GlideWield => states::glide_wield::Data.behavior(j), + CharacterState::GlideWield(data) => data.behavior(j), CharacterState::Stunned(data) => data.behavior(j), CharacterState::Sit => states::sit::Data::behavior(&states::sit::Data, j), CharacterState::Dance => states::dance::Data::behavior(&states::dance::Data, j), @@ -264,7 +264,7 @@ impl CharacterState { CharacterState::Talk => states::talk::Data.handle_event(j, action), CharacterState::Climb(data) => data.handle_event(j, action), CharacterState::Glide(data) => data.handle_event(j, action), - CharacterState::GlideWield => states::glide_wield::Data.handle_event(j, action), + CharacterState::GlideWield(data) => data.handle_event(j, action), CharacterState::Stunned(data) => data.handle_event(j, action), CharacterState::Sit => states::sit::Data::handle_event(&states::sit::Data, j, action), CharacterState::Dance => { diff --git a/common/src/states/glide.rs b/common/src/states/glide.rs index 00f9b65336..2542cfa211 100644 --- a/common/src/states/glide.rs +++ b/common/src/states/glide.rs @@ -4,7 +4,10 @@ use crate::{ fluid_dynamics::angle_of_attack, inventory::slot::EquipSlot, CharacterState, Ori, StateUpdate, Vel, }, - states::behavior::{CharacterBehavior, JoinData}, + states::{ + behavior::{CharacterBehavior, JoinData}, + glide_wield, + }, util::{Dir, Plane, Projection}, }; use serde::{Deserialize, Serialize}; @@ -77,8 +80,7 @@ impl CharacterBehavior for Data { if data.physics.on_ground.is_some() && (data.vel.0 - data.physics.ground_vel).magnitude_squared() < 2_f32.powi(2) { - update.character = CharacterState::GlideWield; - update.ori = update.ori.to_horizontal(); + update.character = CharacterState::GlideWield(glide_wield::Data::default()); } else if data.physics.in_liquid().is_some() || data .inventory @@ -86,7 +88,6 @@ impl CharacterBehavior for Data { .is_none() { update.character = CharacterState::Idle; - update.ori = update.ori.to_horizontal(); } else if !handle_climb(data, &mut update) { let air_flow = data .physics @@ -193,8 +194,6 @@ impl CharacterBehavior for Data { inputs_disabled, ..*self }); - } else { - update.ori = update.ori.to_horizontal(); } update @@ -203,7 +202,6 @@ impl CharacterBehavior for Data { fn unwield(&self, data: &JoinData) -> StateUpdate { let mut update = StateUpdate::from(data); update.character = CharacterState::Idle; - update.ori = update.ori.to_horizontal(); update } } diff --git a/common/src/states/glide_wield.rs b/common/src/states/glide_wield.rs index 269d8c50b2..de8af4ea12 100644 --- a/common/src/states/glide_wield.rs +++ b/common/src/states/glide_wield.rs @@ -6,8 +6,18 @@ use crate::{ glide, }, }; +use serde::{Deserialize, Serialize}; -pub struct Data; +#[derive(Copy, Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct Data { + // time since left ground, for preventing state transition + // before block snapping kicks in + timer: f32, +} + +impl Default for Data { + fn default() -> Self { Self { timer: 0.0 } } +} impl CharacterBehavior for Data { fn behavior(&self, data: &JoinData) -> StateUpdate { @@ -21,7 +31,13 @@ impl CharacterBehavior for Data { // If not on the ground while wielding glider enter gliding state if data.physics.on_ground.is_none() { - update.character = CharacterState::Glide(glide::Data::new(10.0, 0.6, *data.ori)); + update.character = if self.timer > 0.3 { + CharacterState::Glide(glide::Data::new(10.0, 0.6, *data.ori)) + } else { + CharacterState::GlideWield(Self { + timer: self.timer + data.dt.0, + }) + }; } if data .physics diff --git a/common/src/states/utils.rs b/common/src/states/utils.rs index 0275524f6f..3e0553982a 100644 --- a/common/src/states/utils.rs +++ b/common/src/states/utils.rs @@ -639,7 +639,7 @@ pub fn attempt_glide_wield(data: &JoinData<'_>, update: &mut StateUpdate) { .unwrap_or(false) && data.body.is_humanoid() { - update.character = CharacterState::GlideWield; + update.character = CharacterState::GlideWield(glide_wield::Data::default()); } } diff --git a/flake.lock b/flake.lock index 2a87ca1208..9c1d6b3ff6 100644 --- a/flake.lock +++ b/flake.lock @@ -24,11 +24,11 @@ "rustOverlay": "rustOverlay" }, "locked": { - "lastModified": 1625378930, - "narHash": "sha256-iBnCmrLweBmtN9VkG6AX4wSE5UUF//4VtfX6Ebhbaew=", + "lastModified": 1627752074, + "narHash": "sha256-iuOGIbJC4hn1XqwrBjiol6j0Xj+AImND6Z9fP/6Za74=", "owner": "yusdacra", "repo": "nix-cargo-integration", - "rev": "4d6efcfd0bc6c6235b180837257ab8020f108c23", + "rev": "47e6414440c66bfd44a0ea07d64ca62075470f62", "type": "github" }, "original": { @@ -39,11 +39,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1625375231, - "narHash": "sha256-dbp2RRftypbAYad/xhDBBG0N7s1WQW+T4jazimvtvRo=", + "lastModified": 1627533199, + "narHash": "sha256-NyIUcNevwtsMBINn56jnDF8wz3TV1AFxw+Vw6JMnkyE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "8aff53d3cf23b5eb67c0ba9ba2392d694ade3930", + "rev": "dd98b100651cfbb8804f32d852f75ef7c97a6b74", "type": "github" }, "original": { @@ -62,11 +62,11 @@ "rustOverlay": { "flake": false, "locked": { - "lastModified": 1625364738, - "narHash": "sha256-TPlpEcywGnB8jNIPOlCqFVbioskGOpasrVhxdw0BHzA=", + "lastModified": 1627697717, + "narHash": "sha256-ij7rk2VkPpNf0NTbpP5jfbwuIWfrLXN00pZ+pizGnGM=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "f08a653d9d6bbf06b5cc5dd1e570f1c449acbcf3", + "rev": "6d957c2105a5a548211c412fbc97bae81b7b8eb6", "type": "github" }, "original": { diff --git a/server/src/sys/agent.rs b/server/src/sys/agent.rs index 77468133fb..a0ac28315e 100644 --- a/server/src/sys/agent.rs +++ b/server/src/sys/agent.rs @@ -291,7 +291,7 @@ impl<'a> System<'a> for Sys { let is_gliding = matches!( read_data.char_states.get(entity), - Some(CharacterState::GlideWield | CharacterState::Glide(_)) + Some(CharacterState::GlideWield(_) | CharacterState::Glide(_)) ) && physics_state.on_ground.is_none(); if let Some(pid) = agent.position_pid_controller.as_mut() { diff --git a/voxygen/egui/src/character_states.rs b/voxygen/egui/src/character_states.rs index 52b1c9df13..39a8660119 100644 --- a/voxygen/egui/src/character_states.rs +++ b/voxygen/egui/src/character_states.rs @@ -24,7 +24,7 @@ pub fn draw_char_state_group( CharacterState::Dance | CharacterState::Idle | CharacterState::Sit - | CharacterState::GlideWield + | CharacterState::GlideWield(_) | CharacterState::Sneak | CharacterState::Talk | CharacterState::Wielding => {},