diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7d7f893 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + components: rustfmt + override: true + + - name: Cache dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-cargo- + + - name: Check formatting + run: cargo fmt -- --check + + - name: Build + run: cargo build --verbose + + - name: Run tests + run: cargo test --verbose diff --git a/.gitignore b/.gitignore index ffcf9c1..d035986 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,6 @@ Cargo.lock # Nix build artifacts/direnv stuff .direnv -result \ No newline at end of file +result + +bin \ No newline at end of file diff --git a/crates/league-toolkit/src/core/animation/asset/compressed/frame.rs b/crates/league-toolkit/src/core/animation/asset/compressed/frame.rs index 1d39557..3cf0fcf 100644 --- a/crates/league-toolkit/src/core/animation/asset/compressed/frame.rs +++ b/crates/league-toolkit/src/core/animation/asset/compressed/frame.rs @@ -13,7 +13,8 @@ impl Frame { self.joint_id & 0x3fff } pub fn transform_type(&self) -> TransformType { - TransformType::try_from_primitive((self.joint_id >> 14) as u8).expect("invalid transform type") + TransformType::try_from_primitive((self.joint_id >> 14) as u8) + .expect("invalid transform type") } } @@ -23,4 +24,4 @@ pub enum TransformType { Rotation = 0, Translation = 1, Scale = 2, -} \ No newline at end of file +} diff --git a/crates/league-toolkit/src/core/animation/asset/compressed/mod.rs b/crates/league-toolkit/src/core/animation/asset/compressed/mod.rs index 3ed9995..b2d2d2c 100644 --- a/crates/league-toolkit/src/core/animation/asset/compressed/mod.rs +++ b/crates/league-toolkit/src/core/animation/asset/compressed/mod.rs @@ -1,12 +1,12 @@ -use glam::{Vec3}; -use crate::core::animation::{AnimationAsset}; use crate::core::animation::asset::compressed::frame::Frame; use crate::core::animation::asset::compressed::read::AnimationFlags; use crate::core::animation::asset::error_metric::ErrorMetric; +use crate::core::animation::AnimationAsset; +use glam::Vec3; +mod frame; mod read; mod write; -mod frame; #[derive(Clone, Debug)] pub struct Compressed { diff --git a/crates/league-toolkit/src/core/animation/asset/compressed/read.rs b/crates/league-toolkit/src/core/animation/asset/compressed/read.rs index df94f9a..4804e05 100644 --- a/crates/league-toolkit/src/core/animation/asset/compressed/read.rs +++ b/crates/league-toolkit/src/core/animation/asset/compressed/read.rs @@ -1,13 +1,10 @@ -use std::io::{Read, Seek, SeekFrom}; -use std::mem::size_of; -use bitflags::bitflags; -use byteorder::ReadBytesExt; -use num_enum::{FromPrimitive, IntoPrimitive, TryFromPrimitive}; -use crate::core::animation::{asset, Compressed}; use crate::core::animation::asset::compressed::frame::Frame; use crate::core::animation::asset::error_metric::ErrorMetric; use crate::core::animation::AssetParseError::{InvalidField, InvalidFileVersion, MissingData}; -use crate::util::ReaderExt; +use crate::core::animation::{asset, Compressed}; +use bitflags::bitflags; +use std::io::{Read, Seek, SeekFrom}; +use std::mem::size_of; bitflags! { #[derive(Clone, Debug)] @@ -31,7 +28,6 @@ impl Compressed { return Err(InvalidFileVersion(version)); } - let resource_size = reader.read_u32::()?; let format_token = reader.read_u32::()?; let flags = reader.read_u32::()?; @@ -87,9 +83,7 @@ impl Compressed { if align_of > 0 && (p & (align_of - 1)) != 0 { panic!("bad alignment!"); } - let frame = unsafe { - std::mem::transmute::<_, Frame>(frame) - }; + let frame = unsafe { std::mem::transmute::<_, Frame>(frame) }; frames.push(frame); } @@ -99,10 +93,10 @@ impl Compressed { true => 24, false => 48, }; - let mut jump_caches = Vec::with_capacity(jump_cache_count as usize * jump_frame_size * joint_count as usize); + let mut jump_caches = + Vec::with_capacity(jump_cache_count as usize * jump_frame_size * joint_count as usize); reader.read_exact(&mut jump_caches)?; - Ok(Self { flags, duration, @@ -120,4 +114,4 @@ impl Compressed { joints, }) } -} \ No newline at end of file +} diff --git a/crates/league-toolkit/src/core/animation/asset/compressed/write.rs b/crates/league-toolkit/src/core/animation/asset/compressed/write.rs index 0db746e..1edee4c 100644 --- a/crates/league-toolkit/src/core/animation/asset/compressed/write.rs +++ b/crates/league-toolkit/src/core/animation/asset/compressed/write.rs @@ -1,11 +1,9 @@ -use std::io::{Write}; use crate::core::animation; use crate::core::animation::Compressed; +use std::io::Write; impl Compressed { pub fn to_writer(&self, writer: &mut W) -> animation::Result<()> { - use byteorder::{LE, WriteBytesExt as _}; - use crate::util::WriterExt as _; unimplemented!("TODO: animation::asset::Compressed writing"); } -} \ No newline at end of file +} diff --git a/crates/league-toolkit/src/core/animation/asset/error_metric.rs b/crates/league-toolkit/src/core/animation/asset/error_metric.rs index e5ce05d..84bc2ec 100644 --- a/crates/league-toolkit/src/core/animation/asset/error_metric.rs +++ b/crates/league-toolkit/src/core/animation/asset/error_metric.rs @@ -1,6 +1,6 @@ +use byteorder::{ReadBytesExt, LE}; use std::io; use std::io::Read; -use byteorder::{LE, ReadBytesExt}; // Represents the optimization settings of a transform component #[derive(Clone, Debug)] @@ -22,10 +22,16 @@ impl Default for ErrorMetric { impl ErrorMetric { pub fn new(margin: f32, discontinuity_threshold: f32) -> Self { - Self { margin, discontinuity_threshold } + Self { + margin, + discontinuity_threshold, + } } pub fn from_reader(reader: &mut R) -> io::Result { - Ok(Self::new(reader.read_f32::()?, reader.read_f32::()?)) + Ok(Self::new( + reader.read_f32::()?, + reader.read_f32::()?, + )) } -} \ No newline at end of file +} diff --git a/crates/league-toolkit/src/core/animation/asset/mod.rs b/crates/league-toolkit/src/core/animation/asset/mod.rs index b46bc55..f815736 100644 --- a/crates/league-toolkit/src/core/animation/asset/mod.rs +++ b/crates/league-toolkit/src/core/animation/asset/mod.rs @@ -11,10 +11,9 @@ mod error_metric; pub use error::*; +use error::AssetParseError::UnknownAssetType; use std::io; use std::io::{Read, Seek, SeekFrom}; -use error::AssetParseError::UnknownAssetType; -use crate::util::ReaderExt; #[derive(Clone, Debug)] pub enum AnimationAsset { @@ -35,20 +34,24 @@ impl AnimationAsset { let asset_type = Self::identify_from_reader(reader)?; reader.seek(SeekFrom::Start(0))?; match asset_type { - AnimationAssetType::Uncompressed => Uncompressed::from_reader(reader).map(Self::Uncompressed), + AnimationAssetType::Uncompressed => { + Uncompressed::from_reader(reader).map(Self::Uncompressed) + } AnimationAssetType::Compressed => Compressed::from_reader(reader).map(Self::Compressed), AnimationAssetType::Unknown => Err(UnknownAssetType), } } - pub fn identify_from_reader(reader: &mut R) -> io::Result { + pub fn identify_from_reader( + reader: &mut R, + ) -> io::Result { let mut magic = [0_u8; 8]; reader.read_exact(&mut magic)?; Ok(match &magic { b"r3d2anmd" => AnimationAssetType::Uncompressed, b"r3d2canm" => AnimationAssetType::Compressed, - _ => AnimationAssetType::Unknown + _ => AnimationAssetType::Unknown, }) } } diff --git a/crates/league-toolkit/src/core/animation/asset/uncompressed/mod.rs b/crates/league-toolkit/src/core/animation/asset/uncompressed/mod.rs index b5d31f6..280b485 100644 --- a/crates/league-toolkit/src/core/animation/asset/uncompressed/mod.rs +++ b/crates/league-toolkit/src/core/animation/asset/uncompressed/mod.rs @@ -10,4 +10,4 @@ impl Into for Uncompressed { fn into(self) -> AnimationAsset { AnimationAsset::Uncompressed(self) } -} \ No newline at end of file +} diff --git a/crates/league-toolkit/src/core/animation/asset/uncompressed/read.rs b/crates/league-toolkit/src/core/animation/asset/uncompressed/read.rs index 5ccd399..b73d77d 100644 --- a/crates/league-toolkit/src/core/animation/asset/uncompressed/read.rs +++ b/crates/league-toolkit/src/core/animation/asset/uncompressed/read.rs @@ -1,10 +1,8 @@ -use std::io::Read; use crate::core::animation::{asset, Uncompressed}; +use std::io::Read; impl Uncompressed { pub fn from_reader(reader: &mut R) -> asset::Result { - use crate::util::ReaderExt as _; - use byteorder::{ReadBytesExt as _, LE}; unimplemented!("TODO: animation::asset::Uncompressed reading"); } -} \ No newline at end of file +} diff --git a/crates/league-toolkit/src/core/animation/asset/uncompressed/write.rs b/crates/league-toolkit/src/core/animation/asset/uncompressed/write.rs index b0b1986..09a11ca 100644 --- a/crates/league-toolkit/src/core/animation/asset/uncompressed/write.rs +++ b/crates/league-toolkit/src/core/animation/asset/uncompressed/write.rs @@ -1,11 +1,9 @@ -use std::io::{Write}; use crate::core::animation; use crate::core::animation::Uncompressed; +use std::io::Write; impl Uncompressed { pub fn to_writer(&self, writer: &mut W) -> animation::Result<()> { - use byteorder::{LE, WriteBytesExt as _}; - use crate::util::WriterExt as _; unimplemented!("TODO: animation::asset::Uncompressed writing"); } -} \ No newline at end of file +} diff --git a/crates/league-toolkit/src/core/animation/error.rs b/crates/league-toolkit/src/core/animation/error.rs index 0384d44..a4d5bd9 100644 --- a/crates/league-toolkit/src/core/animation/error.rs +++ b/crates/league-toolkit/src/core/animation/error.rs @@ -12,4 +12,4 @@ pub enum ParseError { Utf8Error(#[from] std::str::Utf8Error), } -pub type Result = core::result::Result; \ No newline at end of file +pub type Result = core::result::Result; diff --git a/crates/league-toolkit/src/core/animation/joint/mod.rs b/crates/league-toolkit/src/core/animation/joint/mod.rs index e176532..6a4e376 100644 --- a/crates/league-toolkit/src/core/animation/joint/mod.rs +++ b/crates/league-toolkit/src/core/animation/joint/mod.rs @@ -1,12 +1,9 @@ -use std::io::{Read, Seek}; -use byteorder::ReadBytesExt; use glam::{Mat4, Quat, Vec3}; -use crate::util::ReaderExt; +mod builder; pub mod legacy; mod read; mod write; -mod builder; pub use builder::Builder; @@ -25,7 +22,6 @@ pub struct Joint { inverse_bind_translation: Vec3, inverse_bind_scale: Vec3, inverse_bind_rotation: Quat, - } impl Joint { diff --git a/crates/league-toolkit/src/core/animation/mod.rs b/crates/league-toolkit/src/core/animation/mod.rs index 4204cee..4611bce 100644 --- a/crates/league-toolkit/src/core/animation/mod.rs +++ b/crates/league-toolkit/src/core/animation/mod.rs @@ -6,11 +6,9 @@ pub mod error; pub use error::*; -pub mod rig; pub mod asset; +pub mod rig; -pub use asset::{AnimationAsset, AnimationAssetType, AssetParseError, Uncompressed, Compressed}; +pub use asset::{AnimationAsset, AnimationAssetType, AssetParseError, Compressed, Uncompressed}; pub use rig::*; - - diff --git a/crates/league-toolkit/src/core/animation/rig/snapshots/league_toolkit__core__animation__rig__builder__tests__build_rig.snap b/crates/league-toolkit/src/core/animation/rig/snapshots/league_toolkit__core__animation__rig__builder__tests__build_rig.snap new file mode 100644 index 0000000..19fe864 --- /dev/null +++ b/crates/league-toolkit/src/core/animation/rig/snapshots/league_toolkit__core__animation__rig__builder__tests__build_rig.snap @@ -0,0 +1,561 @@ +--- +source: crates/league-toolkit/src/core/animation/rig/builder.rs +expression: rig +--- +RigResource { + flags: 0, + name: "my_rig", + asset_name: "my_rig_asset", + joints: [ + Joint { + name: "root_1", + flags: 10, + id: 0, + parent_id: -1, + radius: 2.1, + local_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + local_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + local_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + local_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + inverse_bind_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + inverse_bind_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + inverse_bind_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + inverse_bind_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + Joint { + name: "2a", + flags: 11, + id: 1, + parent_id: 0, + radius: 2.1, + local_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + local_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + local_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + local_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + inverse_bind_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + inverse_bind_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + inverse_bind_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + inverse_bind_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + Joint { + name: "2b", + flags: 12, + id: 2, + parent_id: 0, + radius: 2.1, + local_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + local_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + local_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + local_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + inverse_bind_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + inverse_bind_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + inverse_bind_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + inverse_bind_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + Joint { + name: "root_2", + flags: 20, + id: 3, + parent_id: -1, + radius: 2.1, + local_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + local_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + local_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + local_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + inverse_bind_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + inverse_bind_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + inverse_bind_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + inverse_bind_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + Joint { + name: "2a", + flags: 21, + id: 4, + parent_id: 3, + radius: 2.1, + local_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + local_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + local_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + local_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + inverse_bind_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + inverse_bind_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + inverse_bind_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + inverse_bind_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + Joint { + name: "2aa", + flags: 211, + id: 5, + parent_id: 4, + radius: 2.1, + local_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + local_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + local_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + local_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + inverse_bind_transform: Mat4 { + x_axis: Vec4( + 1.0, + 0.0, + 0.0, + 0.0, + ), + y_axis: Vec4( + 0.0, + 1.0, + 0.0, + 0.0, + ), + z_axis: Vec4( + 0.0, + 0.0, + 1.0, + 0.0, + ), + w_axis: Vec4( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + inverse_bind_translation: Vec3( + 0.0, + 0.0, + 0.0, + ), + inverse_bind_scale: Vec3( + 1.0, + 1.0, + 1.0, + ), + inverse_bind_rotation: Quat( + 0.0, + 0.0, + 0.0, + 1.0, + ), + }, + ], + influences: [ + 2, + 4, + ], +} diff --git a/crates/league-toolkit/src/core/mod.rs b/crates/league-toolkit/src/core/mod.rs index 5371b33..15e14b4 100644 --- a/crates/league-toolkit/src/core/mod.rs +++ b/crates/league-toolkit/src/core/mod.rs @@ -1,5 +1,5 @@ +pub mod animation; pub mod mem; pub mod mesh; pub mod primitives; pub mod wad; -pub mod animation; diff --git a/crates/league-toolkit/src/core/primitives/aabb.rs b/crates/league-toolkit/src/core/primitives/aabb.rs index 98c362e..69cadcf 100644 --- a/crates/league-toolkit/src/core/primitives/aabb.rs +++ b/crates/league-toolkit/src/core/primitives/aabb.rs @@ -1,5 +1,5 @@ -use glam::{Vec3, vec3}; use super::Sphere; +use glam::{vec3, Vec3}; #[derive(Default, Debug, Clone, Copy, PartialEq)] pub struct AABB { diff --git a/crates/league-toolkit/src/core/primitives/color.rs b/crates/league-toolkit/src/core/primitives/color.rs index 707a7b0..34472b5 100644 --- a/crates/league-toolkit/src/core/primitives/color.rs +++ b/crates/league-toolkit/src/core/primitives/color.rs @@ -1,5 +1,5 @@ -use std::io::Write; use byteorder::{ByteOrder, WriteBytesExt}; +use std::io::Write; #[derive(Debug, Clone, Copy)] pub struct Color { @@ -16,7 +16,10 @@ impl Color { Self { r, g, b, a } } - pub fn to_writer(&self, writer: &mut (impl Write + ?Sized)) -> std::io::Result<()> { + pub fn to_writer( + &self, + writer: &mut (impl Write + ?Sized), + ) -> std::io::Result<()> { writer.write_f32::(self.r)?; writer.write_f32::(self.g)?; writer.write_f32::(self.b)?; diff --git a/crates/league-toolkit/src/util/hash.rs b/crates/league-toolkit/src/util/hash.rs index 0b9a20c..d76ed8e 100644 --- a/crates/league-toolkit/src/util/hash.rs +++ b/crates/league-toolkit/src/util/hash.rs @@ -17,6 +17,9 @@ pub fn elf>(input: S) -> usize { mod tests { #[test] fn elf() { - assert_eq!(super::elf("jdfgsdhfsdfsd 6445dsfsd7fg/*/+bfjsdgf%$^"), 248446350); + assert_eq!( + super::elf("jdfgsdhfsdfsd 6445dsfsd7fg/*/+bfjsdgf%$^"), + 248446350 + ); } -} \ No newline at end of file +} diff --git a/crates/league-toolkit/src/util/mod.rs b/crates/league-toolkit/src/util/mod.rs index b590db0..48c8693 100644 --- a/crates/league-toolkit/src/util/mod.rs +++ b/crates/league-toolkit/src/util/mod.rs @@ -1,6 +1,6 @@ +pub mod hash; pub mod reader; pub mod writer; -pub mod hash; pub use reader::*; pub use writer::*; diff --git a/crates/league-toolkit/src/util/reader.rs b/crates/league-toolkit/src/util/reader.rs index 2f2659b..7f649d0 100644 --- a/crates/league-toolkit/src/util/reader.rs +++ b/crates/league-toolkit/src/util/reader.rs @@ -73,10 +73,7 @@ pub trait ReaderExt: Read { } fn read_sphere(&mut self) -> io::Result { - Ok(Sphere::new( - self.read_vec3::()?, - self.read_f32::()?, - )) + Ok(Sphere::new(self.read_vec3::()?, self.read_f32::()?)) } } diff --git a/crates/league-toolkit/src/util/writer.rs b/crates/league-toolkit/src/util/writer.rs index 60912a0..4290528 100644 --- a/crates/league-toolkit/src/util/writer.rs +++ b/crates/league-toolkit/src/util/writer.rs @@ -49,7 +49,6 @@ pub trait WriterExt: Write { Ok(()) } - fn write_aabb(&mut self, aabb: &AABB) -> io::Result<()> { self.write_vec3::(&aabb.min)?; self.write_vec3::(&aabb.max)?; diff --git a/crates/league-toolkit/tests/mod.rs b/crates/league-toolkit/tests/mod.rs index 4271702..8b13789 100644 --- a/crates/league-toolkit/tests/mod.rs +++ b/crates/league-toolkit/tests/mod.rs @@ -1,2 +1 @@ -pub mod skeleton; -pub mod skinned; \ No newline at end of file + diff --git a/crates/league-toolkit/tests/skeleton/mod.rs b/crates/league-toolkit/tests/skeleton/mod.rs deleted file mode 100644 index da06ffc..0000000 --- a/crates/league-toolkit/tests/skeleton/mod.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::io::{BufReader, Cursor}; -use insta::assert_debug_snapshot; -use league_toolkit::core::animation::RigResource; - -#[test] -pub fn read() { - let mut r = Cursor::new(include_bytes!("jackinthebox.skl")); - let skl = RigResource::from_reader(&mut r).unwrap(); - assert_debug_snapshot!(skl); -} \ No newline at end of file diff --git a/crates/league-toolkit/tests/skinned/mod.rs b/crates/league-toolkit/tests/skinned/mod.rs deleted file mode 100644 index 7964ccb..0000000 --- a/crates/league-toolkit/tests/skinned/mod.rs +++ /dev/null @@ -1,30 +0,0 @@ -use std::io::BufReader; -use glam::vec3; -use insta::assert_debug_snapshot; -use league_toolkit::core::mesh::{SkinnedMesh, SkinnedMeshRange}; -use league_toolkit::core::primitives::{AABB, Sphere}; - -#[test] -pub fn read() { - let mesh = SkinnedMesh::from_reader(&mut &include_bytes!("jackinthebox.skn")[..]).unwrap(); - - assert_eq!(mesh.aabb(), AABB::new(vec3(-11.59685, 0.16613889, -5.102246), vec3(11.607941, 29.03124, 10.6147995))); - assert_eq!(mesh.bounding_sphere(), Sphere::new(vec3(0.0055451393, 14.59869, 2.7562768), 20.116425)); - assert_eq!(mesh.ranges(), [SkinnedMeshRange::new("lambert2", 0, 573, 0, 2067)]); - - assert_debug_snapshot!(mesh); -} - - -#[test] -pub fn round_trip() { - let mut raw = &include_bytes!("jackinthebox.skn")[..]; - let mesh = SkinnedMesh::from_reader(&mut raw).unwrap(); - - let mut vec = Vec::with_capacity(raw.len()); - mesh.to_writer(&mut vec).unwrap(); - - let rt_mesh = SkinnedMesh::from_reader(&mut &vec[..]).unwrap(); - - assert_eq!(mesh, rt_mesh); -} \ No newline at end of file