Make each race's hitbox and weight scale linearly with their height

This causes all humanoids to handle identically when falling, gliding, or swimming
This commit is contained in:
Treeco 2021-08-05 17:23:02 +01:00
parent ebf489984c
commit 2fc62bfe7f
4 changed files with 29 additions and 41 deletions

View File

@ -210,14 +210,10 @@ impl Body {
//
// If you want to change that value, consult with
// Physics and Combat teams
match humanoid.species {
humanoid::Species::Orc => 100.0,
humanoid::Species::Elf => 85.0,
humanoid::Species::Human => 85.0,
humanoid::Species::Dwarf => 80.0,
humanoid::Species::Undead => 75.0,
humanoid::Species::Danari => 75.0,
}
//
// Weight is proportional height, where
// a 1.75m character would weigh 65kg
65.0 * humanoid.height() / 1.75f32
},
Body::Object(obj) => obj.mass().0,
Body::QuadrupedLow(body) => match body.species {
@ -331,21 +327,8 @@ impl Body {
Body::FishSmall(_) => Vec3::new(0.3, 1.2, 0.6),
Body::Golem(_) => Vec3::new(5.0, 5.0, 7.5),
Body::Humanoid(humanoid) => {
let height = match (humanoid.species, humanoid.body_type) {
(humanoid::Species::Orc, humanoid::BodyType::Male) => 2.0,
(humanoid::Species::Orc, humanoid::BodyType::Female) => 1.9,
(humanoid::Species::Human, humanoid::BodyType::Male) => 1.8,
(humanoid::Species::Human, humanoid::BodyType::Female) => 1.7,
(humanoid::Species::Elf, humanoid::BodyType::Male) => 1.9,
(humanoid::Species::Elf, humanoid::BodyType::Female) => 1.8,
(humanoid::Species::Dwarf, humanoid::BodyType::Male) => 1.6,
(humanoid::Species::Dwarf, humanoid::BodyType::Female) => 1.5,
(humanoid::Species::Undead, humanoid::BodyType::Male) => 1.9,
(humanoid::Species::Undead, humanoid::BodyType::Female) => 1.8,
(humanoid::Species::Danari, humanoid::BodyType::Male) => 1.5,
(humanoid::Species::Danari, humanoid::BodyType::Female) => 1.4,
};
Vec3::new(1.5, 0.5, height)
let height = humanoid.height();
Vec3::new(height / 1.3, 1.75 / 2.0, height)
},
Body::Object(object) => object.dimensions(),
Body::QuadrupedMedium(body) => match body.species {

View File

@ -64,6 +64,25 @@ impl Body {
.accessory
.min(self.species.num_accessories(self.body_type) - 1);
}
pub fn height(&self) -> f32 { (20.0 / 9.0) * self.scaler() }
pub fn scaler(&self) -> f32 {
match (self.species, self.body_type) {
(Species::Orc, BodyType::Male) => 0.91,
(Species::Orc, BodyType::Female) => 0.81,
(Species::Human, BodyType::Male) => 0.81,
(Species::Human, BodyType::Female) => 0.76,
(Species::Elf, BodyType::Male) => 0.82,
(Species::Elf, BodyType::Female) => 0.76,
(Species::Dwarf, BodyType::Male) => 0.67,
(Species::Dwarf, BodyType::Female) => 0.62,
(Species::Undead, BodyType::Male) => 0.78,
(Species::Undead, BodyType::Female) => 0.72,
(Species::Danari, BodyType::Male) => 0.56,
(Species::Danari, BodyType::Female) => 0.56,
}
}
}
impl From<Body> for super::Body {

View File

@ -17,15 +17,15 @@ pub struct Data {
impl From<&JoinData<'_>> for Data {
fn from(data: &JoinData) -> Self {
let scale = data.body.dimensions().z;
let scale = data.body.dimensions().z.sqrt();
Self {
// Aspect ratio is what really matters for lift/drag ratio
// and the aerodynamics model works for ARs up to 25.
// The inflated dimensions are hopefully only a temporary
// bandaid for the poor glide ratio experienced under 2.5G.
// A span/chord ratio of 4.5 gives an AR of ~5.73.
span_length: scale * 3.0,
chord_length: scale / 1.5,
span_length: scale * 4.5,
chord_length: scale,
ori: *data.ori,
}
}

View File

@ -231,21 +231,7 @@ impl<'a> From<&'a Body> for SkeletonAttr {
fn from(body: &'a Body) -> Self {
use comp::humanoid::{BodyType::*, Species::*};
Self {
scaler: match (body.species, body.body_type) {
// TODO : Derive scale from body proportions
(Orc, Male) => 0.91,
(Orc, Female) => 0.81,
(Human, Male) => 0.81,
(Human, Female) => 0.76,
(Elf, Male) => 0.82,
(Elf, Female) => 0.76,
(Dwarf, Male) => 0.67,
(Dwarf, Female) => 0.62,
(Undead, Male) => 0.78,
(Undead, Female) => 0.72,
(Danari, Male) => 0.56,
(Danari, Female) => 0.56,
},
scaler: body.scaler(),
head_scale: match (body.species, body.body_type) {
(Orc, Male) => 0.9,
(Orc, Female) => 0.9,