Set beam offset depending on body dimensions

This commit is contained in:
Snowram 2021-09-18 14:47:06 +02:00 committed by Robin Gilh
parent 7a73e4240b
commit cf6bf74f7a
2 changed files with 10 additions and 9 deletions

View File

@ -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(_)) }

View File

@ -257,7 +257,16 @@ pub fn beam_offsets(
velocity: Vec3<f32>,
on_ground: Option<Block>,
) -> Vec3<f32> {
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,