diff --git a/voxygen/anim/src/lib.rs b/voxygen/anim/src/lib.rs index 92050272b1..dfe3ac86d2 100644 --- a/voxygen/anim/src/lib.rs +++ b/voxygen/anim/src/lib.rs @@ -112,6 +112,38 @@ pub trait Skeleton: Send + Sync + 'static { #[cfg(feature = "use-dyn-lib")] const COMPUTE_FN: &'static [u8]; + fn compute_matrices( + &self, + base_mat: Mat4, + buf: &mut [FigureBoneData; MAX_BONE_COUNT], + body: Self::Body, + ) -> Offsets { + #[cfg(not(feature = "use-dyn-lib"))] + { + self.compute_matrices_inner(base_mat, buf, body) + } + #[cfg(feature = "use-dyn-lib")] + { + let lock = LIB.lock().unwrap(); + let lib = &lock.as_ref().unwrap().lib; + + let compute_fn: voxygen_dynlib::Symbol< + fn(&Self, Mat4, &mut [FigureBoneData; MAX_BONE_COUNT], Self::Body) -> Offsets, + > = unsafe { lib.get(Self::COMPUTE_FN) }.unwrap_or_else(|e| { + panic!( + "Trying to use: {} but had error: {:?}", + CStr::from_bytes_with_nul(Self::COMPUTE_FN) + .map(CStr::to_str) + .unwrap() + .unwrap(), + e + ) + }); + + compute_fn(self, base_mat, buf, body) + } + } + fn compute_matrices_inner( &self, base_mat: Mat4, @@ -126,30 +158,7 @@ pub fn compute_matrices( buf: &mut [FigureBoneData; MAX_BONE_COUNT], body: S::Body, ) -> Offsets { - #[cfg(not(feature = "use-dyn-lib"))] - { - S::compute_matrices_inner(skeleton, base_mat, buf, body) - } - #[cfg(feature = "use-dyn-lib")] - { - let lock = LIB.lock().unwrap(); - let lib = &lock.as_ref().unwrap().lib; - - let compute_fn: voxygen_dynlib::Symbol< - fn(&S, Mat4, &mut [FigureBoneData; MAX_BONE_COUNT], S::Body) -> Offsets, - > = unsafe { lib.get(S::COMPUTE_FN) }.unwrap_or_else(|e| { - panic!( - "Trying to use: {} but had error: {:?}", - CStr::from_bytes_with_nul(S::COMPUTE_FN) - .map(CStr::to_str) - .unwrap() - .unwrap(), - e - ) - }); - - compute_fn(skeleton, base_mat, buf, body) - } + S::compute_matrices(skeleton, base_mat, buf, body) } pub trait Animation { diff --git a/voxygen/src/scene/figure/volume.rs b/voxygen/src/scene/figure/volume.rs index 15915e3063..92f1ced12b 100644 --- a/voxygen/src/scene/figure/volume.rs +++ b/voxygen/src/scene/figure/volume.rs @@ -26,9 +26,8 @@ impl anim::Skeleton for VolumeKey { type Body = Self; const BONE_COUNT: usize = 4; - - //#[cfg(feature = "use-dyn-lib")] - // TODO + #[cfg(feature = "hot-anim")] + const COMPUTE_FN: &'static [u8] = b"I AM NOT USED\0"; fn compute_matrices_inner( &self, @@ -52,6 +51,17 @@ impl anim::Skeleton for VolumeKey { mount_bone: anim::vek::Transform::default(), } } + + // Override compute_matrices so that hotloading is not done for this (since it + // will fail as this isn't part of the hotloaded anim crate) + fn compute_matrices( + &self, + base_mat: anim::vek::Mat4, + buf: &mut [anim::FigureBoneData; anim::MAX_BONE_COUNT], + body: Self::Body, + ) -> anim::Offsets { + self.compute_matrices_inner(base_mat, buf, body) + } } impl BodySpec for VolumeKey {