Skip to content

Commit

Permalink
Merge pull request #100 from SlimeYummy/issue/clippy
Browse files Browse the repository at this point in the history
fix clippy
  • Loading branch information
SlimeYummy authored Nov 14, 2024
2 parents d8b7730 7cc7b79 commit de96942
Show file tree
Hide file tree
Showing 18 changed files with 161 additions and 172 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 19,8 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Clippy
run: cargo clippy -p ozz-animation-rs -- --no-deps
- name: Build
run: cargo build --release
- name: Run tests
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
[package]
name = "ozz-animation-rs"
version = "0.10.0"
version = "0.10.1"
authors = ["SlimeYummy <[email protected]>"]
edition = "2021"
rust-version = "1.75"
Expand Down
2 changes: 1 addition & 1 deletion demo/src/blend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 109,7 @@ impl OzzBlend {

impl OzzExample for OzzBlend {
fn root(&self) -> Mat4 {
return self.models.buf().unwrap()[0];
self.models.buf().unwrap()[0]
}

fn bone_trans(&self) -> &[OzzTransform] {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/playback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 69,7 @@ impl OzzPlayback {

impl OzzExample for OzzPlayback {
fn root(&self) -> Mat4 {
return self.models.buf().unwrap()[0];
self.models.buf().unwrap()[0]
}

fn bone_trans(&self) -> &[OzzTransform] {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/two_bone_ik.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 70,7 @@ impl OzzTwoBoneIK {

impl OzzExample for OzzTwoBoneIK {
fn root(&self) -> Mat4 {
return self.models2.buf().unwrap()[0];
self.models2.buf().unwrap()[0]
}

fn bone_trans(&self) -> &[OzzTransform] {
Expand Down
81 changes: 40 additions & 41 deletions src/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 403,6 @@ impl Animation {
archive.read_slice(animation.s_iframe_desc_mut())?;
animation.s_iframe_interval = archive.read()?;
archive.read_slice(animation.scales_mut())?;

Ok(animation)
}

Expand Down Expand Up @@ -465,7 464,7 @@ impl Animation {
}

pub(crate) fn to_raw(&self) -> AnimationRaw {
return AnimationRaw {
AnimationRaw {
duration: self.duration,
num_tracks: self.num_tracks,
name: self.name.clone(),
Expand All @@ -491,7 490,7 @@ impl Animation {
s_iframe_interval: self.s_iframe_interval,
s_iframe_entries: self.s_iframe_entries().to_vec(),
s_iframe_desc: self.s_iframe_desc().to_vec(),
};
}
}

fn new(meta: AnimationMeta) -> Animation {
Expand Down Expand Up @@ -652,207 651,207 @@ impl Animation {
/// Gets the buffer of time points.
#[inline]
pub fn timepoints(&self) -> &[f32] {
return unsafe { slice::from_raw_parts(self.timepoints, self.timepoints_count as usize) };
unsafe { slice::from_raw_parts(self.timepoints, self.timepoints_count as usize) }
}

#[inline]
fn timepoints_mut(&mut self) -> &mut [f32] {
return unsafe { slice::from_raw_parts_mut(self.timepoints, self.timepoints_count as usize) };
unsafe { slice::from_raw_parts_mut(self.timepoints, self.timepoints_count as usize) }
}

/// Gets the buffer of translation keys.
#[inline]
pub fn translations(&self) -> &[Float3Key] {
return unsafe { slice::from_raw_parts(self.translations, self.translations_count as usize) };
unsafe { slice::from_raw_parts(self.translations, self.translations_count as usize) }
}

#[inline]
fn translations_mut(&mut self) -> &mut [Float3Key] {
return unsafe { slice::from_raw_parts_mut(self.translations, self.translations_count as usize) };
unsafe { slice::from_raw_parts_mut(self.translations, self.translations_count as usize) }
}

#[inline]
fn t_ratios(&self) -> &[u16] {
return unsafe { slice::from_raw_parts(self.t_ratios, self.translations_count as usize) };
unsafe { slice::from_raw_parts(self.t_ratios, self.translations_count as usize) }
}

#[inline]
fn t_ratios_mut(&mut self) -> &mut [u16] {
return unsafe { slice::from_raw_parts_mut(self.t_ratios, self.translations_count as usize) };
unsafe { slice::from_raw_parts_mut(self.t_ratios, self.translations_count as usize) }
}

#[inline]
fn t_previouses(&self) -> &[u16] {
return unsafe { slice::from_raw_parts(self.t_previouses, self.translations_count as usize) };
unsafe { slice::from_raw_parts(self.t_previouses, self.translations_count as usize) }
}

#[inline]
fn t_previouses_mut(&mut self) -> &mut [u16] {
return unsafe { slice::from_raw_parts_mut(self.t_previouses, self.translations_count as usize) };
unsafe { slice::from_raw_parts_mut(self.t_previouses, self.translations_count as usize) }
}

#[inline]
fn t_iframe_entries(&self) -> &[u8] {
return unsafe { slice::from_raw_parts(self.t_iframe_entries, self.t_iframe_entries_count as usize) };
unsafe { slice::from_raw_parts(self.t_iframe_entries, self.t_iframe_entries_count as usize) }
}

#[inline]
fn t_iframe_entries_mut(&mut self) -> &mut [u8] {
return unsafe { slice::from_raw_parts_mut(self.t_iframe_entries, self.t_iframe_entries_count as usize) };
unsafe { slice::from_raw_parts_mut(self.t_iframe_entries, self.t_iframe_entries_count as usize) }
}

#[inline]
fn t_iframe_desc(&self) -> &[u32] {
return unsafe { slice::from_raw_parts(self.t_iframe_desc, self.t_iframe_desc_count as usize) };
unsafe { slice::from_raw_parts(self.t_iframe_desc, self.t_iframe_desc_count as usize) }
}

#[inline]
fn t_iframe_desc_mut(&mut self) -> &mut [u32] {
return unsafe { slice::from_raw_parts_mut(self.t_iframe_desc, self.t_iframe_desc_count as usize) };
unsafe { slice::from_raw_parts_mut(self.t_iframe_desc, self.t_iframe_desc_count as usize) }
}

/// Gets the buffer of rotation keys.
#[inline]
pub fn rotations(&self) -> &[QuaternionKey] {
return unsafe { slice::from_raw_parts(self.rotations, self.rotations_count as usize) };
unsafe { slice::from_raw_parts(self.rotations, self.rotations_count as usize) }
}

#[inline]
fn rotations_mut(&mut self) -> &mut [QuaternionKey] {
return unsafe { slice::from_raw_parts_mut(self.rotations, self.rotations_count as usize) };
unsafe { slice::from_raw_parts_mut(self.rotations, self.rotations_count as usize) }
}

#[inline]
fn r_ratios(&self) -> &[u16] {
return unsafe { slice::from_raw_parts(self.r_ratios, self.rotations_count as usize) };
unsafe { slice::from_raw_parts(self.r_ratios, self.rotations_count as usize) }
}

#[inline]
fn r_ratios_mut(&mut self) -> &mut [u16] {
return unsafe { slice::from_raw_parts_mut(self.r_ratios, self.rotations_count as usize) };
unsafe { slice::from_raw_parts_mut(self.r_ratios, self.rotations_count as usize) }
}

#[inline]
fn r_previouses(&self) -> &[u16] {
return unsafe { slice::from_raw_parts(self.r_previouses, self.rotations_count as usize) };
unsafe { slice::from_raw_parts(self.r_previouses, self.rotations_count as usize) }
}

#[inline]
fn r_previouses_mut(&mut self) -> &mut [u16] {
return unsafe { slice::from_raw_parts_mut(self.r_previouses, self.rotations_count as usize) };
unsafe { slice::from_raw_parts_mut(self.r_previouses, self.rotations_count as usize) }
}

#[inline]
fn r_iframe_entries(&self) -> &[u8] {
return unsafe { slice::from_raw_parts(self.r_iframe_entries, self.r_iframe_entries_count as usize) };
unsafe { slice::from_raw_parts(self.r_iframe_entries, self.r_iframe_entries_count as usize) }
}

#[inline]
fn r_iframe_entries_mut(&mut self) -> &mut [u8] {
return unsafe { slice::from_raw_parts_mut(self.r_iframe_entries, self.r_iframe_entries_count as usize) };
unsafe { slice::from_raw_parts_mut(self.r_iframe_entries, self.r_iframe_entries_count as usize) }
}

#[inline]
fn r_iframe_desc(&self) -> &[u32] {
return unsafe { slice::from_raw_parts(self.r_iframe_desc, self.r_iframe_desc_count as usize) };
unsafe { slice::from_raw_parts(self.r_iframe_desc, self.r_iframe_desc_count as usize) }
}

#[inline]
fn r_iframe_desc_mut(&mut self) -> &mut [u32] {
return unsafe { slice::from_raw_parts_mut(self.r_iframe_desc, self.r_iframe_desc_count as usize) };
unsafe { slice::from_raw_parts_mut(self.r_iframe_desc, self.r_iframe_desc_count as usize) }
}

/// Gets the buffer of scale keys.
#[inline]
pub fn scales(&self) -> &[Float3Key] {
return unsafe { slice::from_raw_parts(self.scales, self.scales_count as usize) };
unsafe { slice::from_raw_parts(self.scales, self.scales_count as usize) }
}

#[inline]
fn scales_mut(&mut self) -> &mut [Float3Key] {
return unsafe { slice::from_raw_parts_mut(self.scales, self.scales_count as usize) };
unsafe { slice::from_raw_parts_mut(self.scales, self.scales_count as usize) }
}

#[inline]
fn s_ratios(&self) -> &[u16] {
return unsafe { slice::from_raw_parts(self.s_ratios, self.scales_count as usize) };
unsafe { slice::from_raw_parts(self.s_ratios, self.scales_count as usize) }
}

#[inline]
fn s_ratios_mut(&mut self) -> &mut [u16] {
return unsafe { slice::from_raw_parts_mut(self.s_ratios, self.scales_count as usize) };
unsafe { slice::from_raw_parts_mut(self.s_ratios, self.scales_count as usize) }
}

#[inline]
fn s_previouses(&self) -> &[u16] {
return unsafe { slice::from_raw_parts(self.s_previouses, self.scales_count as usize) };
unsafe { slice::from_raw_parts(self.s_previouses, self.scales_count as usize) }
}

#[inline]
fn s_previouses_mut(&mut self) -> &mut [u16] {
return unsafe { slice::from_raw_parts_mut(self.s_previouses, self.scales_count as usize) };
unsafe { slice::from_raw_parts_mut(self.s_previouses, self.scales_count as usize) }
}

#[inline]
fn s_iframe_entries(&self) -> &[u8] {
return unsafe { slice::from_raw_parts(self.s_iframe_entries, self.s_iframe_entries_count as usize) };
unsafe { slice::from_raw_parts(self.s_iframe_entries, self.s_iframe_entries_count as usize) }
}

#[inline]
fn s_iframe_entries_mut(&mut self) -> &mut [u8] {
return unsafe { slice::from_raw_parts_mut(self.s_iframe_entries, self.s_iframe_entries_count as usize) };
unsafe { slice::from_raw_parts_mut(self.s_iframe_entries, self.s_iframe_entries_count as usize) }
}

#[inline]
fn s_iframe_desc(&self) -> &[u32] {
return unsafe { slice::from_raw_parts(self.s_iframe_desc, self.s_iframe_desc_count as usize) };
unsafe { slice::from_raw_parts(self.s_iframe_desc, self.s_iframe_desc_count as usize) }
}

#[inline]
fn s_iframe_desc_mut(&mut self) -> &mut [u32] {
return unsafe { slice::from_raw_parts_mut(self.s_iframe_desc, self.s_iframe_desc_count as usize) };
unsafe { slice::from_raw_parts_mut(self.s_iframe_desc, self.s_iframe_desc_count as usize) }
}

/// Gets the buffer of translation keys.
#[inline]
pub fn translations_ctrl(&self) -> KeyframesCtrl<'_> {
return unsafe {
unsafe {
KeyframesCtrl {
ratios: slice::from_raw_parts(self.t_ratios, self.translations_count as usize),
previouses: slice::from_raw_parts(self.t_previouses, self.translations_count as usize),
iframe_entries: slice::from_raw_parts(self.t_iframe_entries, self.t_iframe_entries_count as usize),
iframe_desc: slice::from_raw_parts(self.t_iframe_desc, self.t_iframe_desc_count as usize),
iframe_interval: self.t_iframe_interval,
}
};
}
}

/// Gets the buffer of rotation keys.
#[inline]
pub fn rotations_ctrl(&self) -> KeyframesCtrl<'_> {
return unsafe {
unsafe {
KeyframesCtrl {
ratios: slice::from_raw_parts(self.r_ratios, self.rotations_count as usize),
previouses: slice::from_raw_parts(self.r_previouses, self.rotations_count as usize),
iframe_entries: slice::from_raw_parts(self.r_iframe_entries, self.r_iframe_entries_count as usize),
iframe_desc: slice::from_raw_parts(self.r_iframe_desc, self.r_iframe_desc_count as usize),
iframe_interval: self.r_iframe_interval,
}
};
}
}

/// Gets the buffer of scale keys.
#[inline]
pub fn scales_ctrl(&self) -> KeyframesCtrl<'_> {
return unsafe {
unsafe {
KeyframesCtrl {
ratios: slice::from_raw_parts(self.s_ratios, self.scales_count as usize),
previouses: slice::from_raw_parts(self.s_previouses, self.scales_count as usize),
iframe_entries: slice::from_raw_parts(self.s_iframe_entries, self.s_iframe_entries_count as usize),
iframe_desc: slice::from_raw_parts(self.s_iframe_desc, self.s_iframe_desc_count as usize),
iframe_interval: self.s_iframe_interval,
}
};
}
}
}

Expand Down
7 changes: 3 additions & 4 deletions src/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 43,6 @@ impl<R: Read> Archive<R> {

let version = archive.read::<u32>()?;
archive.version = version;

Ok(archive)
}

Expand Down Expand Up @@ -105,9 104,9 @@ impl Archive<Cursor<Vec<u8>>> {
#[cfg(all(feature = "wasm", feature = "nodejs"))]
pub fn from_path(path: &str) -> Result<Archive<Cursor<Vec<u8>>>, OzzError> {
match crate::nodejs::read_file(path) {
Ok(buf) => return Archive::from_vec(buf),
Err(err) => return Err(OzzError::Custom(Box::new(err.as_string().unwrap_or("".into())))),
};
Ok(buf) => Archive::from_vec(buf),
Err(err) => Err(OzzError::Custom(Box::new(err.as_string().unwrap_or("".into())))),
}
}
}

Expand Down
Loading

0 comments on commit de96942

Please sign in to comment.