Browse Source

Fixup some mistaken API usage and tests

pull/28/head
Ian Chamberlain 1 year ago
parent
commit
163a42cc47
No known key found for this signature in database
GPG Key ID: AE5484D09405AA60
  1. 2
      .github/workflows/ci.yml
  2. 8
      citro3d/src/math/fvec.rs
  3. 4
      citro3d/src/math/ops.rs

2
.github/workflows/ci.yml

@ -10,6 +10,7 @@ on: @@ -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: @@ -46,6 +47,7 @@ jobs:
test:
strategy:
fail-fast: false
matrix:
toolchain:
- nightly-2023-06-01

8
citro3d/src/math/fvec.rs

@ -57,12 +57,12 @@ impl FVec4 { @@ -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 { @@ -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 { @@ -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);

4
citro3d/src/math/ops.rs

@ -15,7 +15,7 @@ impl<Rhs: Borrow<Self>> Sub<Rhs> for FVec4 { @@ -15,7 +15,7 @@ impl<Rhs: Borrow<Self>> Sub<Rhs> 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<Rhs: Borrow<Self>> Sub<Rhs> for FVec3 { @@ -47,7 +47,7 @@ impl<Rhs: Borrow<Self>> Sub<Rhs> 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) })
}
}

Loading…
Cancel
Save