Skip to content

Commit

Permalink
Fix derive_op_impl_rev, #[inline] as_ref, cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Demindiro committed Mar 24, 2021
1 parent 392c6c1 commit 2a304a6
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
15 changes: 9 additions & 6 deletions gdnative-core/src/core_types/geom/basis.rs
Expand Up @@ -670,7 +670,7 @@ mod tests {
fn euler() {
let (_b, bn) = test_inputs();

dbg!(bn.to_euler());
dbg!(bn.to_euler());
assert!(Vector3::new(0.57079, 0.310283, 0.760213).is_equal_approx(bn.to_euler()));
}

Expand All @@ -696,7 +696,10 @@ mod tests {
Vector3::new(0.012407, -0.040492, -0.007774),
Vector3::new(-0.682131, -0.212475, 0.018051),
]);
dbg!(expected, b.scaled(&Vector3::new(0.677813, -0.043058, 0.714685)));
dbg!(
expected,
b.scaled(&Vector3::new(0.677813, -0.043058, 0.714685))
);
assert!(expected.is_equal_approx(&b.scaled(&Vector3::new(0.677813, -0.043058, 0.714685))));
}

Expand All @@ -718,7 +721,7 @@ mod tests {
fn to_quat() {
let (b, _bn) = test_inputs();

dbg!(b.to_quat());
dbg!(b.to_quat());
assert!(Quat::new(-0.167156, 0.677813, -0.043058, 0.714685).is_equal_approx(&b.to_quat()));
}

Expand Down Expand Up @@ -751,7 +754,7 @@ mod tests {
fn xform() {
let (b, _bn) = test_inputs();

dbg!(b.xform(Vector3::new(0.5, 0.7, -0.2)));
dbg!(b.xform(Vector3::new(0.5, 0.7, -0.2)));
assert!(Vector3::new(-0.273471, 0.478102, -0.690386)
.is_equal_approx(b.xform(Vector3::new(0.5, 0.7, -0.2))));
}
Expand All @@ -760,7 +763,7 @@ mod tests {
fn xform_inv() {
let (b, _bn) = test_inputs();

dbg!(b.xform(Vector3::new(0.077431, -0.165055, 0.98324)));
dbg!(b.xform(Vector3::new(0.077431, -0.165055, 0.98324)));
assert!(Vector3::new(-0.884898, -0.460316, 0.071165)
.is_equal_approx(b.xform_inv(Vector3::new(0.077431, -0.165055, 0.98324))));
}
Expand All @@ -774,7 +777,7 @@ mod tests {
Vector3::new(-0.165055, 0.94041, -0.297299),
Vector3::new(0.98324, 0.180557, 0.025257),
]);
dbg!(b.inverted(), expected);
dbg!(b.inverted(), expected);
assert!(expected.is_equal_approx(&b.inverted()));
}
}
8 changes: 4 additions & 4 deletions gdnative-core/src/core_types/geom/plane.rs
Expand Up @@ -192,7 +192,7 @@ mod test {

let expected_valid = Plane::from_coordinates(0.447214, 0.0, -0.894427, -0.447214);

dbg!(expected_valid);
dbg!(expected_valid);
assert!(Plane::from_points(a, b, c)
.unwrap()
.is_equal_approx(expected_valid));
Expand Down Expand Up @@ -240,8 +240,8 @@ mod test {
let d = Plane::from_coordinates(0.01, 0.02, 0.4, 0.16);
let e = Plane::from_coordinates(0.01, 0.02, 0.4, 0.32);

dbg!(p.intersect_3(b, c));
dbg!(expected);
dbg!(p.intersect_3(b, c));
dbg!(expected);
assert!(p.intersect_3(b, c).unwrap().is_equal_approx(expected));
assert_eq!(p.intersect_3(d, e), None);
}
Expand Down Expand Up @@ -287,7 +287,7 @@ mod test {
fn normalize() {
let (p, _v) = test_inputs();

dbg!(p.normalize());
dbg!(p.normalize());
assert!(p.normalize().is_equal_approx(Plane::from_coordinates(
0.218218, 0.436436, 0.872872, 1.745743
)));
Expand Down
2 changes: 1 addition & 1 deletion gdnative-core/src/core_types/mod.rs
Expand Up @@ -22,9 +22,9 @@ mod vector2;
mod vector2_array;
mod vector3_array;

pub mod dictionary;
pub mod error;
pub mod vector3;
pub mod dictionary;

pub use geom::*;

Expand Down
7 changes: 4 additions & 3 deletions gdnative-core/src/core_types/vector3.rs
Expand Up @@ -184,7 +184,7 @@ impl Vector3 {
/// Returns the axis of the vector's largest value. See `Axis` enum.
/// If all components are equal, this method returns `Axis::X`.
#[inline]
#[allow(clippy::collapsible-if)]
#[allow(clippy::collapsible_if)]
pub fn max_axis(self) -> Axis {
if self.z > self.y {
if self.z > self.x {
Expand All @@ -204,7 +204,7 @@ impl Vector3 {
/// Returns the axis of the vector's smallest value. See `Axis` enum.
/// If all components are equal, this method returns `Axis::Z`.
#[inline]
#[allow(clippy::collapsible-if)]
#[allow(clippy::collapsible_if)]
pub fn min_axis(self) -> Axis {
if self.x < self.y {
if self.x < self.z {
Expand Down Expand Up @@ -374,6 +374,7 @@ impl Vector3 {
}

impl AsRef<[f32; 3]> for Vector3 {
#[inline]
fn as_ref(&self) -> &[f32; 3] {
// SAFETY: Vector3 is repr(C)
unsafe { &*(self as *const Vector3 as *const [f32; 3]) }
Expand Down Expand Up @@ -410,7 +411,7 @@ macro_rules! derive_op_impl_rev {

#[inline]
fn $func(self, with: Self::Output) -> Self::Output {
with * self
$trait::$func(with, self)
}
}
};
Expand Down

0 comments on commit 2a304a6

Please sign in to comment.