Experimental entity pop-in fix

This commit is contained in:
Snowram 2021-05-07 17:39:53 +02:00
parent 2c36524c90
commit 634f059d3d
21 changed files with 152 additions and 14 deletions

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Ogre,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::BipedLarge(body) } fn from(body: Body) -> Self { super::Body::BipedLarge(body) }
} }

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Gnome,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::BipedSmall(body) } fn from(body: Body) -> Self { super::Body::BipedSmall(body) }
} }

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Phoenix,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::BirdLarge(body) } fn from(body: Body) -> Self { super::Body::BirdLarge(body) }
} }

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Duck,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::BirdMedium(body) } fn from(body: Body) -> Self { super::Body::BirdMedium(body) }
} }

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Reddragon,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::Dragon(body) } fn from(body: Body) -> Self { super::Body::Dragon(body) }
} }

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Marlin,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::FishMedium(body) } fn from(body: Body) -> Self { super::Body::FishMedium(body) }
} }

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Clownfish,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::FishSmall(body) } fn from(body: Body) -> Self { super::Body::FishSmall(body) }
} }

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::StoneGolem,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::Golem(body) } fn from(body: Body) -> Self { super::Body::Golem(body) }
} }

View File

@ -65,6 +65,22 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Danari,
body_type: BodyType::Female,
hair_style: 0,
beard: 0,
accessory: 0,
hair_color: 0,
skin: 0,
eye_color: 0,
eyes: 0,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::Humanoid(body) } fn from(body: Body) -> Self { super::Body::Humanoid(body) }
} }

View File

@ -89,6 +89,10 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self { Body::Arrow }
}
pub const ALL_OBJECTS: [Body; 67] = [ pub const ALL_OBJECTS: [Body; 67] = [
Body::Arrow, Body::Arrow,
Body::Bomb, Body::Bomb,

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Crocodile,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::QuadrupedLow(body) } fn from(body: Body) -> Self { super::Body::QuadrupedLow(body) }
} }

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Grolgar,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::QuadrupedMedium(body) } fn from(body: Body) -> Self { super::Body::QuadrupedMedium(body) }
} }

View File

@ -25,6 +25,15 @@ impl Body {
} }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Pig,
body_type: BodyType::Female,
}
}
}
impl From<Body> for super::Body { impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::QuadrupedSmall(body) } fn from(body: Body) -> Self { super::Body::QuadrupedSmall(body) }
} }

View File

@ -54,6 +54,10 @@ impl Body {
pub fn mass(&self) -> Mass { Mass((self.hull_vol() + self.balloon_vol()) * self.density().0) } pub fn mass(&self) -> Mass { Mass((self.hull_vol() + self.balloon_vol()) * self.density().0) }
} }
impl Default for Body {
fn default() -> Self { Body::DefaultAirship }
}
/// Terrain is 11.0 scale relative to small-scale voxels, /// Terrain is 11.0 scale relative to small-scale voxels,
/// airship scale is multiplied by 11 to reach terrain scale. /// airship scale is multiplied by 11 to reach terrain scale.
pub const AIRSHIP_SCALE: f32 = 11.0; pub const AIRSHIP_SCALE: f32 = 11.0;

View File

@ -25,6 +25,15 @@ impl From<Body> for super::Body {
fn from(body: Body) -> Self { super::Body::Theropod(body) } fn from(body: Body) -> Self { super::Body::Theropod(body) }
} }
impl Default for Body {
fn default() -> Self {
Self {
species: Species::Archaeos,
body_type: BodyType::Female,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[repr(u32)] #[repr(u32)]
pub enum Species { pub enum Species {

View File

@ -42,7 +42,6 @@ impl Animation for IdleAnimation {
next.back.scale = Vec3::one() * 1.02; next.back.scale = Vec3::one() * 1.02;
next.hold.scale = Vec3::one() * 0.0; next.hold.scale = Vec3::one() * 0.0;
next.lantern.scale = Vec3::one() * 0.65; next.lantern.scale = Vec3::one() * 0.65;
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler;
next.shoulder_l.scale = Vec3::one() * 1.1; next.shoulder_l.scale = Vec3::one() * 1.1;
next.shoulder_r.scale = Vec3::one() * 1.1; next.shoulder_r.scale = Vec3::one() * 1.1;
@ -135,7 +134,7 @@ impl Animation for IdleAnimation {
next.lantern.position = Vec3::new(s_a.lantern.0, s_a.lantern.1, s_a.lantern.2); next.lantern.position = Vec3::new(s_a.lantern.0, s_a.lantern.1, s_a.lantern.2);
next.lantern.orientation = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1); next.lantern.orientation = Quaternion::rotation_x(0.1) * Quaternion::rotation_y(0.1);
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * s_a.scaler; next.torso.position = Vec3::new(0.0, 0.0, 0.0);
next.second.scale = match hands { next.second.scale = match hands {
(Some(Hands::One), Some(Hands::One)) => Vec3::one(), (Some(Hands::One), Some(Hands::One)) => Vec3::one(),

View File

@ -70,12 +70,14 @@ skeleton_impls!(struct CharacterSkeleton {
control_l, control_l,
control_r, control_r,
:: // Begin non-bone fields :: // Begin non-bone fields
body: Body,
holding_lantern: bool, holding_lantern: bool,
}); });
impl CharacterSkeleton { impl CharacterSkeleton {
pub fn new(holding_lantern: bool) -> Self { pub fn new(body: Body, holding_lantern: bool) -> Self {
Self { Self {
body,
holding_lantern, holding_lantern,
..Self::default() ..Self::default()
} }
@ -97,7 +99,10 @@ impl Skeleton for CharacterSkeleton {
base_mat: Mat4<f32>, base_mat: Mat4<f32>,
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
) -> Vec3<f32> { ) -> Vec3<f32> {
let torso_mat = base_mat * Mat4::<f32>::from(self.torso); let torso_mat = base_mat
* Mat4::<f32>::from(self.torso)
* Mat4::scaling_3d(1.0 / 11.0)
* Mat4::scaling_3d(SkeletonAttr::from(&self.body).scaler);
let chest_mat = torso_mat * Mat4::<f32>::from(self.chest); let chest_mat = torso_mat * Mat4::<f32>::from(self.chest);
let head_mat = chest_mat * Mat4::<f32>::from(self.head); let head_mat = chest_mat * Mat4::<f32>::from(self.head);
let shorts_mat = chest_mat * Mat4::<f32>::from(self.shorts); let shorts_mat = chest_mat * Mat4::<f32>::from(self.shorts);

View File

@ -273,8 +273,7 @@ impl Animation for RunAnimation {
* Quaternion::rotation_y(tilt * 4.0 * fast + tilt * 3.0 + fast2 * speednorm * 0.25); * Quaternion::rotation_y(tilt * 4.0 * fast + tilt * 3.0 + fast2 * speednorm * 0.25);
} }
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * s_a.scaler; next.torso.position = Vec3::new(0.0, 0.0, 0.0);
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler;
match hands { match hands {
(Some(Hands::One), _) => match active_tool_kind { (Some(Hands::One), _) => match active_tool_kind {

View File

@ -85,7 +85,7 @@ impl Animation for SitAnimation {
next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2); next.shoulder_r.position = Vec3::new(s_a.shoulder.0, s_a.shoulder.1, s_a.shoulder.2);
next.shoulder_r.orientation = Quaternion::rotation_x(0.0); next.shoulder_r.orientation = Quaternion::rotation_x(0.0);
next.torso.position = Vec3::new(0.0, -0.2, stop * -0.16) * s_a.scaler; next.torso.position = Vec3::new(0.0, -0.2, stop * -0.16);
if skeleton.holding_lantern { if skeleton.holding_lantern {
next.hand_r.position = Vec3::new( next.hand_r.position = Vec3::new(

View File

@ -44,7 +44,7 @@ impl Animation for StandAnimation {
next.back.scale = Vec3::one() * 1.02; next.back.scale = Vec3::one() * 1.02;
next.hold.scale = Vec3::one() * 0.0; next.hold.scale = Vec3::one() * 0.0;
next.lantern.scale = Vec3::one() * 0.65; next.lantern.scale = Vec3::one() * 0.65;
next.torso.scale = Vec3::one() / 11.0 * s_a.scaler; next.torso.scale = Vec3::one();
next.shoulder_l.scale = Vec3::one() * 1.1; next.shoulder_l.scale = Vec3::one() * 1.1;
next.shoulder_r.scale = Vec3::one() * 1.1; next.shoulder_r.scale = Vec3::one() * 1.1;
@ -162,7 +162,7 @@ impl Animation for StandAnimation {
* Quaternion::rotation_y(fast2 * 0.1); * Quaternion::rotation_y(fast2 * 0.1);
} }
next.torso.position = Vec3::new(0.0, 0.0, 0.0) * s_a.scaler; next.torso.position = Vec3::new(0.0, 0.0, 0.0);
next.second.scale = Vec3::one(); next.second.scale = Vec3::one();
next.second.scale = match hands { next.second.scale = match hands {
(Some(Hands::One) | None, Some(Hands::One)) => Vec3::one(), (Some(Hands::One) | None, Some(Hands::One)) => Vec3::one(),

View File

@ -773,7 +773,10 @@ impl FigureMgr {
.character_states .character_states
.entry(entity) .entry(entity)
.or_insert_with(|| { .or_insert_with(|| {
FigureState::new(renderer, CharacterSkeleton::new(holding_lantern)) FigureState::new(
renderer,
CharacterSkeleton::new(*body, holding_lantern),
)
}); });
// Average velocity relative to the current ground // Average velocity relative to the current ground
@ -795,7 +798,7 @@ impl FigureMgr {
) { ) {
// Standing // Standing
(true, false, false) => anim::character::StandAnimation::update_skeleton( (true, false, false) => anim::character::StandAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern), &CharacterSkeleton::new(*body, holding_lantern),
(active_tool_kind, second_tool_kind, hands, time, rel_avg_vel), (active_tool_kind, second_tool_kind, hands, time, rel_avg_vel),
state.state_time, state.state_time,
&mut state_animation_rate, &mut state_animation_rate,
@ -803,7 +806,7 @@ impl FigureMgr {
), ),
// Running // Running
(true, true, false) => anim::character::RunAnimation::update_skeleton( (true, true, false) => anim::character::RunAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern), &CharacterSkeleton::new(*body, holding_lantern),
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
@ -822,7 +825,7 @@ impl FigureMgr {
), ),
// In air // In air
(false, _, false) => anim::character::JumpAnimation::update_skeleton( (false, _, false) => anim::character::JumpAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern), &CharacterSkeleton::new(*body, holding_lantern),
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,
@ -839,7 +842,7 @@ impl FigureMgr {
), ),
// Swim // Swim
(_, _, true) => anim::character::SwimAnimation::update_skeleton( (_, _, true) => anim::character::SwimAnimation::update_skeleton(
&CharacterSkeleton::new(holding_lantern), &CharacterSkeleton::new(*body, holding_lantern),
( (
active_tool_kind, active_tool_kind,
second_tool_kind, second_tool_kind,