From cf6bf74f7a55b146c0b04a8ddafbf116fb3210fb Mon Sep 17 00:00:00 2001 From: Snowram Date: Sat, 18 Sep 2021 14:47:06 +0200 Subject: [PATCH] Set beam offset depending on body dimensions --- common/src/comp/body.rs | 8 -------- common/src/states/basic_beam.rs | 11 ++++++++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/common/src/comp/body.rs b/common/src/comp/body.rs index ecc6bc3ac2..fe389bae7e 100644 --- a/common/src/comp/body.rs +++ b/common/src/comp/body.rs @@ -147,14 +147,6 @@ impl< const EXTENSION: &'static str = "ron"; } -// Utility enum used to build Stadium points -// Read doc for [Body::sausage] for more. -// -// Actually can be removed I guess? -// We can just determine shape form dimensions. -// -// But I want Dachshund in Veloren at least somewhere XD - impl Body { pub fn is_humanoid(&self) -> bool { matches!(self, Body::Humanoid(_)) } diff --git a/common/src/states/basic_beam.rs b/common/src/states/basic_beam.rs index ffa0e2f14c..a9da6c3f24 100644 --- a/common/src/states/basic_beam.rs +++ b/common/src/states/basic_beam.rs @@ -257,7 +257,16 @@ pub fn beam_offsets( velocity: Vec3, on_ground: Option, ) -> Vec3 { - let body_radius = body.min_radius(); + let dim = body.dimensions(); + // The width (shoulder to shoulder) and length (nose to tail) + let (width, length) = (dim.x, dim.y); + let body_radius = if length > width { + // Dachshund-like + body.max_radius() + } else { + // Cyclops-like + body.min_radius() + }; let body_offsets_z = height_offset(body, look_dir, velocity, on_ground); Vec3::new( body_radius * ori.x * 1.1,