Swaps bird_small skeleton to a new bird_large

This commit is contained in:
Snowram 2021-04-02 02:04:32 +02:00
parent 869f1f9501
commit 5b8fbe9a23
42 changed files with 1233 additions and 373 deletions

View File

@ -1068,12 +1068,19 @@
)
)
),
bird_small: (
bird_large: (
body: (
keyword: "bird_small",
names_0: []
keyword: "bird_large",
names_0: [
"Aitvaras"
]
),
species: ()
species: (
phoenix: (
keyword: "phoenix",
generic: "Phoenix"
),
)
),
quadruped_low: (
body: (

View File

@ -0,0 +1,54 @@
({
(Phoenix, Male): (
head: (
offset: (-2.0, -1.0, -0.0),
central: ("npc.phoenix.male.head"),
),
beak: (
offset: (-2.0, 0.0, -1.0),
central: ("npc.phoenix.male.beak"),
),
neck: (
offset: (-2.0, -0.0, -0.0),
central: ("npc.phoenix.male.neck"),
),
chest: (
offset: (-3.0, -5.5, -4.0),
central: ("npc.phoenix.male.chest"),
),
tail_front: (
offset: (-2.0, -3.0, -3.0),
central: ("npc.phoenix.male.tail_front"),
),
tail_rear: (
offset: (-1.0, -3.0, -3.0),
central: ("npc.phoenix.male.tail_rear"),
)
),
(Phoenix, Female): (
head: (
offset: (-2.0, -1.0, -0.0),
central: ("npc.phoenix.male.head"),
),
beak: (
offset: (-2.0, 0.0, -1.0),
central: ("npc.phoenix.male.beak"),
),
neck: (
offset: (-2.0, -0.0, -0.0),
central: ("npc.phoenix.male.neck"),
),
chest: (
offset: (-3.0, -5.5, -4.0),
central: ("npc.phoenix.male.chest"),
),
tail_front: (
offset: (-2.0, -3.0, -3.0),
central: ("npc.phoenix.male.tail_front"),
),
tail_rear: (
offset: (-1.0, -3.0, -3.0),
central: ("npc.phoenix.male.tail_rear"),
)
),
})

View File

@ -0,0 +1,86 @@
({
(Phoenix, Male): (
wing_in_l: (
offset: (-6.0, -5.0, -2.0),
lateral: ("npc.phoenix.male.wing_in_l"),
),
wing_in_r: (
offset: (0.0, -5.0, -2.0),
lateral: ("npc.phoenix.male.wing_in_r"),
),
wing_mid_l: (
offset: (-2.5, -7.0, -2.0),
lateral: ("npc.phoenix.male.wing_mid_l"),
),
wing_mid_r: (
offset: (-2.5, -7.0, -2.0),
lateral: ("npc.phoenix.male.wing_mid_r"),
),
wing_out_l: (
offset: (-9.0, -8.0, -2.0),
lateral: ("npc.phoenix.male.wing_out_l"),
),
wing_out_r: (
offset: (0.0, -8.0, -2.0),
lateral: ("npc.phoenix.male.wing_out_r"),
),
leg_l: (
offset: (-1.5, -1.5, -1.5),
lateral: ("npc.phoenix.male.leg_l"),
),
leg_r: (
offset: (-1.5, -1.5, -1.5),
lateral: ("npc.phoenix.male.leg_r"),
),
foot_l: (
offset: (-1.5, -2.0, -4.0),
lateral: ("npc.phoenix.male.foot_l"),
),
foot_r: (
offset: (-1.5, -2.0, -4.0),
lateral: ("npc.phoenix.male.foot_r"),
)
),
(Phoenix, Female): (
wing_in_l: (
offset: (-6.0, -5.0, -2.0),
lateral: ("npc.phoenix.male.wing_in_l"),
),
wing_in_r: (
offset: (0.0, -5.0, -2.0),
lateral: ("npc.phoenix.male.wing_in_r"),
),
wing_mid_l: (
offset: (-2.5, -7.0, -2.0),
lateral: ("npc.phoenix.male.wing_mid_l"),
),
wing_mid_r: (
offset: (-2.5, -7.0, -2.0),
lateral: ("npc.phoenix.male.wing_mid_r"),
),
wing_out_l: (
offset: (-9.0, -8.0, -2.0),
lateral: ("npc.phoenix.male.wing_out_l"),
),
wing_out_r: (
offset: (0.0, -8.0, -2.0),
lateral: ("npc.phoenix.male.wing_out_r"),
),
leg_l: (
offset: (-1.5, -1.5, -1.5),
lateral: ("npc.phoenix.male.leg_l"),
),
leg_r: (
offset: (-1.5, -1.5, -1.5),
lateral: ("npc.phoenix.male.leg_r"),
),
foot_l: (
offset: (-1.5, -2.0, -4.0),
lateral: ("npc.phoenix.male.foot_l"),
),
foot_r: (
offset: (-1.5, -2.0, -4.0),
lateral: ("npc.phoenix.male.foot_r"),
)
),
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -247,7 +247,7 @@ impl<'a> From<&'a Body> for Psyche {
},
Body::BipedSmall(_) => 0.5,
Body::BirdMedium(_) => 0.5,
Body::BirdSmall(_) => 0.4,
Body::BirdLarge(_) => 0.4,
Body::FishMedium(_) => 0.15,
Body::FishSmall(_) => 0.0,
Body::BipedLarge(_) => 1.0,

View File

@ -1,7 +1,7 @@
pub mod biped_large;
pub mod biped_small;
pub mod bird_large;
pub mod bird_medium;
pub mod bird_small;
pub mod dragon;
pub mod fish_medium;
pub mod fish_small;
@ -38,7 +38,7 @@ make_case_elim!(
BirdMedium(body: bird_medium::Body) = 3,
FishMedium(body: fish_medium::Body) = 4,
Dragon(body: dragon::Body) = 5,
BirdSmall(body: bird_small::Body) = 6,
BirdLarge(body: bird_large::Body) = 6,
FishSmall(body: fish_small::Body) = 7,
BipedLarge(body: biped_large::Body)= 8,
BipedSmall(body: biped_small::Body)= 9,
@ -73,7 +73,7 @@ pub struct AllBodies<BodyMeta, SpeciesMeta> {
pub bird_medium: BodyData<BodyMeta, bird_medium::AllSpecies<SpeciesMeta>>,
pub fish_medium: BodyData<BodyMeta, fish_medium::AllSpecies<SpeciesMeta>>,
pub dragon: BodyData<BodyMeta, dragon::AllSpecies<SpeciesMeta>>,
pub bird_small: BodyData<BodyMeta, ()>,
pub bird_large: BodyData<BodyMeta, bird_large::AllSpecies<SpeciesMeta>>,
pub fish_small: BodyData<BodyMeta, fish_small::AllSpecies<SpeciesMeta>>,
pub biped_large: BodyData<BodyMeta, biped_large::AllSpecies<SpeciesMeta>>,
pub biped_small: BodyData<BodyMeta, biped_small::AllSpecies<SpeciesMeta>>,
@ -95,6 +95,7 @@ impl<BodyMeta, SpeciesMeta> core::ops::Index<NpcKind> for AllBodies<BodyMeta, Sp
NpcKind::Pig => &self.quadruped_small.body,
NpcKind::Wolf => &self.quadruped_medium.body,
NpcKind::Duck => &self.bird_medium.body,
NpcKind::Phoenix => &self.bird_large.body,
NpcKind::Marlin => &self.fish_medium.body,
NpcKind::Clownfish => &self.fish_small.body,
NpcKind::Ogre => &self.biped_large.body,
@ -118,9 +119,10 @@ impl<'a, BodyMeta, SpeciesMeta> core::ops::Index<&'a Body> for AllBodies<BodyMet
Body::QuadrupedSmall(_) => &self.quadruped_small.body,
Body::QuadrupedMedium(_) => &self.quadruped_medium.body,
Body::BirdMedium(_) => &self.bird_medium.body,
Body::BirdLarge(_) => &self.bird_large.body,
Body::FishMedium(_) => &self.fish_medium.body,
Body::Dragon(_) => &self.dragon.body,
Body::BirdSmall(_) => &self.bird_small.body,
Body::BirdLarge(_) => &self.bird_large.body,
Body::FishSmall(_) => &self.fish_small.body,
Body::BipedLarge(_) => &self.biped_large.body,
Body::BipedSmall(_) => &self.biped_small.body,
@ -152,7 +154,7 @@ impl Body {
let d = match self {
// based on a house sparrow (Passer domesticus)
Body::BirdMedium(_) => 700.0,
Body::BirdSmall(_) => 700.0,
Body::BirdLarge(_) => 700.0,
// based on its mass divided by the volume of a bird scaled up to the size of the dragon
Body::Dragon(_) => 3_700.0,
@ -184,7 +186,7 @@ impl Body {
// ravens are 0.69-2 kg, crows are 0.51 kg on average
Body::BirdMedium(_) => 1.0,
// australian magpies are around 0.22-0.35 kg
Body::BirdSmall(_) => 0.3,
Body::BirdLarge(_) => 0.3,
Body::Dragon(_) => 20_000.0,
Body::FishMedium(_) => 2.5,
@ -285,7 +287,7 @@ impl Body {
bird_medium::Species::Cockatrice => Vec3::new(2.0, 1.0, 1.8),
_ => Vec3::new(2.0, 1.0, 1.1),
},
Body::BirdSmall(_) => Vec3::new(1.2, 0.6, 1.1),
Body::BirdLarge(_) => Vec3::new(1.2, 0.6, 1.1),
Body::Dragon(_) => Vec3::new(16.0, 10.0, 16.0),
Body::FishMedium(_) => Vec3::new(0.5, 2.0, 0.8),
Body::FishSmall(_) => Vec3::new(0.3, 1.2, 0.6),
@ -435,7 +437,7 @@ impl Body {
},
Body::FishMedium(_) => 50,
Body::Dragon(_) => 5000,
Body::BirdSmall(_) => 50,
Body::BirdLarge(_) => 50,
Body::FishSmall(_) => 20,
Body::BipedLarge(biped_large) => match biped_large.species {
biped_large::Species::Ogre => 2500,
@ -548,7 +550,7 @@ impl Body {
},
Body::FishMedium(_) => 10,
Body::Dragon(_) => 500,
Body::BirdSmall(_) => 10,
Body::BirdLarge(_) => 10,
Body::FishSmall(_) => 10,
Body::BipedLarge(biped_large) => match biped_large.species {
biped_large::Species::Ogre => 70,
@ -587,7 +589,7 @@ impl Body {
pub fn flying_height(&self) -> f32 {
match self {
Body::BirdSmall(_) => 30.0,
Body::BirdLarge(_) => 30.0,
Body::BirdMedium(_) => 40.0,
Body::Dragon(_) => 60.0,
Body::Ship(ship::Body::DefaultAirship) => 60.0,

View File

@ -0,0 +1,79 @@
use crate::{make_case_elim, make_proj_elim};
use rand::{seq::SliceRandom, thread_rng};
use serde::{Deserialize, Serialize};
make_proj_elim!(
body,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Body {
pub species: Species,
pub body_type: BodyType,
}
);
impl Body {
pub fn random() -> Self {
let mut rng = thread_rng();
let species = *(&ALL_SPECIES).choose(&mut rng).unwrap();
Self::random_with(&mut rng, &species)
}
#[inline]
pub fn random_with(rng: &mut impl rand::Rng, &species: &Species) -> Self {
let body_type = *(&ALL_BODY_TYPES).choose(rng).unwrap();
Self { species, body_type }
}
}
impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::BirdLarge(body) }
}
make_case_elim!(
species,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum Species {
Phoenix = 0,
}
);
/// Data representing per-species generic data.
///
/// NOTE: Deliberately don't (yet?) implement serialize.
#[derive(Clone, Debug, Deserialize)]
pub struct AllSpecies<SpeciesMeta> {
pub phoenix: SpeciesMeta,
}
impl<'a, SpeciesMeta> core::ops::Index<&'a Species> for AllSpecies<SpeciesMeta> {
type Output = SpeciesMeta;
#[inline]
fn index(&self, &index: &'a Species) -> &Self::Output {
match index {
Species::Phoenix => &self.phoenix,
}
}
}
pub const ALL_SPECIES: [Species; 1] = [Species::Phoenix];
impl<'a, SpeciesMeta: 'a> IntoIterator for &'a AllSpecies<SpeciesMeta> {
type IntoIter = std::iter::Copied<std::slice::Iter<'static, Self::Item>>;
type Item = Species;
fn into_iter(self) -> Self::IntoIter { ALL_SPECIES.iter().copied() }
}
make_case_elim!(
body_type,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum BodyType {
Female = 0,
Male = 1,
}
);
pub const ALL_BODY_TYPES: [BodyType; 2] = [BodyType::Female, BodyType::Male];

View File

@ -1,66 +0,0 @@
use crate::{make_case_elim, make_proj_elim};
use rand::{seq::SliceRandom, thread_rng};
use serde::{Deserialize, Serialize};
make_proj_elim!(
body,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct Body {
pub head: Head,
pub torso: Torso,
pub wing_l: WingL,
pub wing_r: WingR,
}
);
impl Body {
pub fn random() -> Self {
let mut rng = thread_rng();
Self {
head: *(&ALL_HEADS).choose(&mut rng).unwrap(),
torso: *(&ALL_TORSOS).choose(&mut rng).unwrap(),
wing_l: *(&ALL_WING_LS).choose(&mut rng).unwrap(),
wing_r: *(&ALL_WING_RS).choose(&mut rng).unwrap(),
}
}
}
make_case_elim!(
head,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum Head {
Default = 0,
}
);
const ALL_HEADS: [Head; 1] = [Head::Default];
make_case_elim!(
torso,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum Torso {
Default = 0,
}
);
const ALL_TORSOS: [Torso; 1] = [Torso::Default];
make_case_elim!(
wing_l,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum WingL {
Default = 0,
}
);
const ALL_WING_LS: [WingL; 1] = [WingL::Default];
make_case_elim!(
wing_r,
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)]
pub enum WingR {
Default = 0,
}
);
const ALL_WING_RS: [WingR; 1] = [WingR::Default];

View File

@ -129,11 +129,11 @@ impl Body {
},
// Cross-section, zero-lift angle; exclude the wings (width * 0.2)
Body::BirdMedium(_) | Body::BirdSmall(_) | Body::Dragon(_) => {
Body::BirdMedium(_) | Body::BirdLarge(_) | Body::Dragon(_) => {
let dim = self.dimensions().map(|a| a * 0.5);
let cd = match self {
Body::BirdMedium(_) => 0.2,
Body::BirdSmall(_) => 0.4,
Body::BirdLarge(_) => 0.4,
_ => 0.7,
};
cd * std::f32::consts::PI * dim.x * 0.2 * dim.z

View File

@ -50,7 +50,7 @@ pub use self::{
aura::{Aura, AuraChange, AuraKind, Auras},
beam::{Beam, BeamSegment},
body::{
biped_large, biped_small, bird_medium, bird_small, dragon, fish_medium, fish_small, golem,
biped_large, biped_small, bird_large, bird_medium, dragon, fish_medium, fish_small, golem,
humanoid, object, quadruped_low, quadruped_medium, quadruped_small, ship, theropod,
AllBodies, Body, BodyData,
},

View File

@ -135,6 +135,7 @@ impl EntityInfo {
Some(get_npc_name(&npc_names.quadruped_medium, body.species))
},
Body::BirdMedium(body) => Some(get_npc_name(&npc_names.bird_medium, body.species)),
Body::BirdLarge(body) => Some(get_npc_name(&npc_names.bird_large, body.species)),
Body::FishSmall(body) => Some(get_npc_name(&npc_names.fish_small, body.species)),
Body::FishMedium(body) => Some(get_npc_name(&npc_names.fish_medium, body.species)),
Body::Theropod(body) => Some(get_npc_name(&npc_names.theropod, body.species)),

View File

@ -13,6 +13,7 @@ pub enum NpcKind {
Wolf,
Pig,
Duck,
Phoenix,
Clownfish,
Marlin,
Ogre,
@ -23,11 +24,12 @@ pub enum NpcKind {
Crocodile,
}
pub const ALL_NPCS: [NpcKind; 12] = [
pub const ALL_NPCS: [NpcKind; 13] = [
NpcKind::Humanoid,
NpcKind::Wolf,
NpcKind::Pig,
NpcKind::Duck,
NpcKind::Phoenix,
NpcKind::Clownfish,
NpcKind::Marlin,
NpcKind::Ogre,
@ -122,6 +124,7 @@ pub fn kind_to_body(kind: NpcKind) -> Body {
NpcKind::Pig => comp::quadruped_small::Body::random().into(),
NpcKind::Wolf => comp::quadruped_medium::Body::random().into(),
NpcKind::Duck => comp::bird_medium::Body::random().into(),
NpcKind::Phoenix => comp::bird_large::Body::random().into(),
NpcKind::Clownfish => comp::fish_small::Body::random().into(),
NpcKind::Marlin => comp::fish_medium::Body::random().into(),
NpcKind::Ogre => comp::biped_large::Body::random().into(),
@ -228,6 +231,14 @@ impl NpcBody {
comp::bird_medium::Body::random_with,
)
})
.or_else(|| {
parse(
s,
NpcKind::Phoenix,
&npc_names.bird_large,
comp::bird_large::Body::random_with,
)
})
.or_else(|| {
parse(
s,

View File

@ -77,7 +77,7 @@ impl Body {
Body::BirdMedium(_) => 80.0,
Body::FishMedium(_) => 80.0,
Body::Dragon(_) => 250.0,
Body::BirdSmall(_) => 75.0,
Body::BirdLarge(_) => 75.0,
Body::FishSmall(_) => 60.0,
Body::BipedSmall(biped_small) => match biped_small.species {
biped_small::Species::Haniwa => 65.0,
@ -133,7 +133,7 @@ impl Body {
Body::BirdMedium(_) => 6.0,
Body::FishMedium(_) => 6.0,
Body::Dragon(_) => 1.0,
Body::BirdSmall(_) => 7.0,
Body::BirdLarge(_) => 7.0,
Body::FishSmall(_) => 7.0,
Body::BipedLarge(_) => 1.6,
Body::BipedSmall(_) => 2.4,
@ -165,7 +165,7 @@ impl Body {
Body::BipedLarge(_) | Body::Golem(_) => Some(200.0 * self.mass().0),
Body::BipedSmall(_) => Some(100.0 * self.mass().0),
Body::BirdMedium(_) => Some(50.0 * self.mass().0),
Body::BirdSmall(_) => Some(50.0 * self.mass().0),
Body::BirdLarge(_) => Some(50.0 * self.mass().0),
Body::FishMedium(_) => Some(50.0 * self.mass().0),
Body::FishSmall(_) => Some(50.0 * self.mass().0),
Body::Dragon(_) => Some(200.0 * self.mass().0),
@ -188,7 +188,7 @@ impl Body {
pub fn fly_thrust(&self) -> Option<f32> {
match self {
Body::BirdMedium(_) => Some(GRAVITY * self.mass().0 * 2.0),
Body::BirdSmall(_) => Some(GRAVITY * self.mass().0 * 2.0),
Body::BirdLarge(_) => Some(GRAVITY * self.mass().0 * 2.0),
Body::Dragon(_) => Some(200_000.0),
Body::Ship(ship::Body::DefaultAirship) => Some(300_000.0),
_ => None,
@ -377,7 +377,7 @@ pub fn fly_move(data: &JoinData, update: &mut StateUpdate, efficiency: f32) -> b
// Elevation control
match data.body {
// flappy flappy
Body::Dragon(_) | Body::BirdMedium(_) | Body::BirdSmall(_) => {
Body::Dragon(_) | Body::BirdMedium(_) | Body::BirdLarge(_) => {
let anti_grav = GRAVITY * (1.0 + data.inputs.move_z.min(0.0));
update.vel.0.z += data.dt.0 * (anti_grav + accel * data.inputs.move_z.max(0.0));
},

View File

@ -60,7 +60,7 @@ impl Entity {
comp::Body::BirdMedium(b) => {
get_npc_name(&npc_names.bird_medium, b.species).to_string()
},
comp::Body::BirdSmall(_) => "Warbler".to_string(),
comp::Body::BirdLarge(_) => "Warbler".to_string(),
comp::Body::Dragon(b) => get_npc_name(&npc_names.dragon, b.species).to_string(),
comp::Body::Humanoid(b) => get_npc_name(&npc_names.humanoid, b.species).to_string(),
comp::Body::Ship(_) => "Veloren Air".to_string(),

View File

@ -0,0 +1,146 @@
use super::{
super::{vek::*, Animation},
BirdLargeSkeleton, SkeletonAttr,
};
pub struct FlyAnimation;
impl Animation for FlyAnimation {
type Dependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f32, Vec3<f32>, f32);
type Skeleton = BirdLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"bird_large_fly\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_fly")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(velocity, orientation, last_ori, _global_time, avg_vel, _acc_vel): Self::Dependency,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let slow = (anim_time * 2.0).sin();
let fast = (anim_time * 4.0).sin();
let freq = 8.0;
let off1 = 0.0;
let off2 = -1.7;
let off3 = -2.0;
let off4 = -2.4;
let flap1 = 7.0 / 16.0 * (freq * anim_time + off1).sin()
+ 7.0 / 64.0 * (freq * 2.0 * anim_time + off1).sin()
+ 1.0 / 48.0 * (freq * 3.0 * anim_time + off1).sin();
let flap2 = 7.0 / 16.0 * (freq * anim_time + off2).sin()
+ 7.0 / 64.0 * (freq * 2.0 * anim_time + off2).sin()
+ 1.0 / 48.0 * (freq * 3.0 * anim_time + off2).sin();
let flap3 = 7.0 / 16.0 * (freq * anim_time + off3).sin()
+ 7.0 / 64.0 * (freq * 2.0 * anim_time + off3).sin()
+ 1.0 / 48.0 * (freq * 3.0 * anim_time + off3).sin();
let flap4 = 7.0 / 16.0 * (freq * anim_time + off4).sin()
+ 7.0 / 64.0 * (freq * 2.0 * anim_time + off4).sin()
+ 1.0 / 48.0 * (freq * 3.0 * anim_time + off4).sin();
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()
&& ori.angle_between(last_ori).is_finite()
{
ori.angle_between(last_ori).min(0.2)
* last_ori.determine_side(Vec2::zero(), ori).signum()
} else {
0.0
} * 1.3;
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude());
next.chest.scale = Vec3::one() * s_a.scaler / 4.0;
next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1);
next.neck.orientation = Quaternion::rotation_x(0.2);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1 - 3.0);
next.head.orientation = Quaternion::rotation_x(0.2 + fast * 0.05);
next.beak.position = Vec3::new(0.0, s_a.beak.0, s_a.beak.1);
dbg!(velocity);
if velocity.z > 2.0 {
next.chest.position =
Vec3::new(0.0, s_a.chest.0, s_a.chest.1 - flap4 * 1.5) * s_a.scaler / 4.0;
next.chest.orientation =
Quaternion::rotation_x(-0.5 - flap1 * 0.2) * Quaternion::rotation_y(tilt * 1.8);
next.wing_in_l.position = Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_r.position = Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_l.orientation =
Quaternion::rotation_y(-flap1 * 1.9 + 0.2) * Quaternion::rotation_x(0.4);
next.wing_in_r.orientation =
Quaternion::rotation_y(flap1 * 1.9 - 0.2) * Quaternion::rotation_x(0.4);
next.wing_mid_l.position = Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_r.position = Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_l.orientation = Quaternion::rotation_y(-flap2 * 1.4 - 0.2);
next.wing_mid_r.orientation = Quaternion::rotation_y(flap2 * 1.4 + 0.2);
next.wing_out_l.position = Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_l.orientation = Quaternion::rotation_y(-flap3 * 1.2 - 0.3);
next.wing_out_r.orientation = Quaternion::rotation_y(flap3 * 1.2 + 0.3);
next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
next.tail_front.orientation =
Quaternion::rotation_x(-flap2 * 0.2) * Quaternion::rotation_z(-tilt * 1.0);
next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
next.tail_rear.orientation =
Quaternion::rotation_x(-flap3 * 0.3) * Quaternion::rotation_z(-tilt * 1.0);
} else {
next.chest.position =
Vec3::new(0.0, s_a.chest.0, s_a.chest.1 + slow * 0.05) * s_a.scaler / 4.0;
next.chest.orientation =
Quaternion::rotation_x(-0.5 + slow * 0.05) * Quaternion::rotation_y(tilt * 1.8);
next.wing_in_l.position = Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_r.position = Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_l.orientation =
Quaternion::rotation_y(0.1 + slow * 0.04) * Quaternion::rotation_x(0.6);
next.wing_in_r.orientation =
Quaternion::rotation_y(-0.1 + slow * -0.04) * Quaternion::rotation_x(0.6);
next.wing_mid_l.position = Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_r.position = Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_l.orientation = Quaternion::rotation_y(0.1 + slow * 0.04);
next.wing_mid_r.orientation = Quaternion::rotation_y(-0.1 + slow * -0.04);
next.wing_out_l.position = Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_l.orientation = Quaternion::rotation_y(0.1 + slow * 0.04);
next.wing_out_r.orientation = Quaternion::rotation_y(-0.1 + slow * -0.04);
next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
next.tail_front.orientation =
Quaternion::rotation_x(slow * 0.04) * Quaternion::rotation_z(-tilt * 1.0);
next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
next.tail_rear.orientation =
Quaternion::rotation_x(-0.2 + slow * 0.08) * Quaternion::rotation_z(-tilt * 1.0);
}
next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2 + 3.0);
next.leg_l.orientation = Quaternion::rotation_x(-1.0 - flap1 * 0.1);
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2 + 3.0);
next.leg_r.orientation = Quaternion::rotation_x(-1.0 - flap1 * 0.1);
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(-1.0 - flap1 * 0.1);
next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(-1.0 - flap1 * 0.1);
next
}
}

View File

@ -0,0 +1,89 @@
use super::{
super::{vek::*, Animation},
BirdLargeSkeleton, SkeletonAttr,
};
pub struct IdleAnimation;
impl Animation for IdleAnimation {
type Dependency = f32;
type Skeleton = BirdLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"bird_large_idle\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_idle")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
_global_time: Self::Dependency,
anim_time: f32,
_rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let fast = anim_time * 4.0;
let freq = 8.0;
let off2 = -1.7;
let off3 = -2.0;
let off4 = -2.4;
let flap1 = 7.0 / 16.0 * (freq * anim_time).sin()
+ 7.0 / 64.0 * (freq * 2.0 * anim_time).sin()
+ 1.0 / 48.0 * (freq * 3.0 * anim_time).sin();
let flap2 = 7.0 / 16.0 * (freq * anim_time + off2).sin()
+ 7.0 / 64.0 * (freq * 2.0 * anim_time + off2).sin()
+ 1.0 / 48.0 * (freq * 3.0 * anim_time + off2).sin();
let flap3 = 7.0 / 16.0 * (freq * anim_time + off3).sin()
+ 7.0 / 64.0 * (freq * 2.0 * anim_time + off3).sin()
+ 1.0 / 48.0 * (freq * 3.0 * anim_time + off3).sin();
let flap4 = 7.0 / 16.0 * (freq * anim_time + off4).sin()
+ 7.0 / 64.0 * (freq * 2.0 * anim_time + off4).sin()
+ 1.0 / 48.0 * (freq * 3.0 * anim_time + off4).sin();
next.chest.scale = Vec3::one() * s_a.scaler / 4.0;
next.chest.position = Vec3::new(0.0, s_a.chest.0, s_a.chest.1) * s_a.scaler / 4.0;
next.chest.orientation = Quaternion::rotation_x(0.0);
next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1);
next.neck.orientation = Quaternion::rotation_x(0.0);
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_x(0.0);
next.beak.position = Vec3::new(0.0, s_a.beak.0, s_a.beak.1);
next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
next.tail_front.orientation = Quaternion::rotation_x(0.0);
next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
next.tail_rear.orientation = Quaternion::rotation_x(0.0);
next.wing_in_l.position = Vec3::new(-s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_r.position = Vec3::new(s_a.wing_in.0, s_a.wing_in.1, s_a.wing_in.2);
next.wing_in_l.orientation = Quaternion::rotation_y(0.0);
next.wing_in_r.orientation = Quaternion::rotation_y(0.0) * Quaternion::rotation_x(0.0);
next.wing_mid_l.position = Vec3::new(-s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_r.position = Vec3::new(s_a.wing_mid.0, s_a.wing_mid.1, s_a.wing_mid.2);
next.wing_mid_l.orientation = Quaternion::rotation_y(0.0);
next.wing_mid_r.orientation = Quaternion::rotation_y(0.0);
next.wing_out_l.position = Vec3::new(-s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_r.position = Vec3::new(s_a.wing_out.0, s_a.wing_out.1, s_a.wing_out.2);
next.wing_out_l.orientation = Quaternion::rotation_y(0.0);
next.wing_out_r.orientation = Quaternion::rotation_y(0.0);
next.leg_l.position = Vec3::new(-s_a.leg.0, s_a.leg.1, s_a.leg.2 + 3.0);
next.leg_l.orientation = Quaternion::rotation_x(0.0);
next.leg_r.position = Vec3::new(s_a.leg.0, s_a.leg.1, s_a.leg.2 + 3.0);
next.leg_r.orientation = Quaternion::rotation_x(0.0);
next.foot_l.position = Vec3::new(-s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_l.orientation = Quaternion::rotation_x(0.0);
next.foot_r.position = Vec3::new(s_a.foot.0, s_a.foot.1, s_a.foot.2);
next.foot_r.orientation = Quaternion::rotation_x(0.0);
next
}
}

View File

@ -0,0 +1,174 @@
pub mod fly;
pub mod idle;
pub mod run;
// Reexports
pub use self::{fly::FlyAnimation, idle::IdleAnimation, run::RunAnimation};
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
pub type Body = comp::bird_large::Body;
skeleton_impls!(struct BirdLargeSkeleton {
+ head,
+ beak,
+ neck,
+ chest,
+ tail_front,
+ tail_rear,
+ wing_in_l,
+ wing_in_r,
+ wing_mid_l,
+ wing_mid_r,
+ wing_out_l,
+ wing_out_r,
+ leg_l,
+ leg_r,
+ foot_l,
+ foot_r,
});
impl Skeleton for BirdLargeSkeleton {
type Attr = SkeletonAttr;
type Body = Body;
const BONE_COUNT: usize = 16;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"bird_large_compute_mats\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_compute_mats")]
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let chest_mat = base_mat * Mat4::<f32>::from(self.chest);
let neck_mat = chest_mat * Mat4::<f32>::from(self.neck);
let head_mat = neck_mat * Mat4::<f32>::from(self.head);
let beak_mat = head_mat * Mat4::<f32>::from(self.beak);
let tail_front_mat = chest_mat * Mat4::<f32>::from(self.tail_front);
let tail_rear_mat = tail_front_mat * Mat4::<f32>::from(self.tail_rear);
let wing_in_l_mat = chest_mat * Mat4::<f32>::from(self.wing_in_l);
let wing_in_r_mat = chest_mat * Mat4::<f32>::from(self.wing_in_r);
let wing_mid_l_mat = wing_in_l_mat * Mat4::<f32>::from(self.wing_mid_l);
let wing_mid_r_mat = wing_in_r_mat * Mat4::<f32>::from(self.wing_mid_r);
let wing_out_l_mat = wing_mid_l_mat * Mat4::<f32>::from(self.wing_out_l);
let wing_out_r_mat = wing_mid_r_mat * Mat4::<f32>::from(self.wing_out_r);
let leg_l_mat = chest_mat * Mat4::<f32>::from(self.leg_l);
let leg_r_mat = chest_mat * Mat4::<f32>::from(self.leg_r);
let foot_l_mat = chest_mat * Mat4::<f32>::from(self.leg_l);
let foot_r_mat = chest_mat * Mat4::<f32>::from(self.leg_r);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(head_mat),
make_bone(beak_mat),
make_bone(neck_mat),
make_bone(chest_mat),
make_bone(tail_front_mat),
make_bone(tail_rear_mat),
make_bone(wing_in_l_mat),
make_bone(wing_in_r_mat),
make_bone(wing_mid_l_mat),
make_bone(wing_mid_r_mat),
make_bone(wing_out_l_mat),
make_bone(wing_out_r_mat),
make_bone(leg_l_mat),
make_bone(leg_r_mat),
make_bone(foot_l_mat),
make_bone(foot_r_mat),
];
Vec3::default()
}
}
pub struct SkeletonAttr {
chest: (f32, f32),
neck: (f32, f32),
head: (f32, f32),
beak: (f32, f32),
tail_front: (f32, f32),
tail_rear: (f32, f32),
wing_in: (f32, f32, f32),
wing_mid: (f32, f32, f32),
wing_out: (f32, f32, f32),
leg: (f32, f32, f32),
foot: (f32, f32, f32),
scaler: f32,
}
impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr {
type Error = ();
fn try_from(body: &'a comp::Body) -> Result<Self, Self::Error> {
match body {
comp::Body::BirdLarge(body) => Ok(SkeletonAttr::from(body)),
_ => Err(()),
}
}
}
impl Default for SkeletonAttr {
fn default() -> Self {
Self {
chest: (0.0, 0.0),
neck: (0.0, 0.0),
head: (0.0, 0.0),
beak: (0.0, 0.0),
tail_front: (0.0, 0.0),
tail_rear: (0.0, 0.0),
wing_in: (0.0, 0.0, 0.0),
wing_mid: (0.0, 0.0, 0.0),
wing_out: (0.0, 0.0, 0.0),
leg: (0.0, 0.0, 0.0),
foot: (0.0, 0.0, 0.0),
scaler: 0.0,
}
}
}
impl<'a> From<&'a Body> for SkeletonAttr {
fn from(body: &'a Body) -> Self {
use comp::bird_large::Species::*;
Self {
chest: match (body.species, body.body_type) {
(Phoenix, _) => (2.5, 8.5),
},
neck: match (body.species, body.body_type) {
(Phoenix, _) => (0.5, 3.0),
},
head: match (body.species, body.body_type) {
(Phoenix, _) => (2.0, 3.0),
},
beak: match (body.species, body.body_type) {
(Phoenix, _) => (2.0, 1.0),
},
tail_front: match (body.species, body.body_type) {
(Phoenix, _) => (-5.5, -2.0),
},
tail_rear: match (body.species, body.body_type) {
(Phoenix, _) => (-3.0, -3.0),
},
wing_in: match (body.species, body.body_type) {
(Phoenix, _) => (3.0, 2.5, 4.0),
},
wing_mid: match (body.species, body.body_type) {
(Phoenix, _) => (6.5, -1.0, 0.0),
},
wing_out: match (body.species, body.body_type) {
(Phoenix, _) => (0.5, -1.0, 0.0),
},
leg: match (body.species, body.body_type) {
(Phoenix, _) => (2.5, -2.5, -6.5),
},
foot: match (body.species, body.body_type) {
(Phoenix, _) => (2.5, -16.5, -6.5),
},
scaler: match (body.species, body.body_type) {
(Phoenix, _) => (1.0),
},
}
}
}

View File

@ -0,0 +1,140 @@
use super::{
super::{vek::*, Animation},
BirdLargeSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
pub struct RunAnimation;
impl Animation for RunAnimation {
type Dependency = (Vec3<f32>, Vec3<f32>, Vec3<f32>, f32, Vec3<f32>, f32);
type Skeleton = BirdLargeSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"bird_large_run\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_large_run")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(velocity, orientation, last_ori, _global_time, avg_vel, acc_vel): Self::Dependency,
_anim_time: f32,
rate: &mut f32,
s_a: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
let speed = (Vec2::<f32>::from(velocity).magnitude()).min(22.0);
*rate = 1.0;
//let speednorm = speed / 13.0;
let speednorm = (speed / 13.0).powf(0.25);
let speedmult = 1.0;
let lab: f32 = 0.6; //6
let short = ((1.0
/ (0.72
+ 0.28 * ((acc_vel * 1.0 * lab * speedmult + PI * -0.15 - 0.5).sin()).powi(2)))
.sqrt())
* ((acc_vel * 1.0 * lab * speedmult + PI * -0.15 - 0.5).sin())
* speednorm;
//
let shortalt = (acc_vel * 1.0 * lab * speedmult + PI * 3.0 / 8.0 - 0.5).sin() * speednorm;
//FL
let foot1a = (acc_vel * 1.0 * lab * speedmult + 0.0 + PI).sin() * speednorm; //1.5
let foot1b = (acc_vel * 1.0 * lab * speedmult + 1.57 + PI).sin() * speednorm; //1.9
//FR
let foot2a = (acc_vel * 1.0 * lab * speedmult).sin() * speednorm; //1.2
let foot2b = (acc_vel * 1.0 * lab * speedmult + 1.57).sin() * speednorm; //1.6
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()
&& ori.angle_between(last_ori).is_finite()
{
ori.angle_between(last_ori).min(0.2)
* last_ori.determine_side(Vec2::zero(), ori).signum()
} else {
0.0
} * 1.3;
let x_tilt = avg_vel.z.atan2(avg_vel.xy().magnitude()) * speednorm;
next.head.scale = Vec3::one() * 1.02;
next.neck.scale = Vec3::one() * 0.98;
next.beak.scale = Vec3::one() * 0.98;
next.foot_l.scale = Vec3::one() * 0.96;
next.foot_r.scale = Vec3::one() * 0.96;
next.chest.scale = Vec3::one() * s_a.scaler / 4.0;
next.head.position = Vec3::new(0.0, s_a.head.0, s_a.head.1);
next.head.orientation = Quaternion::rotation_x(-0.1 * speednorm + short * -0.05)
* Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(shortalt * -0.2 - tilt * 2.5);
next.beak.position = Vec3::new(0.0, s_a.beak.0, s_a.beak.1);
next.beak.orientation = Quaternion::rotation_x(short * -0.03);
next.neck.position = Vec3::new(0.0, s_a.neck.0, s_a.neck.1);
next.neck.orientation = Quaternion::rotation_x(-0.1 * speednorm + short * -0.04)
* Quaternion::rotation_y(tilt * 0.3)
* Quaternion::rotation_z(shortalt * -0.1 - tilt * 3.2);
next.chest.position = Vec3::new(
0.0,
s_a.chest.0,
s_a.chest.1 + short * 0.5 + x_tilt * 10.0 + 0.5 * speednorm,
) * s_a.scaler
/ 4.0;
next.chest.orientation = Quaternion::rotation_x(short * 0.07 + x_tilt)
* Quaternion::rotation_y(tilt * 0.8)
* Quaternion::rotation_z(shortalt * 0.15 + tilt * -1.5);
next.tail_front.position = Vec3::new(0.0, s_a.tail_front.0, s_a.tail_front.1);
next.tail_front.orientation = Quaternion::rotation_x(0.1 + short * -0.02)
* Quaternion::rotation_z(shortalt * -0.1 + tilt * 1.0);
next.tail_rear.position = Vec3::new(0.0, s_a.tail_rear.0, s_a.tail_rear.1);
next.tail_rear.orientation = Quaternion::rotation_x(0.2 + short * -0.1)
* Quaternion::rotation_z(shortalt * -0.2 + tilt * 1.4);
next.leg_l.position = Vec3::new(
-s_a.leg.0 + speednorm * 1.5,
s_a.leg.1 + foot1b * -1.3,
s_a.leg.2 + foot1a * 1.0,
);
next.leg_l.orientation = Quaternion::rotation_x(-0.2 * speednorm + foot1a * 0.15)
* Quaternion::rotation_y(tilt * 0.5)
* Quaternion::rotation_z(foot1a * -0.3 + tilt * -0.5);
next.leg_r.position = Vec3::new(
s_a.leg.0 + speednorm * -1.5,
s_a.leg.1 + foot2b * -1.3,
s_a.leg.2 + foot2a * 1.0,
);
next.leg_r.orientation = Quaternion::rotation_x(-0.2 * speednorm + foot2a * 0.15)
* Quaternion::rotation_y(tilt * 0.5)
* Quaternion::rotation_z(foot2a * 0.3 + tilt * -0.5);
next.foot_l.position = Vec3::new(
-s_a.foot.0,
s_a.foot.1 + foot1b * -2.0,
s_a.foot.2 + speednorm * 0.5 + (foot1a * 1.5).max(0.0),
);
next.foot_l.orientation = Quaternion::rotation_x(-0.2 * speednorm + foot1b * -0.35)
* Quaternion::rotation_y(tilt * -1.0)
* Quaternion::rotation_z(tilt * -0.5);
next.foot_r.position = Vec3::new(
s_a.foot.0,
s_a.foot.1 + foot2b * -2.0,
s_a.foot.2 + speednorm * 0.5 + (foot2a * 1.5).max(0.0),
);
next.foot_r.orientation = Quaternion::rotation_x(-0.2 * speednorm + foot2b * -0.35)
* Quaternion::rotation_y(tilt * -1.0);
next
}
}

View File

@ -1,42 +0,0 @@
use super::{super::Animation, BirdSmallSkeleton, SkeletonAttr};
//use std::{f32::consts::PI, ops::Mul};
use super::super::vek::*;
pub struct IdleAnimation;
impl Animation for IdleAnimation {
type Dependency = f32;
type Skeleton = BirdSmallSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"bird_small_idle\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_small_idle")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
_global_time: Self::Dependency,
_anim_time: f32,
_rate: &mut f32,
_skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() / 10.88;
next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 10.88;
next.wing_l.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_l.scale = Vec3::one() / 10.88;
next.wing_r.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_r.scale = Vec3::one() / 10.88;
next
}
}

View File

@ -1,42 +0,0 @@
use super::{super::Animation, BirdSmallSkeleton, SkeletonAttr};
//use std::f32::consts::PI;
use super::super::vek::*;
pub struct JumpAnimation;
impl Animation for JumpAnimation {
type Dependency = (f32, f32);
type Skeleton = BirdSmallSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"bird_small_jump\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_small_jump")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
_global_time: Self::Dependency,
_anim_time: f32,
_rate: &mut f32,
_skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() / 10.88;
next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 10.88;
next.wing_l.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_l.scale = Vec3::one() / 10.88;
next.wing_r.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_r.scale = Vec3::one() / 10.88;
next
}
}

View File

@ -1,67 +0,0 @@
pub mod idle;
pub mod jump;
pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{make_bone, vek::*, FigureBoneData, Skeleton};
use common::comp::{self};
use core::convert::TryFrom;
pub type Body = comp::bird_small::Body;
skeleton_impls!(struct BirdSmallSkeleton {
+ head,
+ torso,
+ wing_l,
+ wing_r,
});
impl Skeleton for BirdSmallSkeleton {
type Attr = SkeletonAttr;
type Body = Body;
const BONE_COUNT: usize = 4;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"bird_small_compute_mats\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_small_compute_mats")]
fn compute_matrices_inner(
&self,
base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso);
*(<&mut [_; Self::BONE_COUNT]>::try_from(&mut buf[0..Self::BONE_COUNT]).unwrap()) = [
make_bone(torso_mat * Mat4::<f32>::from(self.head)),
make_bone(torso_mat),
make_bone(torso_mat * Mat4::<f32>::from(self.wing_l)),
make_bone(torso_mat * Mat4::<f32>::from(self.wing_r)),
];
Vec3::default()
}
}
pub struct SkeletonAttr;
impl<'a> std::convert::TryFrom<&'a comp::Body> for SkeletonAttr {
type Error = ();
fn try_from(body: &'a comp::Body) -> Result<Self, Self::Error> {
match body {
comp::Body::BirdSmall(body) => Ok(SkeletonAttr::from(body)),
_ => Err(()),
}
}
}
impl Default for SkeletonAttr {
fn default() -> Self { Self }
}
impl<'a> From<&'a Body> for SkeletonAttr {
fn from(_body: &'a Body) -> Self { Self }
}

View File

@ -1,42 +0,0 @@
use super::{super::Animation, BirdSmallSkeleton, SkeletonAttr};
//use std::{f32::consts::PI, ops::Mul};
use super::super::vek::*;
pub struct RunAnimation;
impl Animation for RunAnimation {
type Dependency = (f32, f32);
type Skeleton = BirdSmallSkeleton;
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"bird_small_run\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "bird_small_run")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_velocity, _global_time): Self::Dependency,
_anim_time: f32,
_rate: &mut f32,
_skeleton_attr: &SkeletonAttr,
) -> Self::Skeleton {
let mut next = (*skeleton).clone();
next.head.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.head.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.head.scale = Vec3::one() / 10.88;
next.torso.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.torso.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.torso.scale = Vec3::one() / 10.88;
next.wing_l.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_l.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_l.scale = Vec3::one() / 10.88;
next.wing_r.position = Vec3::new(0.0, 7.5, 15.0) / 11.0;
next.wing_r.orientation = Quaternion::rotation_z(0.0) * Quaternion::rotation_x(0.0);
next.wing_r.scale = Vec3::one() / 10.88;
next
}
}

View File

@ -50,8 +50,8 @@ macro_rules! skeleton_impls {
pub mod biped_large;
pub mod biped_small;
pub mod bird_large;
pub mod bird_medium;
pub mod bird_small;
pub mod character;
pub mod dragon;
#[cfg(feature = "use-dyn-lib")] pub mod dyn_lib;

View File

@ -93,7 +93,7 @@ impl EventMapper for MovementEventMapper {
Body::QuadrupedMedium(_) | Body::QuadrupedSmall(_) | Body::QuadrupedLow(_) => {
Self::map_quadruped_movement_event(physics, vel.0, underfoot_block_kind)
},
Body::BirdMedium(_) | Body::BirdSmall(_) | Body::BipedLarge(_) => {
Body::BirdMedium(_) | Body::BirdLarge(_) | Body::BipedLarge(_) => {
Self::map_non_humanoid_movement_event(physics, vel.0, underfoot_block_kind)
},
_ => SfxEvent::Idle, // Ignore fish, etc...
@ -281,7 +281,7 @@ impl MovementEventMapper {
Body::QuadrupedMedium(_) => 0.7,
Body::QuadrupedLow(_) => 0.7,
Body::BirdMedium(_) => 0.3,
Body::BirdSmall(_) => 0.2,
Body::BirdLarge(_) => 0.2,
Body::BipedLarge(_) => 1.0,
_ => 0.9,
}

View File

@ -2,7 +2,7 @@ use super::*;
use crate::audio::sfx::SfxEvent;
use common::{
comp::{
bird_small, humanoid, quadruped_medium, quadruped_small, Body, CharacterState, InputKind,
bird_large, humanoid, quadruped_medium, quadruped_small, Body, CharacterState, InputKind,
PhysicsState,
},
states,
@ -340,12 +340,12 @@ fn determines_relative_volumes() {
quadruped_small::Body::random(),
));
let bird_small =
MovementEventMapper::get_volume_for_body_type(&Body::BirdSmall(bird_small::Body::random()));
let bird_large =
MovementEventMapper::get_volume_for_body_type(&Body::BirdLarge(bird_large::Body::random()));
assert!(quadruped_medium < human);
assert!(quadruped_small < quadruped_medium);
assert!(bird_small < quadruped_small);
assert!(bird_large < quadruped_small);
}
fn empty_ability_info() -> states::utils::AbilityInfo {

View File

@ -4,8 +4,8 @@ use common::{
comp::{
biped_large::{self, BodyType as BLBodyType, Species as BLSpecies},
biped_small,
bird_large::{self, BodyType as BLABodyType, Species as BLASpecies},
bird_medium::{self, BodyType as BMBodyType, Species as BMSpecies},
bird_small,
dragon::{self, BodyType as DBodyType, Species as DSpecies},
fish_medium::{self, BodyType as FMBodyType, Species as FMSpecies},
fish_small::{self, BodyType as FSBodyType, Species as FSSpecies},
@ -3109,65 +3109,379 @@ impl DragonLateralSpec {
}
////
#[derive(Deserialize)]
struct BirdLargeCentralSpec(HashMap<(BLASpecies, BLABodyType), SidedBLACentralVoxSpec>);
#[derive(Deserialize)]
struct SidedBLACentralVoxSpec {
head: BirdLargeCentralSubSpec,
beak: BirdLargeCentralSubSpec,
neck: BirdLargeCentralSubSpec,
chest: BirdLargeCentralSubSpec,
tail_front: BirdLargeCentralSubSpec,
tail_rear: BirdLargeCentralSubSpec,
}
#[derive(Deserialize)]
struct BirdLargeCentralSubSpec {
offset: [f32; 3], // Should be relative to initial origin
central: VoxSimple,
}
#[derive(Deserialize)]
struct BirdLargeLateralSpec(HashMap<(BLASpecies, BLABodyType), SidedBLALateralVoxSpec>);
#[derive(Deserialize)]
struct SidedBLALateralVoxSpec {
wing_in_l: BirdLargeLateralSubSpec,
wing_in_r: BirdLargeLateralSubSpec,
wing_mid_l: BirdLargeLateralSubSpec,
wing_mid_r: BirdLargeLateralSubSpec,
wing_out_l: BirdLargeLateralSubSpec,
wing_out_r: BirdLargeLateralSubSpec,
leg_l: BirdLargeLateralSubSpec,
leg_r: BirdLargeLateralSubSpec,
foot_l: BirdLargeLateralSubSpec,
foot_r: BirdLargeLateralSubSpec,
}
#[derive(Deserialize)]
struct BirdLargeLateralSubSpec {
offset: [f32; 3], // Should be relative to initial origin
lateral: VoxSimple,
}
make_vox_spec!(
bird_small::Body,
struct BirdSmallSpec {},
|FigureKey { body, .. }, _spec| {
bird_large::Body,
struct BirdLargeSpec {
central: BirdLargeCentralSpec = "voxygen.voxel.bird_large_central_manifest",
lateral: BirdLargeLateralSpec = "voxygen.voxel.bird_large_lateral_manifest",
},
|FigureKey { body, .. }, spec| {
[
Some(mesh_bird_small_head(body.head)),
Some(mesh_bird_small_torso(body.torso)),
Some(mesh_bird_small_wing_l(body.wing_l)),
Some(mesh_bird_small_wing_r(body.wing_r)),
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
None,
Some(spec.central.read().0.mesh_head(
body.species,
body.body_type,
)),
Some(spec.central.read().0.mesh_beak(
body.species,
body.body_type,
)),
Some(spec.central.read().0.mesh_neck(
body.species,
body.body_type,
)),
Some(spec.central.read().0.mesh_chest(
body.species,
body.body_type,
)),
Some(spec.central.read().0.mesh_tail_front(
body.species,
body.body_type,
)),
Some(spec.central.read().0.mesh_tail_rear(
body.species,
body.body_type,
)),
Some(spec.lateral.read().0.mesh_wing_in_l(
body.species,
body.body_type,
)),
Some(spec.lateral.read().0.mesh_wing_in_r(
body.species,
body.body_type,
)),
Some(spec.lateral.read().0.mesh_wing_mid_l(
body.species,
body.body_type,
)),
Some(spec.lateral.read().0.mesh_wing_mid_r(
body.species,
body.body_type,
)),
Some(spec.lateral.read().0.mesh_wing_out_l(
body.species,
body.body_type,
)),
Some(spec.lateral.read().0.mesh_wing_out_r(
body.species,
body.body_type,
)),
Some(spec.lateral.read().0.mesh_leg_l(
body.species,
body.body_type,
)),
Some(spec.lateral.read().0.mesh_leg_r(
body.species,
body.body_type,
)),
Some(spec.lateral.read().0.mesh_foot_l(
body.species,
body.body_type,
)),
Some(spec.lateral.read().0.mesh_foot_r(
body.species,
body.body_type,
)),
]
},
);
fn mesh_bird_small_head(head: bird_small::Head) -> BoneMeshes {
load_mesh(
match head {
bird_small::Head::Default => "npc.crow.head",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
impl BirdLargeCentralSpec {
fn mesh_head(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No head specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let central = graceful_load_segment(&spec.head.central.0);
fn mesh_bird_small_torso(torso: bird_small::Torso) -> BoneMeshes {
load_mesh(
match torso {
bird_small::Torso::Default => "npc.crow.torso",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
(central, Vec3::from(spec.head.offset))
}
fn mesh_bird_small_wing_l(wing_l: bird_small::WingL) -> BoneMeshes {
load_mesh(
match wing_l {
bird_small::WingL::Default => "npc.crow.wing_l",
},
Vec3::new(-7.0, -6.0, -6.0),
)
}
fn mesh_beak(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No beak specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let central = graceful_load_segment(&spec.beak.central.0);
fn mesh_bird_small_wing_r(wing_r: bird_small::WingR) -> BoneMeshes {
load_mesh(
match wing_r {
bird_small::WingR::Default => "npc.crow.wing_r",
},
Vec3::new(-7.0, -6.0, -6.0),
)
(central, Vec3::from(spec.beak.offset))
}
fn mesh_neck(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No neck specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let central = graceful_load_segment(&spec.neck.central.0);
(central, Vec3::from(spec.neck.offset))
}
fn mesh_chest(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No chest specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let central = graceful_load_segment(&spec.chest.central.0);
(central, Vec3::from(spec.chest.offset))
}
fn mesh_tail_front(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No tail front specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let central = graceful_load_segment(&spec.tail_front.central.0);
(central, Vec3::from(spec.tail_front.offset))
}
fn mesh_tail_rear(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No tail rear specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let central = graceful_load_segment(&spec.tail_rear.central.0);
(central, Vec3::from(spec.tail_rear.offset))
}
}
impl BirdLargeLateralSpec {
fn mesh_wing_in_l(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No wing in in left specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let lateral = graceful_load_segment(&spec.wing_in_l.lateral.0);
(lateral, Vec3::from(spec.wing_in_l.offset))
}
fn mesh_wing_in_r(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No wing in right specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let lateral = graceful_load_segment(&spec.wing_in_r.lateral.0);
(lateral, Vec3::from(spec.wing_in_r.offset))
}
fn mesh_wing_mid_l(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No wing mid specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let lateral = graceful_load_segment(&spec.wing_mid_l.lateral.0);
(lateral, Vec3::from(spec.wing_mid_l.offset))
}
fn mesh_wing_mid_r(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No wing mid specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let lateral = graceful_load_segment(&spec.wing_in_l.lateral.0);
(lateral, Vec3::from(spec.wing_mid_r.offset))
}
fn mesh_wing_out_l(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No wing out specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let lateral = graceful_load_segment(&spec.wing_out_l.lateral.0);
(lateral, Vec3::from(spec.wing_out_l.offset))
}
fn mesh_wing_out_r(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No wing out specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let lateral = graceful_load_segment(&spec.wing_out_r.lateral.0);
(lateral, Vec3::from(spec.wing_out_r.offset))
}
fn mesh_leg_l(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No leg specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let lateral = graceful_load_segment(&spec.leg_l.lateral.0);
(lateral, Vec3::from(spec.leg_l.offset))
}
fn mesh_leg_r(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No leg specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let lateral = graceful_load_segment(&spec.leg_r.lateral.0);
(lateral, Vec3::from(spec.leg_r.offset))
}
fn mesh_foot_l(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No foot specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let lateral = graceful_load_segment(&spec.foot_l.lateral.0);
(lateral, Vec3::from(spec.foot_l.offset))
}
fn mesh_foot_r(&self, species: BLASpecies, body_type: BLABodyType) -> BoneMeshes {
let spec = match self.0.get(&(species, body_type)) {
Some(spec) => spec,
None => {
error!(
"No foot specification exists for the combination of {:?} and {:?}",
species, body_type
);
return load_mesh("not_found", Vec3::new(-5.0, -5.0, -2.5));
},
};
let lateral = graceful_load_segment(&spec.foot_r.lateral.0);
(lateral, Vec3::from(spec.foot_r.offset))
}
}
////

View File

@ -19,7 +19,7 @@ use crate::{
};
use anim::{
biped_large::BipedLargeSkeleton, biped_small::BipedSmallSkeleton,
bird_medium::BirdMediumSkeleton, bird_small::BirdSmallSkeleton, character::CharacterSkeleton,
bird_large::BirdLargeSkeleton, bird_medium::BirdMediumSkeleton, character::CharacterSkeleton,
dragon::DragonSkeleton, fish_medium::FishMediumSkeleton, fish_small::FishSmallSkeleton,
golem::GolemSkeleton, object::ObjectSkeleton, quadruped_low::QuadrupedLowSkeleton,
quadruped_medium::QuadrupedMediumSkeleton, quadruped_small::QuadrupedSmallSkeleton,
@ -95,7 +95,7 @@ struct FigureMgrStates {
fish_medium_states: HashMap<EcsEntity, FigureState<FishMediumSkeleton>>,
theropod_states: HashMap<EcsEntity, FigureState<TheropodSkeleton>>,
dragon_states: HashMap<EcsEntity, FigureState<DragonSkeleton>>,
bird_small_states: HashMap<EcsEntity, FigureState<BirdSmallSkeleton>>,
bird_large_states: HashMap<EcsEntity, FigureState<BirdLargeSkeleton>>,
fish_small_states: HashMap<EcsEntity, FigureState<FishSmallSkeleton>>,
biped_large_states: HashMap<EcsEntity, FigureState<BipedLargeSkeleton>>,
biped_small_states: HashMap<EcsEntity, FigureState<BipedSmallSkeleton>>,
@ -115,7 +115,7 @@ impl FigureMgrStates {
fish_medium_states: HashMap::new(),
theropod_states: HashMap::new(),
dragon_states: HashMap::new(),
bird_small_states: HashMap::new(),
bird_large_states: HashMap::new(),
fish_small_states: HashMap::new(),
biped_large_states: HashMap::new(),
biped_small_states: HashMap::new(),
@ -164,8 +164,8 @@ impl FigureMgrStates {
.get_mut(&entity)
.map(DerefMut::deref_mut),
Body::Dragon(_) => self.dragon_states.get_mut(&entity).map(DerefMut::deref_mut),
Body::BirdSmall(_) => self
.bird_small_states
Body::BirdLarge(_) => self
.bird_large_states
.get_mut(&entity)
.map(DerefMut::deref_mut),
Body::FishSmall(_) => self
@ -202,7 +202,7 @@ impl FigureMgrStates {
Body::FishMedium(_) => self.fish_medium_states.remove(&entity).map(|e| e.meta),
Body::Theropod(_) => self.theropod_states.remove(&entity).map(|e| e.meta),
Body::Dragon(_) => self.dragon_states.remove(&entity).map(|e| e.meta),
Body::BirdSmall(_) => self.bird_small_states.remove(&entity).map(|e| e.meta),
Body::BirdLarge(_) => self.bird_large_states.remove(&entity).map(|e| e.meta),
Body::FishSmall(_) => self.fish_small_states.remove(&entity).map(|e| e.meta),
Body::BipedLarge(_) => self.biped_large_states.remove(&entity).map(|e| e.meta),
Body::BipedSmall(_) => self.biped_small_states.remove(&entity).map(|e| e.meta),
@ -222,7 +222,7 @@ impl FigureMgrStates {
self.fish_medium_states.retain(|k, v| f(k, &mut *v));
self.theropod_states.retain(|k, v| f(k, &mut *v));
self.dragon_states.retain(|k, v| f(k, &mut *v));
self.bird_small_states.retain(|k, v| f(k, &mut *v));
self.bird_large_states.retain(|k, v| f(k, &mut *v));
self.fish_small_states.retain(|k, v| f(k, &mut *v));
self.biped_large_states.retain(|k, v| f(k, &mut *v));
self.biped_small_states.retain(|k, v| f(k, &mut *v));
@ -241,7 +241,7 @@ impl FigureMgrStates {
+ self.fish_medium_states.len()
+ self.theropod_states.len()
+ self.dragon_states.len()
+ self.bird_small_states.len()
+ self.bird_large_states.len()
+ self.fish_small_states.len()
+ self.biped_large_states.len()
+ self.biped_small_states.len()
@ -291,7 +291,7 @@ impl FigureMgrStates {
.filter(|(_, c)| c.visible())
.count()
+ self
.bird_small_states
.bird_large_states
.iter()
.filter(|(_, c)| c.visible())
.count()
@ -332,7 +332,7 @@ pub struct FigureMgr {
quadruped_medium_model_cache: FigureModelCache<QuadrupedMediumSkeleton>,
quadruped_low_model_cache: FigureModelCache<QuadrupedLowSkeleton>,
bird_medium_model_cache: FigureModelCache<BirdMediumSkeleton>,
bird_small_model_cache: FigureModelCache<BirdSmallSkeleton>,
bird_large_model_cache: FigureModelCache<BirdLargeSkeleton>,
dragon_model_cache: FigureModelCache<DragonSkeleton>,
fish_medium_model_cache: FigureModelCache<FishMediumSkeleton>,
fish_small_model_cache: FigureModelCache<FishSmallSkeleton>,
@ -354,7 +354,7 @@ impl FigureMgr {
quadruped_medium_model_cache: FigureModelCache::new(),
quadruped_low_model_cache: FigureModelCache::new(),
bird_medium_model_cache: FigureModelCache::new(),
bird_small_model_cache: FigureModelCache::new(),
bird_large_model_cache: FigureModelCache::new(),
dragon_model_cache: FigureModelCache::new(),
fish_medium_model_cache: FigureModelCache::new(),
fish_small_model_cache: FigureModelCache::new(),
@ -381,7 +381,7 @@ impl FigureMgr {
.clean(&mut self.col_lights, tick);
self.bird_medium_model_cache
.clean(&mut self.col_lights, tick);
self.bird_small_model_cache
self.bird_large_model_cache
.clean(&mut self.col_lights, tick);
self.dragon_model_cache.clean(&mut self.col_lights, tick);
self.fish_medium_model_cache
@ -3263,8 +3263,8 @@ impl FigureMgr {
physics.ground_vel,
);
},
Body::BirdSmall(body) => {
let (model, skeleton_attr) = self.bird_small_model_cache.get_or_create_model(
Body::BirdLarge(body) => {
let (model, skeleton_attr) = self.bird_large_model_cache.get_or_create_model(
renderer,
&mut self.col_lights,
*body,
@ -3277,14 +3277,14 @@ impl FigureMgr {
let state = self
.states
.bird_small_states
.bird_large_states
.entry(entity)
.or_insert_with(|| {
FigureState::new(renderer, BirdSmallSkeleton::default())
FigureState::new(renderer, BirdLargeSkeleton::default())
});
// Average velocity relative to the current ground
let _rel_avg_vel = state.avg_vel - physics.ground_vel;
let rel_avg_vel = state.avg_vel - physics.ground_vel;
let (character, last_character) = match (character, last_character) {
(Some(c), Some(l)) => (c, l),
@ -3301,33 +3301,49 @@ impl FigureMgr {
physics.in_liquid().is_some(), // In water
) {
// Standing
(true, false, false) => anim::bird_small::IdleAnimation::update_skeleton(
&BirdSmallSkeleton::default(),
(true, false, false) => anim::bird_large::IdleAnimation::update_skeleton(
&BirdLargeSkeleton::default(),
time,
state.state_time,
&mut state_animation_rate,
skeleton_attr,
),
// Running
(true, true, false) => anim::bird_small::RunAnimation::update_skeleton(
&BirdSmallSkeleton::default(),
(rel_vel.magnitude(), time),
(true, true, false) => anim::bird_large::RunAnimation::update_skeleton(
&BirdLargeSkeleton::default(),
(
rel_vel,
// TODO: Update to use the quaternion.
ori * anim::vek::Vec3::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
time,
rel_avg_vel,
state.acc_vel,
),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
),
// In air
(false, _, false) => anim::bird_small::JumpAnimation::update_skeleton(
&BirdSmallSkeleton::default(),
(rel_vel.magnitude(), time),
(false, _, false) => anim::bird_large::FlyAnimation::update_skeleton(
&BirdLargeSkeleton::default(),
(
rel_vel,
// TODO: Update to use the quaternion.
ori * anim::vek::Vec3::<f32>::unit_y(),
state.last_ori * anim::vek::Vec3::<f32>::unit_y(),
time,
rel_avg_vel,
state.acc_vel,
),
state.state_time,
&mut state_animation_rate,
skeleton_attr,
),
// TODO!
_ => anim::bird_small::IdleAnimation::update_skeleton(
&BirdSmallSkeleton::default(),
_ => anim::bird_large::IdleAnimation::update_skeleton(
&BirdLargeSkeleton::default(),
time,
state.state_time,
&mut state_animation_rate,
@ -4572,7 +4588,7 @@ impl FigureMgr {
quadruped_medium_model_cache,
quadruped_low_model_cache,
bird_medium_model_cache,
bird_small_model_cache,
bird_large_model_cache,
dragon_model_cache,
fish_medium_model_cache,
fish_small_model_cache,
@ -4591,7 +4607,7 @@ impl FigureMgr {
fish_medium_states,
theropod_states,
dragon_states,
bird_small_states,
bird_large_states,
fish_small_states,
biped_large_states,
biped_small_states,
@ -4738,14 +4754,14 @@ impl FigureMgr {
),
)
}),
Body::BirdSmall(body) => bird_small_states
Body::BirdLarge(body) => bird_large_states
.get(&entity)
.filter(|state| filter_state(&*state))
.map(move |state| {
(
state.locals(),
state.bone_consts(),
bird_small_model_cache.get_model(
bird_large_model_cache.get_model(
col_lights,
*body,
inventory,