Makes anim hotload work for quadlow

This commit is contained in:
unknown 2020-06-20 01:34:56 +02:00 committed by jshipsey
parent b1f4e4b9c1
commit 0de4b6b7f9
8 changed files with 29 additions and 71 deletions

View File

@ -8,7 +8,7 @@ edition = "2018"
name = "voxygen_anim"
# Uncomment to use animation hot reloading
# Note: this breaks `cargo test`
# crate-type = ["lib", "cdylib"]
crate-type = ["lib", "cdylib"]
[features]
use-dyn-lib = ["libloading", "notify", "lazy_static", "tracing", "find_folder"]

View File

@ -15,6 +15,7 @@ pub mod golem;
pub mod object;
pub mod quadruped_medium;
pub mod quadruped_small;
pub mod quadruped_low;
#[cfg(feature = "use-dyn-lib")]
pub use dyn_lib::init;

View File

@ -8,7 +8,11 @@ impl Animation for IdleAnimation {
type Dependency = f64;
type Skeleton = QuadrupedLowSkeleton;
fn update_skeleton(
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"quadruped_low_idle\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_idle")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
global_time: Self::Dependency,
anim_time: f64,

View File

@ -8,7 +8,11 @@ impl Animation for JumpAnimation {
type Dependency = (f32, f64);
type Skeleton = QuadrupedLowSkeleton;
fn update_skeleton(
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"quadruped_low_jump\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_jump")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
_global_time: Self::Dependency,
anim_time: f64,

View File

@ -5,8 +5,7 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{Bone, Skeleton};
use crate::render::FigureBoneData;
use super::{Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
@ -31,9 +30,13 @@ impl QuadrupedLowSkeleton {
impl Skeleton for QuadrupedLowSkeleton {
type Attr = SkeletonAttr;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"quadruped_low_compute_mats\0";
fn bone_count(&self) -> usize { 10 }
fn compute_matrices(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_compute_mats")]
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
let head_upper_mat = self.head_upper.compute_base_matrix();
let head_lower_mat = self.head_lower.compute_base_matrix();
let chest_mat = self.chest.compute_base_matrix();

View File

@ -8,7 +8,11 @@ impl Animation for RunAnimation {
type Dependency = (f32, f64);
type Skeleton = QuadrupedLowSkeleton;
fn update_skeleton(
#[cfg(feature = "use-dyn-lib")]
const UPDATE_FN: &'static [u8] = b"quadruped_low_run\0";
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_low_run")]
fn update_skeleton_inner(
skeleton: &Self::Skeleton,
(_velocity, global_time): Self::Dependency,
anim_time: f64,

View File

@ -28,60 +28,6 @@ pub struct QuadrupedMediumSkeleton {
foot_br: Bone,
}
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const HEAD_UPPER_Y: f32 = 6.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const HEAD_UPPER_Z: f32 = 1.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const HEAD_LOWER_Y: f32 = 1.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const HEAD_LOWER_Z: f32 = -3.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const JAW_Y: f32 = -2.5;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const JAW_Z: f32 = 0.5;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const TAIL_Y: f32 = -5.5;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const TAIL_Z: f32 = -0.5;
#[const_tweaker::tweak(min = -25.0, max = 20.0, step = 0.5)]
const TORSO_BACK_Y: f32 = -20.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const TORSO_BACK_Z: f32 = 1.5;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const TORSO_FRONT_Y: f32 = 0.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const TORSO_FRONT_Z: f32 = 11.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const EARS_Y: f32 = 5.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const EARS_Z: f32 = 9.5;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const LEG_FRONT_X: f32 = -7.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const LEG_FRONT_Y: f32 = -5.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const LEG_FRONT_Z: f32 = -2.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const LEG_BACK_X: f32 = 6.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const LEG_BACK_Y: f32 = -0.5;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const LEG_BACK_Z: f32 = -5.5;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const FEET_FRONT_X: f32 = 0.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const FEET_FRONT_Y: f32 = 1.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const FEET_FRONT_Z: f32 = -6.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const FEET_BACK_X: f32 = 0.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const FEET_BACK_Y: f32 = 0.0;
#[const_tweaker::tweak(min = -20.0, max = 20.0, step = 0.5)]
const FEET_BACK_Z: f32 = -5.0;
impl QuadrupedMediumSkeleton {
pub fn new() -> Self { Self::default() }
}
@ -89,6 +35,9 @@ impl QuadrupedMediumSkeleton {
impl Skeleton for QuadrupedMediumSkeleton {
type Attr = SkeletonAttr;
#[cfg(feature = "use-dyn-lib")]
const COMPUTE_FN: &'static [u8] = b"quadruped_medium_compute_mats\0";
fn bone_count(&self) -> usize { 15 }
#[cfg_attr(feature = "be-dyn-lib", export_name = "quadruped_medium_compute_mats")]
@ -207,7 +156,6 @@ impl<'a> From<&'a comp::quadruped_medium::Body> for SkeletonAttr {
(Saber, _) => (1.0, 0.0),
(Tuskram, _) => (1.0, 1.0),
(Lion, _) => (0.5, 1.0),
(Tiger, _) => (0.0, 0.0),
(Tarasque, _) => (0.5, -2.0),
(Tiger, _) => (-5.0, -6.0),
},

View File

@ -5,13 +5,6 @@ pub use cache::FigureModelCache;
pub use load::load_mesh; // TODO: Don't make this public.
use crate::{
anim::{
self, biped_large::BipedLargeSkeleton, bird_medium::BirdMediumSkeleton,
bird_small::BirdSmallSkeleton, character::CharacterSkeleton, critter::CritterSkeleton,
dragon::DragonSkeleton, fish_medium::FishMediumSkeleton, fish_small::FishSmallSkeleton,
golem::GolemSkeleton, object::ObjectSkeleton, quadruped_medium::QuadrupedMediumSkeleton,
quadruped_small::QuadrupedSmallSkeleton, quadruped_low::QuadrupedLowSkeleton, Animation, Skeleton,
},
ecs::comp::Interpolated,
render::{Consts, FigureBoneData, FigureLocals, Globals, Light, Renderer, Shadow},
scene::{
@ -24,7 +17,7 @@ use anim::{
bird_small::BirdSmallSkeleton, character::CharacterSkeleton, critter::CritterSkeleton,
dragon::DragonSkeleton, fish_medium::FishMediumSkeleton, fish_small::FishSmallSkeleton,
golem::GolemSkeleton, object::ObjectSkeleton, quadruped_medium::QuadrupedMediumSkeleton,
quadruped_small::QuadrupedSmallSkeleton, Animation, Skeleton,
quadruped_small::QuadrupedSmallSkeleton, quadruped_low::QuadrupedLowSkeleton, Animation, Skeleton,
};
use common::{
comp::{
@ -1020,7 +1013,7 @@ impl FigureMgr {
is_player,
);
},
Body::QuadrupedLow(_) => {
Body::QuadrupedLow(quadruped_body) => {
let skeleton_attr = &self
.quadruped_low_model_cache
.get_or_create_model(
@ -1032,6 +1025,7 @@ impl FigureMgr {
None,
)
.1;
let ref skeleton_attr = quadruped_body.into();
let state = self
.quadruped_low_states