From 163a42cc47f72552721df38f1f81f374742c145b Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Sat, 7 Oct 2023 01:11:24 -0400 Subject: [PATCH] Fixup some mistaken API usage and tests --- .github/workflows/ci.yml | 2 ++ citro3d/src/math/fvec.rs | 8 ++++---- citro3d/src/math/ops.rs | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5617ee5..5452463 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,6 +10,7 @@ on: jobs: lint: strategy: + fail-fast: false matrix: toolchain: # Run against a "known good" nightly. Rustc version is 1 day behind the toolchain date @@ -46,6 +47,7 @@ jobs: test: strategy: + fail-fast: false matrix: toolchain: - nightly-2023-06-01 diff --git a/citro3d/src/math/fvec.rs b/citro3d/src/math/fvec.rs index b1d7f12..c6624c6 100644 --- a/citro3d/src/math/fvec.rs +++ b/citro3d/src/math/fvec.rs @@ -57,12 +57,12 @@ impl FVec4 { /// The dot product of two vectors. pub fn dot(&self, rhs: &Self) -> f32 { - unsafe { citro3d_sys::FVec3_Dot(self.0, rhs.0) } + unsafe { citro3d_sys::FVec4_Dot(self.0, rhs.0) } } /// The magnitude of the vector. pub fn magnitude(&self) -> f32 { - unsafe { citro3d_sys::FVec3_Magnitude(self.0) } + unsafe { citro3d_sys::FVec4_Magnitude(self.0) } } /// Normalize the vector to a magnitude of `1.0`. @@ -144,7 +144,7 @@ mod tests { let dot = l.dot(&FVec4::splat(3.0)); assert!((dot - 24.0).abs() < f32::EPSILON); - assert!((l.magnitude() - 8.0).abs() < f32::EPSILON); + assert!((l.magnitude() - 4.0).abs() < f32::EPSILON); let norm = l.normalize(); assert!((norm.magnitude() - 1.0).abs() < f32::EPSILON); @@ -166,7 +166,7 @@ mod tests { let dot = l.dot(&FVec3::splat(3.0)); assert!((dot - 18.0).abs() < f32::EPSILON); - assert!((l.magnitude() - 8.0).abs() < f32::EPSILON); + assert!((l.magnitude() - f32::sqrt(12.0)).abs() < f32::EPSILON); let norm = l.normalize(); assert!((norm.magnitude() - 1.0).abs() < f32::EPSILON); diff --git a/citro3d/src/math/ops.rs b/citro3d/src/math/ops.rs index dffe352..7a4f486 100644 --- a/citro3d/src/math/ops.rs +++ b/citro3d/src/math/ops.rs @@ -15,7 +15,7 @@ impl> Sub for FVec4 { type Output = Self; fn sub(self, rhs: Rhs) -> Self::Output { - Self(unsafe { citro3d_sys::FVec4_Add(self.0, rhs.borrow().0) }) + Self(unsafe { citro3d_sys::FVec4_Subtract(self.0, rhs.borrow().0) }) } } @@ -47,7 +47,7 @@ impl> Sub for FVec3 { type Output = Self; fn sub(self, rhs: Rhs) -> Self::Output { - Self(unsafe { citro3d_sys::FVec3_Add(self.0, rhs.borrow().0) }) + Self(unsafe { citro3d_sys::FVec3_Subtract(self.0, rhs.borrow().0) }) } }