Skip to content

Commit

Permalink
Implement style choices
Browse files Browse the repository at this point in the history
  • Loading branch information
chompaa committed Feb 28, 2024
1 parent 92c6a46 commit 4bfd4f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
10 changes: 5 additions & 5 deletions crates/bevy_math/src/bounding/bounded2d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ mod aabb2d_tests {
#[test]
fn scale_around_center() {
let a = Aabb2d {
min: Vec2::new(-1., -1.),
max: Vec2::new(1., 1.),
min: Vec2::NEG_ONE,
max: Vec2::ONE,
};
let scaled = a.scale_around_center(Vec2::new(2., 2.));
assert!((scaled.min - Vec2::new(-2., -2.)).length() < std::f32::EPSILON);
assert!((scaled.max - Vec2::new(2., 2.)).length() < std::f32::EPSILON);
let scaled = a.scale_around_center(Vec2::splat(2.));
assert!((scaled.min - Vec2::splat(-2.)).length() < std::f32::EPSILON);
assert!((scaled.max - Vec2::splat(2.)).length() < std::f32::EPSILON);
assert!(!a.contains(&scaled));
assert!(scaled.contains(&a));
}
Expand Down
17 changes: 6 additions & 11 deletions crates/bevy_math/src/bounding/bounded3d/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,12 @@ mod aabb3d_tests {
#[test]
fn scale_around_center() {
let a = Aabb3d {
min: Vec3::new(-1., -1., -1.),
max: Vec3::new(1., 1., 1.),
min: Vec3::NEG_ONE,
max: Vec3::ONE,
};
let scaled = a.scale_around_center(Vec3::new(2., 2., 2.));
assert!((scaled.min - Vec3::new(-2., -2., -2.)).length() < std::f32::EPSILON);
assert!((scaled.max - Vec3::new(2., 2., 2.)).length() < std::f32::EPSILON);
let scaled = a.scale_around_center(Vec3::splat(2.));
assert!((scaled.min - Vec3::splat(-2.)).length() < std::f32::EPSILON);
assert!((scaled.max - Vec3::splat(2.)).length() < std::f32::EPSILON);
assert!(!a.contains(&scaled));
assert!(scaled.contains(&a));
}
Expand Down Expand Up @@ -478,12 +478,7 @@ impl BoundingVolume for BoundingSphere {
#[inline(always)]
fn scale_around_center(&self, scale: Self::HalfSize) -> Self {
debug_assert!(scale >= 0.);
Self {
center: self.center,
sphere: Sphere {
radius: self.radius() * scale,
},
}
Self::new(self.center, self.radius() * scale)
}
}

Expand Down

0 comments on commit 4bfd4f3

Please sign in to comment.